From 52b0fea30aeab17dee1ba063a5d412f565f88277 Mon Sep 17 00:00:00 2001 From: Michael Beckwith Date: Thu, 2 Apr 2020 08:47:57 -0500 Subject: [PATCH] no consequence version bump, compat confirmation, changelog --- Taxonomy_Switcher_UI.php | 14 +------------- js/taxonomy-switcher.js | 10 ---------- readme.txt | 7 +++++-- taxonomy-switcher.php | 6 +----- 4 files changed, 7 insertions(+), 30 deletions(-) diff --git a/Taxonomy_Switcher_UI.php b/Taxonomy_Switcher_UI.php index b177152..7e7728b 100644 --- a/Taxonomy_Switcher_UI.php +++ b/Taxonomy_Switcher_UI.php @@ -192,26 +192,20 @@ public function fill_options( $name ) { */ public function ajax_term_results() { - // Verify our nonce, and required data. if ( ! ( isset( $_REQUEST[ 'nonce' ], $_REQUEST[ 'search' ] ) && wp_verify_nonce( $_REQUEST[ 'nonce' ], __FILE__ ) ) ) { $this->send_error( __LINE__, __( 'Security check failed', 'wds' ) ); } - // Set taxonomy. $taxonomy = isset( $_REQUEST[ 'tax_name' ] ) ? $_REQUEST[ 'tax_name' ] : 'category'; - // Sanitize our search string. $search_string = sanitize_text_field( $_REQUEST[ 'search' ] ); - // No search string, bail. if ( empty( $search_string ) ) { $this->send_error( __LINE__, __( 'Please Try Again', 'wds' ) ); } - // Do term search. $terms = $this->get_terms( $search_string, $taxonomy ); - // No terms, bail. if ( ! $terms ) { $this->send_error( __LINE__ ); } @@ -227,15 +221,12 @@ public function ajax_term_results() { $items = $this->get_list_items( $terms ); } - // No items, bail. if ( ! $items ) { $this->send_error( __LINE__, __( 'No terms found with children.', 'wds' ) ); } - // Build our ordered list. $return = sprintf( '
    %s
', $items ); - // Send back our encoded data. wp_send_json_success( array( 'html' => $return ) ); } @@ -276,7 +267,7 @@ public function get_terms( $search_string, $taxonomy, $number = 10 ) { // Add our term clause filter for this iteration (if < than 3.7). add_filter( 'terms_clauses', array( $this, 'wilcard_term_name' ) ); } - // Do term search. + $terms = get_terms( $taxonomy, array( 'number' => absint( $number ), 'name__like' => $search_string, @@ -300,17 +291,14 @@ public function get_terms( $search_string, $taxonomy, $number = 10 ) { */ public function get_list_items( $terms ) { - // Loop found terms and concatenate list items. $items = ''; foreach ( $terms as $term ) { - // Check if this term has child terms. $children = get_terms( $term->taxonomy, array( 'parent' => $term->term_id, 'hide_empty' => false, ) ); - // If no child terms to convert, bail. if ( ! $children ) { continue; } diff --git a/js/taxonomy-switcher.js b/js/taxonomy-switcher.js index bd62dbf..6f8b4b4 100644 --- a/js/taxonomy-switcher.js +++ b/js/taxonomy-switcher.js @@ -22,11 +22,9 @@ txsw.resultsClick = function( event ) { event.preventDefault(); var $self = $(this); - // hide our spinner $spinner.hide(); // populate post ID to field $ajaxinput.val( $self.data('termid') );/*.focus()*/ - // clear our results $ajaxresults.html(''); $ajaxhelp.hide(); } @@ -36,9 +34,7 @@ // hide our spinner $spinner.hide(); - // if we have a response id if ( typeof response.data !== 'undefined' ) { - // and populate our results from ajax response $ajaxresults.html(response.data.html); $ajaxhelp.show(); } @@ -47,9 +43,7 @@ txsw.maybeAjax = function( evt ) { $self = $(this); - // get typed value var term_search = $self.val(); - // only proceed if the user's typed more than 2 characters if ( term_search.length < 2 ) return this; @@ -58,9 +52,7 @@ // clear out our results $ajaxresults.html(''); $ajaxhelp.hide(); - // show our spinner $spinner.css({'float':'none'}).show(); - // and run our ajax function setTimeout(function(){ // if they haven't typed in 500 ms if ( $ajaxinput.val() == term_search ) { @@ -82,9 +74,7 @@ } $context - // when typing a term name.. .on( 'keyup', '#taxonomy-switcher-parent', txsw.maybeAjax ).blur( txsw.hideSpinner ) - // When clicking on a results post, populate our input .on( 'click', '.taxonomy-switcher-ajax-results-posts a', txsw.resultsClick ); })(window, document, jQuery); diff --git a/readme.txt b/readme.txt index 1891955..b115386 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: webdevstudios, pluginize, sc0ttkclark, jtsternberg Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3084056 Tags: taxonomy, taxonomies, term, terms, category, categories, convert, converter, tag, tags, custom taxonomy, custom taxonomies, switch taxonomies Requires at least: 3.5 -Tested up to: 4.7 -Stable tag: 1.0.2 +Tested up to: 5.4 +Stable tag: 1.0.3 License: GNU AGPLv3 License URI: http://www.gnu.org/licenses/agpl-3.0.html @@ -44,6 +44,9 @@ Please keep in mind, if parent isn't set, or you don't specify a comma-separated == Changelog == += 1.0.3 = +* Confirmed compatibility with WordPress 5.4.0 + = 1.0.2 = * Update for xss vulnerability, https://make.wordpress.org/plugins/2015/04/20/fixing-add_query_arg-and-remove_query_arg-usage diff --git a/taxonomy-switcher.php b/taxonomy-switcher.php index d00f511..31dea95 100755 --- a/taxonomy-switcher.php +++ b/taxonomy-switcher.php @@ -3,7 +3,7 @@ Plugin Name: Taxonomy Switcher Plugin URI: https://github.com/WebDevStudios/taxonomy-switcher Description: Switches the Taxonomy of terms to a different Taxonomy -Version: 1.0.2 +Version: 1.0.3 Author: WebDevStudios Author URI: http://webdevstudios.com */ @@ -20,12 +20,10 @@ class Taxonomy_Switcher_Init { */ public function __construct() { - // WP-CLI integration. if ( defined( 'WP_CLI' ) && WP_CLI ) { require_once( dirname( __FILE__ ) . '/Taxonomy_Switcher.php' ); require_once( dirname( __FILE__ ) . '/wp-cli.php' ); } else { - // No WP-CLI? Ok, let's add our UI. require_once( dirname( __FILE__ ) . '/Taxonomy_Switcher_UI.php' ); $this->ui = new Taxonomy_Switcher_UI(); $this->ui->hooks(); @@ -69,9 +67,7 @@ public function taxonomy_switcher_init() { return; } - // Save notices. add_option( 'taxonomy-switcher-notices', $success_notices, null, 'no' ); - // Redirect and strip query string. wp_redirect( esc_url_raw( add_query_arg( 'page', $this->ui->admin_slug, admin_url( '/tools.php' ) ) ) ); }