/** * PHP5 constructor. * * @since 1.0.0 */ public function __construct() { parent::__construct($this->get_widget_slug(), __('Cherry Testimonials', 'cherry-testimonials'), array('classname' => $this->get_widget_slug(), 'description' => __("Your site's most recent Testimonials.", 'cherry-testimonials'))); $this->data = Cherry_Testimonials_Data::get_instance(); // Refreshing the widget's cached output with each new post. add_action('save_post', array($this, 'flush_widget_cache')); add_action('deleted_post', array($this, 'flush_widget_cache')); add_action('switch_theme', array($this, 'flush_widget_cache')); }
/** * Get post thumbnail. * * @since 1.0.2 */ public function get_avatar() { global $post; if (isset($this->atts['display_avatar']) && false === $this->atts['display_avatar']) { return; } $size = 50; if (!empty($this->atts['size'])) { $size = $this->atts['size']; } $avatar = Cherry_Testimonials_Data::get_image($post->ID, $size); return apply_filters('cherry_testimonials_avatar_template_callbacks', $avatar, $post->ID, $this->atts); }
/** * Sets up our actions/filters. * * @since 1.0.0 */ public function __construct() { add_action('init', array($this, 'register_shortcode')); // Register shortcode and add it to the dialog. add_filter('cherry_shortcodes/data/shortcodes', array($this, 'shortcodes')); add_filter('cherry_templater/data/shortcodes', array($this, 'shortcodes')); add_filter('cherry_templater_target_dirs', array($this, 'add_target_dir'), 11); add_filter('cherry_templater_macros_buttons', array($this, 'add_macros_buttons'), 11, 2); // Modify `swiper_carousel` shortcode to allow it process testimonials. add_filter('cherry_shortcodes_add_carousel_macros', array($this, 'extend_carousel_macros')); add_filter('cherry-shortcode-swiper-carousel-postdata', array($this, 'add_carousel_data'), 10, 3); $this->data = Cherry_Testimonials_Data::get_instance(); }
<?php /** * The Template for displaying single CPT Testimonial. * * @package Cherry_Testimonials * @since 1.0.0 */ while (have_posts()) { the_post(); do_action('cherry_entry_before'); $args = array('id' => get_the_ID(), 'size' => 100, 'template' => 'single.tmpl', 'custom_class' => 'testimonials-page-single'); $data = new Cherry_Testimonials_Data(); $data->the_testimonials($args); do_action('cherry_entry_after'); }
/** * Returns the instance. * * @since 1.0.2 * @return object */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }