Beispiel #1
0
 /**
  * Helper method for retrieving slider transitions.
  *
  * @since 1.0.0
  *
  * @return array Array of thumbnail transition data.
  */
 public function get_slider_transitions()
 {
     $instance = Soliloquy_Common_Lite::get_instance();
     return $instance->get_slider_transitions();
 }
Beispiel #2
0
 /**
  * Untrash a slider when the slider post type is untrashed.
  *
  * @since 1.0.0
  *
  * @param $id   The post ID being untrashed.
  * @return null Return early if no slider is found.
  */
 public function untrash_slider($id)
 {
     $slider = get_post($id);
     // Flush necessary slider caches to ensure untrashed sliders are showing.
     Soliloquy_Common_Lite::get_instance()->flush_slider_caches($id);
     // Return early if not an Soliloquy slider.
     if ('soliloquyv2' !== $slider->post_type) {
         return;
     }
     // Set the slider status to inactive.
     $slider_data = get_post_meta($id, '_sol_slider_data', true);
     if (empty($slider_data)) {
         return;
     }
     if (isset($slider_data['status'])) {
         unset($slider_data['status']);
     }
     update_post_meta($id, '_sol_slider_data', $slider_data);
 }
 /**
  * Helper method for retrieving config values.
  *
  * @since 1.0.0
  *
  * @param string $key The config key to retrieve.
  * @param array $data The slider data to use for retrieval.
  * @return string     Key value on success, default if not set.
  */
 public function get_config($key, $data)
 {
     $instance = Soliloquy_Common_Lite::get_instance();
     return isset($data['config'][$key]) ? $data['config'][$key] : $instance->get_config_default($key);
 }
Beispiel #4
0
 /**
  * Returns the singleton instance of the class.
  *
  * @since 1.0.0
  *
  * @return object The Soliloquy_Common_Lite object.
  */
 public static function get_instance()
 {
     if (!isset(self::$instance) && !self::$instance instanceof Soliloquy_Common_Lite) {
         self::$instance = new Soliloquy_Common_Lite();
     }
     return self::$instance;
 }
Beispiel #5
0
/**
 * Saves the metadata for an image in a slider.
 *
 * @since 1.0.0
 */
function soliloquy_lite_ajax_save_meta()
{
    // Run a security check first.
    check_ajax_referer('soliloquy-save-meta', 'nonce');
    // Prepare variables.
    $post_id = absint($_POST['post_id']);
    $attach_id = $_POST['attach_id'];
    $meta = $_POST['meta'];
    $slider_data = get_post_meta($post_id, '_sol_slider_data', true);
    // Save the different types of default meta fields for images, videos and HTML slides.
    if (isset($meta['title'])) {
        $slider_data['slider'][$attach_id]['title'] = trim(esc_html($meta['title']));
    }
    if (isset($meta['alt'])) {
        $slider_data['slider'][$attach_id]['alt'] = trim(esc_html($meta['alt']));
    }
    if (isset($meta['link'])) {
        $slider_data['slider'][$attach_id]['link'] = esc_url($meta['link']);
    }
    if (isset($meta['caption'])) {
        $slider_data['slider'][$attach_id]['caption'] = trim($meta['caption']);
    }
    if (isset($meta['url'])) {
        $slider_data['slider'][$attach_id]['url'] = esc_url($meta['url']);
    }
    if (isset($meta['thumb'])) {
        $slider_data['slider'][$attach_id]['thumb'] = esc_url($meta['thumb']);
        $slider_data['slider'][$attach_id]['src'] = esc_url($meta['thumb']);
    }
    if (isset($meta['code'])) {
        $slider_data['slider'][$attach_id]['code'] = trim($meta['code']);
    }
    // Allow filtering of meta before saving.
    $slider_data = apply_filters('soliloquy_ajax_save_meta', $slider_data, $meta, $attach_id, $post_id);
    // Update the slider data.
    update_post_meta($post_id, '_sol_slider_data', $slider_data);
    // Flush the slider cache.
    Soliloquy_Common_Lite::get_instance()->flush_slider_caches($post_id);
    echo json_encode(true);
    die;
}
Beispiel #6
0
 /**
  * Update Soliloquy Lite slides to include ID and Attachemnt ID.
  * 
  * @access public
  * @param mixed $post_id
  * @return void
  */
 function update_slides($post_id)
 {
     // Grab and update any slider data if necessary.
     $in_slider = get_post_meta($post_id, '_sol_in_slider', true);
     if (empty($in_slider)) {
         $in_slider = array();
     }
     // Set data and order of image in slider.
     $slider_data = get_post_meta($post_id, '_sol_slider_data', true);
     if (empty($slider_data)) {
         $slider_data = array();
     }
     // If no slider ID has been set, set it now.
     if (empty($slider_data['id'])) {
         $slider_data['id'] = $post_id;
     }
     foreach ($slider_data['slider'] as $id => $data) {
         if (!array_key_exists('id', $data) || !array_key_exists('attachment_id', $data)) {
             $slide = array('status' => $data['status'], 'id' => $id, 'attachment_id' => $id, 'src' => $data['src'], 'title' => $data['title'], 'link' => $data['link'], 'alt' => $data['alt'], 'caption' => $data['caption'], 'type' => $data['type']);
         } else {
             $slide = array('status' => $data['status'], 'id' => $data['id'], 'attachment_id' => $data['attachment_id'], 'src' => $data['src'], 'title' => $data['title'], 'link' => $data['link'], 'alt' => $data['alt'], 'caption' => $data['caption'], 'type' => $data['type']);
         }
         $slider_data['slider'][$id] = $slide;
         $in_slider[] = $id;
     }
     // Update the slider data.
     // update_post_meta( $post_id, '_sol_in_slider', $in_slider );
     update_post_meta($post_id, '_sol_slider_data', $slider_data);
     Soliloquy_Common_Lite::get_instance()->flush_slider_caches($post_id);
     return $slider_data;
 }
Beispiel #7
0
 function change_slide_status()
 {
     // Run a security check first.
     check_ajax_referer('soliloquy-save-meta', 'nonce');
     // Prepare variables.
     $post_id = absint($_POST['post_id']);
     $attach_id = $_POST['slide_id'];
     $status = $_POST['status'];
     $slider_data = get_post_meta($post_id, '_sol_slider_data', true);
     // Go ahead and ensure to store the attachment ID.
     $slider_data['slider'][$attach_id]['id'] = $attach_id;
     // Save the different types of default meta fields for images, videos and HTML slides.
     if (isset($status)) {
         $slider_data['slider'][$attach_id]['status'] = trim(esc_html($status));
     }
     // Allow filtering of meta before saving.
     $slider_data = apply_filters('soliloquy_ajax_change_status', $slider_data, $status, $attach_id, $post_id);
     // Update the slider data.
     update_post_meta($post_id, '_sol_slider_data', $slider_data);
     // Flush the slider cache.
     Soliloquy_Common_Lite::get_instance()->flush_slider_caches($post_id);
     wp_send_json_success();
     die;
 }