Пример #1
0
function msd_bootstrap_carousel($atts)
{
    $slidedeck = new SlideDeck();
    extract(shortcode_atts(array('id' => NULL), $atts));
    $sd = $slidedeck->get($id);
    $slides = $slidedeck->fetch_and_sort_slides($sd);
    $i = 0;
    foreach ($slides as $slide) {
        $active = $i == 0 ? ' active' : '';
        $items .= '
        <div style="background: url(' . $slide['image'] . ') center top no-repeat #000000;background-size: cover;" class="item' . $active . '">
           ' . $slide['content'] . '
        </div>';
        $i++;
    }
    return msd_carousel_wrapper($items, array('id' => $id));
}
Пример #2
0
 function __construct()
 {
     parent::__construct();
     include dirname(__FILE__) . '/slide-model.php';
     $slide_type_files = (array) glob(dirname(__FILE__) . '/slides/*/slide.php');
     foreach ((array) $slide_type_files as $filename) {
         if (is_readable($filename)) {
             include_once $filename;
             $slug = basename(dirname($filename));
             $classname = slidedeck2_get_classname_from_filename(dirname($filename));
             $prefix_classname = "SlideDeckSlideType_{$classname}";
             if (class_exists($prefix_classname)) {
                 $this->slide_types[$slug] = new $prefix_classname();
             }
         }
     }
     $this->Slide = new SlideDeckSlideModel();
 }
Пример #3
0
 /**
  * Hook into register_activation_hook action
  * 
  * NOTE: DO NOT RELY ON THIS PLUGIN HOOK FOR DATABASE MIGRATIONS
  * -------------------------------------------------------------
  * WordPress will not run the activation hook properly when it is bulk upgrading plugins
  * so database migrations and the like will not run if the user has selected to bulk update
  * all of their SlideDeck plugins at once. 
  * 
  * Put code here that needs to happen when your plugin is first activated
  * (database
  * creation, permalink additions, etc.)
  *
  * @uses wp_remote_fopen()
  */
 static function activate()
 {
     SlideDeckLitePlugin::load_constants();
     include_once dirname(__FILE__) . '/lib/template-functions.php';
     if (!is_dir(SLIDEDECK2_CUSTOM_LENS_DIR)) {
         if (is_writable(dirname(SLIDEDECK2_CUSTOM_LENS_DIR))) {
             mkdir(SLIDEDECK2_CUSTOM_LENS_DIR, 0777);
         }
     }
     self::check_plugin_updates();
     $installed_version = get_option("slidedeck_version", false);
     $installed_license = get_option("slidedeck_license", false);
     if ($installed_license) {
         if (strtolower($installed_license) == "lite" && strtolower(self::$license) != "lite") {
             // Upgrade from Lite to PRO
             slidedeck2_km("Upgrade to PRO", array('license' => self::$license, 'version' => self::$version));
         }
     }
     // First time installation
     if (!$installed_version) {
         slidedeck2_km("SlideDeck Installed", array('license' => self::$license, 'version' => self::$version));
         // Setup the cohorts data
         self::set_cohort_data();
         // Setup the partner data
         self::set_partner_data();
     }
     if ($installed_version && version_compare(self::$version, $installed_version, '>')) {
         /**
          * 2.0.x to 2.1.x upgrade process...
          */
         if (version_compare($installed_version, '2.1', '<')) {
             if (!class_exists("SlideDeck")) {
                 include dirname(__FILE__) . '/classes/slidedeck.php';
             }
             global $SlideDeckPlugin, $wpdb;
             // Update various cache settings and durations...
             $SlideDeck = new SlideDeck();
             $slidedecks = $SlideDeck->get(null, 'post_title', 'ASC', 'publish');
             foreach ($slidedecks as $slidedeck) {
                 $sources = $slidedeck['source'];
                 if (!is_array($sources)) {
                     $sources = array($sources);
                 }
                 if (count($slidedeck['source']) > 1) {
                     continue;
                 }
                 // Update cache duration option name
                 if (isset($slidedeck['options']['feedCacheDuration'])) {
                     $slidedeck['options']['cache_duration'] = $slidedeck['options']['feedCacheDuration'];
                     unset($slidedeck['options']['feedCacheDuration']);
                 }
                 // Update Twitter source meta
                 if (in_array('twitter', $sources)) {
                     $slidedeck['options']['twitter_search_or_user'] = $slidedeck['options']['search_or_user'];
                     unset($slidedeck['options']['search_or_user']);
                 }
                 // Adjust cache to minutes instead of seconds
                 $intersect = array_intersect(array('twitter', 'youtube', 'vimeo', 'dailymotion'), $sources);
                 if (!empty($intersect)) {
                     $slidedeck['options']['cache_duration'] = round($slidedeck['options']['cache_duration'] / 60);
                 }
                 update_post_meta($slidedeck['id'], "slidedeck_options", $slidedeck['options']);
             }
             // End of Update various cache settings and durations...
         }
         // Upgrade to new version
         slidedeck2_km("SlideDeck Upgraded", array('license' => self::$license, 'version' => self::$version));
     }
     update_option("slidedeck_version", self::$version);
     update_option("slidedeck_license", self::$license);
     /**
      * Installation timestamp: SlideDeck 3
      */
     $existing_timestamp = get_option('slidedeck2_installed', false);
     if (!$existing_timestamp) {
         update_option('slidedeck2_installed', time());
     }
     /**
      * Installation timestamp: SlideDeck 3 Lite
      */
     $existing_timestamp = get_option('slidedeck2_lite_installed', false);
     if (!$existing_timestamp) {
         update_option('slidedeck2_lite_installed', time());
     }
     // Activation
     slidedeck2_km("SlideDeck Activated", array('license' => self::$license, 'version' => self::$version));
 }
Пример #4
0
 /**
  * Hook into register_activation_hook action
  * 
  * NOTE: DO NOT RELY ON THIS PLUGIN HOOK FOR DATABASE MIGRATIONS
  * -------------------------------------------------------------
  * WordPress will not run the activation hook properly when it is bulk upgrading plugins
  * so database migrations and the like will not run if the user has selected to bulk update
  * all of their SlideDeck plugins at once. 
  * 
  * Put code here that needs to happen when your plugin is first activated
  * (database
  * creation, permalink additions, etc.)
  *
  * @uses wp_remote_fopen()
  */
 static function activate()
 {
     SlideDeckPlugin::load_constants();
     include_once dirname(__FILE__) . '/lib/template-functions.php';
     if (!is_dir(SLIDEDECK2_CUSTOM_LENS_DIR)) {
         if (is_writable(dirname(SLIDEDECK2_CUSTOM_LENS_DIR))) {
             mkdir(SLIDEDECK2_CUSTOM_LENS_DIR, 0777);
         }
     }
     self::check_plugin_updates();
     $installed_version = get_option("slidedeck_version", false);
     $installed_license = get_option("slidedeck_license", false);
     if ($installed_license) {
         if (strtolower($installed_license) == "lite" && strtolower(self::$license) != "lite") {
             // Upgrade from Lite to PRO
             slidedeck2_km("Upgrade to PRO", array('license' => self::$license, 'version' => self::$version));
         }
     }
     // First time installation
     if (!$installed_version) {
         slidedeck2_km("SlideDeck Installed", array('license' => self::$license, 'version' => self::$version));
         // Setup the cohorts data
         self::set_cohort_data();
     }
     if ($installed_version && version_compare(self::$version, $installed_version, '>')) {
         /**
          * 2.0.x to 2.1.x upgrade process...
          */
         if (version_compare($installed_version, '2.1', '<')) {
             if (!class_exists("SlideDeck")) {
                 include dirname(__FILE__) . '/classes/slidedeck.php';
             }
             if (!class_exists("SlideDeckSlideModel")) {
                 include dirname(__FILE__) . '/sources/custom/slide-model.php';
             }
             global $SlideDeckPlugin, $wpdb;
             // Import Media Library and List of Videos decks
             $SlideDeck = new SlideDeck();
             $SlideDeckSlide = new SlideDeckSlideModel();
             $SlideDeckPlugin = (object) array();
             $SlideDeckPlugin->SlideDeck = $SlideDeck;
             $slidedecks = $SlideDeck->get(null, 'post_title', 'ASC', 'publish');
             foreach ($slidedecks as $slidedeck) {
                 $sources = $slidedeck['source'];
                 if (!is_array($sources)) {
                     $sources = array($sources);
                 }
                 // Import Media Library SlideDecks
                 if (in_array("medialibrary", $sources) && !in_array("custom", $sources)) {
                     $media_ids = $slidedeck['options']['medialibrary_ids'];
                     $slide_counter = 0;
                     foreach ($media_ids as $media_id) {
                         $media_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d", $media_id));
                         // Get the image meta data
                         $meta_data = wp_get_attachment_metadata($media_id);
                         // Create the slide
                         $slide_id = $SlideDeckSlide->create($slidedeck['id'], "image", array('menu_order' => $slide_counter + 1, 'post_title' => $media_post->post_title, 'post_excerpt' => $media_post->post_excerpt, 'post_content' => $media_post->post_excerpt, 'post_date' => $media_post->post_date));
                         // Associate the image with the slide
                         update_post_meta($slide_id, "_image_attachment", $media_id);
                         update_post_meta($slide_id, "_image_source", "upload");
                         update_post_meta($slide_id, "_image_url", "");
                         $_layout = "body-text";
                         $_caption_position = "left";
                         switch ($slidedeck['lens']) {
                             case "block-title":
                                 $_layout = "body-text";
                                 $_caption_position = "left";
                                 break;
                             case "fashion":
                                 $_layout = "body-text";
                                 $_caption_position = "left";
                                 break;
                             case "half-moon":
                                 $_layout = "body-text";
                                 $_caption_position = "right";
                                 break;
                             case "o-town":
                                 $_layout = "body-text";
                                 $_caption_position = "left";
                                 break;
                             case "proto":
                                 $_layout = "body-text";
                                 $_caption_position = "left";
                                 break;
                         }
                         update_post_meta($slide_id, "_layout", $_layout);
                         update_post_meta($slide_id, "_caption_position", $_caption_position);
                         $slidedeck['options']['total_slides'] = 999;
                         $slide_counter++;
                     }
                     // Update the source
                     add_post_meta($slidedeck['id'], "slidedeck_source", "custom");
                 }
                 // Import Video List SlideDecks
                 if (in_array("listofvideos", $sources) && !in_array("custom", $sources)) {
                     $video_urls = get_post_meta($slidedeck['id'], "slidedeck_list_of_videos", true);
                     $video_urls = explode("\n", $video_urls);
                     $video_urls = array_map("trim", $video_urls);
                     $slide_counter = 0;
                     foreach ($video_urls as $video_url) {
                         $video_meta = $SlideDeck->get_video_meta_from_url($video_url);
                         // Create the slide
                         $slide_id = $SlideDeckSlide->create($slidedeck['id'], "video", array('menu_order' => $slide_counter + 1, 'post_title' => slidedeck2_stip_tags_and_truncate_text($video_meta['title'], $slidedeck['options']['titleLength']), 'post_excerpt' => slidedeck2_stip_tags_and_truncate_text($video_meta['description'], $slidedeck['options']['descriptionLength']), 'post_content' => slidedeck2_stip_tags_and_truncate_text($video_meta['description'], $slidedeck['options']['descriptionLength'])));
                         update_post_meta($slide_id, "_permalink", $video_meta['permalink']);
                         update_post_meta($slide_id, "_video_url", $video_url);
                         update_post_meta($slide_id, "_video_meta", $video_meta);
                         $_layout = "body-text";
                         $_caption_position = "left";
                         switch ($slidedeck['lens']) {
                             case "fashion":
                                 $_layout = "body-text";
                                 $_caption_position = "left";
                                 break;
                             case "o-town":
                                 $_layout = "body-text";
                                 $_caption_position = "left";
                                 break;
                             case "video":
                                 $_layout = "body-text";
                                 $_caption_position = "left";
                                 break;
                         }
                         update_post_meta($slide_id, "_layout", $_layout);
                         update_post_meta($slide_id, "_caption_position", $_caption_position);
                         $slidedeck['options']['total_slides'] = 999;
                         $slidedeck['options']['show-excerpt'] = true;
                         $slidedeck['options']['show-title'] = true;
                         $slidedeck['options']['show-readmore'] = true;
                         $slide_counter++;
                     }
                     // Update the source
                     add_post_meta($slidedeck['id'], "slidedeck_source", "custom");
                     // Proto video lens is being deprecated for custom SlideDecks
                     if ($slidedeck['lens'] == "video") {
                         update_post_meta($slidedeck['id'], "slidedeck_lens", "tool-kit");
                     }
                 }
                 update_post_meta($slidedeck['id'], "slidedeck_options", $slidedeck['options']);
             }
             // End of Import Media Library and List of Videos decks
             // Update various cache settings and durations...
             $SlideDeck = new SlideDeck();
             $slidedecks = $SlideDeck->get(null, 'post_title', 'ASC', 'publish');
             foreach ($slidedecks as $slidedeck) {
                 $sources = $slidedeck['source'];
                 if (!is_array($sources)) {
                     $sources = array($sources);
                 }
                 if (count($slidedeck['source']) > 1) {
                     continue;
                 }
                 // Update cache duration option name
                 if (isset($slidedeck['options']['feedCacheDuration'])) {
                     $slidedeck['options']['cache_duration'] = $slidedeck['options']['feedCacheDuration'];
                     unset($slidedeck['options']['feedCacheDuration']);
                 }
                 // Update Twitter source meta
                 if (in_array('twitter', $sources)) {
                     $slidedeck['options']['twitter_search_or_user'] = $slidedeck['options']['search_or_user'];
                     unset($slidedeck['options']['search_or_user']);
                 }
                 // Adjust cache to minutes instead of seconds
                 $intersect = array_intersect(array('twitter', 'youtube', 'vimeo', 'dailymotion'), $sources);
                 if (!empty($intersect)) {
                     $slidedeck['options']['cache_duration'] = round($slidedeck['options']['cache_duration'] / 60);
                 }
                 update_post_meta($slidedeck['id'], "slidedeck_options", $slidedeck['options']);
             }
             // End of Update various cache settings and durations...
         }
         // Upgrade to new version
         slidedeck2_km("SlideDeck Upgraded", array('license' => self::$license, 'version' => self::$version));
     }
     update_option("slidedeck_version", self::$version);
     update_option("slidedeck_license", self::$license);
     /**
      * Installation timestamp: SlideDeck 2
      */
     $existing_timestamp = get_option('slidedeck2_installed', false);
     if (!$existing_timestamp) {
         update_option('slidedeck2_installed', time());
     }
     /**
      * Installation timestamp: SlideDeck 2 Paid
      */
     $existing_timestamp = get_option('slidedeck2_paid_installed', false);
     if (!$existing_timestamp) {
         update_option('slidedeck2_paid_installed', time());
     }
     // Activation
     slidedeck2_km("SlideDeck Activated", array('license' => self::$license, 'version' => self::$version));
 }