public function form($instance)
 {
     $defaults = Testimonials_Widget::get_defaults();
     $do_number = true;
     if (empty($instance)) {
         $do_number = false;
         if (empty($defaults['char_limit'])) {
             $defaults['char_limit'] = 500;
         }
         if (empty($defaults['random'])) {
             $defaults['random'] = 1;
         }
         $instance = array();
     }
     $instance = wp_parse_args($instance, $defaults);
     $form_parts = Testimonials_Widget_Settings::get_settings();
     if ($do_number) {
         $number = $this->number;
         $std = ' .' . Testimonials_Widget::id . $number;
         $form_parts['css_class'] = array('section' => 'widget', 'type' => 'readonly', 'title' => __('CSS Class', 'testimonials-widget'), 'desc' => __('This widget\'s unique CSS class for styling', 'testimonials-widget'), 'std' => $std);
     }
     // remove non-widget parts
     unset($form_parts['paging']);
     unset($form_parts['debug_mode']);
     // fixme make reset work
     unset($form_parts['reset_defaults']);
     foreach ($form_parts as $key => $part) {
         $part['id'] = $key;
         $this->display_setting($part, $instance);
     }
 }
 function testimonialswidget_init()
 {
     if (Testimonials_Widget::version_check()) {
         global $Testimonials_Widget_Settings;
         if (is_null($Testimonials_Widget_Settings)) {
             $Testimonials_Widget_Settings = new Testimonials_Widget_Settings();
         }
         global $Testimonials_Widget;
         if (is_null($Testimonials_Widget)) {
             $Testimonials_Widget = new Testimonials_Widget();
         }
     }
 }
 public static function admin_init()
 {
     add_filter('wp_unique_post_slug_is_bad_hierarchical_slug', array(__CLASS__, 'is_bad_hierarchical_slug'), 10, 4);
     add_filter('wp_unique_post_slug_is_bad_flat_slug', array(__CLASS__, 'is_bad_flat_slug'), 10, 3);
     $version = tw_get_option('version');
     self::$version = Testimonials_Widget::VERSION;
     self::$version = apply_filters('testimonials_widget_version', self::$version);
     if ($version != self::$version) {
         self::initialize_settings();
     }
     if (!Testimonials_Widget::do_load()) {
         return;
     }
     self::load_options();
     self::register_settings();
 }
 public static function get_review_count($testimonial)
 {
     self::$aggregate_data = apply_filters('tw_cache_get', self::$aggregate_data, 'tw_aggregate_data');
     $testimonial_item = !empty($testimonial['testimonial_item']) ? $testimonial['testimonial_item'] : self::$aggregate_no_item;
     if (!isset(self::$aggregate_data[$testimonial_item]['count'])) {
         if (self::$aggregate_no_item != $testimonial_item) {
             // @codingStandardsIgnoreStart
             $query_args = array('post_type' => Testimonials_Widget::PT, 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => 'testimonials-widget-item', 'value' => $testimonial_item, 'compare' => 'LIKE')));
             // @codingStandardsIgnoreEnd
         } else {
             // @codingStandardsIgnoreStart
             $query_args = array('post_type' => Testimonials_Widget::PT, 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => 'testimonials-widget-item', 'value' => '', 'compare' => 'LIKE')));
             // @codingStandardsIgnoreEnd
         }
         $count = 0;
         $query = new WP_Query($query_args);
         while ($query->have_posts()) {
             $query->the_post();
             $count++;
         }
         self::$aggregate_data[$testimonial_item]['count'] = $count;
         self::$aggregate_data = apply_filters('tw_cache_set', self::$aggregate_data, 'tw_aggregate_data');
     }
     return self::$aggregate_data[$testimonial_item]['count'];
 }
 /**
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public static function get_content($instance = null, $widget_number = null)
 {
     return Testimonials_Widget::testimonials_archives($instance, $widget_number);
 }
 /**
  *
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public static function settings()
 {
     // Widget
     self::$settings['title'] = array('section' => 'widget', 'title' => esc_html__('Title', 'testimonials-widget'), 'std' => esc_html__('Testimonials', 'testimonials-widget'), 'validate' => 'wp_kses_post');
     self::$settings['title_link'] = array('section' => 'widget', 'title' => esc_html__('Title Link', 'testimonials-widget'), 'desc' => esc_html__('URL, path, or post ID to link widget title to. Ex: http://example.com/stuff, /testimonials, or 123', 'testimonials-widget'), 'validate' => 'wp_kses_data');
     self::$settings['adaptive_height'] = array('section' => 'widget', 'title' => esc_html__('Adaptive Slider Height?', 'testimonials-widget'), 'desc' => esc_html__('Dynamically adjust slider height based on each slide\'s height.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1);
     self::$settings['bottom_text'] = array('section' => 'widget', 'title' => esc_html__('Bottom Text', 'testimonials-widget'), 'desc' => esc_html__('Common text or HTML for bottom of testimonials.', 'testimonials-widget'), 'type' => 'textarea', 'validate' => 'wp_kses_post');
     self::$settings['char_limit'] = array('section' => 'widget', 'title' => esc_html__('Character Limit', 'testimonials-widget'), 'desc' => esc_html__('Number of characters to limit non-single testimonial views to.', 'testimonials-widget'), 'validate' => 'absint');
     self::$settings['keep_whitespace'] = array('section' => 'widget', 'title' => esc_html__('Keep Whitespace?', 'testimonials-widget'), 'desc' => esc_html__('Keeps testimonials looking as entered than sans auto-formatting.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true');
     self::$settings['refresh_interval'] = array('section' => 'widget', 'title' => esc_html__('Rotation Speed', 'testimonials-widget'), 'desc' => esc_html__('Number of seconds between testimonial rotations or 0 for no rotation at all refresh.', 'testimonials-widget'), 'std' => 5, 'validate' => 'absint');
     self::$settings['show_start_stop'] = array('section' => 'widget', 'title' => esc_html__('Show Play/Pause?', 'testimonials-widget'), 'desc' => esc_html__('Display start and stop buttons underneath the testimonial slider.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1);
     self::$settings['slide_width'] = array('section' => 'widget', 'title' => esc_html__('Slide Width?', 'testimonials-widget'), 'desc' => esc_html__('Width of each testimonial. Increase to thumbnail width or greater for improved looks. Requried for horizontal transitions.', 'testimonials-widget'), 'validate' => 'intval', 'std' => 0);
     self::$settings['transition_mode'] = array('section' => 'widget', 'title' => esc_html__('Transition Mode?', 'testimonials-widget'), 'desc' => esc_html__('Type of transition between slides.', 'testimonials-widget'), 'type' => 'select', 'choices' => array('fade' => esc_html__('Fade', 'testimonials-widget'), 'horizontal' => esc_html__('Horizontal', 'testimonials-widget'), 'vertical' => esc_html__('Vertical', 'testimonials-widget')), 'std' => 'fade');
     self::$settings['widget_expand_all'] = array('section' => 'widget', 'type' => 'expand_all');
     // General
     self::$settings['general_expand_begin'] = array('desc' => esc_html__('General Options', 'testimonials-widget'), 'type' => 'expand_begin');
     self::$settings['item_reviewed'] = array('title' => esc_html__('Default Reviewed Item?', 'testimonials-widget'), 'desc' => esc_html__('Name of thing being referenced in testimonials.', 'testimonials-widget'), 'std' => get_option('blogname'), 'widget' => 0, 'validate' => 'wp_kses_post');
     self::$settings['item_reviewed_url'] = array('title' => esc_html__('Default Reviewed Item URL?', 'testimonials-widget'), 'desc' => esc_html__('URL of thing being referenced in testimonials.', 'testimonials-widget'), 'std' => network_site_url(), 'validate' => 'url', 'widget' => 0);
     self::$settings['disable_quotes'] = array('title' => esc_html__('Disable built-in quotes?', 'testimonials-widget'), 'desc' => esc_html__('Remove open and close quote span tags surrounding testimonial content.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true');
     self::$settings['hide_not_found'] = array('title' => esc_html__('Disable "Testimonials Not Found"?', 'testimonials-widget'), 'desc' => esc_html__('Remove "Testimonials Not Found" content when no testimonials are found to be displayed.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true');
     self::$settings['paging'] = array('title' => esc_html__('Enable Paging?', 'testimonials-widget'), 'desc' => esc_html__('Show paging controls for `[testimonials]` listing.', 'testimonials-widget'), 'type' => 'select', 'choices' => array('' => esc_html__('Disable', 'testimonials-widget'), 1 => esc_html__('Enable', 'testimonials-widget'), 'before' => esc_html__('Before testimonials', 'testimonials-widget'), 'after' => esc_html__('After testimonials', 'testimonials-widget')), 'std' => 1, 'widget' => 0);
     $desc = __('Adds HTML tag markup per the <a href="%s">Review schema</a> to testimonials. Search engines including Bing, Google, Yahoo! and Yandex rely on this markup to improve the display of search results.', 'testimonials-widget');
     self::$settings['enable_schema'] = array('title' => esc_html__('Enable Review Schema?', 'testimonials-widget'), 'desc' => sprintf($desc, 'http://schema.org/Review'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1);
     self::$settings['do_shortcode'] = array('title' => esc_html__('Enable [shortcodes]?', 'testimonials-widget'), 'desc' => esc_html__('If unchecked, shortcodes are stripped.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1);
     self::$settings['enable_video'] = array('title' => esc_html__('Enable Video?', 'testimonials-widget'), 'desc' => esc_html__('Only enable when displaying video content.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true');
     self::$settings['exclude_bxslider_css'] = array('title' => esc_html__('Exclude bxSlider CSS?', 'testimonials-widget'), 'desc' => esc_html__('For a bare-bones, unthemed slider.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'widget' => 0, 'show_code' => false);
     self::$settings['exclude_css'] = array('title' => esc_html__('Exclude default CSS?', 'testimonials-widget'), 'desc' => esc_html__('Prevent default CSS from being loaded.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'widget' => 0, 'show_code' => false);
     self::$settings['remove_hentry'] = array('title' => esc_html__('Remove `.hentry` CSS?', 'testimonials-widget'), 'desc' => esc_html__('Some themes use class `.hentry` in a manner that breaks Testimonials\' CSS.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1);
     self::$settings['target'] = array('title' => esc_html__('URL Target', 'testimonials-widget'), 'desc' => esc_html__('Add target to all URLs; leave blank if none.', 'testimonials-widget'), 'validate' => 'term');
     self::$settings['use_quote_tag'] = array('title' => esc_html__('Use `&lt;q&gt;` tag?', 'testimonials-widget'), 'desc' => esc_html__('Not HTML5 compliant.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true');
     self::$settings['general_expand_end'] = array('type' => 'expand_end');
     // Fields
     self::$settings['fields_expand_begin'] = array('section' => 'fields', 'desc' => esc_html__('Field Options', 'testimonials-widget'), 'type' => 'expand_begin');
     self::$settings['hide_source'] = array('section' => 'fields', 'title' => esc_html__('Hide Author?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display testimonial title in cite.', 'testimonials-widget'));
     self::$settings['hide_company'] = array('section' => 'fields', 'title' => esc_html__('Hide Company?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display testimonial company in cite.', 'testimonials-widget'));
     self::$settings['hide_content'] = array('section' => 'fields', 'title' => esc_html__('Hide Content?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display testimonial content in a view.', 'testimonials-widget'));
     self::$settings['hide_email'] = array('section' => 'fields', 'title' => esc_html__('Hide Email?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'desc' => esc_html__('Don\'t display or link to testimonial email in cite.', 'testimonials-widget'));
     self::$settings['hide_gravatar'] = array('section' => 'fields', 'title' => esc_html__('Hide Gravatar?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display Gravatar image with testimonial.', 'testimonials-widget'));
     self::$settings['hide_image'] = array('section' => 'fields', 'title' => esc_html__('Hide Image?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display featured image with testimonial.', 'testimonials-widget'));
     self::$settings['hide_image_single'] = array('section' => 'fields', 'title' => esc_html__('Hide Image in Single View?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'widget' => 0);
     self::$settings['hide_title'] = array('section' => 'fields', 'title' => esc_html__('Hide Job Title?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display testimonial job title in cite.', 'testimonials-widget'));
     self::$settings['hide_location'] = array('section' => 'fields', 'title' => esc_html__('Hide Location?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display testimonial location in cite.', 'testimonials-widget'));
     self::$settings['hide_url'] = array('section' => 'fields', 'title' => esc_html__('Hide URL?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('Don\'t display or link to testimonial URL in cite.', 'testimonials-widget'));
     self::$settings['fields_expand_end'] = array('type' => 'expand_end');
     // Selection
     self::$settings['selection_expand_begin'] = array('section' => 'selection', 'desc' => esc_html__('Selection Options', 'testimonials-widget'), 'type' => 'expand_begin');
     self::$settings['category'] = array('section' => 'selection', 'title' => esc_html__('Category Filter', 'testimonials-widget'), 'desc' => esc_html__('Comma separated category names or IDs.', 'testimonials-widget'), 'validate' => 'terms', 'suggest' => true);
     self::$settings['exclude'] = array('section' => 'selection', 'title' => esc_html__('Exclude IDs Filter', 'testimonials-widget'), 'desc' => esc_html__('Comma separated testimonial IDs.', 'testimonials-widget'), 'validate' => 'ids');
     self::$settings['ids'] = array('section' => 'selection', 'title' => esc_html__('Include IDs Filter', 'testimonials-widget'), 'desc' => esc_html__('Comma separated testimonial IDs.', 'testimonials-widget'), 'validate' => 'ids');
     self::$settings['limit'] = array('section' => 'selection', 'title' => esc_html__('Limit', 'testimonials-widget'), 'desc' => esc_html__('Number of testimonials to select per instance.', 'testimonials-widget'), 'std' => 10, 'validate' => 'nozero');
     self::$settings['tags_all'] = array('section' => 'selection', 'title' => esc_html__('Require All Tags?', 'testimonials-widget'), 'desc' => esc_html__('Select only testimonials with all of the given tags.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true');
     self::$settings['tags'] = array('section' => 'selection', 'title' => esc_html__('Tags Filter', 'testimonials-widget'), 'desc' => esc_html__('Comma separated tag slugs or IDs.', 'testimonials-widget'), 'validate' => 'terms', 'suggest' => true);
     self::$settings['selection_expand_end'] = array('section' => 'selection', 'type' => 'expand_end');
     // Ordering
     self::$settings['ordering_expand_begin'] = array('section' => 'ordering', 'desc' => esc_html__('Ordering Options', 'testimonials-widget'), 'type' => 'expand_begin');
     self::$settings['orderby'] = array('section' => 'ordering', 'title' => esc_html__('ORDER BY', 'testimonials-widget'), 'desc' => esc_html__('Used when "Random Order" is disabled.', 'testimonials-widget'), 'type' => 'select', 'choices' => array('ID' => esc_html__('Testimonial ID', 'testimonials-widget'), 'author' => esc_html__('Author', 'testimonials-widget'), 'date' => esc_html__('Date', 'testimonials-widget'), 'menu_order' => esc_html__('Menu Order', 'testimonials-widget'), 'title' => esc_html__('Author', 'testimonials-widget'), 'none' => esc_html__('No order', 'testimonials-widget')), 'std' => 'ID', 'validate' => 'term');
     self::$settings['meta_key'] = array('section' => 'ordering', 'title' => esc_html__('ORDER BY meta_key', 'testimonials-widget'), 'desc' => esc_html__('Used when "Random Order" is disabled and sorting by a testimonials meta key is needed. Overrides ORDER BY.', 'testimonials-widget'), 'type' => 'select', 'choices' => array('' => esc_html__('None', 'testimonials-widget'), 'testimonials-widget-title' => esc_html__('Job Title', 'testimonials-widget'), 'testimonials-widget-email' => esc_html__('Email', 'testimonials-widget'), 'testimonials-widget-location' => esc_html__('Location', 'testimonials-widget'), 'testimonials-widget-company' => esc_html__('Company', 'testimonials-widget'), 'testimonials-widget-url' => esc_html__('URL', 'testimonials-widget')), 'validate' => 'slug');
     self::$settings['order'] = array('section' => 'ordering', 'title' => esc_html__('ORDER BY Order', 'testimonials-widget'), 'type' => 'select', 'choices' => array('DESC' => esc_html__('Descending', 'testimonials-widget'), 'ASC' => esc_html__('Ascending', 'testimonials-widget')), 'std' => 'DESC', 'validate' => 'order');
     self::$settings['random'] = array('section' => 'ordering', 'title' => esc_html__('Random Order?', 'testimonials-widget'), 'desc' => esc_html__('If checked, ignores ORDER BY, ORDER BY meta_key, and ORDER BY Order. Widgets are random by default automatically.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true');
     self::$settings['ordering_expand_end'] = array('section' => 'ordering', 'type' => 'expand_end');
     // Post Type
     self::$settings['allow_comments'] = array('section' => 'post_type', 'title' => esc_html__('Allow Comments?', 'testimonials-widget'), 'desc' => esc_html__('Only affects the Testimonials post edit page. Your theme controls the front-end view.', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'widget' => 0, 'show_code' => false);
     $desc = __('URL slug-name for <a href="%1s">testimonials archive</a> page.', 'testimonials-widget');
     $has_archive = tw_get_option('has_archive', '');
     $site_url = network_site_url('/' . $has_archive . '/');
     self::$settings['has_archive'] = array('section' => 'post_type', 'title' => esc_html__('Archive Page URL', 'testimonials-widget'), 'desc' => sprintf($desc, $site_url), 'std' => 'testimonials-archive', 'validate' => 'slash_sanitize_title', 'widget' => 0, 'show_code' => false);
     self::$settings['use_cpt_taxonomy'] = array('section' => 'post_type', 'title' => esc_html__('Disable Default Taxonomies?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'desc' => esc_html__('If checked, use Testimonials\' own category and tag taxonomies than WordPress\' defaults.', 'testimonials-widget'), 'widget' => 0, 'show_code' => false);
     self::$settings['enable_archives'] = array('desc' => esc_html__('Include testimonials in archive and category views.', 'testimonials-widget'), 'section' => 'post_type', 'show_code' => false, 'title' => esc_html__('Enable archives view?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'widget' => 0);
     $desc = esc_html__('URL slug-name for testimonial view pages. Shouldn\'t be the same as the Archive Page URL nor should it match a page URL slug.', 'testimonials-widget');
     self::$settings['rewrite_slug'] = array('section' => 'post_type', 'title' => esc_html__('Testimonial Page URL', 'testimonials-widget'), 'desc' => $desc, 'std' => 'testimonial', 'validate' => 'slash_sanitize_title', 'widget' => 0, 'show_code' => false);
     // Columns
     self::$settings['columns_author'] = array('section' => 'columns', 'title' => esc_html__('Hide Author?', 'testimonials-widget', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'widget' => 0, 'show_code' => false);
     self::$settings['columns_company'] = array('section' => 'columns', 'title' => esc_html__('Hide Company?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'widget' => 0, 'show_code' => false);
     self::$settings['columns_email'] = array('section' => 'columns', 'title' => esc_html__('Hide Email?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'widget' => 0, 'show_code' => false);
     self::$settings['columns_id'] = array('section' => 'columns', 'title' => esc_html__('Hide ID?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'widget' => 0, 'show_code' => false);
     self::$settings['columns_thumbnail'] = array('section' => 'columns', 'title' => esc_html__('Hide Image?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'widget' => 0, 'show_code' => false);
     self::$settings['columns_job_title'] = array('section' => 'columns', 'title' => esc_html__('Hide Job Title?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'widget' => 0, 'show_code' => false);
     self::$settings['columns_location'] = array('section' => 'columns', 'title' => esc_html__('Hide Location?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'widget' => 0, 'show_code' => false);
     self::$settings['columns_shortcode'] = array('section' => 'columns', 'title' => esc_html__('Hide Shortcode?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'widget' => 0, 'show_code' => false);
     self::$settings['columns_url'] = array('section' => 'columns', 'title' => esc_html__('Hide URL?', 'testimonials-widget'), 'type' => 'checkbox', 'validate' => 'is_true', 'std' => 1, 'widget' => 0, 'show_code' => false);
     // Reset
     self::$settings['reset_expand_begin'] = array('section' => 'reset', 'desc' => esc_html__('Reset', 'testimonials-widget'), 'type' => 'expand_begin');
     parent::settings();
     self::$settings['reset_expand_end'] = array('section' => 'reset', 'type' => 'expand_end');
     self::$settings = apply_filters('tw_settings', self::$settings);
     foreach (self::$settings as $id => $parts) {
         self::$settings[$id] = wp_parse_args($parts, self::$default);
     }
     if (!empty($_REQUEST['page']) && 'testimonialswidget_settings' == $_REQUEST['page']) {
         // Examples
         self::$settings['examples'] = array('section' => 'examples', 'desc' => Testimonials_Widget::testimonials_examples(), 'type' => 'content', 'widget' => 0);
         self::$settings['examples'] = wp_parse_args(self::$settings['examples'], self::$default);
         // Shortcode Attributes
         self::$settings['options'] = array('section' => 'options', 'type' => 'content', 'desc' => Testimonials_Widget::testimonials_options(), 'widget' => 0);
         self::$settings['options'] = wp_parse_args(self::$settings['options'], self::$default);
     }
 }
Beispiel #7
0
 public function get_testimonials_scripts()
 {
     if (empty(self::$scripts_called)) {
         foreach (self::$scripts as $key => $script) {
             echo $script;
         }
         self::$scripts_called = true;
     }
 }
 public static function set_not_found($not_found = false)
 {
     self::$not_found = $not_found;
 }
<?php

global $tw_template_args;
$atts = $tw_template_args['atts'];
$testimonial = $tw_template_args['testimonial'];
$widget_number = $tw_template_args['widget_number'];
$char_limit = $atts['char_limit'];
$content_more = apply_filters('tw_content_more', esc_html__('…', 'testimonials-widget'));
$content_more .= Testimonials_Widget::$tag_close_quote;
$do_content = !$atts['hide_content'] && !empty($testimonial['testimonial_content']);
$use_quote_tag = $atts['use_quote_tag'];
if ($do_content) {
    $content = $testimonial['testimonial_content'];
    $content = Testimonials_Widget::format_content($content, $widget_number, $atts);
    if ($char_limit) {
        $content = Testimonials_Widget::testimonials_truncate($content, $char_limit, $content_more);
        $content = force_balance_tags($content);
    }
    $content = apply_filters('tw_content', $content, $widget_number, $testimonial, $atts);
    $content = make_clickable($content);
    if (!$use_quote_tag) {
        ?>
		<blockquote><?php 
        echo $content;
        ?>
</blockquote>
		<?php 
    } else {
        ?>
		<q><?php 
        echo $content;
}
if (($do_company || $do_url && !$done_url) && $cite) {
    $cite .= Testimonials_Widget::get_template_part('span', 'join-company');
}
if ($do_company && $do_url) {
    $cite .= Testimonials_Widget::get_template_part('span', 'company-url');
} elseif ($do_company) {
    $cite .= Testimonials_Widget::get_template_part('span', 'company');
} elseif ($do_url && !$done_url) {
    $cite .= Testimonials_Widget::get_template_part('span', 'url');
}
if ($do_location && $cite) {
    $cite .= Testimonials_Widget::get_template_part('span', 'join-location');
}
if ($do_location) {
    $cite .= Testimonials_Widget::get_template_part('span', 'location');
}
if (!empty($cite)) {
    $cite = preg_replace("#\r|\n#", '', $cite);
}
$cite = apply_filters('tw_cite_html', $cite, $testimonial, $atts);
if (empty($cite)) {
    return;
}
if (!$use_quote_tag) {
    ?>
	<div class="credit"><?php 
    echo $cite;
    ?>
</div>
	<?php 
 public static function get_content($instance, $widget_number)
 {
     return Testimonials_Widget::testimonials_slider($instance, $widget_number);
 }