michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Terms in taxonomy checklist disappeared #209

Closed vladkucherov closed 9 years ago

vladkucherov commented 9 years ago

Hi,

For some reason I can't see any terms. noticed this after upgrading to WP 4.2.1

image

This is a screenshot from your demo.

vladkucherov commented 9 years ago

Looks like WP added this block of code

if ( ! empty( $args['name'] ) ) {
    if ( is_array( $args['name'] ) ) {
        $name = array_map( 'sanitize_text_field', $args['name'] );
        $where .= " AND t.name IN ('" . implode( "', '", array_map( 'esc_sql', $name ) ) . "')";
    } else {
        $name = sanitize_text_field( $args['name'] );
        $where .= $wpdb->prepare( " AND t.name = %s", $name );
    }
}

Inside: wp-includes/taxonomy.php _line:_ 1847 get_terms()

You are passing the name (I couldn't figure why, I removed it and it worked properly) of the taxonomy to wp_list_categories and it gets passed along to get_terms() which starting from this version is using this argument (I also couldn't find any info describing this change), and they didn't updated their docs with this change.

https://codex.wordpress.org/Function_Reference/get_terms

Can you explain why we need to pass the name of the taxonomy to the wp_list_categories function? The quick fix would be to just remove it.

Ideas?

michaeluno commented 9 years ago

Hi,

I could confirm the problem. The name argument passed to the wp_list_categories() function is a custom argument added by the framework to pass the name attribute prefix to calculate the name attribute value for each checkbox. And it caused the argument name conflict with the WordPress 4.2 .

This can be simply avoided by changing the argument name used by the framework internally. Thanks for the report.

michaeluno commented 9 years ago

I've updated the 3.5.7b branch that includes a fix for this issue. Download. Let me know if it works for you.

vladkucherov commented 9 years ago

@michaeluno Works like a charm :+1:

Thank you.