/** * The shortcode function. * @since 1.0.0 * @param array $atts Shortcode attributes. * @param string $content If the shortcode is a wrapper, this is the content being wrapped. * @return string Output using the template tag. */ function woothemes_testimonials_shortcode($atts, $content = null) { $args = (array) $atts; $defaults = array('limit' => 5, 'per_row' => null, 'orderby' => 'menu_order', 'order' => 'DESC', 'id' => 0, 'display_author' => true, 'display_avatar' => true, 'display_url' => true, 'effect' => 'fade', 'pagination' => false, 'echo' => true, 'size' => 50, 'category' => 0); $args = shortcode_atts($defaults, $atts); // Make sure we return and don't echo. $args['echo'] = false; // Fix integers. if (isset($args['limit'])) { $args['limit'] = intval($args['limit']); } if (isset($args['size']) && 0 < intval($args['size'])) { $args['size'] = intval($args['size']); } if (isset($args['category']) && is_numeric($args['category'])) { $args['category'] = intval($args['category']); } // Fix booleans. foreach (array('display_author', 'display_url', 'pagination', 'display_avatar') as $k => $v) { if (isset($args[$v]) && 'true' == $args[$v]) { $args[$v] = true; } else { $args[$v] = false; } } return woothemes_testimonials($args); }
/** * Output Projects Testimonial. * * This function is only used if the Testimonials plugin is enabled. * It can be used to output a project's testimonial. * * Hooked into projects_after_single_project * * @access public * @return void * @since 1.1.0 */ function projects_output_testimonial() { if (class_exists('Woothemes_Testimonials') && is_singular('project')) { global $post; $testimonial_id = esc_attr(get_post_meta($post->ID, '_testimonials_id', true)); if (isset($testimonial_id) && '' != $testimonial_id && '0' != $testimonial_id) { $args = apply_filters('projects_testimonials_args', array('id' => $testimonial_id, 'per_row' => 1)); echo '<div class="project-testimonial">'; woothemes_testimonials($args); echo '</div>'; } } }
/** * Display the widget on the frontend. * @since 1.0.0 * @param array $args Widget arguments. * @param array $instance Widget settings for this instance. * @return void */ public function widget($args, $instance) { extract($args, EXTR_SKIP); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); /* Before widget (defined by themes). */ $args = array(); $args['before'] = $before_widget; $args['after'] = $after_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { $args['before_title'] = $before_title; $args['title'] = $title; $args['after_title'] = $after_title; } /* Widget content. */ // Add actions for plugins/themes to hook onto. do_action($this->woothemes_widget_cssclass . '_top'); // Integer values. if (isset($instance['limit']) && 0 < count($instance['limit'])) { $args['limit'] = intval($instance['limit']); } if (isset($instance['specific_id']) && 0 < count($instance['specific_id'])) { $args['id'] = intval($instance['specific_id']); } if (isset($instance['size']) && 0 < count($instance['size'])) { $args['size'] = intval($instance['size']); } // Boolean values. if (isset($instance['display_author']) && 1 == $instance['display_author']) { $args['display_author'] = true; } else { $args['display_author'] = false; } if (isset($instance['display_avatar']) && 1 == $instance['display_avatar']) { $args['display_avatar'] = true; } else { $args['display_avatar'] = false; } if (isset($instance['display_url']) && 1 == $instance['display_url']) { $args['display_url'] = true; } else { $args['display_url'] = false; } // Select boxes. if (isset($instance['orderby']) && in_array($instance['orderby'], array_keys($this->get_orderby_options()))) { $args['orderby'] = $instance['orderby']; } if (isset($instance['order']) && in_array($instance['order'], array_keys($this->get_order_options()))) { $args['order'] = $instance['order']; } // Display the testimonials. woothemes_testimonials($args); // Add actions for plugins/themes to hook onto. do_action($this->woothemes_widget_cssclass . '_bottom'); }