Changeset 13900
- Timestamp:
- 06/02/2024 07:12:25 PM (6 months ago)
- Location:
- trunk/src/bp-core/classes
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-component.php
r13878 r13900 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 if ( !class_exists( 'BP_Component' ) ) : 13 if ( class_exists( 'BP_Component' ) ) { 14 return; 15 } 14 16 15 17 /** … … 40 42 * 41 43 * @since 1.5.0 44 * 42 45 * @var string 43 46 */ … … 48 51 * 49 52 * @since 1.5.0 53 * 50 54 * @var string 51 55 */ … … 56 60 * 57 61 * @since 1.5.0 62 * 58 63 * @var bool 59 64 */ … … 64 69 * 65 70 * @since 12.0.0 71 * 66 72 * @var string 67 73 */ … … 72 78 * 73 79 * @since 12.0.0 80 * 74 81 * @var array 75 82 */ … … 80 87 * 81 88 * @since 1.5.0 89 * 82 90 * @var string 83 91 */ … … 88 96 * 89 97 * @since 1.5.0 98 * 90 99 * @var WP_Query 91 100 */ … … 96 105 * 97 106 * @since 1.5.0 107 * 98 108 * @var string 99 109 */ … … 104 114 * 105 115 * @since 1.5.0 116 * 106 117 * @var callable 107 118 */ … … 112 123 * 113 124 * @since 1.5.0 125 * 114 126 * @var array 115 127 */ … … 120 132 * 121 133 * @since 1.6.0 134 * 122 135 * @var string 123 136 */ … … 128 141 * 129 142 * @since 1.6.0 143 * 130 144 * @var string 131 145 */ … … 136 150 * 137 151 * @since 2.0.0 152 * 138 153 * @var array 139 154 */ … … 144 159 * 145 160 * @since 2.0.0 161 * 146 162 * @var array 147 163 */ … … 152 168 * 153 169 * @since 12.0.0 170 * 154 171 * @var string 155 172 */ … … 160 177 * 161 178 * @since 2.4.0 179 * 162 180 * @var string 163 181 */ … … 168 186 * 169 187 * @since 9.0.0 188 * 170 189 * @var array 171 190 */ … … 176 195 * 177 196 * @since 1.5.0 197 * 178 198 * @var int 179 199 */ … … 184 204 * 185 205 * @since 1.5.0 206 * 186 207 * @var string[] 187 208 */ … … 192 213 * 193 214 * @since 2.0.0 215 * 194 216 * @var string 195 217 */ … … 200 222 * 201 223 * @since 12.0.0 224 * 202 225 * @var array 203 226 */ … … 208 231 * 209 232 * @since 12.0.0 233 * 210 234 * @var array 211 235 */ 212 public $sub_nav 236 public $sub_nav = array(); 213 237 214 238 /** Methods ***************************************************************/ … … 239 263 240 264 // Internal identifier of component. 241 $this->id 265 $this->id = $id; 242 266 243 267 // Internal component name. … … 364 388 * @param array $value The list of rewrite IDs for the component. 365 389 */ 366 (array) apply_filters( 'bp_' . $this->id . '_rewrite_ids', $r['rewrite_ids'] ),390 (array) apply_filters( 'bp_' . $this->id . '_rewrite_ids', $r['rewrite_ids'] ), 367 391 array_fill_keys( array_keys( bp_rewrites_get_default_url_chunks() ), '' ) 368 392 ); … … 480 504 * @since 1.5.0 481 505 * 482 *483 506 * @param array $includes An array of file names, or file name chunks, 484 507 * to be parsed and then included. … … 496 519 497 520 // Passed with no extension. 498 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file 521 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php', 499 522 'bp-' . $this->id . '-' . $file . '.php', 500 523 'bp-' . $this->id . '/' . $file . '.php', … … 508 531 foreach ( $paths as $path ) { 509 532 if ( @is_file( $slashed_path . $path ) ) { 510 require ( $slashed_path . $path );533 require $slashed_path . $path; 511 534 break; 512 535 } … … 540 563 * 541 564 * @since 1.5.0 542 *543 565 */ 544 566 public function setup_actions() { 545 567 546 568 // Setup globals. 547 add_action( 'bp_setup_globals', array( $this, 'setup_globals'), 10 );569 add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 ); 548 570 549 571 // Set up canonical stack. 550 add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack'), 10 );572 add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack' ), 10 ); 551 573 552 574 // Include required files. Called early to ensure that BP core … … 555 577 // compatibility; henceforth, plugins should register themselves by 556 578 // extending this base class. 557 add_action( 'bp_include', array( $this, 'includes' ),8 );579 add_action( 'bp_include', array( $this, 'includes' ), 8 ); 558 580 559 581 // Load files conditionally, based on certain pages. 560 add_action( 'bp_late_include', array( $this, 'late_includes'), 10 );582 add_action( 'bp_late_include', array( $this, 'late_includes' ), 10 ); 561 583 562 584 // Generate navigation. 563 add_action( 'bp_register_nav', array( $this, 'register_nav' ),9 );585 add_action( 'bp_register_nav', array( $this, 'register_nav' ), 9 ); 564 586 565 587 // Setup navigation. 566 add_action( 'bp_setup_nav', array( $this, 'setup_nav' ),9 );588 add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 9 ); 567 589 568 590 // Setup WP Toolbar menus. 569 add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar'), $this->adminbar_myaccount_order );591 add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), $this->adminbar_myaccount_order ); 570 592 571 593 // Setup component title. 572 add_action( 'bp_setup_title', array( $this, 'setup_title'), 10 );594 add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 ); 573 595 574 596 // Setup cache groups. 575 add_action( 'bp_setup_cache_groups', array( $this, 'setup_cache_groups'), 10 );597 add_action( 'bp_setup_cache_groups', array( $this, 'setup_cache_groups' ), 10 ); 576 598 577 599 // Register post types. 578 add_action( 'bp_register_post_types', array( $this, 'register_post_types'), 10 );600 add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 ); 579 601 580 602 // Register post statuses. … … 582 604 583 605 // Register taxonomies. 584 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies'), 10 );606 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 ); 585 607 586 608 // Add the rewrite tags. 587 add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags'), 10, 0 );609 add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10, 0 ); 588 610 589 611 // Add the rewrite rules. 590 add_action( 'bp_add_rewrite_rules', array( $this, 'add_rewrite_rules'), 10, 0 );612 add_action( 'bp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ), 10, 0 ); 591 613 592 614 // Add the permalink structure. 593 add_action( 'bp_add_permastructs', array( $this, 'add_permastructs'), 10 );615 add_action( 'bp_add_permastructs', array( $this, 'add_permastructs' ), 10 ); 594 616 595 617 // Allow components to parse the main query. 596 add_action( 'bp_parse_query', 618 add_action( 'bp_parse_query', array( $this, 'parse_query' ), 10 ); 597 619 598 620 // Generate rewrite rules. … … 722 744 723 745 // No sub nav items without a main nav item. 724 if ( $this->main_nav && $generate ) {746 if ( $this->main_nav && $generate ) { 725 747 if ( isset( $this->main_nav['user_has_access_callback'] ) && is_callable( $this->main_nav['user_has_access_callback'] ) ) { 726 748 $this->main_nav['show_for_displayed_user'] = call_user_func( $this->main_nav['user_has_access_callback'] ); … … 824 846 825 847 // Do we have Toolbar menus to add? 826 if ( ! empty( $wp_admin_nav ) ) {848 if ( ! empty( $wp_admin_nav ) ) { 827 849 // Fill in position if one wasn't passed for backpat. 828 $pos = 0;850 $pos = 0; 829 851 $not_set_pos = 1; 830 852 foreach ( $wp_admin_nav as $key => $nav ) { 831 853 if ( ! isset( $nav['position'] ) ) { 832 $wp_admin_nav[ $key]['position'] = $pos + $not_set_pos;854 $wp_admin_nav[ $key ]['position'] = $pos + $not_set_pos; 833 855 834 856 if ( 9 !== $not_set_pos ) { … … 871 893 * 872 894 * @since 1.5.0 873 *874 895 */ 875 896 public function setup_title() { … … 882 903 * @since 1.5.0 883 904 */ 884 do_action( 905 do_action( 'bp_' . $this->id . '_setup_title' ); 885 906 } 886 907 … … 889 910 * 890 911 * @since 2.2.0 891 *892 912 */ 893 913 public function setup_cache_groups() { … … 924 944 925 945 // Add to the BuddyPress global object. 926 if ( ! empty( $tables ) && is_array( $tables ) ) {946 if ( ! empty( $tables ) && is_array( $tables ) ) { 927 947 foreach ( $tables as $global_name => $table_name ) { 928 948 $this->{$global_name} = $table_name; … … 971 991 * components to play nicely with the WordPress metadata API. 972 992 */ 973 if ( ! empty( $tables ) && is_array( $tables ) ) {993 if ( ! empty( $tables ) && is_array( $tables ) ) { 974 994 foreach ( $tables as $meta_prefix => $table_name ) { 975 995 $wpdb->{$meta_prefix . 'meta'} = $table_name; … … 994 1014 * 995 1015 * @since 1.5.0 996 *997 1016 */ 998 1017 public function register_post_types() { … … 1029 1048 * 1030 1049 * @since 1.5.0 1031 *1032 1050 */ 1033 1051 public function register_taxonomies() { … … 1132 1150 } else { 1133 1151 $regex = trailingslashit( $regex ) . $rule_information['regex']; 1134 $query .= '&' . $this->rewrite_ids[ $rule_key ] . '=$matches[' . $match .']';1135 $match += 1;1152 $query .= '&' . $this->rewrite_ids[ $rule_key ] . '=$matches[' . $match . ']'; 1153 ++$match; 1136 1154 1137 1155 $rules[ $rule_key ]['regex'] = $regex . '/?$'; … … 1304 1322 */ 1305 1323 $do_redirect_to_login_screen = apply_filters( 'bp_view_no_access_redirect_to_login_screen', false ); 1306 If ( true === $do_redirect_to_login_screen && ! is_user_logged_in() ) {1324 if ( true === $do_redirect_to_login_screen && ! is_user_logged_in() ) { 1307 1325 bp_core_no_access(); 1308 1326 } … … 1365 1383 * 1366 1384 * @since 1.5.0 1367 *1368 1385 */ 1369 1386 public function generate_rewrite_rules() { … … 1408 1425 } 1409 1426 1410 $component_controller = new $controller ;1427 $component_controller = new $controller(); 1411 1428 $component_controller->register_routes(); 1412 1429 } … … 1468 1485 * 1469 1486 * @param string[] $states An array of post display states. 1470 * @param WP_Post $post The current post object. 1471 * @return array The component's directory states. 1472 */ 1473 public function admin_directory_states( $states = array(), $post = null ) { 1487 * @return array The component's directory states. 1488 */ 1489 public function admin_directory_states( $states = array() ) { 1474 1490 _deprecated_function( __METHOD__, '12.0.0' ); 1491 1475 1492 return $states; 1476 1493 } 1477 1494 } 1478 endif; // BP_Component. -
trunk/src/bp-core/classes/class-bp-core-bp-nav-backcompat.php
r13818 r13900 3 3 * Backward compatibility for the $bp->bp_nav global. 4 4 * 5 * @package BuddyPress 6 * @subpackage Core 5 7 * @since 2.6.0 6 8 * @deprecated 12.0.0 9 * 10 * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found 11 * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed 7 12 */ 8 13 … … 11 16 12 17 /** 13 * bp_nav backward compatibility class.14 *15 18 * This class is used to provide backward compatibility for extensions that access and modify 16 19 * the $bp->bp_nav global. 20 * 21 * Backward compatibility class for `bp_nav`. 17 22 * 18 23 * @since 2.6.0 … … 20 25 */ 21 26 class BP_Core_BP_Nav_BackCompat implements ArrayAccess { 27 22 28 /** 23 29 * Nav items. 24 30 * 25 31 * @since 2.6.0 26 * @access public32 * 27 33 * @var array 28 34 */ … … 33 39 * 34 40 * @since 2.6.0 35 * @access public41 * 36 42 * @var array 37 43 */ … … 81 87 * 82 88 * @param mixed $offset Array offset. 83 * @return BP_Core_BP_Nav_BackCompat84 89 */ 85 90 #[ReturnTypeWillChange] … … 100 105 * 101 106 * @param mixed $offset Array offset. 102 * @return bool103 107 */ 104 108 #[ReturnTypeWillChange] … … 135 139 * @since 2.6.0 136 140 * @deprecated 12.0.0 137 * 138 * @param string $component 139 */ 140 public function set_component( $component ) { 141 */ 142 public function set_component() { 141 143 _deprecated_function( __METHOD__, '12.0.0' ); 142 144 } … … 151 153 * @since 2.6.0 152 154 * @deprecated 12.0.0 153 * 154 * @param mixed $offset Array offset. 155 * @return string|array 156 */ 157 public function get_component( $offset = '' ) { 155 */ 156 public function get_component() { 158 157 _deprecated_function( __METHOD__, '12.0.0' ); 159 158 } … … 178 177 * 179 178 * @param mixed $offset Array offset. 180 * @return bool|array181 179 */ 182 180 protected function get_nav( $offset ) { … … 197 195 * 198 196 * @param string $offset Nav item name. 199 * @return BP_Core_Nav200 197 */ 201 198 protected function get_component_nav( $offset = '' ) { … … 208 205 * @since 2.6.0 209 206 * @deprecated 12.0.0 210 *211 * @return array212 207 */ 213 208 protected function to_array() { -
trunk/src/bp-core/classes/class-bp-core-bp-options-nav-backcompat.php
r13818 r13900 3 3 * Backward compatibility for the $bp->bp_options_nav global. 4 4 * 5 * @package BuddyPress 6 * @subpackage Core 5 7 * @since 2.6.0 6 8 * @deprecated 12.0.0 … … 11 13 12 14 /** 13 * bp_options_nav backward compatibility class.14 *15 15 * This class is used to provide backward compatibility for extensions that access and modify 16 16 * the $bp->bp_options_nav global. 17 * 18 * Backward compatibility class for `bp_options_nav`. 17 19 * 18 20 * @since 2.6.0 … … 20 22 */ 21 23 class BP_Core_BP_Options_Nav_BackCompat extends BP_Core_BP_Nav_BackCompat { 24 22 25 /** 23 26 * Parent slug of the current nav item. 24 27 * 25 28 * @since 2.6.0 26 * @access protected29 * 27 30 * @var string 28 31 */ … … 36 39 * 37 40 * @param mixed $offset Array offset. 38 * @return BP_Core_BP_Nav_BackCompat39 41 */ 40 42 public function offsetGet( $offset ) { … … 55 57 * @param mixed $offset Array offset. 56 58 */ 59 #[ReturnTypeWillChange] 57 60 public function offsetUnset( $offset ) { 58 61 _doing_it_wrong( … … 69 72 * @since 2.6.0 70 73 * @deprecated 12.0.0 71 *72 * @return string73 74 */ 74 75 public function get_parent_slug() { … … 82 83 * @deprecated 12.0.0 83 84 */ 84 public function set_parent_slug( $slug) {85 public function set_parent_slug() { 85 86 _deprecated_function( __METHOD__, '12.0.0' ); 86 87 } … … 93 94 * 94 95 * @param mixed $offset Array offset. 95 * @return bool|array96 96 */ 97 97 public function get_nav( $offset ) { -
trunk/src/bp-core/classes/class-bp-core-html-element.php
r13878 r13900 14 14 */ 15 15 class BP_Core_HTML_Element { 16 16 17 /** 17 18 * Open tag for an element. … … 23 24 * @var string 24 25 */ 25 public $open_tag 26 public $open_tag = ''; 26 27 27 28 /** … … 45 46 * @var string 46 47 */ 47 public $close_tag 48 public $close_tag = ''; 48 49 49 50 /** … … 91 92 $this->open_tag = sprintf( '<%1$s %2$s />', $elem, $attributes ); 92 93 93 // All other elements.94 // All other elements. 94 95 } else { 95 96 $this->open_tag = sprintf( '<%1$s %2$s>', $elem, $attributes ); 96 97 $this->inner_html = ! empty( $r['inner_html'] ) ? $r['inner_html'] : ''; 97 $this->close_tag = sprintf( '</%1$s>', 98 $this->close_tag = sprintf( '</%1$s>', $elem ); 98 99 } 99 100 } … … 104 105 * @since 2.7.0 105 106 * 106 * @param 107 * @param string $prop Property name. Either 'open_tag', 'inner_html', 'close_tag'. 107 108 * @return string 108 109 */ -
trunk/src/bp-core/classes/class-bp-core-login-widget.php
r13882 r13900 7 7 * @since 1.9.0 8 8 * @deprecated 12.0.0 9 * 10 * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found 11 * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed 9 12 */ 10 13 -
trunk/src/bp-core/classes/class-bp-core-nav-item.php
r11290 r13900 1 1 <?php 2 /** 3 * Core component class. 4 * 5 * @package BuddyPress 6 * @subpackage Core 7 * @since 2.6.0 8 */ 2 9 3 10 // Exit if accessed directly. … … 10 17 */ 11 18 class BP_Core_Nav_Item extends ArrayObject { 19 20 /** 21 * Constructor. 22 * 23 * @param array $data Data to populate the nav item. 24 */ 12 25 public function __construct( $data ) { 13 26 parent::__construct( $data, ArrayObject::ARRAY_AS_PROPS ); -
trunk/src/bp-core/classes/class-bp-core-nav.php
r13878 r13900 19 19 */ 20 20 class BP_Core_Nav { 21 21 22 /** 22 23 * An associative array containing the nav items for the object ID. 23 24 * 24 25 * @since 2.6.0 26 * 25 27 * @var array 26 28 */ … … 31 33 * 32 34 * @since 2.6.0 35 * 33 36 * @var int 34 37 */ … … 39 42 * 40 43 * @since 12.0.0 44 * 41 45 * @var string 42 46 */ … … 48 52 * @since 2.6.0 49 53 * 50 * @param int $object_id The item ID to build the nav for. Default is the displayed user ID. 54 * @param int $object_id The item ID to build the nav for. Default is the displayed user ID. 55 * @param string $component_id Optional. The component ID. Default is 'members'. 51 56 */ 52 57 public function __construct( $object_id = 0, $component_id = 'members' ) { … … 114 119 * 115 120 * @param string $key The nav item slug to get. Optional. 116 * @return mixed 121 * @return mixed An array of nav item, a single nav item, or null if none found. 117 122 */ 118 123 public function get( $key = '' ) { … … 127 132 } 128 133 129 // Return all nav item items.134 // Return all nav item items. 130 135 } else { 131 136 $return = $this->nav[ $this->object_id ]; … … 159 164 $args['secondary'] = true; 160 165 161 // This is a parent.166 // This is a parent. 162 167 } else { 163 168 $slug = $args['slug']; … … 180 185 181 186 $chunk = 'single_item_action'; 182 if ( $path_chunks['single_item'] . '_manage' === 187 if ( $path_chunks['single_item'] . '_manage' === $path_chunks['single_item_component'] ) { 183 188 $chunk = 'single_item_action_variables'; 184 189 $path_chunks[ $chunk ] = $path_chunks['single_item_action']; 185 190 $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' ); 186 $group_screens = bp_get_group_screens( 'manage' );191 $group_screens = bp_get_group_screens( 'manage' ); 187 192 } else { 188 193 $group_screens = bp_get_group_screens( 'read' ); … … 259 264 return $this->nav[ $this->object_id ][ $slug ]; 260 265 261 // We're editing a child.266 // We're editing a child. 262 267 } else { 263 $sub_items = $this->get_secondary( array( 'parent_slug' => $parent_slug, 'slug' => $slug ), false ); 268 $sub_items = $this->get_secondary( 269 array( 270 'parent_slug' => $parent_slug, 271 'slug' => $slug, 272 ), 273 false 274 ); 264 275 265 276 if ( ! $sub_items ) { … … 305 316 306 317 // Validate the subnav. 307 $sub_items = $this->get_secondary( array( 'parent_slug' => $parent_slug, 'slug' => $slug ), false ); 318 $sub_items = $this->get_secondary( 319 array( 320 'parent_slug' => $parent_slug, 321 'slug' => $slug, 322 ), 323 false 324 ); 308 325 309 326 if ( ! $sub_items ) { … … 323 340 return array( $sub_item->screen_function ); 324 341 325 // We're deleting a parent.342 // We're deleting a parent. 326 343 } else { 327 344 // Validate the nav. … … 340 357 $screen_functions = array( $nav_item->screen_function ); 341 358 342 // Life's unfair, children won't survive the parent :(359 // Life's unfair, children won't survive the parent. 343 360 $sub_items = $this->get_secondary( array( 'parent_slug' => $nav_item->slug ), false ); 344 361 … … 384 401 385 402 do { 386 $position += 1;387 } while ( in_array( $position, $sorted_keys ) );403 ++$position; 404 } while ( in_array( $position, $sorted_keys, true ) ); 388 405 } 389 406 … … 392 409 393 410 ksort( $sorted ); 411 394 412 return $sorted; 395 413 } … … 478 496 foreach ( $primary_nav_items as $key_nav => $primary_nav ) { 479 497 // Try to get the children. 480 $children = $this->get_secondary( array( 'parent_slug' => $primary_nav->slug, 'user_has_access' => true ) ); 498 $children = $this->get_secondary( 499 array( 500 'parent_slug' => $primary_nav->slug, 501 'user_has_access' => true, 502 ) 503 ); 481 504 482 505 if ( $children ) { 483 $primary_nav_items[ $key_nav ] = clone $primary_nav;506 $primary_nav_items[ $key_nav ] = clone $primary_nav; 484 507 $primary_nav_items[ $key_nav ]->children = $children; 485 508 } -
trunk/src/bp-core/classes/class-bp-core-notification.php
r12753 r13900 85 85 public function __construct( $id = 0 ) { 86 86 87 // Bail if no ID 87 // Bail if no ID. 88 88 if ( empty( $id ) ) { 89 89 return; … … 99 99 * @global wpdb $wpdb WordPress database object. 100 100 * 101 * @return bool Success or failure.101 * @return bool 102 102 */ 103 103 public function save() { … … 111 111 $sql = $wpdb->prepare( $query, $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id ); 112 112 113 // Save.113 // Save. 114 114 } else { 115 115 $query = "INSERT INTO {$bp->notifications->table_name} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )"; … … 145 145 146 146 if ( ! empty( $result ) ) { 147 $this->item_id = $result->item_id;147 $this->item_id = $result->item_id; 148 148 $this->secondary_item_id = $result->secondary_item_id; 149 149 $this->user_id = $result->user_id; … … 160 160 * Check the access for a user. 161 161 * 162 * @global wpdb $wpdb WordPress database object. 163 * 162 164 * @param int $user_id ID to check access for. 163 165 * @param int $notification_id Notification ID to check for. … … 181 183 * @global wpdb $wpdb WordPress database object 182 184 * 183 * @static184 *185 185 * @param int $user_id User ID. 186 186 * @param string $status 'is_new' or 'all'. … … 207 207 * 208 208 * @global wpdb $wpdb WordPress database object. 209 *210 * @static211 209 * 212 210 * @param int $user_id ID of the user to delet notification for. … … 232 230 * @global wpdb $wpdb WordPress database object. 233 231 * 234 * @static 235 * 236 * @param int $user_id The ID of the user who the notifications are for. 237 * @param int $item_id The item ID of the notifications we wish to delete. 238 * @param string $component_name The name of the component that the notifications we wish to delete. 239 * @param string $component_action The action of the component that the notifications we wish to delete. 240 * @param int $secondary_item_id (optional) The secondary item id of the notifications that we wish to 241 * use to delete. 232 * @param int $user_id The ID of the user who the notifications are for. 233 * @param int $item_id The item ID of the notifications we wish to delete. 234 * @param string $component_name The name of the component that the notifications we wish to delete. 235 * @param string $component_action The action of the component that the notifications we wish to delete. 236 * @param int $secondary_item_id (optional) The secondary item id of the notifications that we wish to 237 * use to delete. 242 238 * @return mixed 243 239 */ … … 248 244 249 245 $secondary_item_sql = ! empty( $secondary_item_id ) 250 ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id )246 ? $wpdb->prepare( ' AND secondary_item_id = %d', $secondary_item_id ) 251 247 : ''; 252 248 … … 262 258 * 263 259 * @global wpdb $wpdb WordPress database object. 264 *265 * @static266 260 * 267 261 * @param int $user_id The ID of the user whose sent notifications we wish to delete. … … 287 281 * 288 282 * @global wpdb $wpdb WordPress database object. 289 *290 * @static291 283 * 292 284 * @param int $item_id The item id that they notifications are to be for. … … 300 292 301 293 $component_action_sql = ! empty( $component_action ) 302 ? $wpdb->prepare( "AND component_action = %s", $component_action )294 ? $wpdb->prepare( 'AND component_action = %s', $component_action ) 303 295 : ''; 304 296 305 297 $secondary_item_sql = ! empty( $secondary_item_id ) 306 ? $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id )298 ? $wpdb->prepare( 'AND secondary_item_id = %d', $secondary_item_id ) 307 299 : ''; 308 300 -
trunk/src/bp-core/classes/class-bp-core-oembed-extension.php
r13878 r13900 6 6 * @subpackage Core 7 7 * @since 2.6.0 8 * 9 * @phpcs:disable PEAR.NamingConventions.ValidClassName.Invalid 8 10 */ 9 11 … … 54 56 * 55 57 * @since 2.6.0 56 *57 * @return null58 58 */ 59 59 abstract protected function content(); … … 128 128 * @param int $item_id The item ID to do checks for. 129 129 */ 130 protected function set_iframe_title( $item_id ) {} 130 protected function set_iframe_title( $item_id ) {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found 131 131 132 132 /** … … 145 145 * 146 146 * @since 2.6.0 147 * 148 * @return string 147 149 */ 148 150 protected function set_permalink() { … … 165 167 * 166 168 * @since 2.6.0 169 * 170 * @return int 167 171 */ 168 172 protected function get_item_id() { … … 189 193 */ 190 194 protected function setup_hooks() { 191 add_action( 'rest_api_init', 195 add_action( 'rest_api_init', array( $this, 'register_route' ) ); 192 196 add_action( 'bp_embed_content', array( $this, 'inject_content' ) ); 193 197 194 198 add_filter( 'embed_template', array( $this, 'setup_template_parts' ) ); 195 199 add_filter( 'post_embed_url', array( $this, 'filter_embed_url' ) ); 196 add_filter( 'embed_html', 200 add_filter( 'embed_html', array( $this, 'filter_embed_html' ) ); 197 201 add_filter( 'oembed_discovery_links', array( $this, 'add_oembed_discovery_links' ) ); 198 202 add_filter( 'rest_pre_serve_request', array( $this, 'oembed_xml_request' ), 20, 4 ); … … 223 227 'default' => $maxwidth, 224 228 'sanitize_callback' => 'absint', 229 ), 230 ); 231 232 // Merge custom arguments here. 233 $args = $args + (array) $this->set_route_args(); 234 235 register_rest_route( 236 'oembed/1.0', 237 "/embed/{$this->slug_endpoint}", 238 array( 239 array( 240 'methods' => WP_REST_Server::READABLE, 241 'callback' => array( $this, 'get_item' ), 242 'permission_callback' => '__return_true', 243 'args' => $args, 244 ), 225 245 ) 226 246 ); 227 228 // Merge custom arguments here.229 $args = $args + (array) $this->set_route_args();230 231 register_rest_route( 'oembed/1.0', "/embed/{$this->slug_endpoint}", array(232 array(233 'methods' => WP_REST_Server::READABLE,234 'callback' => array( $this, 'get_item' ),235 'permission_callback' => '__return_true',236 'args' => $args237 ),238 ) );239 247 } 240 248 … … 255 263 // Set up some BP-specific embed template overrides. 256 264 add_action( 'get_template_part_embed', array( $this, 'content_buffer_start' ), -999, 2 ); 257 add_action( 'get_footer', 265 add_action( 'get_footer', array( $this, 'content_buffer_end' ), -999 ); 258 266 259 267 // Return the original WP embed template. … … 341 349 } 342 350 343 add_filter( 'rest_url' 351 add_filter( 'rest_url', array( $this, 'filter_rest_url' ) ); 344 352 345 353 $retval = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( $permalink ) ) . '" />' . "\n"; … … 349 357 } 350 358 351 remove_filter( 'rest_url' 359 remove_filter( 'rest_url', array( $this, 'filter_rest_url' ) ); 352 360 353 361 return $retval; … … 357 365 * Fetch our oEmbed response data to return. 358 366 * 359 * A simplified version of {@ linkget_oembed_response_data()}.367 * A simplified version of {@see get_oembed_response_data()}. 360 368 * 361 369 * @since 2.6.0 … … 382 390 383 391 /** This filter is documented in /wp-includes/embed.php */ 384 $min_max_width = apply_filters( 'oembed_min_max_width', array( 385 'min' => 200, 386 'max' => 600 387 ) ); 392 $min_max_width = apply_filters( 393 'oembed_min_max_width', 394 array( 395 'min' => 200, 396 'max' => 600, 397 ) 398 ); 388 399 389 400 $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); … … 396 407 if ( 'video' === $data['type'] || 'rich' === $data['type'] ) { 397 408 // Fake a WP post so we can use get_post_embed_html(). 398 $post = new stdClass;409 $post = new stdClass(); 399 410 $post->post_content = $data['content']; 400 411 $post->post_title = $data['title']; … … 430 441 // This is needed for various oEmbed response data filtering. 431 442 if ( ! isset( buddypress()->{$this->slug_endpoint} ) || ! buddypress()->{$this->slug_endpoint} ) { 432 buddypress()->{$this->slug_endpoint} = new stdClass ;443 buddypress()->{$this->slug_endpoint} = new stdClass(); 433 444 } 434 445 buddypress()->{$this->slug_endpoint}->embedurl_in_progress = $url; … … 569 580 $custom_title = $this->set_iframe_title( $item_id ); 570 581 if ( ! empty( $custom_title ) ) { 571 $title_pos = strpos( $retval, 'title=' ) + 7;582 $title_pos = strpos( $retval, 'title=' ) + 7; 572 583 $title_end_pos = strpos( $retval, '"', $title_pos ); 573 584 … … 587 598 // @todo Maybe use KSES? 588 599 $fallback_html = $this->set_fallback_html( $item_id ); 600 601 $embed_html = $fallback_html . $retval; 589 602 590 603 /** … … 593 606 * @since 2.6.0 594 607 * 595 * @ var string $retval608 * @param string $embed_html Current embed HTML. 596 609 */ 597 return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $ fallback_html . $retval );610 return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $embed_html ); 598 611 } 599 612 -
trunk/src/bp-core/classes/class-bp-date-query.php
r13893 r13900 18 18 * BuddyPress date query class. 19 19 * 20 * Extends the {@ linkWP_Date_Query} class for use with BuddyPress.20 * Extends the {@see WP_Date_Query} class for use with BuddyPress. 21 21 * 22 22 * @since 2.1.0 23 23 * 24 24 * @param array $date_query { 25 * Date query arguments. See first parameter of {@ linkWP_Date_Query::__construct()}.25 * Date query arguments. See first parameter of {@see WP_Date_Query::__construct()}. 26 26 * } 27 27 * @param string $column The DB column to query against. -
trunk/src/bp-core/classes/class-bp-embed.php
r13372 r13900 71 71 * for oEmbed parsing. 72 72 * 73 *74 73 * @param array $attr Shortcode attributes. 75 74 * @param string $url The URL attempting to be embeded. … … 77 76 */ 78 77 public function shortcode( $attr, $url = '' ) { 79 if ( empty( $url ) ) 78 if ( empty( $url ) ) { 80 79 return ''; 80 } 81 81 82 82 $rawattr = $attr; … … 95 95 foreach ( $handlers as $hid => $handler ) { 96 96 if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { 97 if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) { 97 $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ); 98 if ( false !== $return ) { 98 99 99 100 /** … … 102 103 * @since 1.5.0 103 104 * 104 * @param string$return Handler callback for the oEmbed.105 * @param mixed $return Handler callback for the oEmbed. 105 106 * @param string $url URL attempting to be embedded. 106 107 * @param array $attr Shortcode attributes. … … 117 118 * @since 1.5.0 118 119 * 119 * @param int $ value Value of zero.120 * @param int $embed_post_id Embed object id. Default is 0. 120 121 */ 121 122 $id = apply_filters( 'embed_post_id', 0 ); … … 138 139 // Set up a new WP oEmbed object to check URL with registered oEmbed providers. 139 140 if ( file_exists( ABSPATH . WPINC . '/class-wp-oembed.php' ) ) { 140 require_once ( ABSPATH . WPINC . '/class-wp-oembed.php' );141 require_once ABSPATH . WPINC . '/class-wp-oembed.php'; 141 142 } else { 142 143 // class-oembed.php is deprecated in WordPress 5.3.0. 143 require_once ( ABSPATH . WPINC . '/class-oembed.php' );144 require_once ABSPATH . WPINC . '/class-oembed.php'; 144 145 } 145 146 … … 148 149 // If oEmbed discovery is true, skip oEmbed provider check. 149 150 $is_oembed_link = false; 150 if ( ! $attr['discover'] ) {151 if ( ! $attr['discover'] ) { 151 152 foreach ( (array) $oembed_obj->providers as $provider_matchmask => $provider ) { 152 $regex = ( $ is_regex = $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i';153 154 if ( preg_match( $regex, $url ) ) 153 $regex = ( $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i'; 154 155 if ( preg_match( $regex, $url ) ) { 155 156 $is_oembed_link = true; 157 } 156 158 } 157 159 158 160 // If url doesn't match a WP oEmbed provider, stop parsing. 159 if ( ! $is_oembed_link )161 if ( ! $is_oembed_link ) { 160 162 return $this->maybe_make_link( $url ); 163 } 161 164 } 162 165 … … 183 186 184 187 if ( $id ) { 185 // Setup the cache key.188 // Setup the cache key. 186 189 $cachekey = '_oembed_' . md5( $url . serialize( $attr ) ); 187 190 … … 204 207 205 208 // Grab cache and return it if available. 206 if ( ! empty( $cache ) ) {209 if ( ! empty( $cache ) ) { 207 210 208 211 /** … … 218 221 return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr ); 219 222 220 // If no cache, ping the oEmbed provider and cache the result.223 // If no cache, ping the oEmbed provider and cache the result. 221 224 } else { 222 $html = wp_oembed_get( $url, $attr );225 $html = wp_oembed_get( $url, $attr ); 223 226 $cache = ( $html ) ? $html : $url; 224 227 -
trunk/src/bp-core/classes/class-bp-invitation-manager.php
r13890 r13900 373 373 * @since 5.0.0 374 374 * 375 * @see BP_Invitation::get() for a description of accepted parameters. 376 * 375 * @param array $args {@see BP_Invitation::get()}. 377 376 * @return array Located invitations. 378 377 */ … … 393 392 * @since 8.0.0 394 393 * 395 * @see BP_Invitation::get_total_count() for a description of accepted parameters. 396 * 394 * @param array $args {@see BP_Invitation::get_total_count()}. 397 395 * @return int Total number of invitations. 398 396 */ … … 413 411 * @since 5.0.0 414 412 * 415 * @see BP_Invitation::get() for a description of accepted parameters. 416 * 413 * @param array $args {@see BP_Invitation::get()}. 417 414 * @return array Located invitations. 418 415 */ … … 434 431 * @since 5.0.0 435 432 * 436 * @see BP_Invitation::get() for a description of accepted parameters. 437 * 433 * @param array $args {@see BP_Invitation::get()}. 438 434 * @return int|bool ID of first found invitation or false if none found. 439 435 */ … … 454 450 * @since 5.0.0 455 451 * 456 * @see BP_Invitation::get() for a description of accepted parameters. 457 * 452 * @param array $args {@see BP_Invitation::get()}. 458 453 * @return int|bool ID of existing request or false if none found. 459 454 */ … … 476 471 * @since 5.0.0 477 472 * 478 * @see BP_Invitation::get() for a description of 479 * accepted update/where arguments. 480 * 481 * @param array $args { 482 * Invitation characteristics. Some basic info is required to accept an invitation, 483 * because we'll need to accept all similar invitations and requests. 484 * 485 * @type int $user_id User ID of the invitee. 486 * Either 'user_id' or 'invitee_email' is required. 487 * @type string $invitee_email Email address of the invitee. 488 * Either 'user_id' or 'invitee_email' is required. 489 * @type int $item_id Item ID of the invitation to accept. 490 * @type int $secondary_item_id Optional. Secondary item ID if needed. 491 * @type string $invite_sent Optional. Defaults to only allowing the 492 * acceptance of sent invitations. 493 * @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT. 494 * Defaults to current time if not specified. 495 * } 496 * 473 * @param array $args {BP_Invitation::get()}. 497 474 * @return int|bool Number of rows updated on success, false on failure. 498 475 */ 499 476 public function accept_invitation( $args = array() ) { 500 501 477 $r = bp_parse_args( 502 478 $args, … … 539 515 * @since 5.0.0 540 516 * 541 * @see BP_Invitation::get() for a description of 542 * accepted update/where arguments. 543 * 544 * @param array $args { 545 * Invitation characteristics. Some basic info is required to accept an invitation, 546 * because we'll need to accept all similar invitations and requests. 547 * 548 * @type int $user_id User ID of the invitee. 549 * @type int $item_id Item ID of the invitation to accept. 550 * @type int $secondary_item_id Optional. Secondary item ID if needed. 551 * @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT. 552 * Defaults to current time if not specified. 553 * } 554 * 517 * @param array $args {BP_Invitation::get()}. 555 518 * @return bool Number of rows updated on success, false on failure. 556 519 */ 557 520 public function accept_request( $args = array() ) { 558 559 521 $r = bp_parse_args( 560 522 $args, … … 594 556 * @since 5.0.0 595 557 * 596 * @see BP_Invitation:: get() for a description of558 * @see BP_Invitation::update() for a description of 597 559 * accepted update/where arguments. 598 560 * … … 607 569 public function update_invitation( $update_args = array(), $where_args = array() ) { 608 570 $update_args['class'] = $this->class_name; 571 609 572 return BP_Invitation::update( $update_args, $where_args ); 610 573 } … … 669 632 * @since 5.0.0 670 633 * 671 * @see BP_Invitation::mark_accepted() 672 * for a description of arguments. 673 * 674 * @return bool 634 * @param int $id ID of the invitation to mark as accepted. 635 * @param array $args {@see BP_Invitation::mark_accepted()}. 636 * @return int|bool Number of rows updated on success, false on failure. 675 637 */ 676 638 public function mark_accepted_by_id( $id, $args ) { … … 685 647 * @since 5.0.0 686 648 * 687 * @ see BP_Invitation::mark_accepted_by_data()688 * for a description of arguments.649 * @param array $args {BP_Invitation::mark_accepted_by_data()}. 650 * @return int|bool Number of rows updated on success, false on failure. 689 651 */ 690 652 public function mark_accepted( $args ) { … … 700 662 * @since 5.0.0 701 663 * 702 * @see BP_Invitation::delete for a description of arguments. 703 * 664 * @param array $args {BP_Invitation::delete()}. 704 665 * @return int|bool Number of rows deleted on success, false on failure. 705 666 */ … … 717 678 * @since 5.0.0 718 679 * 719 * @see BP_Invitation::delete for a description of arguments. 720 * 680 * @param array $args {BP_Invitation::delete()}. 721 681 * @return int|bool Number of rows deleted on success, false on failure. 722 682 */ … … 737 697 */ 738 698 public function delete_all() { 739 return BP_Invitation::delete( 740 array( 741 'class' => $this->class_name, 742 ) 743 ); 699 return BP_Invitation::delete( array( 'class' => $this->class_name ) ); 744 700 } 745 701 -
trunk/src/bp-core/classes/class-bp-suggestions.php
r13372 r13900 72 72 * 73 73 * @param array $args { 74 * Array of arguments for the suggestions service query. 75 * 74 76 * @type int $limit Maximum number of results to display. Optional, default: 16. 75 77 * @type string $type The name of the suggestion service to use for the request. Mandatory.
Note: See TracChangeset
for help on using the changeset viewer.