Changeset 2327146
- Timestamp:
- 06/18/2020 11:29:17 PM (6 years ago)
- Location:
- taxonomy-taxi-2-electric-boogaloo/trunk
- Files:
-
- 5 edited
-
_plugin.php (modified) (1 diff)
-
activation.php (modified) (1 diff)
-
index.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
screenshot-1.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
taxonomy-taxi-2-electric-boogaloo/trunk/_plugin.php
r1210110 r2327146 1 1 <?php 2 /*3 Plugin Name: Taxonomy Taxi 2 : Electric Boogaloo4 Plugin URI:5 Description:6 Version: 0.6.17 Author: postpostmodern, pinecone-dot-io8 Author URI:9 */10 2 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." );') ); 3 /** 4 * Plugin Name: Taxonomy Taxi: 2 Taxonomy 2 Taxi 5 * Plugin URI: 6 * Description: 7 * Version: 0.6.2 8 * Author: postpostmodern, pinecone-dot-io 9 * Author URI: https://rack.and.pinecone.website 10 * Requires PHP: 7.0 11 * License: GPL-2.0+ 12 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt 13 */ 12 14 13 register_activation_hook( __FILE__, '\taxonomytaxi\electric_boogaloo\activate' ); 14 register_deactivation_hook( __FILE__, '\taxonomytaxi\electric_boogaloo\deactivate' ); 15 register_activation_hook( 16 __FILE__, 17 @create_function("", '$ver = "7.0"; if( version_compare(phpversion(), $ver, "<") ) die( "This plugin requires PHP version $ver or greater be installed." );') 18 ); 15 19 16 require __DIR__.'/index.php'; 20 register_activation_hook( 21 __FILE__, 22 '\Taxonomy_Taxi\Two_Taxonomy_Two_Taxi\activate' 23 ); 24 25 register_deactivation_hook( 26 __FILE__, 27 '\Taxonomy_Taxi\Two_Taxonomy_Two_Taxi\deactivate' 28 ); 29 30 require __DIR__ . '/index.php'; -
taxonomy-taxi-2-electric-boogaloo/trunk/activation.php
r1210109 r2327146 1 1 <?php 2 2 3 namespace taxonomytaxi\electric_boogaloo;3 namespace Taxonomy_Taxi\Two_Taxonomy_Two_Taxi; 4 4 5 /* 6 * called on activation hook 7 */ 8 function activate(){ 9 flush_rewrite_rules( FALSE ); 5 /** 6 * Called on activation hook 7 */ 8 function activate() 9 { 10 flush_rewrite_rules(FALSE); 10 11 } 11 12 12 /* 13 * called on deactivation hook 14 */ 15 function deactivate(){ 16 flush_rewrite_rules( FALSE ); 13 /** 14 * Called on deactivation hook 15 */ 16 function deactivate() 17 { 18 flush_rewrite_rules(FALSE); 17 19 } -
taxonomy-taxi-2-electric-boogaloo/trunk/index.php
r1210109 r2327146 1 1 <?php 2 2 3 namespace taxonomytaxi\electric_boogaloo;3 namespace Taxonomy_Taxi\Two_Taxonomy_Two_Taxi; 4 4 5 require __DIR__ .'/activation.php';5 require __DIR__ . '/activation.php'; 6 6 7 /* 8 * 9 * @param string 10 * @param int|object 11 * @param string 12 * @param string 13 */ 14 function get_edit_term_link( $location, $term_id, $taxonomy, $object_type ){ 15 if( !is_object($term_id) || $term_id->term_id != 0 ) 7 /** 8 * 9 * @param $location string 10 * @param $term_id int|object 11 * @param $taxonomy string 12 * @param $object_type string 13 * 14 * @return string 15 */ 16 function get_edit_term_link($location, $term_id, $taxonomy, $object_type) 17 { 18 if (!is_object($term_id) || $term_id->term_id != 0) { 16 19 return $location; 17 20 } 21 18 22 $args = array( 19 23 'taxonomy' => $taxonomy, 20 24 ); 21 22 if ( trim($object_type) )25 26 if (trim($object_type)) { 23 27 $args['post_type'] = $object_type; 24 25 $location = add_query_arg( $args, admin_url('edit-tags.php') ); 26 28 } 29 30 $location = add_query_arg($args, admin_url('edit-tags.php')); 31 27 32 return $location; 28 33 } 29 add_filter( 'get_edit_term_link', __NAMESPACE__.'\get_edit_term_link', 10, 4);34 add_filter('get_edit_term_link', __NAMESPACE__ . '\get_edit_term_link', 10, 4); 30 35 31 /* 32 * 33 * @param string 34 * @return string 35 */ 36 function queried_taxonomy( $query = NULL ){ 36 /** 37 * 38 * @param $query string 39 * 40 * @return string 41 */ 42 function queried_taxonomy($query = NULL) 43 { 37 44 static $queried_taxonomy = NULL; 38 39 if ( $query )45 46 if ($query) { 40 47 $queried_taxonomy = $query; 41 48 } 49 42 50 return $queried_taxonomy; 43 51 } 44 52 45 /* 46 * 47 * @param WP_Query 48 * @return string 49 */ 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 * @param $wp_query WP_Query 56 * 57 * @return string 58 */ 59 function parse_query(&$wp_query) 60 { 61 if (isset($wp_query->tax_query->queries[0])) { 62 queried_taxonomy($wp_query->tax_query->queries[0]['taxonomy']); 53 63 } 54 64 55 65 return $wp_query; 56 66 } 57 add_filter( 'parse_query', __NAMESPACE__.'\parse_query');67 add_filter('parse_query', __NAMESPACE__ . '\parse_query'); 58 68 59 /* 60 * 61 */ 62 function posts_request( $sql, $wp_query ){ 63 //dbug( $sql ); 69 /** 70 * 71 */ 72 function posts_request($sql, $wp_query) 73 { 74 // dump($sql); 64 75 return $sql; 65 76 } 66 add_filter( 'posts_request', __NAMESPACE__.'\posts_request', 10, 2);77 add_filter('posts_request', __NAMESPACE__ . '\posts_request', 10, 2); 67 78 68 /* 69 * 70 */ 71 function pre_get_posts( $wp_query ){ 79 /** 80 * 81 * @param $wp_query WP_Query 82 * 83 * @return WP_Query 84 */ 85 function pre_get_posts($wp_query) 86 { 72 87 $queried_taxonomy = queried_taxonomy(); 73 88 74 if ( isset($wp_query->query_vars[$queried_taxonomy]) && ($wp_query->query_vars[$queried_taxonomy] == 'show-all-terms') ){89 if (isset($wp_query->query_vars[$queried_taxonomy]) && ($wp_query->query_vars[$queried_taxonomy] == 'show-all-terms')) { 75 90 global $wpdb; 76 91 77 $sql = $wpdb->prepare( "SELECT $wpdb->term_taxonomy.term_id92 $sql = $wpdb->prepare("SELECT $wpdb->term_taxonomy.term_id 78 93 FROM $wpdb->term_taxonomy 79 WHERE taxonomy = %s", $queried_taxonomy );94 WHERE taxonomy = %s", $queried_taxonomy); 80 95 81 $slugs = $wpdb->get_col( $sql);96 $slugs = $wpdb->get_col($sql); 82 97 83 98 $wp_query->query_vars[$queried_taxonomy] = ''; … … 93 108 return $wp_query; 94 109 } 95 add_filter( 'pre_get_posts', __NAMESPACE__.'\pre_get_posts', 10, 1);110 add_filter('pre_get_posts', __NAMESPACE__ . '\pre_get_posts', 10, 1); 96 111 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 ){ 112 /** 113 * Filter for `rewrite_rules_array` to add taxonomy base slugs directly before last catch alls 114 * calls `{slug}_taxonomytaxi-two_rewrite_rules` filters 115 * 116 * @param $r array 117 * 118 * @return array 119 */ 120 function rewrite_rules_array($r) 121 { 104 122 $new_rules = array(); 105 106 $taxonomies = get_taxonomies( '', 'objects');107 123 124 $taxonomies = get_taxonomies('', 'objects'); 125 108 126 // 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 )127 unset($taxonomies['category']); 128 unset($taxonomies['post_tag']); 129 unset($taxonomies['post_format']); 130 131 foreach ($taxonomies as $taxonomy => $properties) { 132 if (!$properties->rewrite){ 115 133 continue; 116 134 } 135 117 136 $slug = $properties->rewrite['slug']; 137 138 $taxonomy_rules = array( 139 $slug . '/page/?([0-9]{1,})' => 'index.php?' . $taxonomy . '=show-all-terms&paged=$matches[1]', 140 $slug => 'index.php?' . $taxonomy . '=show-all-terms' 141 ); 142 143 $taxonomy_rules = apply_filters($slug . '_taxonomytaxi-two_rewrite_rules', $taxonomy_rules); 144 145 $new_rules = array_merge($new_rules, $taxonomy_rules); 146 } 147 148 // insert new rewrite rules directly before the catch alls 149 $k = array_keys($r); 150 $p = array_search('(.+?)/page/?([0-9]{1,})/?$', $k); 151 152 // @TODO figure out a better way of finding this 153 if (!$p){ 154 $p = array_search('page/?([0-9]{1,})/?$', $k); 155 } 118 156 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 157 $a = array_slice($r, 0, $p); 158 $b = array_slice($r, $p); 159 160 $r = array_merge($a, $new_rules, $b); 161 142 162 return $r; 143 163 } 144 add_filter( 'rewrite_rules_array', __NAMESPACE__.'\rewrite_rules_array');164 add_filter('rewrite_rules_array', __NAMESPACE__ . '\rewrite_rules_array'); -
taxonomy-taxi-2-electric-boogaloo/trunk/readme.txt
r1210110 r2327146 1 === Taxonomy Taxi Two Electric Boogaloo===2 Contributors: postpostmodern 3 Donate link: http ://www.heifer.org/1 === Taxonomy Taxi - 2 Taxonomy 2 Taxi === 2 Contributors: postpostmodern, pinecone-dot-io 3 Donate link: https://cash.app/$EricEaglstun 4 4 Tags: custom taxonomies, taxonomy 5 Requires at least: 3.1.36 Tested up to: 4.2.35 Requires at least: 4.2.3 6 Tested up to: 5.4.2 7 7 Stable tag: trunk 8 8 … … 18 18 19 19 == Changelog == 20 21 = 0.6.2 = 22 * No more boogaloo 23 24 = 0.6.1 = 25 * Who knows 26 20 27 = 0.6 = 21 28 * Fix the quries using proper filtering
Note: See TracChangeset
for help on using the changeset viewer.