• The plugin breaks the wp_get_post_terms function.

    if you try to use
    wp_get_post_terms( $product_id, 'product_cat', array('fields' => 'ids' ) );
    the function does not return any value if the plugin is active and the option Hide Category is enabled.

    Please fix it!

Viewing 1 replies (of 1 total)
  • Thread Starter Oscar Gare

    (@oscargare)

    Hi,

    change the category_hide_hcps function by the following code to solve the problem:

    public function category_hide_hcps( $terms, $taxonomies, $args ) : array {
    			$new_terms     = $terms;
    			$hide_category = get_option( 'hcps_data' );
    			if ( ! empty( $hide_category['category'] ) ) {
    				if ( in_array( 'product_cat', $taxonomies, true ) && !is_admin() && empty( $args['class'] ) ) {
    					foreach ( $terms as $key => $term ) {
    						if ( ! empty( $term->term_id ) ) {
    							if ( in_array( $term->term_id, $hide_category['category'], true ) ) {
    								unset( $new_terms[ $key ] );
    							}
    						}
    					}
    				}
    			}
    			return $new_terms;
    		}
    • This reply was modified 2 years, 1 month ago by Oscar Gare.
Viewing 1 replies (of 1 total)
  • The topic ‘This plugin breaks the wp_get_post_terms function’ is closed to new replies.