Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/01/2024 10:19:51 PM (2 years ago)
Author:
espellcaste
Message:

WPCS: Part III: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883] and [13886]

See #9164 and #7228

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-walker-category-checklist.php

    r10811 r13887  
    11<?php
     2/**
     3 * BP_Walker_Category_Checklist class.
     4 *
     5 * @package BuddyPress
     6 * @subpackage Core
     7 * @since 2.5.0
     8 */
     9
     10// Exit if accessed directly.
     11defined( 'ABSPATH' ) || exit;
     12
    213/**
    314 * Walker class to output an unordered list of category checkbox input elements.
     
    1021 */
    1122class BP_Walker_Category_Checklist extends Walker {
     23        /**
     24         * Tree type.
     25         *
     26         * @since 2.5.0
     27         *
     28         * @var string
     29         */
    1230        public $tree_type = 'category';
    13         public $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
     31
     32        /**
     33         * DB Fields.
     34         *
     35         * @since 2.5.0
     36         *
     37         * @var array
     38         */
     39        public $db_fields = array(
     40                'parent' => 'parent',
     41                'id'     => 'term_id',
     42        );
    1443
    1544        /**
     
    3766         */
    3867        public function end_lvl( &$output, $depth = 0, $args = array() ) {
    39                 $indent = str_repeat( "\t", $depth );
     68                $indent  = str_repeat( "\t", $depth );
    4069                $output .= "$indent</ul>\n";
    4170        }
     
    5786                }
    5887
    59                 if ( $taxonomy == 'category' ) {
     88                if ( 'category' === $taxonomy ) {
    6089                        $name = 'post_category';
    6190                } else {
     
    6493
    6594                $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
    66                 $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
     95                $class                = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
    6796
    6897                $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
     
    7099                if ( ! empty( $args['list_only'] ) ) {
    71100                        $aria_cheched = 'false';
    72                         $inner_class = 'category';
     101                        $inner_class  = 'category';
    73102
    74                         if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
     103                        if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
    75104                                $inner_class .= ' selected';
    76105                                $aria_cheched = 'true';
     
    85114                        /** This filter is documented in wp-includes/category-template.php */
    86115                        $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
    87                                 '<label for="in-'.$taxonomy.'-' . $category->term_id . '" class="selectit"><input value="' . $category->slug . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' .
    88                                 checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
     116                                '<label for="in-' . $taxonomy . '-' . $category->term_id . '" class="selectit"><input value="' . $category->slug . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
     117                                checked( in_array( $category->term_id, $args['selected_cats'], true ), true, false ) .
    89118                                disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
    90119                                esc_html( apply_filters( 'the_category', $category->description ) ) . '</label>';
     
    102131         * @param object $category The current term object.
    103132         * @param int    $depth    Depth of the term in reference to parents. Default 0.
    104          * @param array  $args     An array of arguments. @see wp_terms_checklist()
     133         * @param array  $args     An array of arguments.
    105134         */
    106135        public function end_el( &$output, $category, $depth = 0, $args = array() ) {
Note: See TracChangeset for help on using the changeset viewer.