/**
  * 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 edit view
  *
  * @return void
  */
 public function display_edit_view()
 {
     // Get the page
     $page = sanitize_key($_GET['page']);
     // Show the appropriate view
     if (isset($_GET['edit'])) {
         // Get and validate the ID, protecting against XSS attacks
         $id = sanitize_key($_GET['edit']);
         // Get the slider by its ID
         $slider = ES_Slider::find($id);
         // Display the editor
         require plugin_dir_path(dirname(__FILE__)) . 'partials/edit-slider.php';
     } else {
         // Get the sliders list table
         $list_table = new ES_Sliders_List_Table();
         // Display the list
         require plugin_dir_path(dirname(__FILE__)) . 'partials/list-sliders.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';
     }
 }
Exemplo n.º 4
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();
     }
 }
Exemplo n.º 5
0
 /**
  * Gets the Easing Slider "Lite" legacy slider.
  *
  * @return ES_Slider|false
  */
 public function get_lite_slider()
 {
     // 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;
 }
 /**
  * Processes a duplicate action
  *
  * @param  int $id The slider ID
  * @return void
  */
 public function process_duplicate_action($id)
 {
     // Get the slider
     $slider = ES_Slider::find($id);
     // Unset the slider ID
     unset($slider->ID);
     // Append "- Copy" to the slider title
     $slider->post_title = sprintf(__("%s - Copy", 'easingslider'), $slider->post_title);
     // Save the slider, thus creating a new one as no ID is present.
     $slider->save();
 }