示例#1
0
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     extract($args);
     $id = (int) $instance['viral'];
     if (!empty($id)) {
         global $wpdb;
         $tableViral = $wpdb->prefix . 'viralcs_virals';
         $viral = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$tableViral} WHERE id = %d", $id));
         if (!empty($viral)) {
             if (!class_exists('VcsShortcode')) {
                 include_once VIRALCONTENTSLIDER_PLUGIN_DIR . 'codes/shortcodes/shortcode.php';
             }
             $shortcode = new VcsShortcode($viral, 'wdg');
             echo $shortcode->generate();
         }
     }
 }
示例#2
0
 /**
  * Display shortcode
  * @param $atts get parameter from the shortcode
  * More info please visit http://codex.wordpress.org/Shortcode_API
  */
 public function viralcontentslider_shortcode($atts)
 {
     extract(shortcode_atts(array('id' => ''), $atts));
     if (!empty($id)) {
         global $wpdb;
         $tableViral = $wpdb->prefix . 'viralcs_virals';
         $viral = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$tableViral} WHERE id = %d AND deleted_at IS NULL", $id));
         if (!empty($viral)) {
             if (!class_exists('VcsShortcode')) {
                 include_once VIRALCONTENTSLIDER_PLUGIN_DIR . 'codes/shortcodes/shortcode.php';
             }
             $shortcode = new VcsShortcode($viral, 'sdc');
             /**
              * Check for extension options
              * If the display in home setting is yes then show the slider
              */
             if (class_exists('VcsExtension')) {
                 $extensionOptions = $this->get_extension_options($viral->id);
                 if (!empty($extensionOptions)) {
                     /**
                      * If home page is displayed and display in home option is yes, then display the slider
                      * More info can be found here http://codex.wordpress.org/Function_Reference/is_home
                      */
                     if (is_home() && $extensionOptions->display_in_home == 'yes') {
                         return $shortcode->generate();
                     }
                 }
             }
             /**
              * If single page is displayed then always display the slider
              * More info can be found here http://codex.wordpress.org/Function_Reference/is_single
              */
             if (is_single() || is_page()) {
                 return $shortcode->generate();
             }
         }
     }
 }