Changeset 619000
- Timestamp:
- 10/30/2012 01:36:33 PM (12 years ago)
- Location:
- cat-tag-filter-widget
- Files:
-
- 11 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cat-tag-filter-widget/trunk/cat-tag-filter.php
r609238 r619000 5 5 Description: This plugin adds a widget to your WordPress site that allows your visitors to filter posts by category and tag. 6 6 Author: Ajay Verma 7 Version: 0. 8.57 Version: 0.9 8 8 Author URI: http://ajayver.com/ 9 9 */ … … 16 16 $cat = ''; //initialize variables for category and tag parts of the url 17 17 $tag = ''; 18 $tag_prefix = '?'. $_POST["tag_prefix"] .'='; //get tag and category prefix19 $cat_prefix = '?'. $_POST["cat_prefix"] .'=';18 $tag_prefix = $_POST["tag_prefix"] .'/'; //get tag and category prefix 19 $cat_prefix = $_POST["cat_prefix"] .'/'; 20 20 if ($_POST["tag_logic"] == 1) $tag_logic = '+'; //logic for tags (AND or OR) 21 21 else $tag_logic = ','; … … 23 23 $_POST['cat'] = get_term($_POST['cat'], $_POST['category_tax']); //get category slug from it's id 24 24 $cat = '/'. $cat_prefix . $_POST['cat']->slug; //add it to category part of the url 25 $tag_prefix = ' &' . $_POST["tag_prefix"] . '='; //add & to tag part of url25 $tag_prefix = '/' . $_POST["tag_prefix"] . '/'; //add & to tag part of url 26 26 } 27 27 … … 37 37 38 38 if ($cat == '' && $tag == '' && $_POST["blog_url"] != '') $url = $_POST["home_url"] . '/' . $_POST["blog_url"]; //if no category or no tag was chosen, just create a link to blog 39 else $url = $_POST["home_url"] . $cat . $tag; //else, create a link to blog + category and tag arguments39 else $url = $_POST["home_url"]. '/' . $cat . $tag; //else, create a link to blog + category and tag arguments 40 40 header('Location: ' . $url); //redirect user to the created url 41 41 exit; … … 217 217 <input type="hidden" name="tag_logic" value="<?php echo $ctf_options['tag_logic'] ?>" /> 218 218 <?php $taxonomies=get_taxonomies('','',''); ?> 219 <input type="hidden" name="tag_prefix" value="<?php echo $taxonomies[$ctf_options['tag_tax']]-> query_var?>" />219 <input type="hidden" name="tag_prefix" value="<?php echo $taxonomies[$ctf_options['tag_tax']]->rewrite['slug'] ?>" /> 220 220 <input type="hidden" name="category_tax" value="<?php echo $ctf_options['category_tax'] ?>" /> 221 <input type="hidden" name="cat_prefix" value="<?php echo $taxonomies[$ctf_options['category_tax']]-> query_var?>" />221 <input type="hidden" name="cat_prefix" value="<?php echo $taxonomies[$ctf_options['category_tax']]->rewrite['slug'] ?>" /> 222 222 <input id="ctf-submit" class="button" type="submit" value="<?php echo $ctf_options['button_title']; ?>"/> 223 223 </form> … … 234 234 parent::WP_Widget(false, $name = 'Cat + Tag Filter', $widget_ops); 235 235 } 236 237 236 238 /** @see WP_Widget::widget */ 237 239 function widget($args, $instance) { … … 260 262 echo $before_widget; 261 263 if ( $ctf_options['title'] ) echo $before_title . $ctf_options['title'] . $after_title; 264 262 265 ctf_widget(); 263 266 echo $after_widget; … … 430 433 431 434 <?php 432 } 435 436 } 437 433 438 } // class Cat + Tag Filter 434 439 // register Cat + Tag Filter widget … … 438 443 } 439 444 add_action('widgets_init', create_function('', 'return register_widget("cat_tag_filter");')); 445 446 function add_rewrite_rules() { 447 global $wp_rewrite; 448 $ctf_options = get_option('widget_cat_tag_filter'); 449 foreach ($ctf_options as $widget_options){ 450 if ($widget_options['category_tax']){ 451 452 $taxonomies = get_taxonomies('','',''); 453 454 $new_rules = array( 455 $taxonomies[$widget_options['category_tax']]->rewrite['slug'] . '/(.+?)/' . $taxonomies[$widget_options['tag_tax']]->rewrite['slug'] . '/(.+?)/?$' => 'index.php?' . $taxonomies[$widget_options['category_tax']]->query_var . '=' . $wp_rewrite->preg_index(1) . '&' . $taxonomies[$widget_options['tag_tax']]->query_var . '=' . $wp_rewrite->preg_index(2) 456 ); 457 $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; 458 459 } 460 } 461 462 463 464 } 465 466 467 add_action( 'generate_rewrite_rules', 'add_rewrite_rules' ); 468 469 470 440 471 ?> -
cat-tag-filter-widget/trunk/readme.txt
r609235 r619000 74 74 == Changelog == 75 75 76 = 0.9 = 77 * Added permalink support. 78 76 79 = 0.8.4 = 77 80 * Added an option to switch off corresponding tags mode.
Note: See TracChangeset
for help on using the changeset viewer.