Changeset 13883 for trunk/src/bp-core/classes/class-bp-admin-types.php
- Timestamp:
- 06/01/2024 05:06:17 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-admin-types.php
r13877 r13883 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 if ( ! class_exists( 'BP_Admin_Types' ) ) : 13 if ( class_exists( 'BP_Admin_Types' ) ) { 14 return; 15 } 14 16 15 17 /** … … 31 33 * 32 34 * @since 7.0.0 33 * @var array ()35 * @var array 34 36 */ 35 37 public $taxonomies = array(); … … 72 74 * @since 7.0.0 73 75 * 74 * @return BP_Admin_Types 76 * @return BP_Admin_Types|null The BP Types Admin object or null if not in admin. 75 77 */ 76 78 public static function register_types_admin() { … … 82 84 83 85 if ( empty( $bp->core->types_admin ) ) { 84 $bp->core->types_admin = new self ;86 $bp->core->types_admin = new self(); 85 87 } 86 88 … … 128 130 add_action( "{$this->taxonomy}_edit_form_fields", array( $this, 'edit_form_fields' ), 10, 2 ); 129 131 130 // Filters 132 // Filters. 131 133 add_filter( 'bp_core_admin_register_scripts', array( $this, 'register_scripts' ) ); 132 134 add_filter( "manage_{$this->screen_id}_columns", array( $this, 'column_headers' ), 10, 1 ); … … 260 262 * Override the Admin parent file to highlight the right menu. 261 263 * 264 * @global string $parent_file The parent file of the current admin screen. 265 * 262 266 * @since 7.0.0 263 267 */ … … 276 280 * 277 281 * @since 7.0.0 282 * 283 * @param array $scripts The registered scripts. 278 284 */ 279 285 public function register_scripts( $scripts = array() ) { … … 327 333 328 334 // Default values for the Type ID field. 329 $type_id_label 330 $type_id_desc 335 $type_id_label = __( 'Type ID', 'buddypress' ); 336 $type_id_desc = __( 'Enter a lower-case string without spaces or special characters (used internally to identify the type).', 'buddypress' ); 331 337 332 338 if ( isset( $labels->bp_type_id_label ) && $labels->bp_type_id_label ) { … … 374 380 sprintf( 375 381 /* translators: %s is the name of the Type meta key */ 376 esc_html__( 'As a result, the form elements for the "%s" meta key cannot be displayed', 'buddypress' ), esc_html( $meta_key ) ), 382 esc_html__( 'As a result, the form elements for the "%s" meta key cannot be displayed', 'buddypress' ), 383 esc_html( $meta_key ) 384 ), 377 385 '7.0.0' 378 386 ); … … 389 397 $type_prop_value = $type->labels[ $type_key ]; 390 398 } 391 392 399 } elseif ( isset( $type->{$type_key} ) ) { 393 400 $type_prop_value = $type->{$type_key}; … … 407 414 esc_html( $meta_schema['description'] ) 408 415 ); 409 410 416 } else { 411 417 printf( … … 420 426 ); 421 427 } 428 } elseif ( isset( $type->name ) ) { 429 $checked = ''; 430 if ( isset( $type->{$type_key} ) && true === (bool) $type->{$type_key} ) { 431 $checked = ' checked="checked"'; 432 } 433 434 printf( 435 '<tr class="form-field bp-types-form term-%1$s-wrap"> 436 <th scope="row"><label for="%1$s">%2$s</label></th> 437 <td> 438 <input name="%1$s" id="%1$s" type="checkbox" value="1"%3$s> %4$s 439 <p class="description">%5$s</p> 440 </td> 441 </tr>', 442 esc_attr( $meta_key ), 443 esc_html( $labels->{ $meta_key } ), 444 // phpcs:ignore WordPress.Security.EscapeOutput 445 $checked, 446 esc_html__( 'Yes', 'buddypress' ), 447 esc_html( $meta_schema['description'] ) 448 ); 422 449 } else { 423 if ( isset( $type->name ) ) { 424 $checked = ''; 425 if ( isset( $type->{$type_key} ) && true === (bool) $type->{$type_key} ) { 426 $checked = ' checked="checked"'; 427 } 428 429 printf( 430 '<tr class="form-field bp-types-form term-%1$s-wrap"> 431 <th scope="row"><label for="%1$s">%2$s</label></th> 432 <td> 433 <input name="%1$s" id="%1$s" type="checkbox" value="1"%3$s> %4$s 434 <p class="description">%5$s</p> 435 </td> 436 </tr>', 437 esc_attr( $meta_key ), 438 esc_html( $labels->{ $meta_key } ), 439 // phpcs:ignore WordPress.Security.EscapeOutput 440 $checked, 441 esc_html__( 'Yes', 'buddypress' ), 442 esc_html( $meta_schema['description'] ) 443 ); 444 } else { 445 printf( 446 '<div class="form-field bp-types-form term-%1$s-wrap"> 447 <label for="%1$s"> 448 <input name="%1$s" id="%1$s" type="checkbox" value="1"> %2$s 449 </label> 450 <p>%3$s</p> 451 </div>', 452 esc_attr( $meta_key ), 453 esc_html( $labels->{ $meta_key } ), 454 esc_html( $meta_schema['description'] ) 455 ); 456 } 450 printf( 451 '<div class="form-field bp-types-form term-%1$s-wrap"> 452 <label for="%1$s"> 453 <input name="%1$s" id="%1$s" type="checkbox" value="1"> %2$s 454 </label> 455 <p>%3$s</p> 456 </div>', 457 esc_attr( $meta_key ), 458 esc_html( $labels->{ $meta_key } ), 459 esc_html( $meta_schema['description'] ) 460 ); 457 461 } 458 462 } … … 464 468 * @since 7.0.0 465 469 * 466 * @param WP_Term $term The term object for the BP Type. 467 * @param string $taxonomy The type taxonomy name. 468 * @return string HTML Output. 470 * @param WP_Term|null $term The term object for the BP Type. 471 * @param string $taxonomy The type taxonomy name. 469 472 */ 470 473 public function edit_form_fields( $term = null, $taxonomy = '' ) { … … 489 492 } 490 493 491 return$this->add_form_fields( $taxonomy, $type );494 $this->add_form_fields( $taxonomy, $type ); 492 495 } 493 496 … … 497 500 * @since 7.0.0 498 501 * 499 * @param array 500 * @return array 502 * @param array $column_headers The column header labels keyed by column ID. 503 * @return arrayThe column header labels keyed by column ID. 501 504 */ 502 505 public function column_headers( $column_headers = array() ) { … … 518 521 * @since 7.0.0 519 522 * 520 * @param string $string Blank string.521 * @param string $column_nameName of the column.522 * @param int $type_idThe type's term ID.523 * @return string The Type Plural name.523 * @param string $column_content The column content. 524 * @param string $column_name Name of the column. 525 * @param int $type_id The type's term ID. 526 * @return string|null|int 524 527 */ 525 528 public function column_contents( $column_content = '', $column_name = '', $type_id = 0 ) { … … 543 546 * @since 7.0.0 544 547 * 545 * @param string $value Metadata for the BP Type. 548 * @param string $meta_data Metadata for the BP Type. 549 * @param string $type_name The BP Type name. 546 550 */ 547 551 $metadata = apply_filters( "{$this->taxonomy}_set_registered_by_code_metada", array(), $type_name ); … … 557 561 } elseif ( 'counts' === $column_name ) { 558 562 global $parent_file; 559 $type 563 $type = bp_get_term_by( 'id', $type_id, $this->taxonomy ); 560 564 if ( 0 === (int) $type->count ) { 561 565 return 0; … … 587 591 * @since 7.0.0 588 592 * 589 * @param array $actions The table row actions.590 * @param WP_Term $type The current BP Type for the row.591 * @return array 593 * @param array $actions The table row actions. 594 * @param WP_Term|null $type The current BP Type for the row. 595 * @return array The table row actions for the current BP type. 592 596 */ 593 597 public function row_actions( $actions = array(), $type = null ) { … … 602 606 * 603 607 * @since 7.0.0 608 * 609 * @param array $registered_by_code_types The types registered by code. 610 * @param WP_Term|null $type The current BP Type for the row. 604 611 */ 605 $registered_by_code_types = apply_filters( "{$type->taxonomy}_registered_by_code", array() );612 $registered_by_code_types = apply_filters( "{$type->taxonomy}_registered_by_code", array(), $type ); 606 613 607 614 // Types registered by code cannot be deleted as long as the custom registration code exists. … … 621 628 } 622 629 } 623 624 endif;
Note: See TracChangeset
for help on using the changeset viewer.