コード例 #1
0
ファイル: common.php プロジェクト: jkhedani/ccsa
    }
    /**
     * Helper method to return the max execution time for scripts.
     *
     * @since 1.0.0
     *
     * @param int $time The max execution time available for PHP scripts.
     */
    public function get_max_execution_time()
    {
        $time = ini_get('max_execution_time');
        return !$time || empty($time) ? (int) 0 : $time;
    }
    /**
     * Returns the singleton instance of the class.
     *
     * @since 1.0.0
     *
     * @return object The Soliloquy_Common object.
     */
    public static function get_instance()
    {
        if (!isset(self::$instance) && !self::$instance instanceof Soliloquy_Common) {
            self::$instance = new Soliloquy_Common();
        }
        return self::$instance;
    }
}
// Load the common class.
$soliloquy_common = Soliloquy_Common::get_instance();
コード例 #2
0
ファイル: common.php プロジェクト: jkhedani/ccsa
 /**
  * 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::get_instance()->flush_slider_caches($id);
     // Return early if not an Soliloquy slider.
     if ('soliloquy' !== $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);
 }
コード例 #3
0
ファイル: metaboxes.php プロジェクト: plaste/pulvermuhle
 /**
  * Helper method for retrieving aria-live priorities
  *
  * @since 2.4.0.9
  *
  * @return array Array of aria-live priorities
  */
 public function get_aria_live_values()
 {
     $instance = Soliloquy_Common::get_instance();
     return $instance->get_aria_live_values();
 }
コード例 #4
0
ファイル: shortcode.php プロジェクト: jkhedani/ccsa
 /**
  * Helper method for retrieving meta values.
  *
  * @since 1.0.0
  *
  * @param string $key    The config key to retrieve.
  * @param int $attach_id The attachment ID to target.
  * @param array $data    The slider data to use for retrieval.
  * @return string        Key value on success, default if not set.
  */
 public function get_meta($key, $attach_id, $data)
 {
     $instance = Soliloquy_Common::get_instance();
     return isset($data['slider'][$attach_id][$key]) ? $data['slider'][$attach_id][$key] : $instance->get_meta_default($key, $attach_id);
 }
コード例 #5
0
 /**
  * Checks if a Soliloquy Dynamic Slider already exists. If not, a dynamic slider is created.
  *
  * @since 2.1.9
  */
 public function generate_dynamic_slider()
 {
     global $wpdb;
     // Get Soliloquy Common Instance
     $instance = Soliloquy_Common::get_instance();
     // Generate the custom slider options holder for default dynamic galleries if it does not exist.
     $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '%s' AND post_type = '%s' LIMIT 1", 'soliloquy-dynamic-slider', 'soliloquy');
     $exists = $wpdb->get_var($query);
     if (!is_null($exists)) {
         update_option('soliloquy_dynamic', $exists);
         return;
     }
     // Dynamic slider does not exist - create it
     $args = array('post_type' => 'soliloquy', 'post_name' => 'soliloquy-dynamic-slider', 'post_title' => __('Soliloquy Dynamic Slider', 'soliloquy-dynamic'), 'post_status' => 'publish');
     $dynamic_id = wp_insert_post($args);
     // If successful, update our option so that we can know which slider is dynamic.
     if ($dynamic_id) {
         update_option('soliloquy_dynamic', $dynamic_id);
         // Loop through the defaults and prepare them to be stored.
         $defaults = $instance->get_config_defaults($dynamic_id);
         foreach ($defaults as $key => $default) {
             $fields['config'][$key] = $default;
         }
         // Update some default post meta fields.
         $fields = array('id' => $dynamic_id, 'config' => array('title' => __('Soliloquy Dynamic Slider', 'soliloquy-dynamic'), 'slug' => 'soliloquy-dynamic-slider', 'classes' => array('soliloquy-dynamic-slider'), 'type' => 'dynamic'), 'slider' => array());
         // Update the meta field.
         update_post_meta($dynamic_id, '_sol_slider_data', $fields);
     }
 }
コード例 #6
0
ファイル: ajax.php プロジェクト: jkhedani/ccsa
/**
 * Saves the metadata for an image in a slider.
 *
 * @since 1.0.0
 */
function soliloquy_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);
    // 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($meta['status'])) {
        $slider_data['slider'][$attach_id]['status'] = trim(esc_html($meta['status']));
    }
    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['linktab']) && $meta['linktab']) {
        $slider_data['slider'][$attach_id]['linktab'] = 1;
    } else {
        $slider_data['slider'][$attach_id]['linktab'] = 0;
    }
    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['src'])) {
        $slider_data['slider'][$attach_id]['src'] = esc_url($meta['src']);
    }
    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::get_instance()->flush_slider_caches($post_id);
    echo json_encode(true);
    die;
}
コード例 #7
0
/**
 * Callback function for cropping lightbox thumbs.
 *
 * @since 1.0.0
 *
 * @param array $settings  Array of settings to be saved.
 * @param int $post_id     The current post ID.
 * @param object $post     The current post object.
 */
function soliloquy_lightbox_crop_images($args, $post_id)
{
    // Gather all available images to crop.
    $slider_data = get_post_meta($post_id, '_sol_slider_data', true);
    $images = !empty($slider_data['slider']) ? $slider_data['slider'] : false;
    $common = Soliloquy_Common::get_instance();
    // Loop through the images and crop them.
    if ($images) {
        // Increase the time limit to account for large image sets and suspend cache invalidations.
        set_time_limit(0);
        wp_suspend_cache_invalidation(true);
        foreach ($images as $id => $item) {
            // Get the full image attachment. If it does not return the data we need, skip over it.
            $image = wp_get_attachment_image_src($id, 'full');
            if (!is_array($image)) {
                // Check for video/HTML slide and possibly use a thumbnail instead.
                if ((isset($item['type']) && 'video' == $item['type'] || isset($item['type']) && 'html' == $item['type']) && !empty($item['thumb'])) {
                    $image = $item['thumb'];
                } else {
                    continue;
                }
            } else {
                $image = $image[0];
            }
            // Allow image to be filtered to use a different thumbnail than the main image.
            $image = apply_filters('soliloquy_cropped_image', $image, $id, $item, $args, $post_id);
            // Generate the cropped image.
            $cropped_image = $common->resize_image($image, $args['width'], $args['height'], true, $args['position'], $args['quality'], $args['retina']);
            // If there is an error, possibly output error message, otherwise woot!
            if (is_wp_error($cropped_image)) {
                // If debugging is defined, print out the error.
                if (defined('SOLILOQUY_CROP_DEBUG') && SOLILOQUY_CROP_DEBUG) {
                    echo '<pre>' . var_export($cropped_image->get_error_message(), true) . '</pre>';
                }
            } else {
                $slider_data['slider'][$id]['lb_thumb'] = $cropped_image;
            }
        }
        // Turn off cache suspension and flush the cache to remove any cache inconsistencies.
        wp_suspend_cache_invalidation(false);
        wp_cache_flush();
        // Update the slider data.
        update_post_meta($post_id, '_sol_slider_data', $slider_data);
    }
}
コード例 #8
0
ファイル: metaboxes.php プロジェクト: jkhedani/ccsa
 /**
  * Helper method for retrieving slider positions.
  *
  * @since 1.0.0
  *
  * @return array Array of thumbnail position data.
  */
 public function get_slider_positions()
 {
     $instance = Soliloquy_Common::get_instance();
     return $instance->get_slider_positions();
 }