Changeset 1210109
- Timestamp:
- 07/31/2015 02:51:39 AM (11 years ago)
- Location:
- taxonomy-taxi-2-electric-boogaloo/trunk
- Files:
-
- 1 added
- 1 deleted
- 3 edited
-
_plugin.php (modified) (2 diffs)
-
activation.php (added)
-
index.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
taxo-taxi-2.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
taxonomy-taxi-2-electric-boogaloo/trunk/_plugin.php
r977975 r1210109 4 4 Plugin URI: 5 5 Description: 6 Version: . 36 Version: .5 7 7 Author: postpostmodern, pinecone-dot-io 8 8 Author URI: … … 11 11 register_activation_hook( __FILE__, create_function("", '$ver = "5.3"; if( version_compare(phpversion(), $ver, "<") ) die( "This plugin requires PHP version $ver or greater be installed." );') ); 12 12 13 register_activation_hook( __FILE__, ' taxonomytaxi\electric_boogaloo\activate' );14 register_deactivation_hook( __FILE__, ' taxonomytaxi\electric_boogaloo\deactivate' );13 register_activation_hook( __FILE__, '\taxonomytaxi\electric_boogaloo\activate' ); 14 register_deactivation_hook( __FILE__, '\taxonomytaxi\electric_boogaloo\deactivate' ); 15 15 16 16 require __DIR__.'/index.php'; -
taxonomy-taxi-2-electric-boogaloo/trunk/index.php
r977975 r1210109 3 3 namespace taxonomytaxi\electric_boogaloo; 4 4 5 require __DIR__.'/ taxo-taxi-2.php';5 require __DIR__.'/activation.php'; 6 6 7 7 /* 8 * called on activation hook 8 * 9 * @param string 10 * @param int|object 11 * @param string 12 * @param string 9 13 */ 10 function activate(){ 11 \TaxoTaxi2ElecBoog::setup(); 12 flush_rewrite_rules( FALSE ); 14 function get_edit_term_link( $location, $term_id, $taxonomy, $object_type ){ 15 if( !is_object($term_id) || $term_id->term_id != 0 ) 16 return $location; 17 18 $args = array( 19 'taxonomy' => $taxonomy, 20 ); 21 22 if( trim($object_type) ) 23 $args['post_type'] = $object_type; 24 25 $location = add_query_arg( $args, admin_url('edit-tags.php') ); 26 27 return $location; 28 } 29 add_filter( 'get_edit_term_link', __NAMESPACE__.'\get_edit_term_link', 10, 4 ); 30 31 /* 32 * 33 * @param string 34 * @return string 35 */ 36 function queried_taxonomy( $query = NULL ){ 37 static $queried_taxonomy = NULL; 38 39 if( $query ) 40 $queried_taxonomy = $query; 41 42 return $queried_taxonomy; 13 43 } 14 44 15 45 /* 16 * called on deactivation hook 46 * 47 * @param WP_Query 48 * @return string 17 49 */ 18 function deactivate(){ 19 flush_rewrite_rules( FALSE ); 50 function parse_query( &$wp_query ){ 51 if( isset($wp_query->tax_query->queries[0]) ){ 52 queried_taxonomy( $wp_query->tax_query->queries[0]['taxonomy'] ); 53 } 54 55 return $wp_query; 20 56 } 57 add_filter( 'parse_query', __NAMESPACE__.'\parse_query' ); 58 59 /* 60 * 61 */ 62 function posts_request( $sql, $wp_query ){ 63 //dbug( $sql ); 64 return $sql; 65 } 66 add_filter( 'posts_request', __NAMESPACE__.'\posts_request', 10, 2 ); 67 68 /* 69 * 70 */ 71 function pre_get_posts( $wp_query ){ 72 $queried_taxonomy = queried_taxonomy(); 73 74 if( isset($wp_query->query_vars[$queried_taxonomy]) && ($wp_query->query_vars[$queried_taxonomy] == 'show-all-terms') ){ 75 global $wpdb; 76 77 $sql = $wpdb->prepare( "SELECT $wpdb->term_taxonomy.term_id 78 FROM $wpdb->term_taxonomy 79 WHERE taxonomy = %s", $queried_taxonomy ); 80 81 $slugs = $wpdb->get_col( $sql ); 82 83 $wp_query->query_vars[$queried_taxonomy] = ''; 84 $wp_query->query_vars['tax_query'] = array( 85 array( 86 'taxonomy' => $queried_taxonomy, 87 'field' => 'term_id', 88 'terms' => $slugs, 89 ) 90 ); 91 } 92 93 return $wp_query; 94 } 95 add_filter( 'pre_get_posts', __NAMESPACE__.'\pre_get_posts', 10, 1 ); 96 97 /* 98 * filter for `rewrite_rules_array` to add taxonomy base slugs directly before last catch alls 99 * calls `{slug}_taxonomytaxi-two_rewrite_rules` filters 100 * @param array 101 * @return array 102 */ 103 function rewrite_rules_array( $r ){ 104 $new_rules = array(); 105 106 $taxonomies = get_taxonomies( '', 'objects' ); 107 108 // dont duplicate defaults 109 unset( $taxonomies['category'] ); 110 unset( $taxonomies['post_tag'] ); 111 unset( $taxonomies['post_format'] ); 112 113 foreach( $taxonomies as $taxonomy => $properties ){ 114 if( !$properties->rewrite ) 115 continue; 116 117 $slug = $properties->rewrite['slug']; 118 119 $taxonomy_rules = array( 120 $slug.'/page/?([0-9]{1,})' => 'index.php?'.$taxonomy.'=show-all-terms&paged=$matches[1]', 121 $slug => 'index.php?'.$taxonomy.'=show-all-terms' 122 ); 123 124 $taxonomy_rules = apply_filters( $slug.'_taxonomytaxi-two_rewrite_rules', $taxonomy_rules ); 125 126 $new_rules = array_merge( $new_rules, $taxonomy_rules ); 127 } 128 129 // insert new rewrite rules directly before the catch alls 130 $k = array_keys( $r ); 131 $p = array_search( '(.+?)/page/?([0-9]{1,})/?$', $k ); 132 133 // @TODO figure out a better way of finding this 134 if( !$p ) 135 $p = array_search( 'page/?([0-9]{1,})/?$', $k ); 136 137 $a = array_slice( $r, 0, $p ); 138 $b = array_slice( $r, $p ); 139 140 $r = array_merge( $a, $new_rules, $b ); 141 142 return $r; 143 } 144 add_filter( 'rewrite_rules_array', __NAMESPACE__.'\rewrite_rules_array' ); -
taxonomy-taxi-2-electric-boogaloo/trunk/readme.txt
r977973 r1210109 4 4 Tags: custom taxonomies, taxonomy 5 5 Requires at least: 3.1.3 6 Tested up to: 3.96 Tested up to: 4.1.4 7 7 Stable tag: trunk 8 8 … … 18 18 19 19 == Changelog == 20 = 0.5 = 21 * Start on fix for wp 4.2 which fixed the exploited sql 22 23 = 0.45 = 24 * Fix undefined term_id when admin bar is showing 25 26 = 0.4 = 27 * Finish namespace refactor 28 20 29 = 0.3 = 21 30 * Start on namespace refactor
Note: See TracChangeset
for help on using the changeset viewer.