function partnerlist_shortcode_func($atts) { $a = shortcode_atts(array('type' => 'list', 'group' => 'all', 'category' => 'all', 'size' => 'medium', 'links' => 'true', 'controls' => 'hide', 'title' => 'show', 'image' => 'show', 'hidecat' => NULL, 'catdesc' => 'hide', 'height' => 180, 'spacing' => 0, 'orderby' => 'id'), $atts); if ($a['group'] == "all" or $a['group'] == 0) { $termArr = get_terms('partners-groups'); foreach ($termArr as $key => $termA) { $a['group'][$key] = $termA->term_id; print_r($a); } } if ($a['category'] == "all" or $a['category'] == 0) { $custom_terms = get_terms('partners-categories'); } else { $custom_terms[0] = get_term_by('term_id', $a['category'], 'partners-categories'); } if ($a['hidecat']) { foreach ($custom_terms as $key => $cstmtrm) { if ($a['hidecat'] == $cstmtrm->term_id) { unset($custom_terms[$key]); } } } $getviewtype = partnerlist_views_get($a['type']); $dir = plugin_dir_path(__FILE__); require $dir . "../views/" . $getviewtype['slug'] . ".php"; }
public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $a['type'] = $instance['type']; $a['group'] = $instance['groups']; $a['category'] = $instance['categories']; $a['size'] = $instance['size']; $a['height'] = $instance['height']; $a['links'] = $instance['links']; $a['controls'] = $instance['controls']; $a['title'] = $instance['showtitles']; if (isset($instance['spacing'])) { $a['spacing'] = $instance['spacing']; } else { $a['spacing'] = 0; } if (isset($instance['orderby'])) { $a['orderby'] = $instance['orderby']; } else { $a['orderby'] = 'id'; } // before and after widget arguments are defined by themes echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } // This is where you run the code and display the output if ($a['group'] == "all" or $a['group'] == 0) { $termArr = get_terms('partners-groups'); foreach ($termArr as $key => $termA) { $a['group'][$key] = $termA->term_id; } } if ($a['category'] == "all" or $a['category'] == 0) { $custom_terms = get_terms('partners-categories'); } else { $custom_terms[0] = get_term_by('term_id', $a['category'], 'partners-categories'); } $getviewtype = partnerlist_views_get($a['type']); $dir = plugin_dir_path(__FILE__); require $dir . "../views/" . $getviewtype['slug'] . ".php"; //echo $args['after_widget']; }