File: /datos/www/expodubai.colombia.co/wp-content/themes/osapa-child/functions.php
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
function chld_thm_cfg_locale_css( $uri ){
if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
$uri = get_template_directory_uri() . '/rtl.css';
return $uri;
}
endif;
add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( 'font-awesome','pe-icon-7-stroke','owl-carousel','pretty-photo','photoswipe','photoswipe-default','editor-styles' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 1000 );
// END ENQUEUE PARENT ACTION
// Require new custom Element
if ( ! class_exists( 'VcSodaBlockquote' ) ) {
class VcSodaBlockquote extends WPBakeryShortCode {
function __construct() {
add_action( 'init', array( $this, 'create_shortcode' ), 999 );
add_shortcode( 'vc_soda_blockquote', array( $this, 'render_shortcode' ) );
}
public function create_shortcode() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map blockquote with vc_map()
vc_map( array(
'name' => __('Galeria Imágenes', 'sodawebmedia'),
'base' => 'vc_soda_blockquote',
'description' => __( '', 'sodawebmedia' ),
'category' => __( 'SodaWebMedia Modules', 'sodawebmedia'),
'params' => array(
array(
"type" => "attach_images",
"class" => "",
"heading" => __( "Field Label", "my-text-domain" ),
"param_name" => "imagenes",
"value" => '',
"description" => __( "Enter description.", "my-text-domain" )
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'sodawebmedia' ),
'param_name' => 'extra_class',
'value' => __( '', 'sodawebmedia' ),
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'sodawebmedia' ),
'group' => __( 'Extra', 'sodawebmedia'),
),
),
));
}
public function render_shortcode( $atts, $content, $tag ) {
$atts = (shortcode_atts(array(
'extra_class' => '',
'imagenes' => ''
), $atts));
//Content
$content = wpb_js_remove_wpautop($content, true);
$quote_author = esc_html($atts['quote_author']);
$imagenes = esc_attr($atts['imagenes']);
//print_r($imagenes);
//die();
//Cite Link
$blockquote_source = vc_build_link( $atts['blockquote_cite'] );
$blockquote_title = esc_html($blockquote_source["title"]);
$blockquote_url = esc_url( $blockquote_source['url'] );
//Class and Id
$extra_class = esc_attr($atts['extra_class']);
$element_id = esc_attr($atts['element_id']);
$image_ids = explode(',',$imagenes);
$item = 1;
$output = '';
$output .= '<div class="carousel ' . $extra_class . '" id="carousel" >';
foreach( $image_ids as $image_id ){
$images = wp_get_attachment_image_src( $image_id, 'company_logo' );
$output .='<div><img src="'.$images[0].'" alt="'.$atts['title'].'" id="item-'.$item.'"></div>';
$images++;
$item++;
}
$output .= '</div><!--div class="flechas"><a href="#" id="prev">←</a><a href="#" id="next">→</a></div-->';
$output .= "<script>
jQuery(document).ready(function(){
jQuery('#prev').bind('click', function () {
carousel.prev();
return false
});
jQuery('#next').bind('click', function () {
carousel.next();
return false;
});
if (jQuery(window).width() < 600) {
var carousel = jQuery('#carousel').waterwheelCarousel({
separation:0,
separationMultiplier:0,
flankingItems:0
});
}
else{
var carousel = jQuery('#carousel').waterwheelCarousel({
flankingItems: 1,
separation: 400,
separationMultiplier: 0.1,
sizeMultiplier: 0.8,
opacityMultiplier: 0.15,
});
}
/*if (jQuery(window).width() < 800) {
var partialView = jQuery('#partial-view').partialViewSlider({
auto: false,
controls:true,
width:100,
prevHtml:'<i class=\"material-icons\">←</i>',
nextHtml:'<i class=\"material-icons\">→</i>'
});
}
else {
var partialView = jQuery('#partial-view').partialViewSlider({
auto: false,
controls:true,
prevHtml:'<i class=\"material-icons\">←</i>',
nextHtml:'<i class=\"material-icons\">→</i>'
});
}
jQuery('#prev').on('click', function(){
partialView.prev();
});
jQuery('#next').on('click', function(){
partialView.next();
});
jQuery('#play').on('click', function(){
partialView.play();
});
jQuery('#pause').on('click', function(){
partialView.pause();
});*/
});
</script>
<style>
a#prev {
background-color: #474747;
color: #C9A566;
font-size: 14px;
}
a#next {
background: #C9A566;
color: #474747;
}
.flechas a {
width: 63px;
height: 63px;
display: inline-block;
text-align: center;
font-size: 29px !important;
font-family: Arial;
padding-top: 13px;
}
.flechas {
position: absolute;
z-index: 1000;
bottom: 0%;
left: 44%;
}
#carousel {
width:100%;
border:0px solid #222;
height:575px;
position:relative;
clear:both;
overflow:hidden;
background:transparent;
}
#carousel img {
visibility:hidden; /* hide images until carousel can handle them */
cursor:pointer; /* otherwise it's not as obvious items can be clicked */
}
.split-left {
width:400px;
float:left;
}
.split-right {
width:400px;
float:left;
margin-left:10px;
}
</style>";
return $output;
}
}
new VcSodaBlockquote();
}
// Require new custom Element
if ( ! class_exists( 'VcDescargable' ) ) {
class VcDescargable extends WPBakeryShortCode {
function __construct() {
add_action( 'init', array( $this, 'create_shortcode' ), 999 );
add_shortcode( 'vc_descargable_blockquote', array( $this, 'render_shortcode' ) );
}
public function create_shortcode() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
$categories_array = array();
$categories = get_categories();
foreach( $categories as $category ){
//$categories_array[] = $category->term_id;
$categories_array[$category->name] = $category->term_id;
}
// Map blockquote with vc_map()
vc_map( array(
'name' => __('Descargables', 'descargable'),
'base' => 'vc_descargable_blockquote',
'description' => __( '', 'descargable' ),
'category' => __( 'SodaWebMedia Modules', 'descargable'),
'params' => array(
array(
'param_name' => 'category_id',
'type' => 'dropdown',
'value' => $categories_array, // here I'm stuck
'heading' => __('Categoria', 'overmax'),
'description' => '',
'holder' => 'div',
'class' => ''
),
),
));
}
public function render_shortcode( $atts, $content, $tag ) {
$atts = (shortcode_atts(array(
'category_id' => ''
), $atts));
//Content
$category_id = esc_attr($atts['category_id']);
//$output = $category_id ;
global $post, $wp_query;
$args = array(
'cat'=>$category_id ,
'posts_per_page'=>'9'
);
$posts = new WP_Query($args);
if ($posts->have_posts()){
while ($posts->have_posts()){
$posts->the_post();
$title = get_the_title();
$url = get_field('descargable', $posts->ID);
$excertp = get_the_excerpt();
$imagen = get_the_post_thumbnail_url( $posts->ID, 'full');
$output .= '<div class="vc_grid-item vc_clearfix vc_col-sm-4 vc_grid-item-zone-c-bottom vc_visible-item fadeIn animated"><div class="vc_grid-item-mini vc_clearfix">
<div class="vc_gitem-animated-block " "="">
<div class="vc_gitem-zone imagen" style="background-image: url('.$imagen.') !important;">
<img src="'.$imagen .'" class="vc_gitem-zone-img" alt=""><div class="vc_gitem-zone-mini"></div></div></div>
<div class="vc_gitem-zone contenido vc_gitem-zone-c vc_custom_1419240516480"><div class="vc_gitem-zone-mini"><div class="vc_gitem_row vc_row vc_gitem-row-position-top">
<div class="vc_col-sm-12 vc_gitem-col vc_gitem-col-align-"><div class="vc_custom_heading vc_gitem-post-data vc_gitem-post-data-source-post_title">
<h4 style="text-align: left">'. $title.'</h4></div><div class="vc_custom_heading vc_gitem-post-data vc_gitem-post-data-source-post_excerpt">
<p></p></div>
<div class="wpb_text_column wpb_content_element sinmarginbotttom">
<div class="wpb_wrapper">
<div class="descarga"><a target="_blank" href="'.$url.'" id="prev">Descargar PDF</a></div>
</div>
</div>
</div></div></div></div></div><div class="vc_clearfix"></div></div>';
}
}
wp_reset_postdata();
return $output;
}
}
new VcDescargable();
}
//Nuevo elemento wpbakery para logos aliados
if ( ! class_exists( 'VcLogos' ) ) {
class VcLogos extends WPBakeryShortCode {
function __construct() {
add_action( 'init', array( $this, 'create_shortcode' ), 999 );
add_shortcode( 'vc_logos', array( $this, 'render_shortcode' ) );
}
public function create_shortcode() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map blockquote with vc_map()
vc_map( array(
'name' => __('Logos', 'logos'),
'base' => 'vc_logos',
'description' => __( '', 'Logos' ),
'category' => __( 'SodaWebMedia Modules', 'sodawebmedia'),
'params' => array(
array(
'type' => 'dropdown',
'value' => array(3,4,5),
'name' => __('Número de Columnas', 'rrf-maxima'),
'heading' => __('Número de Columnas', 'rrf-maxima'),
'param_name' => 'columnas',
),
array(
'type' => 'param_group',
'value' => '',
'param_name' => 'logos',
// Note params is mapped inside param-group:
'params' => array(
array(
'type' => 'textfield',
'value' => '',
'heading' => 'Nombre',
'param_name' => 'nombre',
'admin_label' => true,
),
array(
'type' => 'vc_link',
'value' => '',
'heading' => 'Url',
'param_name' => 'linklogo',
),
array(
'type' => 'attach_image',
'value' => '',
'heading' => 'Imagen',
'param_name' => 'imagenlogo',
),
)
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'sodawebmedia' ),
'param_name' => 'extra_class',
'value' => __( '', 'sodawebmedia' ),
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'sodawebmedia' ),
'group' => __( 'Extra', 'sodawebmedia'),
),
),
));
}
public function render_shortcode( $atts, $content, $tag ) {
$atts = (shortcode_atts(array(
'extra_class' => '',
'logos' => '',
'columnas' => ''
), $atts));
//print_r($imagenes);
//die();
//Cite Link
$logos = vc_param_group_parse_atts( $atts['logos'] );
$columnas = esc_attr($atts['columnas']);
$output .='<div class="logos">';
foreach( $logos as $logo ){
$images = wp_get_attachment_image_src( $logo["imagenlogo"], 'company_logo' );
$url_link = vc_build_link($logo["linklogo"]);
if($url_link['url'] == "")
$output .='<div class="logo colum-'.$columnas.'"><div class="imagen"><img src="'.$images[0].'" alt="'.$atts['title'].'" id="item-'.$item.'" style="width:231px;height:148px;"></div></div>';
else
$output .='<div class="logo colum-'.$columnas.'"><div class="imagen"><a href="'.esc_url($url_link['url']).'"><img src="'.$images[0].'" alt="'.$atts['title'].'" id="item-'.$item.'"></a></div></div>';
//echo wp_get_attachment_image_src( $logo["imagenlogo"], 'company_logo' );//$logo["imagenlogo"];
}
$output .='</div>';
return $output;
}
}
new VcLogos();
}
if( ! function_exists( 'ftc_header_mobile_navigation' ) ) {
function ftc_header_mobile_navigation() {
global $smof_data;
?>
<?php if( !is_page_template('page-blank.php') ): ?>
<div class="ftc-mobile-wrapper">
<?php if( isset($smof_data['ftc_enable_search']) && $smof_data['ftc_enable_search'] ): ?>
<?php osapa_get_search_form_by_category(); ?>
<?php endif; ?>
<div class= "menu-text">
<button type="button" class="btn btn-toggle-canvas" data-toggle="offcanvas">
<i class="fa fa-close"></i>
</button>
<i class="fa fa-bars"></i>
<?php esc_html_e('Menu', 'osapa') ?>
</div>
<div class="mobile-menu-wrapper">
<?php
wp_nav_menu( array('theme_location' => 'primary', 'container_class' => 'mobile-nav-wrapper', 'menu_id' => 'primary-menu') );
?>
<?php
wp_nav_menu( array(
'theme_location' => 'my-custom-top-menu',
'container_class' => 'mobile-nav-wrapper' ,
'menu_id' => 'top-menu') );
?>
</div>
<div class="bottommenu">
<div class="red fondonegro vacio"><a href="https://www.facebook.com/ColombiaNosUneMRE/live_videos/" target="_blank"><?= ($currentlang=="es-CO")?"Evento en vivo":"Live stream" ?></a></div>
<div class="red fondoblanco ">
<div class="idiomasmovil idiomas">
<?php
if ( function_exists( 'pll_the_languages' ) ) {
$args = [
'show_flags' => 0,
'show_names' => 1,
'echo' => 0,
'display_names_as'=>'slug'
];
$output = '<ul class="polylang_langswitcher">'.pll_the_languages( $args ). '</ul>';
}
echo $output;
?>
</div>
</div>
</div>
<?php
global $smof_data, $woocommerce;
if ( isset($smof_data['ftc_mobile_layout']) && $smof_data['ftc_mobile_layout']):
?>
<div class="footer-mobile">
<div class="mobile-wishlist">
<?php if( class_exists('YITH_WCWL')): ?>
<div class="ftc-my-wishlist"><?php echo osapa_tini_wishlist(); ?></div>
<?php endif; ?>
</div>
<div class="mobile-account">
<?php
$_user_logged = is_user_logged_in();
ob_start();
?>
<a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_html_e('Login','osapa'); ?>">
<i class="fa fa-user"></i>
<?php if ($_user_logged): ?>
<?php esc_html_e('Account','osapa'); ?>
<?php endif; ?>
<?php if (!$_user_logged): ?>
<?php esc_html_e('Login','osapa'); ?>
<?php endif; ?>
</a>
</div>
</div>
<?php endif; ?>
</div>
<?php
endif;
}
}
// Habilitar la subida de imágenes en formato SVG en WordPress
add_filter( 'upload_mimes', 'jc_custom_upload_mimes' );
function jc_custom_upload_mimes( $existing_mimes = array() ) {
$existing_mimes['svg'] = 'image/svg+xml';
return $existing_mimes;
}
function register_custom_widget_area() {
register_sidebar(
array(
'id' => 'top-bar',
'name' => esc_html__( 'Widgets Top Bar', 'topbar-widget' ),
'description' => esc_html__( 'Widgets del top bar', 'topbar-widget' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => ''
)
);
}
add_action( 'widgets_top_bar', 'register_custom_widget_area' );
//Sidebar para el módulo dorado
function register_custom_widget_area2() {
register_sidebar(
array(
'id' => 'top-bar',
'name' => esc_html__( 'Módulo Dorado', 'dorado-widget' ),
'description' => esc_html__( 'Módulo dorado', 'dorado-widget' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => ''
)
);
}
add_action( 'widgets_init', 'register_custom_widget_area2' );
//Sidebar para el módulo dorado ingles
function register_custom_widget_area3() {
register_sidebar(
array(
'id' => 'top-bar-eng',
'name' => esc_html__( 'Módulo Dorado Inglés', 'dorado-widget-eng' ),
'description' => esc_html__( 'Módulo dorado inglés', 'dorado-widget-eng' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => ''
)
);
}
add_action( 'widgets_init', 'register_custom_widget_area3' );
// function that runs when shortcode is called
function wpb_flechas() {
// Things that you want to do.
$message = '<div class="flechas"><a href="#" id="prev">←</a><a href="#" id="next">→</a></div>';
// Output needs to be return
return $message;
}
// register shortcode
add_shortcode('flechas', 'wpb_flechas');
// function that runs when shortcode is called
function wpb_descarga() {
global $post, $wp_query;
$args = array(
'cat'=>'24',
'posts_per_page'=>'9'
);
$posts = new WP_Query($args);
$out = '';
if ($posts->have_posts()){
while ($posts->have_posts()){
$posts->the_post();
$title = get_the_title();
$url = get_field('descargable', $posts->ID);
$excertp = get_the_excerpt();
$imagen = get_the_post_thumbnail_url( $posts->ID, 'thumbnail');
$message .= '<div class="vc_grid-item vc_clearfix vc_col-sm-4 vc_grid-item-zone-c-bottom vc_visible-item fadeIn animated"><div class="vc_grid-item-mini vc_clearfix">
<div class="vc_gitem-animated-block " "="">
<div class="vc_gitem-zone imagen" style="background-image: url('.$imagen.') !important;">
<img src="'.$imagen .'" class="vc_gitem-zone-img" alt=""><div class="vc_gitem-zone-mini"></div></div></div>
<div class="vc_gitem-zone contenido vc_gitem-zone-c vc_custom_1419240516480"><div class="vc_gitem-zone-mini"><div class="vc_gitem_row vc_row vc_gitem-row-position-top">
<div class="vc_col-sm-12 vc_gitem-col vc_gitem-col-align-"><div class="vc_custom_heading vc_gitem-post-data vc_gitem-post-data-source-post_title">
<h4 style="text-align: left">'. $title.'</h4></div><div class="vc_custom_heading vc_gitem-post-data vc_gitem-post-data-source-post_excerpt">
<p style="text-align: left"></p><p>'.$excertp.'</p>
<p></p></div>
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div class="descarga"><a target="_blank" href="'.$url.'" id="prev">Descargar <img src="/wp-content/uploads/2021/05/arrow-right.png"/></a></div>
</div>
</div>
</div></div></div></div></div><div class="vc_clearfix"></div></div>';
}
}
wp_reset_postdata();
// Output needs to be return
return $message;
}
// register shortcode
add_shortcode('descargar', 'wpb_descarga');
add_action( 'widgets_init', 'mapa' );
function mapa () {
register_sidebar( array(
'name' => 'Mapa',
'id' => 'mapa',
'class' => 'mapa',
) );
}
// function that runs when shortcode is called
function wpb_bienvenido() {
$current_user = wp_get_current_user();
// Things that you want to do.
$message = '<div class="bienvenido">Bienvenido <span>'.$current_user->display_name.'</span></div>';
// Output needs to be return
return $message;
}
// register shortcode
add_shortcode('bienvenido', 'wpb_bienvenido');
function wpb_logout() {
// Things that you want to do.
$message = '<div class="logout"><a href="'.wp_logout_url( home_url() ).'"><img src="/wp-content/uploads/2021/07/profile.png" /> Cerrar sesión</a></div>';
// Output needs to be return
return $message;
}
// register shortcode
add_shortcode('logout', 'wpb_logout');
function custom_polylang_langswitcher() {
$output = '';
if ( function_exists( 'pll_the_languages' ) ) {
$args = [
'show_flags' => 0,
'show_names' => 1,
'echo' => 0,
];
$output = '<ul class="polylang_langswitcher">'.pll_the_languages( $args ). '</ul>';
}
return $output;
}
add_shortcode( 'polylang_langswitcher', 'custom_polylang_langswitcher' );
//Shorcode para press & media
// function that runs when shortcode is called
function wpb_pressmedia() {
global $post, $wp_query;
$args = array(
'cat'=>'53',
'posts_per_page'=>'180'
);
$posts = new WP_Query($args);
$out = '';
if ($posts->have_posts()){
while ($posts->have_posts()){
$posts->the_post();
$title = get_the_title();
$url = get_field('link_noticia', $posts->ID);
$labellink = get_field('label_del_link', $posts->ID);
$medio = get_field('medio', $posts->ID);
$excertp = get_the_excerpt();
$imagen = get_the_post_thumbnail_url( $posts->ID, 'full');
$message .= '<div class="vc_grid-item vc_clearfix vc_col-sm-4 vc_grid-item-zone-c-bottom vc_visible-item fadeIn animated">
<div class="medio">'.$medio.'</div>
<div class="vc_grid-item-mini vc_clearfix">
<div class="vc_gitem-animated-block " "="">
<div class="vc_gitem-zone imagen" style="background-image: url('.$imagen.') !important;">
<img src="'.$imagen .'" class="vc_gitem-zone-img" alt=""><div class="vc_gitem-zone-mini">
</div>
</div>
</div>
<div class="vc_gitem-zone contenido vc_gitem-zone-c vc_custom_1419240516480">
<div class="vc_gitem-zone-mini">
<div class="vc_gitem_row vc_row vc_gitem-row-position-top">
<div class="">
<div class="vc_custom_heading vc_gitem-post-data vc_gitem-post-data-source-post_title">
<h2 style="text-align: left">'. $title.'</h2>
</div>
<div class="vc_custom_heading vc_gitem-post-data vc_gitem-post-data-source-post_excerpt">
<p style="text-align: left"></p><p>'.$excertp.'</p>
</div>
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div class="descarga"><a target="_blank" href="'.$url.'" id="prev">'.$labellink.' <img src="/wp-content/uploads/2021/05/arrow-right.png"/></a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="vc_clearfix"></div></div>';
}
}
wp_reset_postdata();
// Output needs to be return
return $message;
}
// register shortcode
add_shortcode('pressmedia', 'wpb_pressmedia');
//Nuevo menu top
function wpb_custom_top_menu() {
register_nav_menu('my-custom-top-menu',__( 'Top menu' ));
}
add_action( 'init', 'wpb_custom_top_menu' );
$subRole = get_role( 'subscriber' );
$subRole->add_cap( 'read_private_posts' );
$subRole->add_cap( 'read_private_pages' );
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
//Nuevo elemento wpbakery para videos de youtube
if ( ! class_exists( 'VcVideosYoutube' ) ) {
class VcVideosYoutube extends WPBakeryShortCode {
function __construct() {
add_action( 'init', array( $this, 'create_shortcode' ), 999 );
add_shortcode( 'vc_videos', array( $this, 'render_shortcode' ) );
}
public function create_shortcode() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map blockquote with vc_map()
vc_map( array(
'name' => __('Videos Youtube', 'videos'),
'base' => 'vc_videos',
'description' => __( '', 'Videos' ),
'category' => __( 'SodaWebMedia Modules', 'sodawebmedia'),
'params' => array(
array(
'type' => 'textfield',
'heading' => __( 'Título seccion', 'sodawebmedia' ),
'param_name' => 'titulo',
'value' => __( '', 'sodawebmedia' ),
'description' => __( 'Ids de los videos de youtube separados por coma (,)', 'sodawebmedia' ),
),
array(
'type' => 'vc_link',
'heading' => __( 'Link a ver más', 'sodawebmedia' ),
'param_name' => 'link',
'value' => __( '', 'sodawebmedia' ),
'description' => __( 'Ids de los videos de youtube separados por coma (,)', 'sodawebmedia' ),
),
array(
'type' => 'textfield',
'heading' => __( 'ID Videos', 'sodawebmedia' ),
'param_name' => 'videos',
'value' => __( '', 'sodawebmedia' ),
'description' => __( 'Ids de los videos de youtube separados por coma (,)', 'sodawebmedia' ),
),
array(
"type" => "checkbox",
"class" => "",
"heading" => __( "¿Destacado?", "sodawebmedia" ),
"param_name" => "destacado",
"value" => __( "", "sodawebmedia" ),
"description" => __( "Es el video destacado.", "sodawebmedia" )
),
array(
"type" => "checkbox",
"class" => "",
"heading" => __( "¿Grilla?", "sodawebmedia" ),
"param_name" => "grilla",
"value" => __( "", "sodawebmedia" ),
"description" => __( "Grilla o Slider.", "sodawebmedia" )
)
),
));
}
public function render_shortcode( $atts, $content, $tag ) {
$atts = (shortcode_atts(array(
'videos' => '',
'destacado' => '',
'titulo' => '',
'link' => '',
'grilla' => ''
), $atts));
$videosId = explode(",",esc_attr( $atts['videos'] ));
$destacado = $atts['destacado'];
$titulo = $atts['titulo'];
$idTagVideos = str_replace(" ","",$titulo);
$link = $atts['link'];
$url_link = vc_build_link($link);
$grilla = $atts['grilla'];
if($grilla == "")
$grilla = false;
/* $curl = curl_init();
// set our url with curl_setopt()
curl_setopt($curl, CURLOPT_URL, "https://www.googleapis.com/youtube/v3/search?key=AIzaSyD0B-XN220JwATFlpldxvLmDsfULLusnWY&channelId=UCYGTY4XRbLdf9YrOUc39cOQ&part=snippet,id&order=date&maxResults=100");
// return the transfer as a string, also with setopt()
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// curl_exec() executes the started curl session
// $output contains the output string
$output = curl_exec($curl);
$videos = json_decode($output);
//print_r($videos->items);
//$arrayVideos = Array();
$respuesta .='<h2>'.$titulo .'</h2><div class="videosyoutube">';
foreach($videos->items as $vid){
//print_r( $vid->id->videoId );
//print_r( $vid->snippet->thumbnails->high->url );
//print_r( $vid->snippet->title );
$idVideo = $vid->id->videoId;
$thumbnail = $vid->snippet->thumbnails->high->url;
$titulo = $vid->snippet->title;
if(in_array($idVideo, $videosId)){
if($destacado){
$respuesta .= '<h2><span>Video destacado</span> | '.$titulo.'</h2>
<div class="video">
<iframe src="https://www.youtube.com/embed/'.$idVideo.'" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>';
}
else{
$respuesta .= "<div class='videopeq'>
<div class='imagen'><img src='".$thumbnail ."'></div>
<h4><a href='https://youtube.com/embed/".$idVideo."'>".$titulo."</a></h4>
</div>";
}
}
}
$respuesta .='</div>';
// close curl resource to free up system resources
// (deletes the variable made by curl_init)
curl_close($curl);*/
$linkvermas = '';
if( $url_link['url'] != ""){
if($url_link['target'] != "")
$linkvermas = '<div class="vertodos"><a href="'.$url_link['url'].'" target="'.$url_link['target'].'">Ver todos</a></div>';
else
$linkvermas = '<div class="vertodos"><a href="'.$url_link['url'].'">Ver todos</a></div>';
}
$respuesta .='<h2>'.$titulo .'</h2>'.$linkvermas .'<div class="flechasnuevas" id="flechas_'.$idTagVideos.'"><div class="your-class-arrow"></div></div><div class="videosyoutube" id="'.$idTagVideos.'">';
foreach($videosId as $vidid){
$curl = curl_init();
// set our url with curl_setopt()
curl_setopt($curl, CURLOPT_URL, "https://www.googleapis.com/youtube/v3/videos?part=snippet&id=".$vidid."&key=AIzaSyD0B-XN220JwATFlpldxvLmDsfULLusnWY");
// return the transfer as a string, also with setopt()
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// curl_exec() executes the started curl session
// $output contains the output string
$output = curl_exec($curl);
//print_r($output);
$videos = json_decode($output);
foreach($videos->items as $vid){
$tituloVideo = $vid->snippet->title;
$thumbnail = $vid->snippet->thumbnails->high->url;
}
if($destacado){
$respuesta .= '<h2><span>Video destacado</span> | '.$tituloVideo.'</h2>
<div class="video videoprincipal" id="videoprincipal">
<iframe src="https://www.youtube.com/embed/'.$vidid.'" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>';
}
else{
if($thumbnail == ""){
$respuesta .= "<div class='videopeq'>
<div class='imagen'><a class='linkvideo' style='cursor:pointer' data-idvideo='".$vidid."'><img src='https://img.youtube.com/vi/".$vidid ."/0.jpg'></a><</div>
<h4><a class='linkvideo' style='cursor:pointer' data-idvideo='".$vidid."'>".$tituloVideo."</a></h4>
</div>";
}
else{
$respuesta .= "<div class='videopeq'>
<div class='imagen'><a class='linkvideo' style='cursor:pointer' data-idvideo='".$vidid."'><img src='".$thumbnail."'></a></div>
<h4><a class='linkvideo' style='cursor:pointer' data-idvideo='".$vidid."'>".$tituloVideo."</a></h4>
</div>";
}
}
curl_close($curl);
}
$respuesta .='</div>';
//https://www.googleapis.com/youtube/v3/videos?part=snippet&id=-fI7h8iGZTo&key=AIzaSyD0B-XN220JwATFlpldxvLmDsfULLusnWY
if(!$grilla){
$respuesta .= "<script>
jQuery(document).ready(function(){
jQuery('#".$idTagVideos."').slick({
dots: false,
infinite: false,
speed: 300,
slidesToShow: 4,
slidesToScroll: 4,
appendArrows: jQuery ('#flechas_".$idTagVideos." .your-class-arrow'),
nextArrow: '<button class=\"any-class-name-you-want-next\">></button>',
prevArrow: '<button class=\"any-class-name-you-want-previous\"><</button>',
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
});
</script>";
}
return $respuesta;
}
}
new VcVideosYoutube();
}