Plugin Directory

Changeset 3215845


Ignore:
Timestamp:
01/02/2025 07:51:16 AM (12 months ago)
Author:
dhanendran
Message:

validate taxonomy before use

Location:
term-taxonomy-converter/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • term-taxonomy-converter/trunk/readme.md

    r2923010 r3215845  
    44Tags: importer, converter, copy, duplicate, categories and tags converter, taxonomy converter, copy taxonomies, duplicate taxonomies, terms
    55Requires at least: 3.0
    6 Tested up to: 6.2.2
    7 Stable tag: 1.2
     6Tested up to: 6.7.1
     7Stable tag: 1.2.1
    88License: GPLv3 or later
    99License URI: <a href="http://www.gnu.org/licenses/gpl-3.0.html">http://www.gnu.org/licenses/gpl-3.0.html</a>
  • term-taxonomy-converter/trunk/term-taxonomy-converter.php

    r2923010 r3215845  
    1111 * Description:       Copy or convert terms between taxonomies. This plugin, allows you to copy (duplicate) or convert (move) terms from one taxonomy to another or to multiple taxonomies, while maintaining associated posts.
    1212 * Tags:              importer, converter, copy, duplicate, categories and tags converter, taxonomy converter, copy taxonomies, duplicate taxonomies, terms
    13  * Version:           1.2
     13 * Version:           1.2.1
    1414 * Author:            Dhanendran
    1515 * Author URI:        http://dhanendranrajagopal.me/
     
    3232    public $all_terms = array();
    3333    public $hybrids_ids = array();
     34    public $terms_to_convert = array();
    3435
    3536    function __construct() {
     
    8788    public function page() {
    8889        $tax = ( isset( $_GET['tax'] ) ) ? sanitize_text_field( $_GET['tax'] ) : 'category';
     90        // Validate that the taxonomy exists
     91        if ( ! taxonomy_exists( $tax ) ) {
     92            $tax = 'category'; // Fallback to default if invalid
     93        }
    8994        $step = ( isset( $_GET['step'] ) ) ? (int) sanitize_text_field( $_GET['step'] ) : 1;
    9095
     
    226231
    227232        if (
    228                 ( ! isset( $_POST['terms_to_convert' ] ) || ! is_array( $_POST['terms_to_convert'] ) )
    229                 && empty( $this->terms_to_convert ) || ( ! isset( $_POST['taxes'] ) )
    230         ) { ?>
    231             <div class="narrow">
    232                 <p><?php printf( __( 'Uh, oh. Something didn&#8217;t work. Please <a href="%s">try again</a>.', 'd9_ttc' ), esc_attr( 'tools.php?page=term_tax_converter&amp;tax=' . $tax ) ); ?></p>
    233             </div>
     233                ( ! isset( $_POST['terms_to_convert' ] ) || ! is_array( $_POST['terms_to_convert'] ) )
     234                && empty( $this->terms_to_convert ) || ( ! isset( $_POST['taxes'] ) )
     235        ) { ?>
     236            <div class="narrow">
     237                <p><?php printf( __( 'Uh, oh. Something didn&#8217;t work. Please <a href="%s">try again</a>.', 'd9_ttc' ), esc_attr( 'tools.php?page=term_tax_converter&amp;tax=' . $tax ) ); ?></p>
     238            </div>
    234239            <?php
    235             return;
     240            return;
    236241        }
    237242
    238243        if ( empty( $this->terms_to_convert ) )
    239             $this->terms_to_convert = filter_input( INPUT_POST, 'terms_to_convert', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
     244            $this->terms_to_convert = filter_input( INPUT_POST, 'terms_to_convert', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
    240245
    241246        $taxonomy = $this->taxes[ $tax ];
     
    247252            $c_label = 'Copy';
    248253
    249         $new_taxes = filter_input( INPUT_POST, 'taxes', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
     254        $new_taxes = filter_input( INPUT_POST, 'taxes', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
    250255
    251256        $hybrid_cats = $clear_parents = $parents = false;
     
    300305                        if ( ! $convert ) {
    301306                            $hybrid_cats = true;
    302                             echo '*';
     307                            echo '*';
    303308                        }
    304309                        $clean_term_cache[] = $term->term_id;
Note: See TracChangeset for help on using the changeset viewer.