Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter ryo3409

    (@ryo3409)

    In fact, an issue has occurred.

    Problem Description:

    • For each custom taxonomy, only the terms registered under the default category are being repeatedly output.

    Conditions for the Problem:

    • WooCommerce is not installed.
    • Multiple custom taxonomies are registered.

    Specific Code:

    The code below is exactly as it appears in version 4.1.21:

    if ( $this->has_woo_commerce ) {

      $defaults = array(

        'descendants_and_self' => 0,

        'selected_cats' => $this->sg->get_option( 'b_exclude_cats' ),

        'popular_cats' => false,

        'walker' => null,

        'taxonomy' => $taxonomy,

        'checked_ontop' => true,

        'echo' => true,

      );

    } else {

      $defaults = array(

        'selected_cats' => $this->sg->get_option( 'b_exclude_cats' ),

        'echo'     => true,

      );

    }

    When WooCommerce is installed, the taxonomy to be extracted is specified. However, when WooCommerce is not installed, the taxonomy extraction specification is missing, resulting in only the default category being extracted.

    Proposed Correction:

    Wouldn’t the following code be more appropriate?

    if ( $this->has_woo_commerce ) {

      $defaults = array(

        'descendants_and_self' => 0,

        'selected_cats' => $this->sg->get_option( 'b_exclude_cats' ),

        'popular_cats' => false,

        'walker' => null,

        'taxonomy' => $taxonomy,

        'checked_ontop' => true,

        'echo' => true,

      );

    } else {

      $defaults = array(

        'selected_cats' => $this->sg->get_option( 'b_exclude_cats' ),

        'taxonomy' => $taxonomy,

        'echo'     => true,

      );

    }

    Additionally, it seems that other sections wrapped in if ( $this->has_woo_commerce ) are also not being tested correctly.

Viewing 1 replies (of 1 total)