コード例 #1
0
    /**
     * Render an HTML mini-preview of the slide images, for use in the widget selector. TODO UNFINISHED
     *
     * This allows an at-a-glance verification that the selected slide group is the desired slide group.
     *
     * @return void
     */
    public function mini_preview()
    {
        /*
        	* Extract background images from slides.
        	* (Get thumbnail versions?)
        	* Get suggested crop width and height, scale down proportionally to calculate thumbnail size of template
        	* Render thumbnail images against those dimensions
        	* JS to spin through them with some kind of animation?
        	
        	How do we disclaim that this isn't truly WYSIWYG? Is that a problem?
        */
        if (empty($this->template) || empty($this->templateLocation)) {
            if (!$this->load()) {
                return false;
            }
        }
        // load template information
        try {
            $t = new Total_Slider_Template($this->template, $this->templateLocation);
        } catch (Exception $e) {
            if (defined('WP_DEBUG') && WP_DEBUG) {
                printf(__('Unable to render the slide mini-preview: %s (error code %d)', 'total-slider'), $e->getMessage(), $e->getCode());
            }
            return false;
        }
        $template_options = $t->determine_options();
        ?>
<p><strong><?php 
        _e('Template:', 'total-slider');
        ?>
</strong> <?php 
        echo esc_html($t->name());
        ?>
</p><?php 
        $current_slides = get_option('total_slider_slides_' . $this->slug);
        if (false === $current_slides || !is_array($current_slides) || count($current_slides) < 0) {
            ?>
<p><?php 
            _e('There are no slides to show.', 'total-slider');
            ?>
</p><?php 
            return true;
        }
        ?>
<div class="total-slider-mini-preview">
		<ul><?php 
        foreach ($current_slides as $idx => $slide) {
            if (is_numeric($slide['background']) && intval($slide['background']) == $slide['background']) {
                // background references an attachment ID
                $image = wp_get_attachment_image_src(intval($slide['background']), 'thumbnail');
                $image = $image[0];
            } else {
                $image = $slide['background'];
            }
            ?>
<li><img src="<?php 
            echo esc_url($image);
            ?>
" alt="<?php 
            echo esc_attr($slide['title']);
            ?>
" title="<?php 
            echo esc_attr($slide['title']);
            ?>
" width="100" height="32" /></li><?php 
        }
        ?>
		</ul>
		</div><?php 
    }
コード例 #2
0
 /**
  * Return the template name used for the slide group.
  *
  * @param Total_Slide_Group $item A slide group object.
  * @return string
  */
 public function column_template($item)
 {
     if (property_exists($item, 'template') && !empty($item->template) && property_exists($item, 'templateLocation') && !empty($item->templateLocation)) {
         // load template's friendly name
         try {
             $t = new Total_Slider_Template($item->template, $item->templateLocation);
         } catch (Exception $e) {
             return esc_html($item->template);
         }
         if ($t->name()) {
             return esc_html($t->name());
         } else {
             return esc_html($item->template);
         }
     } else {
         return 'Default';
     }
 }