/** * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public static function form_parts($instance = null, $number = null) { $form_parts = parent::form_parts($instance, $number); $form_parts['title']['std'] = self::$title; $use_cpt_taxonomy = tw_get_option('use_cpt_taxonomy', false); if (!$use_cpt_taxonomy) { $options = array('category' => esc_html__('Category', 'testimonials-widget'), 'post_tag' => esc_html__('Tags', 'testimonials-widget')); $std = 'post_tag'; } else { $options = array(Axl_Testimonials_Widget::$cpt_category => esc_html__('Category', 'testimonials-widget'), Axl_Testimonials_Widget::$cpt_tags => esc_html__('Tags', 'testimonials-widget')); $std = Axl_Testimonials_Widget::$cpt_tags; } $form_parts['taxonomy'] = array('title' => esc_html__('Taxonomy', 'testimonials-widget'), 'type' => 'select', 'choices' => $options, 'std' => $std); foreach ($form_parts as $id => $parts) { $form_parts[$id] = wp_parse_args($parts, self::$default); } $form_parts = apply_filters('tw_tag_cloud_widget_options', $form_parts); return $form_parts; }
public static function category_column($result, $column_name, $term_id, $category = true) { $attribute = $category ? 'category' : 'tags'; $use_cpt_taxonomy = tw_get_option('use_cpt_taxonomy', false); if (!$use_cpt_taxonomy) { if ($category) { $term = get_term($term_id, 'category'); } else { $term = get_term($term_id, 'post_tag'); } } else { if ($category) { $term = get_term($term_id, self::$cpt_category); } else { $term = get_term($term_id, self::$cpt_tags); } } switch ($column_name) { case 'shortcode': $result = '[testimonials ' . $attribute . '="' . $term->slug . '"]'; $result .= '<br />'; $result .= '[testimonials_slider ' . $attribute . '="' . $term->slug . '"]'; break; } return $result; }
public static function get_suggest($id, $suggest_id) { wp_enqueue_script('suggest'); $use_cpt_taxonomy = tw_get_option('use_cpt_taxonomy', false); switch ($id) { case 'category': if (!$use_cpt_taxonomy) { $taxonomy = 'category'; } else { $taxonomy = Axl_Testimonials_Widget::$cpt_category; } break; case 'tags': if (!$use_cpt_taxonomy) { $taxonomy = 'post_tag'; } else { $taxonomy = Axl_Testimonials_Widget::$cpt_tags; } break; } $ajax_url = site_url() . '/wp-admin/admin-ajax.php'; $suggest_js = "suggest( '{$ajax_url}?action=ajax-tag-search&tax={$taxonomy}', { delay: 500, minchars: 2, multiple: true, multipleSep: ', ' } )"; $scripts = <<<EOD <script type="text/javascript"> jQuery(document).ready( function() { \tjQuery( '.{$suggest_id}' ).{$suggest_js}; }); </script> EOD; return $scripts; }
<?php global $tw_template_args; $atts = $tw_template_args['atts']; $c = !empty($atts['count']) ? '1' : '0'; $d = !empty($atts['dropdown']) ? '1' : '0'; $h = !empty($atts['hierarchical']) ? '1' : '0'; $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); $use_cpt_taxonomy = tw_get_option('use_cpt_taxonomy', false); if ($use_cpt_taxonomy) { $cat_args['taxonomy'] = Axl_Testimonials_Widget::$cpt_category; } if ($d) { $cat_args['show_option_none'] = esc_html__('Select Testimonials Category', 'testimonials-widget'); wp_dropdown_categories(apply_filters('tw_categories_dropdown_args', $cat_args)); ?> <script type='text/javascript'> /* <![CDATA[ */ var dropdown = document.getElementById("cat"); function onCatChange() { if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { location.href = "<?php echo home_url(); ?> /?cat="+dropdown.options[dropdown.selectedIndex].value; } } dropdown.onchange = onCatChange; /* ]]> */ </script> <?php