Example #1
0
        public static function enqueue_styles()
        {
            $options = get_option('wp_theater_options');
            $load_css = isset($options['load_css']) ? (int) $options['load_css'] : '';
            if ($load_css) {
                wp_enqueue_style('wp_theater-styles', static::$uri . 'css/style.min.css', array(), '20150426');
            }
        }
        /**
         * Enqueues our scripts
         * @since WP Theater 1.0.0
         */
        public static function enqueue_scripts()
        {
            $options = get_option('wp_theater_options');
            $load_js = isset($options['load_js']) ? (int) $options['load_js'] : '';
            if ($load_js) {
                wp_enqueue_script('wp_theater-scripts', static::$uri . 'js/script.min.js', array('jquery'), '20150426', TRUE);
            }
        }
    }
    /* END CLASS*/
    // define the plugin's location variables
    WP_Theater::$basename = plugin_basename(__FILE__);
    WP_Theater::$dir = trailingslashit(plugin_dir_path(__FILE__));
    WP_Theater::$uri = trailingslashit(plugin_dir_url(__FILE__));
    WP_Theater::$inc = WP_Theater::$dir . trailingslashit('inc');
    // start it up
    WP_Theater::init();
}
/* END EXISTS CHECK */
 /**
  * Main shortcode
  * @since WP Theater 1.0.0
  *
  * @param array $atts The shortcode's attributes
  * @param string $content The shortcode's inner content
  * @param string $tag The shortcode's tag
  *
  * @return string The string to be inserted in place of the shortcode.
  */
 public function video_shortcode($atts, $content = '', $tag)
 {
     // let the plugin know that we need to load assets
     WP_Theater::enqueue_assets();
     // make sure all the atts are clean, setup correctly and extracted
     $atts = $this->format_params($atts, $content, $tag);
     if ($atts === FALSE) {
         return '<!-- WP Theater - format_params failed -->';
     } elseif (is_string($atts)) {
         return '<!-- WP Theater - ' . esc_attr($atts) . ' -->';
     }
     // this is plain stupid!
     extract($atts);
     // can we just embed an iframe?
     if ('embed' == $mode) {
         return $this->get_iframe($atts);
     }
     // can we just embed a theater?
     if ('theater' == $mode) {
         return $this->theater($atts, $content, $tag);
     }
     //// Else we need data ////
     // TODO: Placeholder would needs data for embed/theater
     // get the data
     $feed = $this->get_api_data($atts);
     // make sure there is actually data
     if ($feed === FALSE || is_string($feed)) {
         return '<!-- WP Theater - API request failed -->';
     }
     // make sure there are videos
     if (!isset($feed->videos) || !($count = count($feed->videos))) {
         return '<!-- WP Theater - No Videos -->';
     }
     // check if we need to pull the title from the feed
     if (($title === FALSE || empty($title)) && isset($feed->title)) {
         $title = $feed->title;
     }
     // Do preview or limit videos to $max
     if ($mode == 'preview') {
         return $this->video_preview($feed->videos[0], $atts);
     } elseif ($max !== FALSE && $max > 0 && $max < $count) {
         $max_videos = array_slice($feed->videos, 0, $max);
         $feed->videos = $max_videos;
     }
     //// Start Output ////
     // allow a filter to bypass the output.
     if ($out = apply_filters('wp_theater-pre_video_shortcode', FALSE, $feed, $atts, $content, $tag)) {
         return $out;
     }
     // build the data attr if need be
     $theater_data = $theater_id ? ' data-theater-id="' . esc_attr($theater_id) . '"' : '';
     // add section
     $out = '<section class="' . esc_attr($this->get_element_classes('section', $atts)) . '"' . $theater_data . '>';
     // add the title
     if ($show_title && !empty($title)) {
         $out .= '	<header>';
         $out .= '		<h3>' . apply_filters('wp_theater-section_title', $title) . '</h3>';
         $out .= '	</header>';
     }
     // add theater
     if ($show_theater) {
         $out .= $this->theater($atts, '', $tag, $feed->videos[0]);
     }
     // add the video listing
     $out .= '	<ul class="' . esc_attr($this->get_element_classes('list', $atts) . ' ' . 'cols-' . $atts['columns']) . '">';
     $is_first = TRUE;
     foreach ($feed->videos as $video) {
         $out .= $this->video_preview($video, $atts, $is_first);
         if ($is_first) {
             $is_first = FALSE;
         }
         // switch this so it pops off first elm
     }
     $out .= '	</ul>';
     // add the more link
     if ($show_more_link) {
         if ($more_url) {
             $feed->url = $more_url;
         }
         if (isset($feed->url) && !empty($feed->url)) {
             if (!$more_text) {
                 $more_text = apply_filters('wp_theater-more_text', __('More', 'wptheater') . ' ' . $title);
             }
             $out .= '	<footer>';
             $out .= '		<a href="' . esc_url($feed->url) . '" title="' . esc_attr($more_text) . '" rel="external" target="_blank" class="wp-theater-more-link"><span>' . $more_text . '</span></a>';
             $out .= '	</footer>';
         }
     }
     // close the section
     $out .= '</section>';
     return $out;
 }