Пример #1
0
 /**
  * Shortcode used to display slideshow
  *
  * @return string HTML output of the shortcode
  */
 public function register_shortcode($atts)
 {
     if (!isset($atts['id'])) {
         return false;
     }
     // handle [metaslider id=123 restrict_to=home]
     if (isset($atts['restrict_to']) && $atts['restrict_to'] == 'home' && !is_front_page()) {
         return;
     }
     // we have an ID to work with
     $slider = get_post($atts['id']);
     // check the slider is published and the ID is correct
     if (!$slider || $slider->post_status != 'publish' || $slider->post_type != 'ml-slider') {
         return "<!-- meta slider {$atts['id']} not found -->";
     }
     // lets go
     $this->set_slider($atts['id'], $atts);
     $this->slider->enqueue_scripts();
     return $this->slider->render_public_slides();
 }
Пример #2
0
 /**
  * Shortcode used to display slideshow
  *
  * @return string HTML output of the shortcode
  */
 public function register_shortcode($atts)
 {
     extract(shortcode_atts(array('id' => false, 'restrict_to' => false), $atts, 'metaslider'));
     if (!$id) {
         return false;
     }
     // handle [metaslider id=123 restrict_to=home]
     if ($restrict_to && $restrict_to == 'home' && !is_front_page()) {
         return;
     }
     if ($restrict_to && $restrict_to != 'home' && !is_page($restrict_to)) {
         return;
     }
     // we have an ID to work with
     $slider = get_post($id);
     // check the slider is published and the ID is correct
     if (!$slider || $slider->post_status != 'publish' || $slider->post_type != 'ml-slider') {
         return "<!-- meta slider {$atts['id']} not found -->";
     }
     // lets go
     $this->set_slider($id, $atts);
     $this->slider->enqueue_scripts();
     return $this->slider->render_public_slides();
 }