if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly if( ! Avia_Config_LayerSlider()->is_active() ) { return; } if ( ! class_exists( 'avia_sc_layerslider' ) ) { class avia_sc_layerslider extends aviaShortcodeTemplate { static $slide_count = 0; /** * Create the config array for the shortcode button */ public function shortcode_insert_button() { $this->config['self_closing'] = 'yes'; $this->config['forced_load_objects'] = array('layerslider'); // Lnea corregida $this->config['name'] = __('Advanced Layerslider', 'avia_framework'); $this->config['tab'] = __('Media Elements', 'avia_framework'); $this->config['icon'] = AviaBuilder::$path['imagesURL'] . "sc-slideshow-layer.png"; $this->config['order'] = 10; $this->config['target'] = 'avia-target-insert'; $this->config['shortcode']= 'av_layerslider'; $this->config['tooltip'] = __('Display a Layerslider Slideshow', 'avia_framework'); $this->config['tinyMCE'] = array('disable' => "true"); $this->config['drag-level'] = 1; } function extra_assets() { //load css wp_enqueue_style( 'avia-module-slideshow-ls' , AviaBuilder::$path['pluginUrlRoot'].'avia-shortcodes/slideshow_layerslider/slideshow_layerslider.css' , array('avia-layout'), false ); //load js wp_enqueue_script( 'avia-module-slideshow-ls' , AviaBuilder::$path['pluginUrlRoot'].'avia-shortcodes/slideshow_layerslider/slideshow_layerslider.js' , array('avia-shortcodes'), false, TRUE ); } /** * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className * * * @param array $params this array holds the default values for $content and $args. * @return $params the return array usually holds an innerHtml key that holds item specific markup. */ public function editor_element($params) { //fetch all registered slides and save them to the slides array $slides = Avia_Config_LayerSlider()->find_layersliders( true ); if(empty($params['args']['id']) && is_array($slides)) $params['args']['id'] = reset($slides); if(empty($params['args']['id'])) $params['args']['id'] = ""; $element = array( 'subtype' => $slides, 'type'=>'select', 'std' => $params['args']['id'], 'class' => 'avia-recalc-shortcode', 'data' => array('attr'=>'id') ); $inner = ""; if(empty($slides)) { $inner.= "
".__('No Layer Slider Found. Click here to create one','avia_framework' )."
"; } else { $inner .= "
".$this->config['name']."
"; $inner .= AviaHtmlHelper::render_element($element); $inner .= "".__('Edit Layer Slider here','avia_framework' ).""; } $params['class'] = "av_sidebar"; $params['innerHtml'] = $inner; return $params; } /** * Frontend Shortcode Handler * * @param array $atts array of attributes * @param string $content text within enclosing form of shortcode element * @param string $shortcodename the shortcode found, when == callback name * @param array $meta * @return string $output returns the modified html string */ public function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = array() ) { $atts = shortcode_atts( array( 'id' => 0 ), $atts, $this->config['shortcode'] ); $output = ""; avia_sc_layerslider::$slide_count++; $skipSecond = false; $params = array(); /** * Get selected slider or last slider */ $slider = Avia_Config_LayerSlider()->get_default_slider( $atts['id'] ); if( ! empty( $slider ) ) { $atts['id'] = $slider['id']; $slides = json_decode( $slider['data'], true ); $height = $slides['properties']['height']; $width = $slides['properties']['width']; $responsive = ! empty( $slides['properties']['responsive'] ) ? $slides['properties']['responsive'] : ''; $responsiveunder = ! empty( $slides['properties']['responsiveunder'] ) ? $slides['properties']['responsiveunder'] : ''; if( ! empty( $slides['properties']['type'] ) && ( 'responsive' == $slides['properties']['type'] ) ) { $params['style'] = " style='height: " . ($height+1) . "px; max-width: {$width}px; margin: 0 auto;' "; } else { $params['style'] = " style='height: " . ($height+1) . "px;' "; } } else { /** * Force an error message in frontend for admins */ $atts['id'] = 0; } $params['class'] = "avia-layerslider main_color avia-shadow ".$meta['el_class']; $params['open_structure'] = false; //we dont need a closing structure if the element is the first one or if a previous fullwidth element was displayed before if(empty($meta['index'])) $params['close'] = false; if(!empty($meta['siblings']['prev']['tag']) && in_array($meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section )) $params['close'] = false; if(!empty($meta['index'])) $params['class'] .= " slider-not-first"; $params['id'] = "layer_slider_".( avia_sc_layerslider::$slide_count ); $output .= avia_new_section($params); if(class_exists('LS_Shortcode') && method_exists('LS_Shortcode', 'handleShortcode')) //fix for search results page - only works with latest LayerSlider versions { $output .= LS_Shortcode::handleShortcode( $atts ); } else if(function_exists('layerslider_init')) //fix for search results page - only works with older LayerSlider versions { $output .= layerslider_init( $atts ); } $output .= ""; //close section //if the next tag is a section dont create a new section from this shortcode if(!empty($meta['siblings']['next']['tag']) && in_array($meta['siblings']['next']['tag'], AviaBuilder::$full_el )) { $skipSecond = true; } //if there is no next element dont create a new section. if(empty($meta['siblings']['next']['tag'])) { $skipSecond = true; } if(empty($skipSecond)) { $output .= avia_new_section(array('close'=>false, 'id' => "after_layer_slider_".avia_sc_layerslider::$slide_count)); } return $output; } } } {"id":2989,"date":"2015-07-03T18:36:41","date_gmt":"2015-07-03T18:36:41","guid":{"rendered":"http:\/\/tornillossanmarcos.com.mx\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png"},"modified":"2015-07-03T18:36:41","modified_gmt":"2015-07-03T18:36:41","slug":"brocas","status":"inherit","type":"attachment","link":"https:\/\/covamsa.com\/inicio\/brocas\/","title":{"rendered":"brocas"},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":[],"class_list":["post-2989","attachment","type-attachment","status-inherit","hentry"],"yoast_head":"\nbrocas - COVAMSA<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"brocas - COVAMSA\" \/>\n<meta property=\"og:url\" content=\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png\" \/>\n<meta property=\"og:site_name\" content=\"COVAMSA\" \/>\n<meta property=\"og:image\" content=\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png\" \/>\n\t<meta property=\"og:image:width\" content=\"258\" \/>\n\t<meta property=\"og:image:height\" content=\"276\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png\",\"url\":\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png\",\"name\":\"brocas - COVAMSA\",\"isPartOf\":{\"@id\":\"https:\/\/covamsa.com\/inicio\/#website\"},\"datePublished\":\"2015-07-03T18:36:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/covamsa.com\/inicio\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"brocas\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/covamsa.com\/inicio\/#website\",\"url\":\"https:\/\/covamsa.com\/inicio\/\",\"name\":\"COVAMSA\",\"description\":\"Surtimos a peque\u00f1os y grandes comercios, con pedidos al mayoreo y menudeo\",\"publisher\":{\"@id\":\"https:\/\/covamsa.com\/inicio\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/covamsa.com\/inicio\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/covamsa.com\/inicio\/#organization\",\"name\":\"COVAMSA\",\"url\":\"https:\/\/covamsa.com\/inicio\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/covamsa.com\/inicio\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/01\/covamsa_logo01.png\",\"contentUrl\":\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/01\/covamsa_logo01.png\",\"width\":289,\"height\":196,\"caption\":\"COVAMSA\"},\"image\":{\"@id\":\"https:\/\/covamsa.com\/inicio\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"brocas - COVAMSA","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png","og_locale":"es_ES","og_type":"article","og_title":"brocas - COVAMSA","og_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png","og_site_name":"COVAMSA","og_image":[{"width":258,"height":276,"url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png","type":"image\/png"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png","url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png","name":"brocas - COVAMSA","isPartOf":{"@id":"https:\/\/covamsa.com\/inicio\/#website"},"datePublished":"2015-07-03T18:36:41+00:00","breadcrumb":{"@id":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/covamsa.com\/inicio\/"},{"@type":"ListItem","position":2,"name":"brocas"}]},{"@type":"WebSite","@id":"https:\/\/covamsa.com\/inicio\/#website","url":"https:\/\/covamsa.com\/inicio\/","name":"COVAMSA","description":"Surtimos a peque\u00f1os y grandes comercios, con pedidos al mayoreo y menudeo","publisher":{"@id":"https:\/\/covamsa.com\/inicio\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/covamsa.com\/inicio\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/covamsa.com\/inicio\/#organization","name":"COVAMSA","url":"https:\/\/covamsa.com\/inicio\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/covamsa.com\/inicio\/#\/schema\/logo\/image\/","url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/01\/covamsa_logo01.png","contentUrl":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/01\/covamsa_logo01.png","width":289,"height":196,"caption":"COVAMSA"},"image":{"@id":"https:\/\/covamsa.com\/inicio\/#\/schema\/logo\/image\/"}}]}},"description":{"rendered":"<p class=\"attachment\"><a href='https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png'><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"276\" src=\"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png\" class=\"attachment-medium size-medium\" alt=\"\" \/><\/a><\/p>\n"},"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":258,"height":276,"file":"2015\/07\/brocas.png","sizes":{"woocommerce_gallery_thumbnail":{"file":"brocas-100x100.png","width":100,"height":100,"mime_type":"image\/png","source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas-100x100.png"},"thumbnail":{"file":"brocas-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas-150x150.png"},"shop_thumbnail":{"file":"brocas-100x100.png","width":100,"height":100,"mime_type":"image\/png","source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas-100x100.png"},"related-post":{"file":"brocas-258x231.png","width":258,"height":231,"mime_type":"image\/png","source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas-258x231.png"},"widget-thumb-medium":{"file":"brocas-85x85.png","width":85,"height":85,"mime_type":"image\/png","source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas-85x85.png"},"widget-thumb":{"file":"brocas-50x50.png","width":50,"height":50,"mime_type":"image\/png","source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas-50x50.png"},"full":{"file":"brocas.png","width":258,"height":276,"mime_type":"image\/png","source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"https:\/\/covamsa.com\/inicio\/wp-content\/uploads\/2015\/07\/brocas.png","_links":{"self":[{"href":"https:\/\/covamsa.com\/inicio\/wp-json\/wp\/v2\/media\/2989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/covamsa.com\/inicio\/wp-json\/wp\/v2\/media"}],"about":[{"href":"https:\/\/covamsa.com\/inicio\/wp-json\/wp\/v2\/types\/attachment"}],"author":[{"embeddable":true,"href":"https:\/\/covamsa.com\/inicio\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/covamsa.com\/inicio\/wp-json\/wp\/v2\/comments?post=2989"}]}}