Plugin Directory

Changeset 2327146


Ignore:
Timestamp:
06/18/2020 11:29:17 PM (6 years ago)
Author:
pinecone-dot-io
Message:

v 0.6.2

Location:
taxonomy-taxi-2-electric-boogaloo/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • taxonomy-taxi-2-electric-boogaloo/trunk/_plugin.php

    r1210110 r2327146  
    11<?php
    2 /*
    3 Plugin Name:    Taxonomy Taxi 2 : Electric Boogaloo
    4 Plugin URI:     
    5 Description:   
    6 Version:        0.6.1
    7 Author:         postpostmodern, pinecone-dot-io
    8 Author URI:
    9 */
    102
    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 */
    1214
    13 register_activation_hook( __FILE__, '\taxonomytaxi\electric_boogaloo\activate' );
    14 register_deactivation_hook( __FILE__, '\taxonomytaxi\electric_boogaloo\deactivate' );
     15register_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);
    1519
    16 require __DIR__.'/index.php';
     20register_activation_hook(
     21    __FILE__,
     22    '\Taxonomy_Taxi\Two_Taxonomy_Two_Taxi\activate'
     23);
     24
     25register_deactivation_hook(
     26    __FILE__,
     27    '\Taxonomy_Taxi\Two_Taxonomy_Two_Taxi\deactivate'
     28);
     29
     30require __DIR__ . '/index.php';
  • taxonomy-taxi-2-electric-boogaloo/trunk/activation.php

    r1210109 r2327146  
    11<?php
    22
    3 namespace taxonomytaxi\electric_boogaloo;
     3namespace Taxonomy_Taxi\Two_Taxonomy_Two_Taxi;
    44
    5 /*
    6 *   called on activation hook
    7 */
    8 function activate(){
    9     flush_rewrite_rules( FALSE );
     5/**
     6 * Called on activation hook
     7 */
     8function activate()
     9{
     10    flush_rewrite_rules(FALSE);
    1011}
    1112
    12 /*
    13 *   called on deactivation hook
    14 */
    15 function deactivate(){
    16     flush_rewrite_rules( FALSE );
     13/**
     14 * Called on deactivation hook
     15 */
     16function deactivate()
     17{
     18    flush_rewrite_rules(FALSE);
    1719}
  • taxonomy-taxi-2-electric-boogaloo/trunk/index.php

    r1210109 r2327146  
    11<?php
    22
    3 namespace taxonomytaxi\electric_boogaloo;
     3namespace Taxonomy_Taxi\Two_Taxonomy_Two_Taxi;
    44
    5 require __DIR__.'/activation.php';
     5require __DIR__ . '/activation.php';
    66
    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 */
     16function get_edit_term_link($location, $term_id, $taxonomy, $object_type)
     17{
     18    if (!is_object($term_id) || $term_id->term_id != 0) {
    1619        return $location;
    17    
     20    }
     21
    1822    $args = array(
    1923        'taxonomy' => $taxonomy,
    2024    );
    21    
    22     if( trim($object_type) )
     25
     26    if (trim($object_type)) {
    2327        $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
    2732    return $location;
    2833}
    29 add_filter( 'get_edit_term_link', __NAMESPACE__.'\get_edit_term_link', 10, 4 );
     34add_filter('get_edit_term_link', __NAMESPACE__ . '\get_edit_term_link', 10, 4);
    3035
    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 */
     42function queried_taxonomy($query = NULL)
     43{
    3744    static $queried_taxonomy = NULL;
    38    
    39     if( $query )
     45
     46    if ($query) {
    4047        $queried_taxonomy = $query;
    41    
     48    }
     49
    4250    return $queried_taxonomy;
    4351}
    4452
    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 */
     59function parse_query(&$wp_query)
     60{
     61    if (isset($wp_query->tax_query->queries[0])) {
     62        queried_taxonomy($wp_query->tax_query->queries[0]['taxonomy']);
    5363    }
    54    
     64
    5565    return $wp_query;
    5666}
    57 add_filter( 'parse_query', __NAMESPACE__.'\parse_query' );
     67add_filter('parse_query', __NAMESPACE__ . '\parse_query');
    5868
    59 /*
    60 *
    61 */
    62 function posts_request( $sql, $wp_query ){
    63     //dbug( $sql );
     69/**
     70 *
     71 */
     72function posts_request($sql, $wp_query)
     73{
     74    // dump($sql);
    6475    return $sql;
    6576}
    66 add_filter( 'posts_request', __NAMESPACE__.'\posts_request', 10, 2 );
     77add_filter('posts_request', __NAMESPACE__ . '\posts_request', 10, 2);
    6778
    68 /*
    69 *
    70 */
    71 function pre_get_posts( $wp_query ){
     79/**
     80 *
     81 * @param $wp_query WP_Query
     82 *
     83 * @return WP_Query
     84 */
     85function pre_get_posts($wp_query)
     86{
    7287    $queried_taxonomy = queried_taxonomy();
    7388
    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')) {
    7590        global $wpdb;
    7691
    77         $sql = $wpdb->prepare( "SELECT $wpdb->term_taxonomy.term_id
     92        $sql = $wpdb->prepare("SELECT $wpdb->term_taxonomy.term_id
    7893                                FROM $wpdb->term_taxonomy
    79                                 WHERE taxonomy = %s", $queried_taxonomy );
     94                                WHERE taxonomy = %s", $queried_taxonomy);
    8095
    81         $slugs = $wpdb->get_col( $sql );
     96        $slugs = $wpdb->get_col($sql);
    8297
    8398        $wp_query->query_vars[$queried_taxonomy] = '';
     
    93108    return $wp_query;
    94109}
    95 add_filter( 'pre_get_posts', __NAMESPACE__.'\pre_get_posts', 10, 1 );
     110add_filter('pre_get_posts', __NAMESPACE__ . '\pre_get_posts', 10, 1);
    96111
    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 */
     120function rewrite_rules_array($r)
     121{
    104122    $new_rules = array();
    105    
    106     $taxonomies = get_taxonomies( '', 'objects' );
    107    
     123
     124    $taxonomies = get_taxonomies('', 'objects');
     125
    108126    // 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){
    115133            continue;
    116            
     134        }
     135
    117136        $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    }
    118156       
    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
    142162    return $r;
    143163}
    144 add_filter( 'rewrite_rules_array', __NAMESPACE__.'\rewrite_rules_array' );
     164add_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 ===
     2Contributors: postpostmodern, pinecone-dot-io
     3Donate link: https://cash.app/$EricEaglstun
    44Tags: custom taxonomies, taxonomy
    5 Requires at least: 3.1.3
    6 Tested up to: 4.2.3
     5Requires at least: 4.2.3
     6Tested up to: 5.4.2
    77Stable tag: trunk
    88
     
    1818
    1919== Changelog ==
     20
     21= 0.6.2 =
     22* No more boogaloo
     23
     24= 0.6.1 =
     25* Who knows
     26
    2027= 0.6 =
    2128* Fix the quries using proper filtering
Note: See TracChangeset for help on using the changeset viewer.