/** * Imports old settings from the old Easing Slider plugin (v1.x). * We don't do this automatically in the ESL_Upgrade class. Instead, we give the user the choice through the 'Edit Slideshow' panel. * This is because users were having issues with the plugin deactivating after upgrade, failing to fire the automatic process. * Although this solution isn't ideal, it is the best failsafe. * * @since 2.1.1 */ public static final function legacy_import() { /** Reset the plugin */ EasingSliderLite::get_instance()->uninstall(); EasingSliderLite::get_instance()->activate(); /** Get default slideshow settings */ $slideshow = EasingSliderLite::get_instance()->slideshow_defaults(); /** Transfer the settings */ $slideshow->dimensions->width = get_option('width'); $slideshow->dimensions->height = get_option('height'); $slideshow->dimensions->responsive = false; $slideshow->transitions->effect = get_option('transition') == 'fade' ? 'fade' : 'slide'; $slideshow->transitions->duration = get_option('transpeed'); $slideshow->navigation->arrows = get_option('buttons') == '' ? 'false' : 'true'; $slideshow->navigation->pagination = get_option('sPagination') == '' ? 'false' : 'true'; $slideshow->playback->pause = get_option('interval'); /** Add the slides */ $slideshow->slides = array(); for ($i = 1; $i <= 10; $i++) { /** Check if the slide has an image. Bail if not. */ $image = get_option("sImg{$i}"); if (empty($image)) { continue; } /** Resize the image and get its thumbnail */ $sizes = (object) array('thumbnail' => (object) array('url' => $image)); /** Add the slide image & link */ $slideshow->slides[] = (object) array('id' => $i, 'url' => $image, 'alt' => null, 'title' => null, 'link' => get_option("sImgLink{$i}"), 'linkTarget' => '_blank', 'sizes' => $sizes); } /** Update the slideshow settings */ update_option('easingsliderlite_slideshow', $slideshow); /** Flag upgrade */ update_option('easingsliderlite_major_upgrade', 1); }
/** * Prints the slideshow custom styling * * @since 2.1 */ public static function print_custom_styles() { /** Get the customizations & defaults */ $customizations = $c = json_decode(get_option('easingsliderlite_customizations')); $defaults = EasingSliderLite::get_instance()->customization_defaults(); /** Bail if there are no customizations */ if ($defaults == $c) { return; } /** Print the styling. Long selectors here ensure styles take preference over CSS files. */ ob_start(); ?> <style type="text/css"> .easingsliderlite { <?php if ($defaults->border->color != $c->border->color) { echo "border-color: {$c->border->color};"; } ?> <?php if ($defaults->border->width != $c->border->width) { echo "border-width: {$c->border->width}px; border-style: solid;"; } ?> <?php if ($defaults->border->radius != $c->border->radius) { echo "-webkit-border-radius: {$c->border->radius}px; -moz-border-radius: {$c->border->radius}px; border-radius: {$c->border->radius}px;"; } ?> } .easingsliderlite .easingsliderlite-arrows.easingsliderlite-next, .easingsliderlite .easingsliderlite-arrows.easingsliderlite-prev { <?php if ($defaults->arrows->width != $c->arrows->width) { echo "width: {$c->arrows->width}px;"; } ?> <?php if ($defaults->arrows->height != $c->arrows->height) { $margin_top = $c->arrows->height / 2; echo "height: {$c->arrows->height}px; margin-top: -{$margin_top}px;"; } ?> } .easingsliderlite .easingsliderlite-arrows.easingsliderlite-next { <?php if ($defaults->arrows->next != $c->arrows->next) { echo "background-image: url({$c->arrows->next});"; } ?> } .easingsliderlite .easingsliderlite-arrows.easingsliderlite-prev { <?php if ($defaults->arrows->prev != $c->arrows->prev) { echo "background-image: url({$c->arrows->prev});"; } ?> } .easingsliderlite .easingsliderlite-pagination .easingsliderlite-icon { <?php if ($defaults->pagination->width != $c->pagination->width) { echo "width: {$c->pagination->width}px;"; } ?> <?php if ($defaults->pagination->height != $c->pagination->height) { echo "height: {$c->pagination->height}px;"; } ?> } .easingsliderlite .easingsliderlite-pagination .easingsliderlite-icon.inactive { <?php if ($defaults->pagination->inactive != $c->pagination->inactive) { echo "background-image: url({$c->pagination->inactive});"; } ?> } .easingsliderlite .easingsliderlite-pagination .easingsliderlite-icon.active { <?php if ($defaults->pagination->active != $c->pagination->active) { echo "background-image: url({$c->pagination->active});"; } ?> } </style> <?php print preg_replace('/\\s+/', ' ', ob_get_clean()); }
/** * Customization page actions * * @since 2.1 */ public function do_customizer_actions($page) { /** Save customizations */ if (isset($_POST['save'])) { /** Security check */ if (!$this->security_check('save', $page)) { wp_die(__('Security check has failed. Save has been prevented. Please try again.', 'easingsliderlite')); exit; } /** Save the customizations */ update_option('easingsliderlite_customizations', json_encode(EasingSliderLite::get_instance()->validate((object) array('arrows' => (object) $_POST['arrows'], 'pagination' => (object) $_POST['pagination'], 'border' => (object) $_POST['border'], 'shadow' => (object) $_POST['shadow'])))); } }
<?php /** Get the slideshow */ $slideshow = $s = EasingSliderLite::get_instance()->validate(get_option('easingsliderlite_slideshow')); /** Get customizations */ $customizations = $c = json_decode(get_option('easingsliderlite_customizations')); /** Bail if we failed to retrieve the slideshow */ if ($s === false) { if (current_user_can('easingsliderlite_edit_slideshow')) { _e('<p style="background-color: #ffebe8; border: 1px solid #c00; border-radius: 4px; padding: 8px !important;">The slideshow does not appear to exist. Oh dear! Please try contacting support.</p>', 'easingsliderlite'); } return; } /** Bail if there are no slides to display */ if (count($slideshow->slides) == 0) { if (current_user_can('easingsliderlite_edit_slideshow')) { _e('<p style="background-color: #ffebe8; border: 1px solid #c00; border-radius: 4px; padding: 8px !important;">This slideshow contains no slides. Uh oh!', 'easingsliderlite'); } return; } /** Get plugin settings */ $settings = get_option('easingsliderlite_settings'); /** Load slideshow scripts and styles in foooter (if set to do so) */ if (isset($settings['load_scripts']) && $settings['load_scripts'] == 'footer') { add_action('wp_footer', array('ESL_Slideshow', 'enqueue_scripts')); } if (isset($settings['load_styles']) && $settings['load_styles'] == 'footer') { add_action('wp_footer', array('ESL_Slideshow', 'enqueue_styles')); add_action('wp_footer', array('ESL_Slideshow', 'print_custom_styles')); } /** Inline slideshow styles */
/** * Does 2.1 plugin upgrade * * @since 2.1 */ public static final function do_210_upgrade() { global $wp_roles; /** Add the customizations database option */ add_option('easingsliderlite_customizations', json_encode(EasingSliderLite::get_instance()->customization_defaults())); /** Add the customization panel capability */ foreach ($wp_roles->roles as $role => $info) { EasingSliderLite::get_instance()->add_capability('easingsliderlite_can_customize', get_role($role)); } }