/**
  * Updates the plugin to v2.2.1.
  *
  * @param  int $version The current plugin version
  * @return void
  */
 public function migrate_to_221($version)
 {
     // Continue if upgrading from a lower version
     if (version_compare($version, '2.2.1', '<')) {
         // Get the settings
         $settings = get_option('easingslider_settings');
         // Bail if we have no settings or the setting we need
         if (!$settings or !isset($settings->image_resizing)) {
             return;
         }
         // Get all sliders
         $sliders = ES_Slider::all();
         // Migrate the "Image Resizing" option
         foreach ($sliders as $slider) {
             $slider->dimensions->image_resizing = $settings->image_resizing;
             $slider->save();
         }
         // Unset the settings option
         unset($settings->image_resizing);
         // Update the settings
         update_option('easingslider_settings', $settings);
     }
 }
Ejemplo n.º 2
0
    /**
     * Widget settings form
     *
     * @param array $instance The widget instance
     */
    public function form($instance)
    {
        // Get all of the sliders
        $sliders = ES_Slider::all();
        // Print the settings
        ?>
			<p>
				<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'easingslider');
        ?>
</label>
				<input type="text" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" class="widefat" value="<?php 
        if (isset($instance['title'])) {
            echo esc_attr($instance['title']);
        }
        ?>
">
			</p>
			<p>
				<label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        _e('Select Slider:', 'easingslider');
        ?>
</label>
				<select id="<?php 
        echo $this->get_field_id('id');
        ?>
" name="<?php 
        echo $this->get_field_name('id');
        ?>
" class="widefat">
					<option value="-1"><?php 
        _e('&#8212; Select &#8212;', 'easingslider');
        ?>
</option>
					<?php 
        foreach ($sliders as $slider) {
            ?>
						<option value="<?php 
            echo esc_attr($slider->ID);
            ?>
" <?php 
            if (isset($instance['id'])) {
                selected($instance['id'], $slider->ID);
            }
            ?>
><?php 
            echo esc_html($slider->post_title) . sprintf(__(' (ID #%s)', 'easingslider'), $slider->ID);
            ?>
</option>
					<?php 
        }
        ?>
				</select>
			</p>
		<?php 
    }
 /**
  * Gets the Easing Slider "Lite" legacy slider.
  *
  * @return ES_Slider|false
  */
 public function get_lite_slider()
 {
     // Bail if Easing Slider isn't active
     if (!class_exists('ES_Slider')) {
         return false;
     }
     // Get the ID of our "Lite" slider
     $lite_id = get_option('easingslider_lite_slider_id');
     // Get the Easing Slider "Lite" slider
     $lite_slider = ES_Slider::find($lite_id);
     return $lite_slider;
 }
 /**
  * Displays the publish view
  *
  * @return void
  */
 public function display_publish_view()
 {
     // Get the current page
     $page = sanitize_key($_GET['page']);
     // Initiate a new slider
     $slider = ES_Slider::create();
     // Display the view
     require plugin_dir_path(dirname(__FILE__)) . 'partials/edit-slider.php';
 }
 /**
  * Displays the view
  *
  * @return void
  */
 public function display_view()
 {
     // Get the current page
     $page = sanitize_key($_GET['page']);
     // We need Easing Slider to be loaded by now, so continue if it has.
     if (class_exists('ES_Slider')) {
         // Get all sliders
         $sliders = ES_Slider::all();
         // If we have no sliders, tell the user.
         if (empty($sliders)) {
             wp_die(__('You need to create some sliders to use the customizer.', 'easingslider'));
             exit;
         }
         // Get the specified slider, or pick the first one.
         if (isset($_GET['edit'])) {
             // Get and validate the ID, protecting against XSS attacks
             $id = sanitize_key($_GET['edit']);
             // Get the slider
             $slider = ES_Slider::find($id);
         } else {
             // Get the first slider
             $slider = array_shift(array_values($sliders));
         }
         // Display the view
         require plugin_dir_path(dirname(__FILE__)) . 'partials/customizer.php';
     }
 }
Ejemplo n.º 6
0
 /**
  * Uninstall
  *
  * @return void
  */
 public static function do_uninstall()
 {
     // Get the settings
     $settings = get_option('easingslider_settings');
     // If enabled, remove the plugin data
     if ($settings->remove_data) {
         // Delete all of the sliders
         foreach (ES_Slider::all() as $slider) {
             ES_Slider::delete($slider->ID);
         }
         // Delete options
         delete_option('easingslider_version');
         delete_option('easingslider_settings');
         // Remove data hook
         do_action('easingslider_remove_data');
     }
     // Trigger hooks
     do_action('easingslider_uninstall');
 }
Ejemplo n.º 7
0
 /**
  * Renders a slider, returning the HTML
  *
  * @param  array $atts The shortcode attributes
  * @return string
  */
 public function render($atts = array())
 {
     // Allow extensions to modify
     $defaults = apply_filters('easingslider_shortcode_defaults', array('id' => false));
     // Combine shortcode attributes with defaults
     $atts = (object) shortcode_atts($defaults, $atts);
     /**
      * Continue as normal if we have an ID.
      * 
      * Otherwise, let's allow extensions to render sliders using their own method(s).
      */
     if (!empty($atts->id)) {
         // Find the slider
         $slider = ES_Slider::find($atts->id);
         // Display error message if no slider has been found
         if (!$slider) {
             return sprintf(__('<p><strong>The slider specified (ID #%s) could not be found.</strong></p>', 'easingslider'), $atts->id);
         }
         // Render and return the slider
         return $slider->render();
     } else {
         // Start output buffer
         ob_start();
         // Trigger action for our extensions
         do_action('easingslider_display_shortcode', (array) $atts);
         // Return output buffer contents
         return ob_get_clean();
     }
 }
Ejemplo n.º 8
0
 /**
  * Creates the Easing Slider "Lite" legacy slider.
  *
  * @return ES_Slider
  */
 public function create_lite_slider()
 {
     // Create the slider
     $lite_slider = ES_Slider::create();
     $lite_slider->post_title = 'Easing Slider "Lite"';
     $lite_slider->save();
     // Save the Easing Slider "Lite" slider ID
     update_option('easingslider_lite_slider_id', $lite_slider->ID);
     return $lite_slider;
 }
 /**
  * Processes a delete action
  *
  * @param  int $id The slider ID
  * @return void
  */
 public function process_delete_action($id)
 {
     // Delete the slider
     ES_Slider::delete($id);
 }