function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $title = !empty($title) ? $before_title . $title . $after_title : $title;
     echo $before_widget, $title, layerslider_init($instance), $after_widget;
 }
Example #2
0
function layerslider($id = 0, $page = '')
{
    // Check id
    if (!isset($id) || empty($id)) {
        echo '[LayerSlider WP] You need to specify the "id" parameter for the layerslider() function call';
        return;
    }
    // Page filter
    if (isset($page) && !empty($page)) {
        // Get page name
        global $pagename;
        // Get page ID
        $pageid = (string) get_the_ID();
        // Get pages
        $pages = explode(',', $page);
        // Iterate over the pages
        foreach ($pages as $page) {
            if ($page == 'homepage' && is_front_page()) {
                echo layerslider_init(array('id' => $id));
            } else {
                if ($pageid == $page) {
                    echo layerslider_init(array('id' => $id));
                } else {
                    if ($pagename == $page) {
                        echo layerslider_init(array('id' => $id));
                    }
                }
            }
        }
        // All pages
    } else {
        echo layerslider_init(array('id' => $id));
    }
}
 /**
  * Render the widget in frontend
  *
  * @param array $args
  * @param array $instance
  * @return string
  */
 function get_widget($args, $instance)
 {
     if (is_admin()) {
         return "<center><i class='icon-th-large  icon-4x'></i></center>";
     }
     $output = "";
     $instance['id'] = $instance['layerslider'];
     $skipSecond = false;
     //check if we got a layerslider
     global $wpdb;
     // Table name
     $table_name = $wpdb->prefix . "layerslider";
     // Get slider
     $slider = $wpdb->get_row("SELECT * FROM {$table_name}\n                                    WHERE id = " . (int) $instance['layerslider'] . " AND flag_hidden = '0'\n                                    AND flag_deleted = '0'\n                                    ORDER BY date_c DESC LIMIT 1", ARRAY_A);
     if (!empty($slider)) {
         $slides = json_decode($slider['data'], true);
         $height = isset($slides['properties']['height']) ? $slides['properties']['height'] : "";
         $width = isset($slides['properties']['width']) ? $slides['properties']['width'] : "";
         $responsive = isset($slides['properties']['responsive']) ? $slides['properties']['responsive'] : "";
         $responsiveunder = isset($slides['properties']['responsiveunder']) ? $slides['properties']['responsiveunder'] : "";
         $params['style'] = " style='height: " . ($height + 1) . "px;' ";
     }
     $params['class'] = "layerslider main_color shadow ";
     $params['open_structure'] = false;
     $params['id'] = "layer_slider";
     $output .= "</div></div></div></div></div></div>";
     //$output .= new_section($params);
     $output .= layerslider_init($instance);
     //$output .= "</div>"; //close section
     //if (empty($skipSecond)) {
     $output .= new_section(array('open_structure' => true, 'open_color_wrap' => false, 'close' => false, 'id' => "after_layerslider"));
     //$output .= new_section(array('close' => false, 'id' => "after_layer_slider"));
     $output .= '<div><div>';
     //}
     return $output;
 }
 /**
  * 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
  * @return string $output returns the modified html string 
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     $output = "";
     $skipSecond = false;
     avia_sc_layerslider::$slide_count++;
     //check if we got a layerslider
     global $wpdb;
     // Table name
     $table_name = $wpdb->prefix . "layerslider";
     // Get slider
     $slider = $wpdb->get_row("SELECT * FROM {$table_name}\n\t\t\t\t\t\t\t\t\t\tWHERE id = " . (int) $atts['id'] . " AND flag_hidden = '0'\n\t\t\t\t\t\t\t\t\t\tAND flag_deleted = '0'\n\t\t\t\t\t\t\t\t\t\tORDER BY date_c DESC LIMIT 1", ARRAY_A);
     if (!empty($slider)) {
         $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'] : '';
         $params['style'] = " style='height: " . ($height + 1) . "px;' ";
     }
     $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);
     $output .= function_exists('layerslider_init') ? layerslider_init($atts) : '';
     //fix for search results page
     $output .= "</div>";
     //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;
 }
 /**
  * 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
  * @return string $output returns the modified html string 
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     $output = "";
     $skipSecond = false;
     avia_sc_layerslider::$slide_count++;
     //check if we got a layerslider
     global $wpdb;
     // Table name
     $table_name = $wpdb->prefix . "layerslider";
     // Get slider
     $slider = $wpdb->get_row("SELECT * FROM {$table_name}\n\t\t\t\t\t\t\t\t\t\tWHERE id = " . (int) $atts['id'] . " AND flag_hidden = '0'\n\t\t\t\t\t\t\t\t\t\tAND flag_deleted = '0'\n\t\t\t\t\t\t\t\t\t\tORDER BY date_c DESC LIMIT 1", ARRAY_A);
     if (!empty($slider)) {
         $slides = json_decode($slider['data'], true);
         $height = $slides['properties']['height'];
         $width = $slides['properties']['width'];
         $responsive = $slides['properties']['responsive'];
         $responsiveunder = $slides['properties']['responsiveunder'];
         $params['style'] = " style='height: " . ($height + 1) . "px;' ";
     }
     $params['class'] = "avia-layerslider main_color avia-shadow " . $meta['el_class'];
     $params['open_structure'] = false;
     if ($meta['index'] == 0) {
         $params['close'] = false;
     }
     if ($meta['index'] != 0) {
         $params['class'] .= " slider-not-first";
     }
     if ($meta['index'] == 0 && get_post_meta(get_the_ID(), 'header', true) != "no") {
         $params['class'] .= " slider-not-first";
     }
     $params['id'] = "layer_slider_" . avia_sc_layerslider::$slide_count;
     $output .= avia_new_section($params);
     $output .= layerslider_init($atts);
     $output .= "</div>";
     //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'], array('av_layerslider', 'av_section', 'av_slideshow_full', 'av_fullscreen'))) {
         $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;
 }