Skip to:
Content

BuddyPress.org

Changeset 13900

Timestamp:
06/02/2024 07:12:25 PM (4 months ago)
Author:
espellcaste
Message:

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

Follow-up to [13883], [13886], [13887], [13888], [13891], [13892], [13893]

See #9164 and #7228

Location:
trunk/src/bp-core/classes
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-component.php

    r13878 r13900  
    1111defined( 'ABSPATH' ) || exit;
    1212
    13 if ( !class_exists( 'BP_Component' ) ) :
     13if ( class_exists( 'BP_Component' ) ) {
     14    return;
     15}
    1416
    1517/**
     
    4042     *
    4143     * @since 1.5.0
     44
    4245     * @var string
    4346     */
     
    4851     *
    4952     * @since 1.5.0
     53
    5054     * @var string
    5155     */
     
    5660     *
    5761     * @since 1.5.0
     62
    5863     * @var bool
    5964     */
     
    6469     *
    6570     * @since 12.0.0
     71
    6672     * @var string
    6773     */
     
    7278     *
    7379     * @since 12.0.0
     80
    7481     * @var array
    7582     */
     
    8087     *
    8188     * @since 1.5.0
     89
    8290     * @var string
    8391     */
     
    8896     *
    8997     * @since 1.5.0
     98
    9099     * @var WP_Query
    91100     */
     
    96105     *
    97106     * @since 1.5.0
     107
    98108     * @var string
    99109     */
     
    104114     *
    105115     * @since 1.5.0
     116
    106117     * @var callable
    107118     */
     
    112123     *
    113124     * @since 1.5.0
     125
    114126     * @var array
    115127     */
     
    120132     *
    121133     * @since 1.6.0
     134
    122135     * @var string
    123136     */
     
    128141     *
    129142     * @since 1.6.0
     143
    130144     * @var string
    131145     */
     
    136150     *
    137151     * @since 2.0.0
     152
    138153     * @var array
    139154     */
     
    144159     *
    145160     * @since 2.0.0
     161
    146162     * @var array
    147163     */
     
    152168     *
    153169     * @since 12.0.0
     170
    154171     * @var string
    155172     */
     
    160177     *
    161178     * @since 2.4.0
     179
    162180     * @var string
    163181     */
     
    168186     *
    169187     * @since 9.0.0
     188
    170189     * @var array
    171190     */
     
    176195     *
    177196     * @since 1.5.0
     197
    178198     * @var int
    179199     */
     
    184204     *
    185205     * @since 1.5.0
     206
    186207     * @var string[]
    187208     */
     
    192213     *
    193214     * @since 2.0.0
     215
    194216     * @var string
    195217     */
     
    200222     *
    201223     * @since 12.0.0
     224
    202225     * @var array
    203226     */
     
    208231     *
    209232     * @since 12.0.0
     233
    210234     * @var array
    211235     */
    212     public $sub_nav  = array();
     236    public $sub_nav = array();
    213237
    214238    /** Methods ***************************************************************/
     
    239263
    240264        // Internal identifier of component.
    241         $this->id   = $id;
     265        $this->id = $id;
    242266
    243267        // Internal component name.
     
    364388                 * @param array $value The list of rewrite IDs for the component.
    365389                 */
    366                 (array) apply_filters( 'bp_' . $this->id. '_rewrite_ids', $r['rewrite_ids'] ),
     390                (array) apply_filters( 'bp_' . $this->id. '_rewrite_ids', $r['rewrite_ids'] ),
    367391                array_fill_keys( array_keys( bp_rewrites_get_default_url_chunks() ), '' )
    368392            );
     
    480504     * @since 1.5.0
    481505     *
    482      *
    483506     * @param array $includes An array of file names, or file name chunks,
    484507     *                        to be parsed and then included.
     
    496519
    497520                    // Passed with no extension.
    498                     'bp-' . $this->id . '/bp-' . $this->id . '-' . $file  . '.php',
     521                    'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php',
    499522                    'bp-' . $this->id . '-' . $file . '.php',
    500523                    'bp-' . $this->id . '/' . $file . '.php',
     
    508531                foreach ( $paths as $path ) {
    509532                    if ( @is_file( $slashed_path . $path ) ) {
    510                         require( $slashed_path . $path );
     533                        require;
    511534                        break;
    512535                    }
     
    540563     *
    541564     * @since 1.5.0
    542      *
    543565     */
    544566    public function setup_actions() {
    545567
    546568        // Setup globals.
    547         add_action( 'bp_setup_globals',          array( $this, 'setup_globals'          ), 10 );
     569        add_action( 'bp_setup_globals', ), 10 );
    548570
    549571        // Set up canonical stack.
    550         add_action( 'bp_setup_canonical_stack',  array( $this, 'setup_canonical_stack' ), 10 );
     572        add_action( 'bp_setup_canonical_stack', ), 10 );
    551573
    552574        // Include required files. Called early to ensure that BP core
     
    555577        // compatibility; henceforth, plugins should register themselves by
    556578        // extending this base class.
    557         add_action( 'bp_include',                array( $this, 'includes'               ), 8 );
     579        add_action( 'bp_include', 8 );
    558580
    559581        // Load files conditionally, based on certain pages.
    560         add_action( 'bp_late_include',           array( $this, 'late_includes'          ), 10 );
     582        add_action( 'bp_late_include', ), 10 );
    561583
    562584        // Generate navigation.
    563         add_action( 'bp_register_nav',           array( $this, 'register_nav'           ), 9 );
     585        add_action( 'bp_register_nav', 9 );
    564586
    565587        // Setup navigation.
    566         add_action( 'bp_setup_nav',              array( $this, 'setup_nav'              ), 9 );
     588        add_action( 'bp_setup_nav', 9 );
    567589
    568590        // 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', ), $this->adminbar_myaccount_order );
    570592
    571593        // Setup component title.
    572         add_action( 'bp_setup_title',            array( $this, 'setup_title'            ), 10 );
     594        add_action( 'bp_setup_title', ), 10 );
    573595
    574596        // Setup cache groups.
    575         add_action( 'bp_setup_cache_groups',     array( $this, 'setup_cache_groups'    ), 10 );
     597        add_action( 'bp_setup_cache_groups', ), 10 );
    576598
    577599        // Register post types.
    578         add_action( 'bp_register_post_types',    array( $this, 'register_post_types'    ), 10 );
     600        add_action( 'bp_register_post_types', ), 10 );
    579601
    580602        // Register post statuses.
     
    582604
    583605        // Register taxonomies.
    584         add_action( 'bp_register_taxonomies',    array( $this, 'register_taxonomies'    ), 10 );
     606        add_action( 'bp_register_taxonomies', ), 10 );
    585607
    586608        // 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', ), 10, 0 );
    588610
    589611        // 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', ), 10, 0 );
    591613
    592614        // Add the permalink structure.
    593         add_action( 'bp_add_permastructs',       array( $this, 'add_permastructs'      ), 10 );
     615        add_action( 'bp_add_permastructs', ), 10 );
    594616
    595617        // Allow components to parse the main query.
    596         add_action( 'bp_parse_query',  array( $this, 'parse_query' ), 10 );
     618        add_action( 'bp_parse_query', array( $this, 'parse_query' ), 10 );
    597619
    598620        // Generate rewrite rules.
     
    722744
    723745            // No sub nav items without a main nav item.
    724             if ( $this->main_nav && $generate) {
     746            if ( $this->main_nav && $generate) {
    725747                if ( isset( $this->main_nav['user_has_access_callback'] ) && is_callable( $this->main_nav['user_has_access_callback'] ) ) {
    726748                    $this->main_nav['show_for_displayed_user'] = call_user_func( $this->main_nav['user_has_access_callback'] );
     
    824846
    825847        // Do we have Toolbar menus to add?
    826         if ( !empty( $wp_admin_nav ) ) {
     848        if ( !empty( $wp_admin_nav ) ) {
    827849            // Fill in position if one wasn't passed for backpat.
    828             $pos = 0;
     850            $pos = 0;
    829851            $not_set_pos = 1;
    830852            foreach ( $wp_admin_nav as $key => $nav ) {
    831853                if ( ! isset( $nav['position'] ) ) {
    832                     $wp_admin_nav[$key]['position'] = $pos + $not_set_pos;
     854                    $wp_admin_nav[]['position'] = $pos + $not_set_pos;
    833855
    834856                    if ( 9 !== $not_set_pos ) {
     
    871893     *
    872894     * @since 1.5.0
    873      *
    874895     */
    875896    public function setup_title() {
     
    882903         * @since 1.5.0
    883904         */
    884         do_action(  'bp_' . $this->id . '_setup_title' );
     905        do_action( 'bp_' . $this->id . '_setup_title' );
    885906    }
    886907
     
    889910     *
    890911     * @since 2.2.0
    891      *
    892912     */
    893913    public function setup_cache_groups() {
     
    924944
    925945        // Add to the BuddyPress global object.
    926         if ( !empty( $tables ) && is_array( $tables ) ) {
     946        if ( !empty( $tables ) && is_array( $tables ) ) {
    927947            foreach ( $tables as $global_name => $table_name ) {
    928948                $this->{$global_name} = $table_name;
     
    971991         * components to play nicely with the WordPress metadata API.
    972992         */
    973         if ( !empty( $tables ) && is_array( $tables ) ) {
     993        if ( !empty( $tables ) && is_array( $tables ) ) {
    974994            foreach ( $tables as $meta_prefix => $table_name ) {
    975995                $wpdb->{$meta_prefix . 'meta'} = $table_name;
     
    9941014     *
    9951015     * @since 1.5.0
    996      *
    9971016     */
    9981017    public function register_post_types() {
     
    10291048     *
    10301049     * @since 1.5.0
    1031      *
    10321050     */
    10331051    public function register_taxonomies() {
     
    11321150                } else {
    11331151                    $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['']';
     1153                    ;
    11361154
    11371155                    $rules[ $rule_key ]['regex'] = $regex . '/?$';
     
    13041322                 */
    13051323                $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                f ( true === $do_redirect_to_login_screen && ! is_user_logged_in() ) {
    13071325                    bp_core_no_access();
    13081326                }
     
    13651383     *
    13661384     * @since 1.5.0
    1367      *
    13681385     */
    13691386    public function generate_rewrite_rules() {
     
    14081425                }
    14091426
    1410                 $component_controller = new $controller;
     1427                $component_controller = new $controller;
    14111428                $component_controller->register_routes();
    14121429            }
     
    14681485     *
    14691486     * @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() ) {
    14741490        _deprecated_function( __METHOD__, '12.0.0' );
     1491
    14751492        return $states;
    14761493    }
    14771494}
    1478 endif; // BP_Component.
  • trunk/src/bp-core/classes/class-bp-core-bp-nav-backcompat.php

    r13818 r13900  
    33 * Backward compatibility for the $bp->bp_nav global.
    44 *
     5
     6
    57 * @since 2.6.0
    68 * @deprecated 12.0.0
     9
     10
     11
    712 */
    813
     
    1116
    1217/**
    13  * bp_nav backward compatibility class.
    14  *
    1518 * This class is used to provide backward compatibility for extensions that access and modify
    1619 * the $bp->bp_nav global.
     20
     21
    1722 *
    1823 * @since 2.6.0
     
    2025 */
    2126class BP_Core_BP_Nav_BackCompat implements ArrayAccess {
     27
    2228    /**
    2329     * Nav items.
    2430     *
    2531     * @since 2.6.0
    26      * @access public
     32     *
    2733     * @var array
    2834     */
     
    3339     *
    3440     * @since 2.6.0
    35      * @access public
     41     *
    3642     * @var array
    3743     */
     
    8187     *
    8288     * @param mixed $offset Array offset.
    83      * @return BP_Core_BP_Nav_BackCompat
    8489     */
    8590    #[ReturnTypeWillChange]
     
    100105     *
    101106     * @param mixed $offset Array offset.
    102      * @return bool
    103107     */
    104108    #[ReturnTypeWillChange]
     
    135139     * @since 2.6.0
    136140     * @deprecated 12.0.0
    137      *
    138      * @param string $component
    139      */
    140     public function set_component( $component ) {
     141     */
     142    public function set_component() {
    141143        _deprecated_function( __METHOD__, '12.0.0' );
    142144    }
     
    151153     * @since 2.6.0
    152154     * @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() {
    158157        _deprecated_function( __METHOD__, '12.0.0' );
    159158    }
     
    178177     *
    179178     * @param mixed $offset Array offset.
    180      * @return bool|array
    181179     */
    182180    protected function get_nav( $offset ) {
     
    197195     *
    198196     * @param string $offset Nav item name.
    199      * @return BP_Core_Nav
    200197     */
    201198    protected function get_component_nav( $offset = '' ) {
     
    208205     * @since 2.6.0
    209206     * @deprecated 12.0.0
    210      *
    211      * @return array
    212207     */
    213208    protected function to_array() {
  • trunk/src/bp-core/classes/class-bp-core-bp-options-nav-backcompat.php

    r13818 r13900  
    33 * Backward compatibility for the $bp->bp_options_nav global.
    44 *
     5
     6
    57 * @since 2.6.0
    68 * @deprecated 12.0.0
     
    1113
    1214/**
    13  * bp_options_nav backward compatibility class.
    14  *
    1515 * This class is used to provide backward compatibility for extensions that access and modify
    1616 * the $bp->bp_options_nav global.
     17
     18
    1719 *
    1820 * @since 2.6.0
     
    2022 */
    2123class BP_Core_BP_Options_Nav_BackCompat extends BP_Core_BP_Nav_BackCompat {
     24
    2225    /**
    2326     * Parent slug of the current nav item.
    2427     *
    2528     * @since 2.6.0
    26      * @access protected
     29     *
    2730     * @var string
    2831     */
     
    3639     *
    3740     * @param mixed $offset Array offset.
    38      * @return BP_Core_BP_Nav_BackCompat
    3941     */
    4042    public function offsetGet( $offset ) {
     
    5557     * @param mixed $offset Array offset.
    5658     */
     59
    5760    public function offsetUnset( $offset ) {
    5861        _doing_it_wrong(
     
    6972     * @since 2.6.0
    7073     * @deprecated 12.0.0
    71      *
    72      * @return string
    7374     */
    7475    public function get_parent_slug() {
     
    8283     * @deprecated 12.0.0
    8384     */
    84     public function set_parent_slug( $slug ) {
     85    public function set_parent_slug() {
    8586        _deprecated_function( __METHOD__, '12.0.0' );
    8687    }
     
    9394     *
    9495     * @param mixed $offset Array offset.
    95      * @return bool|array
    9696     */
    9797    public function get_nav( $offset ) {
  • trunk/src/bp-core/classes/class-bp-core-html-element.php

    r13878 r13900  
    1414 */
    1515class BP_Core_HTML_Element {
     16
    1617    /**
    1718     * Open tag for an element.
     
    2324     * @var string
    2425     */
    25     public $open_tag   = '';
     26    public $open_tag = '';
    2627
    2728    /**
     
    4546     * @var string
    4647     */
    47     public $close_tag  = '';
     48    public $close_tag = '';
    4849
    4950    /**
     
    9192            $this->open_tag = sprintf( '<%1$s %2$s />', $elem, $attributes );
    9293
    93         // All other elements.
     94        // All other elements.
    9495        } else {
    9596            $this->open_tag   = sprintf( '<%1$s %2$s>', $elem, $attributes );
    9697            $this->inner_html = ! empty( $r['inner_html'] ) ? $r['inner_html'] : '';
    97             $this->close_tag  = sprintf( '</%1$s>', $elem );
     98            $this->close_tag  = sprintf( '</%1$s>',$elem );
    9899        }
    99100    }
     
    104105     * @since 2.7.0
    105106     *
    106      * @param  string $prop Property name. Either 'open_tag', 'inner_html', 'close_tag'.
     107     * @param string $prop Property name. Either 'open_tag', 'inner_html', 'close_tag'.
    107108     * @return string
    108109     */
  • trunk/src/bp-core/classes/class-bp-core-login-widget.php

    r13882 r13900  
    77 * @since 1.9.0
    88 * @deprecated 12.0.0
     9
     10
     11
    912 */
    1013
  • trunk/src/bp-core/classes/class-bp-core-nav-item.php

    r11290 r13900  
    11<?php
     2
     3
     4
     5
     6
     7
     8
    29
    310// Exit if accessed directly.
     
    1017 */
    1118class BP_Core_Nav_Item extends ArrayObject {
     19
     20
     21
     22
     23
     24
    1225    public function __construct( $data ) {
    1326        parent::__construct( $data, ArrayObject::ARRAY_AS_PROPS );
  • trunk/src/bp-core/classes/class-bp-core-nav.php

    r13878 r13900  
    1919 */
    2020class BP_Core_Nav {
     21
    2122    /**
    2223     * An associative array containing the nav items for the object ID.
    2324     *
    2425     * @since 2.6.0
     26
    2527     * @var array
    2628     */
     
    3133     *
    3234     * @since 2.6.0
     35
    3336     * @var int
    3437     */
     
    3942     *
    4043     * @since 12.0.0
     44
    4145     * @var string
    4246     */
     
    4852     * @since 2.6.0
    4953     *
    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'.
    5156     */
    5257    public function __construct( $object_id = 0, $component_id = 'members' ) {
     
    114119     *
    115120     * @param string $key The nav item slug to get. Optional.
    116      * @return mixed       An array of nav item, a single nav item, or null if none found.
     121     * @return mixed An array of nav item, a single nav item, or null if none found.
    117122     */
    118123    public function get( $key = '' ) {
     
    127132            }
    128133
    129         // Return all nav item items.
     134        // Return all nav item items.
    130135        } else {
    131136            $return = $this->nav[ $this->object_id ];
     
    159164            $args['secondary']                    = true;
    160165
    161         // This is a parent.
     166        // This is a parent.
    162167        } else {
    163168            $slug                                 = $args['slug'];
     
    180185
    181186                $chunk = 'single_item_action';
    182                 if ( $path_chunks['single_item'] . '_manage' ===  $path_chunks['single_item_component'] ) {
     187                if ( $path_chunks['single_item'] . '_manage' === $path_chunks['single_item_component'] ) {
    183188                    $chunk                             = 'single_item_action_variables';
    184189                    $path_chunks[ $chunk ]             = $path_chunks['single_item_action'];
    185190                    $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' );
    187192                } else {
    188193                    $group_screens = bp_get_group_screens( 'read' );
     
    259264            return $this->nav[ $this->object_id ][ $slug ];
    260265
    261         // We're editing a child.
     266        // We're editing a child.
    262267        } 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            );
    264275
    265276            if ( ! $sub_items ) {
     
    305316
    306317            // 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            );
    308325
    309326            if ( ! $sub_items ) {
     
    323340            return array( $sub_item->screen_function );
    324341
    325         // We're deleting a parent.
     342        // We're deleting a parent.
    326343        } else {
    327344            // Validate the nav.
     
    340357            $screen_functions = array( $nav_item->screen_function );
    341358
    342             // Life's unfair, children won't survive the parent :(
     359            // Life's unfair, children won't survive the parent
    343360            $sub_items = $this->get_secondary( array( 'parent_slug' => $nav_item->slug ), false );
    344361
     
    384401
    385402                do {
    386                     $position += 1;
    387                 } while ( in_array( $position, $sorted_keys ) );
     403                    ;
     404                } while ( in_array( $position, $sorted_keys ) );
    388405            }
    389406
     
    392409
    393410        ksort( $sorted );
     411
    394412        return $sorted;
    395413    }
     
    478496            foreach ( $primary_nav_items as $key_nav => $primary_nav ) {
    479497                // 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                );
    481504
    482505                if ( $children ) {
    483                     $primary_nav_items[ $key_nav ] = clone $primary_nav;
     506                    $primary_nav_items[ $key_nav ] = clone $primary_nav;
    484507                    $primary_nav_items[ $key_nav ]->children = $children;
    485508                }
  • trunk/src/bp-core/classes/class-bp-core-notification.php

    r12753 r13900  
    8585    public function __construct( $id = 0 ) {
    8686
    87         // Bail if no ID
     87        // Bail if no ID
    8888        if ( empty( $id ) ) {
    8989            return;
     
    9999     * @global wpdb $wpdb WordPress database object.
    100100     *
    101      * @return bool Success or failure.
     101     * @return bool
    102102     */
    103103    public function save() {
     
    111111            $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 );
    112112
    113         // Save.
     113        // Save.
    114114        } else {
    115115            $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 )";
     
    145145
    146146        if ( ! empty( $result ) ) {
    147             $this->item_id = $result->item_id;
     147            $this->item_id = $result->item_id;
    148148            $this->secondary_item_id = $result->secondary_item_id;
    149149            $this->user_id           = $result->user_id;
     
    160160     * Check the access for a user.
    161161     *
     162
     163
    162164     * @param int $user_id         ID to check access for.
    163165     * @param int $notification_id Notification ID to check for.
     
    181183     * @global wpdb $wpdb WordPress database object
    182184     *
    183      * @static
    184      *
    185185     * @param int    $user_id User ID.
    186186     * @param string $status 'is_new' or 'all'.
     
    207207     *
    208208     * @global wpdb $wpdb WordPress database object.
    209      *
    210      * @static
    211209     *
    212210     * @param int    $user_id          ID of the user to delet notification for.
     
    232230     * @global wpdb $wpdb WordPress database object.
    233231     *
    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.
    242238     * @return mixed
    243239     */
     
    248244
    249245        $secondary_item_sql = ! empty( $secondary_item_id )
    250             ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id )
     246            ? $wpdb->prepare( , $secondary_item_id )
    251247            : '';
    252248
     
    262258     *
    263259     * @global wpdb $wpdb WordPress database object.
    264      *
    265      * @static
    266260     *
    267261     * @param int    $user_id          The ID of the user whose sent notifications we wish to delete.
     
    287281     *
    288282     * @global wpdb $wpdb WordPress database object.
    289      *
    290      * @static
    291283     *
    292284     * @param int    $item_id           The item id that they notifications are to be for.
     
    300292
    301293        $component_action_sql = ! empty( $component_action )
    302             ? $wpdb->prepare( "AND component_action = %s", $component_action )
     294            ? $wpdb->prepare( , $component_action )
    303295            : '';
    304296
    305297        $secondary_item_sql = ! empty( $secondary_item_id )
    306             ? $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id )
     298            ? $wpdb->prepare( , $secondary_item_id )
    307299            : '';
    308300
  • trunk/src/bp-core/classes/class-bp-core-oembed-extension.php

    r13878 r13900  
    66 * @subpackage Core
    77 * @since 2.6.0
     8
     9
    810 */
    911
     
    5456     *
    5557     * @since 2.6.0
    56      *
    57      * @return null
    5858     */
    5959    abstract protected function content();
     
    128128     * @param int $item_id The item ID to do checks for.
    129129     */
    130     protected function set_iframe_title( $item_id ) {}
     130    protected function set_iframe_title( $item_id ) {}
    131131
    132132    /**
     
    145145     *
    146146     * @since 2.6.0
     147
     148
    147149     */
    148150    protected function set_permalink() {
     
    165167     *
    166168     * @since 2.6.0
     169
     170
    167171     */
    168172    protected function get_item_id() {
     
    189193     */
    190194    protected function setup_hooks() {
    191         add_action( 'rest_api_init',    array( $this, 'register_route' ) );
     195        add_action( 'rest_api_init', array( $this, 'register_route' ) );
    192196        add_action( 'bp_embed_content', array( $this, 'inject_content' ) );
    193197
    194198        add_filter( 'embed_template', array( $this, 'setup_template_parts' ) );
    195199        add_filter( 'post_embed_url', array( $this, 'filter_embed_url' ) );
    196         add_filter( 'embed_html',     array( $this, 'filter_embed_html' ) );
     200        add_filter( 'embed_html', array( $this, 'filter_embed_html' ) );
    197201        add_filter( 'oembed_discovery_links', array( $this, 'add_oembed_discovery_links' ) );
    198202        add_filter( 'rest_pre_serve_request', array( $this, 'oembed_xml_request' ), 20, 4 );
     
    223227                'default'           => $maxwidth,
    224228                'sanitize_callback' => 'absint',
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
    225245            )
    226246        );
    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'                => $args
    237             ),
    238         ) );
    239247    }
    240248
     
    255263        // Set up some BP-specific embed template overrides.
    256264        add_action( 'get_template_part_embed', array( $this, 'content_buffer_start' ), -999, 2 );
    257         add_action( 'get_footer',              array( $this, 'content_buffer_end' ), -999 );
     265        add_action( 'get_footer', array( $this, 'content_buffer_end' ), -999 );
    258266
    259267        // Return the original WP embed template.
     
    341349        }
    342350
    343         add_filter( 'rest_url' , array( $this, 'filter_rest_url' ) );
     351        add_filter( 'rest_url', array( $this, 'filter_rest_url' ) );
    344352
    345353        $retval = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( $permalink ) ) . '" />' . "\n";
     
    349357        }
    350358
    351         remove_filter( 'rest_url' , array( $this, 'filter_rest_url' ) );
     359        remove_filter( 'rest_url', array( $this, 'filter_rest_url' ) );
    352360
    353361        return $retval;
     
    357365     * Fetch our oEmbed response data to return.
    358366     *
    359      * A simplified version of {@link get_oembed_response_data()}.
     367     * A simplified version of {@ get_oembed_response_data()}.
    360368     *
    361369     * @since 2.6.0
     
    382390
    383391        /** 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        );
    388399
    389400        $width  = min( max( $min_max_width['min'], $width ), $min_max_width['max'] );
     
    396407        if ( 'video' === $data['type'] || 'rich' === $data['type'] ) {
    397408            // Fake a WP post so we can use get_post_embed_html().
    398             $post = new stdClass;
     409            $post ;
    399410            $post->post_content = $data['content'];
    400411            $post->post_title   = $data['title'];
     
    430441            // This is needed for various oEmbed response data filtering.
    431442            if ( ! isset( buddypress()->{$this->slug_endpoint} ) || ! buddypress()->{$this->slug_endpoint} ) {
    432                 buddypress()->{$this->slug_endpoint} = new stdClass;
     443                buddypress()->{$this->slug_endpoint} = new stdClass;
    433444            }
    434445            buddypress()->{$this->slug_endpoint}->embedurl_in_progress = $url;
     
    569580        $custom_title = $this->set_iframe_title( $item_id );
    570581        if ( ! empty( $custom_title ) ) {
    571             $title_pos = strpos( $retval, 'title=' ) + 7;
     582            $title_pos = strpos( $retval, 'title=' ) + 7;
    572583            $title_end_pos = strpos( $retval, '"', $title_pos );
    573584
     
    587598        // @todo Maybe use KSES?
    588599        $fallback_html = $this->set_fallback_html( $item_id );
     600
     601
    589602
    590603        /**
     
    593606         * @since 2.6.0
    594607         *
    595          * @var string $retval
     608         * @
    596609         */
    597         return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $fallback_html . $retval );
     610        return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $l );
    598611    }
    599612
  • trunk/src/bp-core/classes/class-bp-date-query.php

    r13893 r13900  
    1818 * BuddyPress date query class.
    1919 *
    20  * Extends the {@link WP_Date_Query} class for use with BuddyPress.
     20 * Extends the {@ WP_Date_Query} class for use with BuddyPress.
    2121 *
    2222 * @since 2.1.0
    2323 *
    2424 * @param array $date_query {
    25  *     Date query arguments.  See first parameter of {@link WP_Date_Query::__construct()}.
     25 *     Date query arguments.  See first parameter of {@ WP_Date_Query::__construct()}.
    2626 * }
    2727 * @param string $column The DB column to query against.
  • trunk/src/bp-core/classes/class-bp-embed.php

    r13372 r13900  
    7171     * for oEmbed parsing.
    7272     *
    73      *
    7473     * @param array  $attr Shortcode attributes.
    7574     * @param string $url  The URL attempting to be embeded.
     
    7776     */
    7877    public function shortcode( $attr, $url = '' ) {
    79         if ( empty( $url ) )
     78        if ( empty( $url ) )
    8079            return '';
     80
    8181
    8282        $rawattr = $attr;
     
    9595            foreach ( $handlers as $hid => $handler ) {
    9696                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 ) {
    9899
    99100                        /**
     
    102103                         * @since 1.5.0
    103104                         *
    104                          * @param string $return Handler callback for the oEmbed.
     105                         * @param $return Handler callback for the oEmbed.
    105106                         * @param string $url    URL attempting to be embedded.
    106107                         * @param array  $attr   Shortcode attributes.
     
    117118         * @since 1.5.0
    118119         *
    119          * @param int $value Value of zero.
     120         * @param int $.
    120121         */
    121122        $id = apply_filters( 'embed_post_id', 0 );
     
    138139        // Set up a new WP oEmbed object to check URL with registered oEmbed providers.
    139140        if ( file_exists( ABSPATH . WPINC . '/class-wp-oembed.php' ) ) {
    140             require_once( ABSPATH . WPINC . '/class-wp-oembed.php' );
     141            require_once;
    141142        } else {
    142143            // class-oembed.php is deprecated in WordPress 5.3.0.
    143             require_once( ABSPATH . WPINC . '/class-oembed.php' );
     144            require_once;
    144145        }
    145146
     
    148149        // If oEmbed discovery is true, skip oEmbed provider check.
    149150        $is_oembed_link = false;
    150         if ( !$attr['discover'] ) {
     151        if ( !$attr['discover'] ) {
    151152            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 ) )
    155156                    $is_oembed_link = true;
     157
    156158            }
    157159
    158160            // If url doesn't match a WP oEmbed provider, stop parsing.
    159             if ( !$is_oembed_link )
     161            if ( !
    160162                return $this->maybe_make_link( $url );
     163
    161164        }
    162165
     
    183186
    184187        if ( $id ) {
    185             // Setup the cachekey.
     188            // Setup the cachekey.
    186189            $cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
    187190
     
    204207
    205208            // Grab cache and return it if available.
    206             if ( !empty( $cache ) ) {
     209            if ( !empty( $cache ) ) {
    207210
    208211                /**
     
    218221                return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr );
    219222
    220             // If no cache, ping the oEmbed provider and cache the result.
     223            // If no cache, ping the oEmbed provider and cache the result.
    221224            } else {
    222                 $html = wp_oembed_get( $url, $attr );
     225                $html = wp_oembed_get( $url, $attr );
    223226                $cache = ( $html ) ? $html : $url;
    224227
  • trunk/src/bp-core/classes/class-bp-invitation-manager.php

    r13890 r13900  
    373373     * @since 5.0.0
    374374     *
    375      * @see BP_Invitation::get() for a description of accepted parameters.
    376      *
     375     * @param array $args {@see BP_Invitation::get()}.
    377376     * @return array Located invitations.
    378377     */
     
    393392     * @since 8.0.0
    394393     *
    395      * @see BP_Invitation::get_total_count() for a description of accepted parameters.
    396      *
     394     * @param array $args {@see BP_Invitation::get_total_count()}.
    397395     * @return int Total number of invitations.
    398396     */
     
    413411     * @since 5.0.0
    414412     *
    415      * @see BP_Invitation::get() for a description of accepted parameters.
    416      *
     413     * @param array $args {@see BP_Invitation::get()}.
    417414     * @return array Located invitations.
    418415     */
     
    434431     * @since 5.0.0
    435432     *
    436      * @see BP_Invitation::get() for a description of accepted parameters.
    437      *
     433     * @param array $args {@see BP_Invitation::get()}.
    438434     * @return int|bool ID of first found invitation or false if none found.
    439435     */
     
    454450     * @since 5.0.0
    455451     *
    456      * @see BP_Invitation::get() for a description of accepted parameters.
    457      *
     452     * @param array $args {@see BP_Invitation::get()}.
    458453     * @return int|bool ID of existing request or false if none found.
    459454     */
     
    476471     * @since 5.0.0
    477472     *
    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()}.
    497474     * @return int|bool Number of rows updated on success, false on failure.
    498475     */
    499476    public function accept_invitation( $args = array() ) {
    500 
    501477        $r = bp_parse_args(
    502478            $args,
     
    539515     * @since 5.0.0
    540516     *
    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()}.
    555518     * @return bool Number of rows updated on success, false on failure.
    556519     */
    557520    public function accept_request( $args = array() ) {
    558 
    559521        $r = bp_parse_args(
    560522            $args,
     
    594556     * @since 5.0.0
    595557     *
    596      * @see BP_Invitation::get() for a description of
     558     * @see BP_Invitation::() for a description of
    597559     *      accepted update/where arguments.
    598560     *
     
    607569    public function update_invitation( $update_args = array(), $where_args = array() ) {
    608570        $update_args['class'] = $this->class_name;
     571
    609572        return BP_Invitation::update( $update_args, $where_args );
    610573    }
     
    669632     * @since 5.0.0
    670633     *
    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.
    675637     */
    676638    public function mark_accepted_by_id( $id, $args ) {
     
    685647     * @since 5.0.0
    686648     *
    687      * @see BP_Invitation::mark_accepted_by_data()
    688      *      for a description of arguments.
     649     * @
     650     * .
    689651     */
    690652    public function mark_accepted( $args ) {
     
    700662     * @since 5.0.0
    701663     *
    702      * @see BP_Invitation::delete for a description of arguments.
    703      *
     664     * @param array $args {BP_Invitation::delete()}.
    704665     * @return int|bool Number of rows deleted on success, false on failure.
    705666     */
     
    717678     * @since 5.0.0
    718679     *
    719      * @see BP_Invitation::delete for a description of arguments.
    720      *
     680     * @param array $args {BP_Invitation::delete()}.
    721681     * @return int|bool Number of rows deleted on success, false on failure.
    722682     */
     
    737697     */
    738698    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 ) );
    744700    }
    745701
  • trunk/src/bp-core/classes/class-bp-suggestions.php

    r13372 r13900  
    7272     *
    7373     * @param array $args {
     74
     75
    7476     *     @type int    $limit Maximum number of results to display. Optional, default: 16.
    7577     *     @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.