Changeset 13883
- Timestamp:
- 06/01/2024 05:06:17 PM (4 months ago)
- Location:
- trunk/src/bp-core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-types.php
r13877 r13883 17 17 * 18 18 * @param string $type_taxonomy The type's taxonomy name. 19 * @return array 19 * @return array Default values for the taxonomy registered metadata. 20 20 */ 21 21 function bp_core_admin_get_type_default_meta_values( $type_taxonomy ) { … … 40 40 * @since 7.0.0 41 41 * 42 * @param array 42 * @param array $args { 43 43 * Array of arguments describing the object type. 44 44 * … … 63 63 64 64 if ( ! $args['bp_type_id'] || ! $args['taxonomy'] ) { 65 return new WP_Error( 66 'invalid_type_taxonomy', 67 __( 'The Type ID value is missing', 'buddypress' ), 68 array( 69 'message' => 1, 70 ) 65 return new WP_Error( 66 'invalid_type_taxonomy', 67 __( 'The Type ID value is missing', 'buddypress' ), 68 array( 'message' => 1 ) 71 69 ); 72 70 } … … 80 78 * @since 7.0.0 81 79 * 82 * @param boolean $ valueTrue if the type exists. False otherwise.83 * @param string $type_id The Type's ID.80 * @param boolean $existing_type True if the type exists. False otherwise. 81 * @param string $type_id The Type's ID. 84 82 */ 85 83 $type_exists = apply_filters( "{$type_taxonomy}_check_existing_type", false, $type_id ); … … 89 87 'type_already_exists', 90 88 __( 'The Type already exists', 'buddypress' ), 91 array( 92 'message' => 5, 93 ) 94 ); 89 array( 'message' => 5 ) 90 ); 95 91 } 96 92 … … 98 94 $metadata = bp_core_admin_get_type_default_meta_values( $type_taxonomy ); 99 95 100 // Validate metadata 96 // Validate metadata. 101 97 $metas = array_filter( array_intersect_key( $args, $metadata ) ); 102 98 … … 141 137 * @since 7.0.0 142 138 * 143 * @param array 139 * @param array $args { 144 140 * Array of arguments describing the object type. 145 141 * … … 164 160 165 161 if ( ! $args['type_term_id'] || ! $args['taxonomy'] ) { 166 return new WP_Error( 167 'invalid_type_taxonomy', 168 __( 'The Term Type ID value is missing', 'buddypress' ), 169 array( 170 'message' => 10, 171 ) 162 return new WP_Error( 163 'invalid_type_taxonomy', 164 __( 'The Term Type ID value is missing', 'buddypress' ), 165 array( 'message' => 10 ) 172 166 ); 173 167 } … … 177 171 178 172 // Get default values for metadata. 179 $metadata 173 $metadata = bp_core_admin_get_type_default_meta_values( $type_taxonomy ); 180 174 181 175 // Merge customs with defaults. … … 215 209 * @since 7.0.0 216 210 * 217 * @param array 211 * @param array $args { 218 212 * Array of arguments describing the object type. 219 213 * … … 237 231 238 232 if ( ! $args['type_term_id'] || ! $args['taxonomy'] ) { 239 return new WP_Error( 240 'invalid_type_taxonomy', 241 __( 'The Term Type ID value is missing', 'buddypress' ), 242 array( 243 'message' => 10, 244 ) 233 return new WP_Error( 234 'invalid_type_taxonomy', 235 __( 'The Term Type ID value is missing', 'buddypress' ), 236 array( 'message' => 10 ) 245 237 ); 246 238 } … … 254 246 'type_doesnotexist', 255 247 __( 'The type was not deleted: it does not exist.', 'buddypress' ), 256 array( 257 'message' => 6, 258 ) 248 array( 'message' => 6 ) 259 249 ); 260 250 } … … 267 257 'type_register_by_code', 268 258 __( 'This type is registered using code, deactivate the plugin or remove the custom code before trying to delete it again.', 'buddypress' ), 269 array( 270 'message' => 7, 271 ) 259 array( 'message' => 7 ) 272 260 ); 273 261 } … … 279 267 'type_not_deleted', 280 268 __( 'There was an error while trying to delete this type.', 'buddypress' ), 281 array( 282 'message' => 8, 283 ) 269 array( 'message' => 8 ) 284 270 ); 285 271 } -
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; -
trunk/src/bp-core/classes/class-bp-admin.php
r13878 r13883 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 if ( !class_exists( 'BP_Admin' ) ) : 13 if ( class_exists( 'BP_Admin' ) ) { 14 return; 15 } 14 16 15 17 /** … … 29 31 * 30 32 * @since 1.6.0 31 * @var string $admin_dir33 * @var string 32 34 */ 33 35 public $admin_dir = ''; … … 37 39 /** 38 40 * URL to the BuddyPress admin directory. 39 *40 * @since 1.6.041 * @var string $admin_url42 */43 public $admin_url = '';44 45 /**46 * URL to the BuddyPress images directory.47 *48 * @since 1.6.049 * @var string $images_url50 */51 public $images_url = '';52 53 /**54 * URL to the BuddyPress admin CSS directory.55 *56 * @since 1.6.057 * @var string $css_url58 */59 public $css_url = '';60 61 /**62 * URL to the BuddyPress admin JS directory.63 41 * 64 42 * @since 1.6.0 65 43 * @var string 66 44 */ 45 public $admin_url = ''; 46 47 /** 48 * URL to the BuddyPress images directory. 49 * 50 * @since 1.6.0 51 * @var string 52 */ 53 public $images_url = ''; 54 55 /** 56 * URL to the BuddyPress admin CSS directory. 57 * 58 * @since 1.6.0 59 * @var string 60 */ 61 public $css_url = ''; 62 63 /** 64 * URL to the BuddyPress admin JS directory. 65 * 66 * @since 1.6.0 67 * @var string 68 */ 67 69 public $js_url = ''; 68 70 … … 73 75 * 74 76 * @since 1.9.0 75 * @var array ()77 * @var array 76 78 */ 77 79 public $notices = array(); … … 81 83 * 82 84 * @since 10.0.0 83 * @var array ()85 * @var array 84 86 */ 85 87 public $nav_tabs = array(); … … 89 91 * 90 92 * @since 10.0.0 91 * @var string ()93 * @var string 92 94 */ 93 95 public $active_nav_tab = ''; … … 97 99 * 98 100 * @since 10.0.0 99 * @var array ()101 * @var array 100 102 */ 101 103 public $submenu_pages = array(); … … 107 109 * 108 110 * @since 1.6.0 109 *110 111 */ 111 112 public function __construct() { … … 123 124 $bp = buddypress(); 124 125 125 // Paths and URLs 126 $this->admin_dir = trailingslashit( $bp->plugin_dir 127 $this->admin_url = trailingslashit( $bp->plugin_url 128 $this->images_url = trailingslashit( $this->admin_url . 'images' 129 $this->css_url = trailingslashit( $this->admin_url . 'css' 130 $this->js_url = trailingslashit( $this->admin_url . 'js' 126 // Paths and URLs. 127 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-core/admin' ); // Admin path. 128 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-core/admin' ); // Admin url. 129 $this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL. 130 $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL. 131 $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL. 131 132 132 133 // Main settings page. … … 159 160 * 160 161 * @since 1.6.0 161 *162 162 */ 163 163 private function setup_actions() { … … 166 166 167 167 // Add some page specific output to the <head>. 168 add_action( 'bp_admin_head', array( $this, 'admin_head' 168 add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); 169 169 170 170 // Add menu item to settings menu. … … 225 225 add_filter( 'user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 ); 226 226 227 // Emails 227 // Emails. 228 228 add_filter( 'bp_admin_menu_order', array( $this, 'emails_admin_menu_order' ), 20 ); 229 229 add_action( 'load-edit.php', array( $this, 'post_type_load_admin_screen' ), 20 ); … … 232 232 // Official BuddyPress supported Add-ons. 233 233 add_filter( 'install_plugins_tabs', array( $this, 'addons_tab' ) ); 234 add_filter( 'install_plugins_table_api_args_bp-add-ons', array( $this, 'addons_args' ) );234 add_filter( 'install_plugins_table_api_args_bp-add-ons', array( $this, 'addons_args' ) ); 235 235 } 236 236 … … 320 320 321 321 $this->submenu_pages['settings']['bp-admin-notifications'] = $bp_admin_notifications; 322 $hooks[] 322 $hooks[] = $bp_admin_notifications; 323 323 324 324 // Credits. … … 477 477 * 478 478 * @since 1.6.0 479 *480 479 */ 481 480 public function register_admin_settings() { … … 490 489 register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' ); 491 490 492 // Community Visibility 491 // Community Visibility. 493 492 if ( 'rewrites' === bp_core_get_query_parser() ) { 494 493 add_settings_field( '_bp_community_visibility', __( 'Community Visibility', 'buddypress' ), 'bp_admin_setting_callback_community_visibility', 'buddypress', 'bp_main' ); … … 547 546 // Profile sync setting. 548 547 add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' ); 549 register_setting 548 register_setting( 'buddypress', 'bp-disable-profile-sync', 'intval' ); 550 549 } 551 550 … … 612 611 } 613 612 614 $wp_admin_bar->add_node( array( 615 'parent' => 'wp-logo', 616 'id' => 'bp-about', 617 'title' => esc_html_x( 'Hello, BuddyPress!', 'Colloquial alternative to "learn about BuddyPress"', 'buddypress' ), 618 'href' => bp_get_admin_url( '?hello=buddypress' ), 619 'meta' => array( 620 'class' => 'say-hello-buddypress', 621 ), 622 ) ); 613 $wp_admin_bar->add_node( 614 array( 615 'parent' => 'wp-logo', 616 'id' => 'bp-about', 617 'title' => esc_html_x( 'Hello, BuddyPress!', 'Colloquial alternative to "learn about BuddyPress"', 'buddypress' ), 618 'href' => bp_get_admin_url( '?hello=buddypress' ), 619 'meta' => array( 620 'class' => 'say-hello-buddypress', 621 ), 622 ) 623 ); 623 624 } 624 625 … … 635 636 636 637 // Return normal links if not BuddyPress. 637 if ( plugin_basename( buddypress()->basename ) != $file ) {638 if ( plugin_basename( buddypress()->basename ) !== $file ) { 638 639 return $links; 639 640 } … … 780 781 781 782 // Get BuddyPress stable version. 782 $version = 783 $version = self::display_version(); 783 784 $version_slug = 'version-' . str_replace( '.', '-', $version ); 784 785 … … 824 825 <h2> 825 826 <?php 826 printf(827 printf( 827 828 /* Translators: %s is a raising hands emoji. */ 828 829 esc_html__( 'You now have complete control over all BuddyPress-generated URLs %s', 'buddypress' ), … … 895 896 <h2> 896 897 <?php 897 printf(898 printf( 898 899 /* Translators: %s is a woman supervillain emoji. */ 899 900 esc_html__( 'Here\'s another benefit of the BP Rewrites API: the new "members only" community visibility level %s', 'buddypress' ), … … 966 967 'span' => array( 967 968 'class' => true, 968 ) 969 ), 969 970 ) 970 971 ); … … 1284 1285 $taxonomy_object = get_taxonomy( bp_get_email_tax_type() ); 1285 1286 1286 if ( is_wp_error( $terms ) || ! $terms 1287 if ( is_wp_error( $terms ) || ! $terms ) { 1287 1288 printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', esc_html( $taxonomy_object->labels->no_terms ) ); 1288 1289 } else { … … 1348 1349 1349 1350 // Check for prerelease hyphen. 1350 $pre 1351 $pre = strpos( $version, '-' ); 1351 1352 1352 1353 // Strip prerelease suffix. … … 1571 1572 } 1572 1573 %2$s', 1573 implode( " ", $grid_columns ),1574 implode( ' ', $grid_columns ), 1574 1575 $help_tab_css 1575 1576 ) … … 1612 1613 * @global int $paged The current page of the Plugin results. 1613 1614 * 1614 * @param false|array $args `false` by default. 1615 * @return array The "BuddyPress add-ons" args. 1616 */ 1617 public function addons_args( $args = false ) { 1615 * @return array The "BuddyPress add-ons" args. 1616 */ 1617 public function addons_args() { 1618 1618 global $paged; 1619 1619 … … 1686 1686 } 1687 1687 } 1688 endif; // End class_exists check.
Note: See TracChangeset
for help on using the changeset viewer.