Skip to content

Commit

Permalink
no consequence version bump, compat confirmation, changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2113 committed Apr 2, 2020
1 parent cde73ab commit 52b0fea
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
14 changes: 1 addition & 13 deletions Taxonomy_Switcher_UI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__ );
}
Expand All @@ -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( '<ol>%s</ol>', $items );

// Send back our encoded data.
wp_send_json_success( array( 'html' => $return ) );

}
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down
10 changes: 0 additions & 10 deletions js/taxonomy-switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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;

Expand All @@ -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 ) {
Expand All @@ -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);
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions taxonomy-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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();
Expand Down Expand Up @@ -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' ) ) ) );

}
Expand Down

0 comments on commit 52b0fea

Please sign in to comment.