예제 #1
0
파일: shortcode.php 프로젝트: jkhedani/ccsa
    {
        // If there are no images, don't do anything.
        $images = '';
        $i = 1;
        if (empty($this->index[$id])) {
            return $images;
        }
        foreach ((array) $this->index[$id] as $attach_id => $data) {
            $images .= '<img class="soliloquy-image soliloquy-no-js-image" src="' . esc_url($data['src']) . '" alt="' . esc_attr($data['alt']) . '" />';
            $i++;
        }
        return apply_filters('soliloquy_indexable_images', $images, $this->index, $id);
    }
    /**
     * Returns the singleton instance of the class.
     *
     * @since 1.0.0
     *
     * @return object The Soliloquy_Shortcode object.
     */
    public static function get_instance()
    {
        if (!isset(self::$instance) && !self::$instance instanceof Soliloquy_Shortcode) {
            self::$instance = new Soliloquy_Shortcode();
        }
        return self::$instance;
    }
}
// Load the shortcode class.
$soliloquy_shortcode = Soliloquy_Shortcode::get_instance();
예제 #2
0
 /**
  * Internal method that returns all sliders created on the site.
  *
  * @since 1.0.0
  *
  * @return array|bool Array of slider data or false if none found.
  */
 public function _get_sliders()
 {
     $sliders = get_posts(array('post_type' => 'any', 'no_found_rows' => true, 'cache_results' => false, 'nopaging' => true, 'fields' => 'ids', 'meta_query' => array(array('key' => '_sol_slider_data'))));
     if (empty($sliders)) {
         return false;
     }
     // Now loop through all the sliders found and only use sliders that have images in them.
     $ret = array();
     foreach ($sliders as $id) {
         $data = get_post_meta($id, '_sol_slider_data', true);
         if (empty($data['slider']) && 'default' == Soliloquy_Shortcode::get_instance()->get_config('type', $data) || 'dynamic' == Soliloquy_Shortcode::get_instance()->get_config('type', $data)) {
             continue;
         }
         $ret[] = $data;
     }
     // Return the slider data.
     return $ret;
 }
/**
 * Adds a Lightbox Theme CSS file to the array of stylesheets to be loaded, if
 * the given slider data's config specifies a non-base theme
 *
 * @since 2.2.3
 *
 * @param array $stylesheets Stylesheets
 * @param array $data Slider Data
 * @return array Stylesheets
 */
function soliloquy_lightbox_theme($stylesheets, $data)
{
    // Get instance
    $instance = Soliloquy_Shortcode::get_instance();
    // Get theme
    $theme = $instance->get_config('lightbox_theme', $data);
    // Check theme isn't base
    if ('base' == $theme) {
        return $stylesheets;
    }
    // Add stylesheet to array for loading
    $stylesheets[] = array('id' => SOLILOQUY_LIGHTBOX_PLUGIN_SLUG . $theme . '-theme-style-css', 'href' => esc_url(add_query_arg('ver', SOLILOQUY_LIGHTBOX_PLUGIN_VERSION, plugins_url('themes/' . $theme . '/style.css', __FILE__))));
    // Return
    return $stylesheets;
}
예제 #4
0
/**
 * Amends the image dimensions = carousel width and height
 *
 * Called when "Set Dimensions on Images" is enabled
 *
 * @since 2.1.4
 *
 * @param array $dimensions Width and Height Dimensions
 * @param array $data Slider Data
 * @return array Dimensions
 */
function soliloquy_carousel_image_dimensions($dimensions, $data)
{
    // If there is no carousel, don't output anything.
    $instance = Soliloquy_Shortcode::get_instance();
    if (!$instance->get_config('carousel', $data)) {
        return $dimensions;
    }
    // Change dimensions = carousel
    $dimensions = array('width' => $instance->get_config('carousel_width', $data), 'height' => $instance->get_config('carousel_height', $data));
    return $dimensions;
}
예제 #5
0
 /**
  * Retrieves the image data for a given NextGen Gallery ID
  *
  * @param array $dynamic_data 	Existing Dynamic Data Array
  * @param int $id				NextGen Gallery ID
  * @param array $data			Slider Configuration
  * @return bool|array			Array of data on success, false on failure
  */
 public function get_nextgen_images($dynamic_data, $id, $data)
 {
     // Return false if the NextGen database class is not available.
     if (!class_exists('nggdb')) {
         return false;
     }
     // Get shortcode instance
     $instance = Soliloquy_Shortcode::get_instance();
     // Get NextGen Gallery ID
     $nextgen_id = explode('-', $id);
     $id = $nextgen_id[1];
     // Get NextGen Gallery Objects
     $nggdb = new nggdb();
     $objects = apply_filters('soliloquy_dynamic_get_nextgen_image_data', $nggdb->get_gallery($id), $id);
     // Return if no objects found
     if (!$objects) {
         return false;
     }
     // Build gallery
     foreach ((array) $objects as $key => $object) {
         // Depending on the NextGEN version, the structure of the object will vary
         if (!isset($object->_ngiw)) {
             // Get path for gallery
             if (!isset($nextgen_gallery_path)) {
                 global $wpdb;
                 $nextgen_gallery_path = $wpdb->get_row($wpdb->prepare("SELECT path FROM {$wpdb->nggallery} WHERE gid = %d", $id));
             }
             $image = $object->_orig_image;
             $image_url = get_bloginfo('url') . '/' . $nextgen_gallery_path->path . '/' . str_replace(' ', '%20', $image->filename);
         } else {
             $image = $object->_ngiw->_orig_image;
             $image_url = get_bloginfo('url') . '/' . $image->path . '/' . str_replace(' ', '%20', $image->filename);
         }
         // Build image attributes to match Envira Gallery
         $dynamic_data[$image->pid] = array('src' => $image_url, 'title' => isset($image->alttext) ? strip_tags(esc_attr($image->alttext)) : '', 'link' => '', 'alt' => isset($image->alttext) ? strip_tags(esc_attr($image->alttext)) : '', 'caption' => isset($image->description) ? $image->description : '');
         // Set the link property based on $data variable.
         $link = $instance->get_config('link', $data);
         if ($link) {
             if ('file' == $link || 'attachment' == $link) {
                 $dynamic_data[$image->pid]['link'] = isset($image_url) ? esc_url($image_url) : '';
             }
         }
     }
     return apply_filters('soliloquy_dynamic_nextgen_images', $dynamic_data, $objects, $id, $data);
 }
예제 #6
0
 /**
  * Grabs JS and executes it for any uninitialised sliders on screen
  *
  * Used by soliloquyInitManually() JS function, which in turn is called
  * by AJAX requests e.g. after an Infinite Scroll event.
  *
  * @since 1.0.0
  */
 function init_sliders()
 {
     // Run a security check first.
     check_ajax_referer('soliloquy-ajax-nonce', 'ajax_nonce');
     // Check we have some slider IDs
     if (!isset($_REQUEST['ids'])) {
         die;
     }
     // Setup instance
     $instance = Soliloquy_Shortcode::get_instance();
     $base = Soliloquy::get_instance();
     // Build JS for each slider
     $js = '';
     foreach ($_REQUEST['ids'] as $slider_id) {
         // Get slider
         $data = $base->get_slider($slider_id);
         // If no slider found, skip
         if (!$data) {
             if (class_exists('Soliloquy_Dynamic_Common')) {
                 $dynamic_id = Soliloquy_Dynamic_Common::get_instance()->get_dynamic_id();
                 $defaults = get_post_meta($dynamic_id, '_sol_slider_data', true);
                 $data = $defaults;
                 $data['id'] = 'custom_' . $slider_id;
             } else {
                 continue;
             }
         }
     }
     // Output JS
     echo $js;
     die;
 }
/**
 * Outputs the custom CSS to the specific slider.
 *
 * @since 1.0.0
 *
 * @param string $slider  The HTML output for the slider.
 * @param array $data     Data for the slider.
 * @return string $slider Amended slider HTML.
 */
function soliloquy_custom_css_output($slider, $data)
{
    // If there is no style, return the default slider HTML.
    $instance = Soliloquy_Shortcode::get_instance();
    if (!$instance->get_config('custom_css', $data)) {
        return $slider;
    }
    // Build out the custom CSS.
    $style = '<style type="text/css">' . $instance->minify(html_entity_decode($data['config']['custom_css'])) . '</style>';
    // Return the style prepended to the slider.
    return $style . $slider;
}
예제 #8
0
 /**
  * Retrieves the caption for the specified post.
  *
  * @since 1.0.0
  *
  * @return string The caption to use for the slide.
  */
 function get_caption($post, $data)
 {
     // Prepare variables.
     $instance = Soliloquy_Shortcode::get_instance();
     $output = '';
     $title = false;
     $above = false;
     // Since our title is first, check to see if we should build that in first.
     if ($instance->get_config('fc_post_title', $data)) {
         if (!empty($post->post_title)) {
             $title = true;
             $output = apply_filters('soliloquy_fc_before_title', $output, $post, $data);
             $output .= '<h2 class="soliloquy-fc-title">';
             // Possibly link the title.
             if ($instance->get_config('fc_post_title_link', $data)) {
                 $output .= '<a class="soliloquy-fc-title-link" href="' . get_permalink($post->ID) . '" title="' . esc_attr($post->post_title) . '">' . $post->post_title . '</a>';
             } else {
                 $output .= $post->post_title;
             }
             $output .= '</h2>';
             $output = apply_filters('soliloquy_fc_after_title', $output, $post, $data);
         }
     }
     // Now that we have built our title, let's possibly build out our caption.
     $content = $instance->get_config('fc_content_type', $data);
     // If the post excerpt, build out the post excerpt caption.
     if ('post_excerpt' == $content) {
         if (!empty($post->post_excerpt)) {
             $above = true;
             $output = apply_filters('soliloquy_fc_before_caption', $output, $post, $data);
             $excerpt = apply_filters('soliloquy_fc_post_excerpt', $post->post_excerpt, $post, $data);
             $output .= '<div class="soliloquy-fc-content' . ($title ? ' soliloquy-fc-title-above' : '') . '"><p>' . $excerpt;
             $output = apply_filters('soliloquy_fc_after_caption', $output, $post, $data);
         }
     }
     // If the post content, build out the post content caption.
     if ('post_content' == $content) {
         if (!empty($post->post_content)) {
             $above = true;
             $output = apply_filters('soliloquy_fc_before_caption', $output, $post, $data);
             // Strip shortcodes to prevent recursion
             $pcontent = strip_shortcodes($post->post_content);
             // Get Post Content as HTML or Plain Text
             if ($instance->get_config('fc_content_html', $data)) {
                 // HTML
                 // Strip images
                 $pattern = '/<img[^>]*src="([^"]*)[^>]*>/i';
                 preg_match_all($pattern, $pcontent, $matches);
                 $images = $matches[1];
                 $pcontent = preg_replace($pattern, '', $pcontent);
                 $pcontent = Soliloquy_Featured_Content_Truncate_HTML::truncateWords($pcontent, $instance->get_config('fc_content_length', $data), $instance->get_config('fc_content_ellipses', $data) ? '...' : '');
             } else {
                 // Plain Text
                 $pcontent = wp_trim_words($pcontent, $instance->get_config('fc_content_length', $data), $instance->get_config('fc_content_ellipses', $data) ? '...' : '');
             }
             // Filter
             $pcontent = apply_filters('soliloquy_fc_post_content', $pcontent, $post, $data);
             $output .= '<div class="soliloquy-fc-content' . ($title ? ' soliloquy-fc-title-above' : '') . '"><p>' . $pcontent;
             $output = apply_filters('soliloquy_fc_after_caption', $output, $post, $data);
         }
     }
     // Possibly display the read more link.
     if ($instance->get_config('fc_read_more', $data)) {
         $output = apply_filters('soliloquy_fc_before_read_more', $output, $post, $data);
         $readmo = apply_filters('soliloquy_fc_read_more', ' <a class="soliloquy-fc-read-more' . ($above ? ' soliloquy-fc-content-above' : '') . '" href="' . get_permalink($post->ID) . '" title="' . esc_attr($post->post_title) . '">' . $instance->get_config('fc_read_more_text', $data) . '</a>', $post, $data);
         $output .= 'post_excerpt' == $content && !empty($post->post_excerpt) || 'post_content' == $content && !empty($post->post_content) ? $readmo . '</p></div>' : $readmo;
         $output = apply_filters('soliloquy_fc_after_read_more', $output, $post, $data);
     }
     // If the output is not empty, wrap it in our caption wrapper.
     if (!empty($output)) {
         $output = '<div class="soliloquy-fc-caption">' . $output . '</div>';
     }
     // Return and apply a filter to the caption.
     return apply_filters('soliloquy_fc_caption', $output, $post, $data);
 }
예제 #9
0
/**
 * Grabs JS and executes it for any uninitialised sliders on screen
 *
 * Used by soliloquyInitManually() JS function, which in turn is called
 * by AJAX requests e.g. after an Infinite Scroll event.
 *
 * @since 1.0.0
 */
function soliloquy_ajax_init_sliders()
{
    // Run a security check first.
    check_ajax_referer('soliloquy-ajax-nonce', 'ajax_nonce');
    // Check we have some slider IDs
    if (!isset($_REQUEST['ids'])) {
        die;
    }
    // Setup instance
    $instance = Soliloquy_Shortcode::get_instance();
    $base = Soliloquy::get_instance();
    // Build JS for each slider
    $js = '';
    foreach ($_REQUEST['ids'] as $slider_id) {
        // Get slider
        $data = $base->get_slider($slider_id);
        // If no slider found, skip
        if (!$data) {
            continue;
        }
        // Build JS for this slider
        $js .= $instance->slider_init_single($data, true);
    }
    // Output JS
    echo $js;
    die;
}