public static function form_parts($instance = null, $number = null)
 {
     $form_parts = Testimonials_Widget_Settings::get_settings();
     if (!empty($instance['do_number'])) {
         $std = ' .' . Testimonials_Widget::ID . $number;
         $form_parts['css_class'] = array('section' => 'widget', 'type' => 'readonly', 'title' => esc_html__('CSS Class', 'testimonials-widget'), 'desc' => esc_html__('This widget\'s unique CSS class for styling', 'testimonials-widget'), 'std' => $std, 'widget' => 1);
     }
     $form_parts = apply_filters('tw_slider_widget_options', $form_parts);
     return $form_parts;
 }
 /**
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public static function get_testimonials_options($atts = null)
 {
     $sections = Testimonials_Widget_Settings::get_sections();
     $settings = Testimonials_Widget_Settings::get_settings();
     $ignored_types = array('expand_begin', 'expand_end', 'expand_all', 'content');
     $do_continue = false;
     $do_used_with = false;
     $first_dl = true;
     $open_dl = false;
     $html = '';
     foreach ($settings as $setting => $parts) {
         if (in_array($parts['type'], $ignored_types)) {
             continue;
         }
         if (empty($parts['show_code'])) {
             continue;
         }
         // section header
         if (!empty($sections[$parts['section']])) {
             if (!$first_dl) {
                 $html .= '</dl>';
                 $open_dl = false;
             }
             $html .= '<h2>' . $sections[$parts['section']] . '</h2>';
             unset($sections[$parts['section']]);
             $do_used_with = true;
         }
         if ('heading' == $parts['type']) {
             if ($open_dl) {
                 $html .= '</dl>';
                 $open_dl = false;
             }
             $html .= '<h2>' . $parts['desc'] . '</h2>';
             $do_continue = true;
             $do_used_with = true;
         }
         if ($do_used_with) {
             $used_with_codes = self::get_used_with_codes($parts);
             if (!empty($used_with_codes)) {
                 $used_with_codes = implode('</code>, <code>', $used_with_codes);
                 $html .= '<p>' . esc_html__('Used with: ', 'testimonials-widget');
                 $html .= '<code>' . $used_with_codes . '</code>';
                 $html .= '</p>';
             }
             $do_used_with = false;
         }
         if ($do_continue) {
             $do_continue = false;
             continue;
         }
         if (empty($open_dl)) {
             $html .= '<dl>';
             $first_dl = false;
             $open_dl = true;
         }
         // option name
         $html .= '<dt>' . $parts['title'] . '</dt>';
         // description
         if (!empty($parts['desc'])) {
             $html .= '<dd>' . $parts['desc'] . '</dd>';
         }
         // validation helpers
         $validate = self::define_options_validate($parts);
         if (!empty($validate)) {
             $html .= '<dd>' . $validate . '</dd>';
         }
         $choices = self::define_options_choices($parts);
         if (!empty($choices)) {
             $html .= '<dd>' . esc_html__('Options: ', 'testimonials-widget') . '<code>' . $choices . '</code></dd>';
         }
         $value = self::define_options_value($setting, $parts);
         if (!empty($value)) {
             $html .= '<dd>' . esc_html__('Usage: ', 'testimonials-widget') . '<code>' . $setting . '="' . $value . '"</code></dd>';
         }
     }
     // remaining widgets
     $widgets = array('Testimonials_Widget_Archives_Widget' => 'testimonials_archives', 'Testimonials_Widget_Categories_Widget' => 'testimonials_categories', 'Testimonials_Widget_Recent_Testimonials_Widget' => 'testimonials_recent', 'Testimonials_Widget_Tag_Cloud_Widget' => 'testimonials_tag_cloud');
     $widgets = apply_filters('tw_options_widgets', $widgets);
     foreach ($widgets as $widget => $shortcode) {
         $form_parts = $widget::form_parts();
         // section header
         $html .= '</dl>';
         $html .= '<h2>' . $widget::$title . '</h2>';
         $used_with_codes = array('[' . $shortcode . ']', '' . $shortcode . '()');
         $used_with_codes = apply_filters('tw_used_with_codes_widgets', $used_with_codes, $widget, $shortcode);
         if (!empty($used_with_codes)) {
             $used_with_codes = implode('</code>, <code>', $used_with_codes);
             $html .= '<p>' . esc_html__('Used with: ', 'testimonials-widget');
             $html .= '<code>' . $used_with_codes . '</code>';
             $html .= '</p>';
         }
         $html .= '<dl>';
         foreach ($form_parts as $setting => $parts) {
             if (in_array($parts['type'], $ignored_types)) {
                 continue;
             }
             // option name
             $html .= '<dt>' . $parts['title'] . '</dt>';
             // description
             if (!empty($parts['desc'])) {
                 $html .= '<dd>' . $parts['desc'] . '</dd>';
             }
             // validation helpers
             $validate = self::define_options_validate($parts);
             if (!empty($validate)) {
                 $html .= '<dd>' . $validate . '</dd>';
             }
             $choices = self::define_options_choices($parts);
             if (!empty($choices)) {
                 $html .= '<dd>' . esc_html__('Options: ', 'testimonials-widget') . '<code>' . $choices . '</code></dd>';
             }
             $value = self::define_options_value($setting, $parts);
             if (!empty($value)) {
                 $html .= '<dd>' . esc_html__('Usage: ', 'testimonials-widget') . '<code>' . $setting . '="' . $value . '"</code></dd>';
             }
         }
         if ($open_dl) {
             $html .= '</dl>';
         }
     }
     if ($open_dl) {
         $html .= '</dl>';
     }
     $html = links_add_target($html, '_tw');
     $html = apply_filters('tw_options_html', $html);
     return $html;
 }
 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);
     }
 }