Skip to:
Content

BuddyPress.org

Changeset 13091


Ignore:
Timestamp:
08/23/2021 02:03:02 AM (3 years ago)
Author:
espellcaste
Message:

Making PHPDoc Improvements to the BP Notifications (component) files.

See #8553

Location:
trunk/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/actions/bulk-manage.php

    r13034 r13091  
    11<?php
    22/**
    3  * Notifications: Bulk-manage action handler
     3 * Notifications: Bulk-manage action handler.
    44 *
    55 * @package BuddyPress
     
    2828
    2929    // Bail if no action or no IDs.
    30     if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $notifications ) || empty( $nonce ) ) {
     30    if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ), true ) ) || empty( $notifications ) || empty( $nonce ) ) {
    3131        return false;
    3232    }
     
    4242    // Delete, mark as read or unread depending on the user 'action'.
    4343    switch ( $action ) {
    44         case 'delete' :
     44        case 'delete':
    4545            foreach ( $notifications as $notification ) {
    4646                bp_notifications_delete_notification( $notification );
    4747            }
    4848            bp_core_add_message( __( 'Notifications deleted.', 'buddypress' ) );
    49         break;
     49            break;
    5050
    51         case 'read' :
     51        case 'read':
    5252            foreach ( $notifications as $notification ) {
    5353                bp_notifications_mark_notification( $notification, false );
    5454            }
    5555            bp_core_add_message( __( 'Notifications marked as read', 'buddypress' ) );
    56         break;
     56            break;
    5757
    58         case 'unread' :
     58        case 'unread':
    5959            foreach ( $notifications as $notification ) {
    6060                bp_notifications_mark_notification( $notification, true );
    6161            }
    6262            bp_core_add_message( __( 'Notifications marked as unread.', 'buddypress' ) );
    63         break;
     63            break;
    6464    }
    6565
  • trunk/src/bp-notifications/actions/delete.php

    r13034 r13091  
    11<?php
    22/**
    3  * Notifications: Delete action handler
     3 * Notifications: Delete action handler.
    44 *
    55 * @package BuddyPress
     
    2323
    2424    // Get the action.
    25     $action = !empty( $_GET['action']          ) ? $_GET['action']          : '';
    26     $nonce  = !empty( $_GET['_wpnonce']        ) ? $_GET['_wpnonce']        : '';
    27     $id     = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
     25    $action = ! empty( $_GET['action']          ) ? $_GET['action']          : '';
     26    $nonce  = ! empty( $_GET['_wpnonce']        ) ? $_GET['_wpnonce']        : '';
     27    $id     = ! empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
    2828
    2929    // Bail if no action or no ID.
     
    3434    // Check the nonce and delete the notification.
    3535    if ( bp_verify_nonce_request( 'bp_notification_delete_' . $id ) && bp_notifications_delete_notification( $id ) ) {
    36         bp_core_add_message( __( 'Notification successfully deleted.',              'buddypress' )          );
     36        bp_core_add_message( __( 'Notification successfully deleted.', 'buddypress' ) );
    3737    } else {
    3838        bp_core_add_message( __( 'There was a problem deleting that notification.', 'buddypress' ), 'error' );
  • trunk/src/bp-notifications/bp-notifications-adminbar.php

    r12495 r13091  
    3535    // Add the top-level Notifications button.
    3636    $wp_admin_bar->add_node( array(
    37         'parent'    => 'top-secondary',
    38         'id'        => 'bp-notifications',
    39         'title'     => $menu_title,
    40         'href'      => $menu_link,
     37        'parent' => 'top-secondary',
     38        'id'     => 'bp-notifications',
     39        'title'  => $menu_title,
     40        'href'   => $menu_link,
    4141    ) );
    4242
     
    5959    }
    6060
    61     return;
     61    return true;
    6262}
    6363add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
  • trunk/src/bp-notifications/bp-notifications-cache.php

    r12518 r13091  
    3131        'object_column'    => 'notification_id',
    3232        'meta_table'       => buddypress()->notifications->table_name_meta,
    33         'cache_key_prefix' => 'bp_notifications_meta'
     33        'cache_key_prefix' => 'bp_notifications_meta',
    3434    ) );
    3535}
     
    5353 * @since 2.0.0
    5454 *
    55  * @param BP_Notifications_Notification $n Notification object.
     55 * @param BP_Notifications_Notification $notification Notification object.
    5656 */
    57 function bp_notifications_clear_all_for_user_cache_after_save( BP_Notifications_Notification $n ) {
    58     bp_notifications_clear_all_for_user_cache( $n->user_id );
     57function bp_notifications_clear_all_for_user_cache_after_save( $notification ) {
     58    bp_notifications_clear_all_for_user_cache( $notification->user_id );
    5959}
    6060add_action( 'bp_notification_after_save', 'bp_notifications_clear_all_for_user_cache_after_save' );
  • trunk/src/bp-notifications/bp-notifications-filters.php

    r12670 r13091  
    77 * @since 4.0.0
    88 */
    9 
    109
    1110// Format numerical output.
  • trunk/src/bp-notifications/bp-notifications-functions.php

    r12605 r13091  
    3030 *     @type string $date_notified     Timestamp for the notification.
    3131 * }
    32  * @return int|bool ID of the newly created notification on success, false
    33  *                  on failure.
     32 * @return int|bool ID of the newly created notification on success, false on failure.
    3433 */
    3534function bp_notifications_add_notification( $args = array() ) {
     
    9695 *
    9796 * @param int $id ID of the notification to delete.
    98  * @return false|int True on success, false on failure.
     97 * @return false|int Integer on success, false on failure.
    9998 */
    10099function bp_notifications_delete_notification( $id ) {
     
    115114 * @param int      $id     ID of the notification.
    116115 * @param int|bool $is_new 0 for read, 1 for unread.
    117  * @return false|int True on success, false on failure.
     116 * @return false|int Number of rows updated on success, false on failure.
    118117 */
    119118function bp_notifications_mark_notification( $id, $is_new = false ) {
     
    147146    if ( false === $notifications ) {
    148147        $notifications = BP_Notifications_Notification::get( array(
    149             'user_id' => $user_id
     148            'user_id' => $user_id,
    150149        ) );
    151150        wp_cache_set( 'all_for_user_' . $user_id, $notifications, 'bp_notifications' );
     
    483482    return BP_Notifications_Notification::update(
    484483        array(
    485             'is_new' => $is_new
     484            'is_new' => $is_new,
    486485        ),
    487486        array(
    488487            'user_id'          => $user_id,
    489488            'component_name'   => $component_name,
    490             'component_action' => $component_action
     489            'component_action' => $component_action,
    491490        )
    492491    );
     
    512511    return BP_Notifications_Notification::update(
    513512        array(
    514             'is_new' => $is_new
     513            'is_new' => $is_new,
    515514        ),
    516515        array(
     
    519518            'secondary_item_id' => $secondary_item_id,
    520519            'component_name'    => $component_name,
    521             'component_action'  => $component_action
     520            'component_action'  => $component_action,
    522521        )
    523522    );
     
    541540    return BP_Notifications_Notification::update(
    542541        array(
    543             'is_new' => $is_new
     542            'is_new' => $is_new,
    544543        ),
    545544        array(
     
    547546            'secondary_item_id' => $secondary_item_id,
    548547            'component_name'    => $component_name,
    549             'component_action'  => $component_action
     548            'component_action'  => $component_action,
    550549        )
    551550    );
     
    572571    return BP_Notifications_Notification::update(
    573572        array(
    574             'is_new' => $is_new
     573            'is_new' => $is_new,
    575574        ),
    576575        array(
    577576            'item_id'          => $user_id,
    578577            'component_name'   => $component_name,
    579             'component_action' => $component_action
     578            'component_action' => $component_action,
    580579        )
    581580    );
  • trunk/src/bp-notifications/bp-notifications-template.php

    r13034 r13091  
    493493    echo bp_get_the_notification_description();
    494494}
    495 
    496495    /**
    497496     * Get full-text description for a specific notification.
     
    526525         * @since 2.3.0 Added the `$notification` parameter.
    527526         *
    528          * @param string $description  Full-text description for a specific notification.
    529          * @param object $notification Notification object.
     527         * @param string                        $description  Full-text description for a specific notification.
     528         * @param BP_Notifications_Notification $notification Notification object.
    530529         */
    531530        return apply_filters( 'bp_get_the_notification_description', $description, $notification );
     
    600599        $args = array(
    601600            'action'          => 'read',
    602             'notification_id' => $id
     601            'notification_id' => $id,
    603602        );
    604603
     
    692691        $args = array(
    693692            'action'          => 'unread',
    694             'notification_id' => $id
     693            'notification_id' => $id,
    695694        );
    696695
     
    835834        $args = array(
    836835            'action'          => 'delete',
    837             'notification_id' => $id
     836            'notification_id' => $id,
    838837        );
    839838
  • trunk/src/bp-notifications/classes/class-bp-notifications-component.php

    r12670 r13091  
    2929            buddypress()->plugin_dir,
    3030            array(
    31                 'adminbar_myaccount_order' => 30
     31                'adminbar_myaccount_order' => 30,
    3232            )
    3333        );
     
    122122            'search_string' => __( 'Search Notifications...', 'buddypress' ),
    123123            'global_tables' => $global_tables,
    124             'meta_tables'   => $meta_tables
     124            'meta_tables'   => $meta_tables,
    125125        );
    126126
     
    250250                'id'     => 'my-account-' . $this->id,
    251251                'title'  => $title,
    252                 'href'   => $notifications_link
     252                'href'   => $notifications_link,
    253253            );
    254254
     
    259259                'title'    => $unread,
    260260                'href'     => $notifications_link,
    261                 'position' => 10
     261                'position' => 10,
    262262            );
    263263
     
    268268                'title'    => _x( 'Read', 'My Account Notification sub nav', 'buddypress' ),
    269269                'href'     => trailingslashit( $notifications_link . 'read' ),
    270                 'position' => 20
     270                'position' => 20,
    271271            );
    272272        }
     
    289289                $bp->bp_options_title = __( 'Notifications', 'buddypress' );
    290290            } else {
     291                $bp->bp_options_title  = bp_get_displayed_user_fullname();
    291292                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    292293                    'item_id' => bp_displayed_user_id(),
     
    294295                    'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
    295296                ) );
    296                 $bp->bp_options_title = bp_get_displayed_user_fullname();
    297297            }
    298298        }
  • trunk/src/bp-notifications/classes/class-bp-notifications-notification.php

    r13069 r13091  
    4242     *
    4343     * @since 1.9.0
     44     * @var int|null
     45     */
     46    public $secondary_item_id = null;
     47
     48    /**
     49     * The ID of the user the notification is associated with.
     50     *
     51     * @since 1.9.0
    4452     * @var int
    4553     */
    46     public $secondary_item_id = null;
    47 
    48     /**
    49      * The ID of the user the notification is associated with.
    50      *
    51      * @since 1.9.0
    52      * @var int
    53      */
    5454    public $user_id;
    5555
     
    9090     *
    9191     * @since 9.1.0
    92      * @access public
    9392     * @var array
    9493     */
     
    101100        'component_action',
    102101        'date_notified',
    103         'is_new'
     102        'is_new',
    104103    );
    105104
     
    220219     *
    221220     * @since 1.9.0
     221     *
     222     * @global wpdb $wpdb WordPress database object.
     223     *
     224     * @see wpdb::insert() for further description of paramater formats.
    222225     *
    223226     * @param array $data {
     
    245248     * @since 1.9.0
    246249     *
     250     * @global wpdb $wpdb WordPress database object.
     251     *
    247252     * @see wpdb::update() for further description of paramater formats.
    248253     *
     
    267272     * @since 1.9.0
    268273     *
    269      * @see wpdb::update() for further description of paramater formats.
     274     * @global wpdb $wpdb WordPress database object.
     275     *
     276     * @see wpdb::delete() for further description of paramater formats.
    270277     *
    271278     * @param array $where        Array of WHERE clauses to filter by, passed to
     
    287294     *
    288295     * @since 1.9.0
     296     *
     297     * @global wpdb $wpdb WordPress database object.
    289298     *
    290299     * @param array  $args           See {@link BP_Notifications_Notification::get()}
     
    438447
    439448        // Sort order direction.
    440         if ( ! empty( $args['sort_order'] ) && in_array( $args['sort_order'], array( 'ASC', 'DESC' ) ) ) {
     449        if ( ! empty( $args['sort_order'] ) && in_array( $args['sort_order'], array( 'ASC', 'DESC' ), true ) ) {
    441450            $sort_order               = $args['sort_order'];
    442451            $conditions['sort_order'] = "{$sort_order}";
     
    457466     *
    458467     * @since 1.9.0
     468     *
     469     * @global wpdb $wpdb WordPress database object.
    459470     *
    460471     * @param array $args See {@link BP_Notifications_Notification::get()}
     
    578589     * @since 1.9.0
    579590     *
     591     * @global BuddyPress $bp The one true BuddyPress instance.
     592     * @global wpdb $wpdb WordPress database object.
     593     *
    580594     * @param int $user_id         ID of the user being checked.
    581595     * @param int $notification_id ID of the notification being checked.
    582      * @return bool True if the notification belongs to the user, otherwise
    583      *              false.
     596     * @return bool True if the notification belongs to the user, otherwise false.
    584597     */
    585598    public static function check_access( $user_id = 0, $notification_id = 0 ) {
     
    600613     * @since 2.3.0
    601614     *
    602      * @param mixed $args Args to parse.
     615     * @param array|string $args Args to parse.
    603616     * @return array
    604617     */
     
    619632            'meta_query'        => false,
    620633            'date_query'        => false,
    621             'update_meta_cache' => true
     634            'update_meta_cache' => true,
    622635        ) );
    623636    }
     
    627640     *
    628641     * @since 1.9.0
     642     *
     643     * @global BuddyPress $bp The one true BuddyPress instance.
     644     * @global wpdb $wpdb WordPress database object.
    629645     *
    630646     * @param array $args {
     
    737753     * @since 1.9.0
    738754     *
    739      * @see BP_Notifications_Notification::get() for a description of arguments.
    740      *
    741      * @param array $args See {@link BP_Notifications_Notification::get()}.
     755     * @global BuddyPress $bp The one true BuddyPress instance.
     756     * @global wpdb $wpdb WordPress database object.
     757     *
     758     * @param array|string $args See {@link BP_Notifications_Notification::get()}.
    742759     * @return int Count of located items.
    743760     */
     
    871888    public static function update( $update_args = array(), $where_args = array() ) {
    872889        $update = self::get_query_clauses( $update_args );
    873         $where  = self::get_query_clauses( $where_args  );
     890        $where  = self::get_query_clauses( $where_args );
    874891
    875892        /**
     
    11741191     * @since 3.0.0
    11751192     *
     1193     * @global BuddyPress $bp The one true BuddyPress instance.
     1194     * @global wpdb $wpdb WordPress database object.
     1195     *
    11761196     * @param int $user_id ID of the user whose notifications are being fetched.
    11771197     * @return array Notifications items for formatting into a list.
  • trunk/src/bp-notifications/classes/class-bp-notifications-template.php

    r10523 r13091  
    142142    /**
    143143     * Constructor method.
    144      *
    145      * @see bp_has_notifications() For information on the array format.
    146144     *
    147145     * @since 1.9.0
     
    171169            'max'               => null,
    172170            'meta_query'        => false,
    173             'date_query'        => false
     171            'date_query'        => false,
    174172        ) );
    175173
    176174        // Sort order direction.
    177175        $orders = array( 'ASC', 'DESC' );
    178         if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders ) ) {
     176        if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders, true ) ) {
    179177            $r['sort_order'] = $_GET['sort_order'];
    180178        } else {
     
    184182        // Setup variables.
    185183        $this->pag_arg      = sanitize_key( $r['page_arg'] );
    186         $this->pag_page     = bp_sanitize_pagination_arg( $this->pag_arg, $r['page']     );
    187         $this->pag_num      = bp_sanitize_pagination_arg( 'num',          $r['per_page'] );
     184        $this->pag_page     = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
     185        $this->pag_num      = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
    188186        $this->user_id      = $r['user_id'];
    189187        $this->is_new       = $r['is_new'];
     
    239237                'current'   => $this->pag_page,
    240238                'prev_text' => _x( '&larr;', 'Notifications pagination previous text', 'buddypress' ),
    241                 'next_text' => _x( '&rarr;', 'Notifications pagination next text',     'buddypress' ),
     239                'next_text' => _x( '&rarr;', 'Notifications pagination next text', 'buddypress' ),
    242240                'mid_size'  => 1,
    243241                'add_args'  => $add_args,
     
    256254     */
    257255    public function has_notifications() {
    258         if ( $this->notification_count ) {
    259             return true;
    260         }
    261 
    262         return false;
     256        return ! empty( $this->notification_count );
    263257    }
    264258
     
    268262     * @since 1.9.0
    269263     *
    270      * @return object The next notification to iterate over.
     264     * @return BP_Notifications_Notification The next notification to iterate over.
    271265     */
    272266    public function next_notification() {
     
    312306            return true;
    313307
    314         } elseif ( $this->current_notification + 1 == $this->notification_count ) {
     308        } elseif ( $this->current_notification + 1 === $this->notification_count ) {
    315309
    316310            /**
     
    319313             * @since 1.9.0
    320314             */
    321             do_action( 'notifications_loop_end');
     315            do_action( 'notifications_loop_end' );
    322316
    323317            $this->rewind_notifications();
  • trunk/src/bp-notifications/screens/read.php

    r13034 r13091  
    11<?php
    22/**
    3  * Notifications: User's "Notifications > Read" screen handler
     3 * Notifications: User's "Notifications > Read" screen handler.
    44 *
    55 * @package BuddyPress
     
    5858    // Check the nonce and mark the notification.
    5959    if ( bp_verify_nonce_request( 'bp_notification_mark_unread_' . $id ) && bp_notifications_mark_notification( $id, true ) ) {
    60         bp_core_add_message( __( 'Notification successfully marked unread.',       'buddypress' )          );
     60        bp_core_add_message( __( 'Notification successfully marked unread.', 'buddypress' ) );
    6161    } else {
    6262        bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' );
  • trunk/src/bp-notifications/screens/unread.php

    r13034 r13091  
    11<?php
    22/**
    3  * Notifications: User's "Notifications" screen handler
     3 * Notifications: User's "Notifications" screen handler.
    44 *
    55 * @package BuddyPress
     
    5858    // Check the nonce and mark the notification.
    5959    if ( bp_verify_nonce_request( 'bp_notification_mark_read_' . $id ) && bp_notifications_mark_notification( $id, false ) ) {
    60         bp_core_add_message( __( 'Notification successfully marked read.',         'buddypress' )          );
     60        bp_core_add_message( __( 'Notification successfully marked read.', 'buddypress' ) );
    6161    } else {
    6262        bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' );
  • trunk/src/bp-settings/classes/class-bp-settings-component.php

    r13090 r13091  
    9999     * @since 1.5.0
    100100     *
    101      * @param array $args Array of arguments.
     101     * @see BP_Component::setup_globals() for a description of arguments.
     102     *
     103     * @param array $args See BP_Component::setup_globals() for a description.
    102104     */
    103105    public function setup_globals( $args = array() ) {
     
    120122     * @since 1.5.0
    121123     *
    122      * @param array $main_nav Array of main nav items.
    123      * @param array $sub_nav  Array of sub nav items.
     124     * @see BP_Component::setup_nav() for a description of arguments.
     125     *
     126     * @param array $main_nav Optional. See BP_Component::setup_nav() for
     127     *                        description.
     128     * @param array $sub_nav  Optional. See BP_Component::setup_nav() for
     129     *                        description.
    124130     */
    125131    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
     
    145151            'show_for_displayed_user' => $access,
    146152            'screen_function'         => 'bp_settings_screen_general',
    147             'default_subnav_slug'     => 'general'
     153            'default_subnav_slug'     => 'general',
    148154        );
    149155
     
    156162            'screen_function' => 'bp_settings_screen_general',
    157163            'position'        => 10,
    158             'user_has_access' => $access
     164            'user_has_access' => $access,
    159165        );
    160166
     
    168174            'screen_function' => 'bp_settings_screen_notification',
    169175            'position'        => 20,
    170             'user_has_access' => $access
     176            'user_has_access' => $access,
    171177        );
    172178
     
    180186                'screen_function' => 'bp_settings_screen_capabilities',
    181187                'position'        => 80,
    182                 'user_has_access' => ! bp_is_my_profile()
     188                'user_has_access' => ! bp_is_my_profile(),
    183189            );
    184190        }
     
    223229
    224230    /**
    225      * Set up the Toolbar.
    226      *
    227      * @since 1.5.0
    228      *
    229      * @param array $wp_admin_nav Array of Admin Bar items.
     231     * Set up the component entries in the WordPress Admin Bar.
     232     *
     233     * @since 1.5.0
     234     *
     235     * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
     236     *      parameter array.
     237     *
     238     * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
     239     *                            description.
    230240     */
    231241    public function setup_admin_bar( $wp_admin_nav = array() ) {
     
    242252                'id'     => 'my-account-' . $this->id,
    243253                'title'  => __( 'Settings', 'buddypress' ),
    244                 'href'   => $settings_link
     254                'href'   => $settings_link,
    245255            );
    246256
     
    251261                'title'    => __( 'General', 'buddypress' ),
    252262                'href'     => $settings_link,
    253                 'position' => 10
     263                'position' => 10,
    254264            );
    255265
     
    261271                    'title'    => __( 'Email', 'buddypress' ),
    262272                    'href'     => trailingslashit( $settings_link . 'notifications' ),
    263                     'position' => 20
     273                    'position' => 20,
    264274                );
    265275            }
     
    286296                    'title'    => __( 'Delete Account', 'buddypress' ),
    287297                    'href'     => trailingslashit( $settings_link . 'delete-account' ),
    288                     'position' => 90
     298                    'position' => 90,
    289299                );
    290300            }
Note: See TracChangeset for help on using the changeset viewer.