admin管理员组

文章数量:1296854

On the post edit screen there is the meta box for categories that utilizes the Walker_Category_Checklist class to create the category checklist within the meta box. One of the conditions (line 90 of /wp-admin/includes/class-walker-category-checklist.php in WP 5.7.1) is:

if ( ! empty( $args['list_only'] ) ) {
  // do some things
}

What is list_only? It does not appear on the dev reference for Walker_Category_Checklist::start_el nor wp_terms_checklist().

And it appears only twice in WP core:

  • includes/template.php
    • line 120: $args['list_only'] = ! empty( $parsed_args['list_only'] );
  • wp-admin/includes/class-walker-category-checklist.php
    • line 90 - if ( ! empty( $args['list_only'] ) ) { as shown fully above.

Here is the whole if clause starting at 90:

if ( ! empty( $args['list_only'] ) ) {
    $aria_checked = 'false';
    $inner_class  = 'category';

    if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
        $inner_class .= ' selected';
        $aria_checked = 'true';
    }

    $output .= "\n" . '<li' . $class . '>' .
      '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
      ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
      /** This filter is documented in wp-includes/category-template.php */
      esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';

本文标签: categoriesWhy does the argument listonly do on WalkerCategoryCheckliststartel