Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/27/2024 09:27:26 AM (13 months ago)
Author:
imath
Message:

Notifications component: improve PHP code standards using WPCS

See #7228 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/bp-notifications-template.php

    r13503 r13812  
    1717 */
    1818function bp_notifications_slug() {
    19     echo bp_get_notifications_slug();
     19    echo esc_url( bp_get_notifications_slug() );
    2020}
    2121    /**
     
    4747 */
    4848function bp_notifications_permalink( $user_id = 0 ) {
    49     echo bp_get_notifications_permalink( $user_id );
     49    echo esc_url( bp_get_notifications_permalink( $user_id ) );
    5050}
    5151    /**
     
    8989 */
    9090function bp_notifications_unread_permalink( $user_id = 0 ) {
    91     echo bp_get_notifications_unread_permalink( $user_id );
     91    echo esc_url( bp_get_notifications_unread_permalink( $user_id ) );
    9292}
    9393    /**
     
    130130 */
    131131function bp_notifications_read_permalink( $user_id = 0 ) {
    132     echo bp_get_notifications_read_permalink( $user_id );
     132    echo esc_url( bp_get_notifications_read_permalink( $user_id ) );
    133133}
    134134    /**
     
    294294 */
    295295function bp_the_notification_id() {
    296     echo bp_get_the_notification_id();
     296    echo intval( bp_get_the_notification_id() );
    297297}
    298298    /**
     
    321321 */
    322322function bp_the_notification_item_id() {
    323     echo bp_get_the_notification_item_id();
     323    echo intval( bp_get_the_notification_item_id() );
    324324}
    325325    /**
     
    348348 */
    349349function bp_the_notification_secondary_item_id() {
    350     echo bp_get_the_notification_secondary_item_id();
     350    echo intval( bp_get_the_notification_secondary_item_id() );
    351351}
    352352    /**
     
    375375 */
    376376function bp_the_notification_component_name() {
    377     echo bp_get_the_notification_component_name();
     377    echo esc_html( bp_get_the_notification_component_name() );
    378378}
    379379    /**
     
    402402 */
    403403function bp_the_notification_component_action() {
    404     echo bp_get_the_notification_component_action();
     404    echo esc_html( bp_get_the_notification_component_action() );
    405405}
    406406    /**
     
    409409     * @since 1.9.0
    410410     *
    411      * @return int Name of the action associated with the current notification.
     411     * @return string Name of the action associated with the current notification.
    412412     */
    413413    function bp_get_the_notification_component_action() {
     
    418418         * @since 1.9.0
    419419         *
    420          * @param int $component_action Name of the action associated with the current notification.
     420         * @param string $component_action Name of the action associated with the current notification.
    421421         */
    422422        return apply_filters( 'bp_get_the_notification_component_action', buddypress()->notifications->query_loop->notification->component_action );
     
    429429 */
    430430function bp_the_notification_date_notified() {
    431     echo bp_get_the_notification_date_notified();
     431    echo esc_html( bp_get_the_notification_date_notified() );
    432432}
    433433    /**
     
    456456 */
    457457function bp_the_notification_time_since() {
    458     echo bp_get_the_notification_time_since();
     458    echo esc_html( bp_get_the_notification_time_since() );
    459459}
    460460    /**
     
    495495 */
    496496function bp_the_notification_description() {
    497     echo bp_get_the_notification_description();
     497    echo wp_kses(
     498        bp_get_the_notification_description(),
     499        array(
     500            'a' => array(
     501                'href'  => true,
     502                'class' => true,
     503            ),
     504        )
     505    );
    498506}
    499507    /**
     
    544552 */
    545553function bp_the_notification_mark_read_link( $user_id = 0 ) {
     554    // Escaping is made in `bp_get_the_notification_mark_read_link()`.
     555    // phpcs:ignore WordPress.Security.EscapeOutput
    546556    echo bp_get_the_notification_mark_read_link( $user_id );
    547557}
     
    559569        $user_id = 0 === $user_id ? bp_displayed_user_id() : $user_id;
    560570
    561         $retval = sprintf( '<a href="%1$s" class="mark-read primary">%2$s</a>', esc_url( bp_get_the_notification_mark_read_url( $user_id ) ), __( 'Read', 'buddypress' ) );
     571        $retval = sprintf( '<a href="%1$s" class="mark-read primary">%2$s</a>', esc_url( bp_get_the_notification_mark_read_url( $user_id ) ), esc_html__( 'Read', 'buddypress' ) );
    562572
    563573        /**
     
    598608
    599609        // Get the notification ID.
    600         $id   = bp_get_the_notification_id();
     610        $id = bp_get_the_notification_id();
    601611
    602612        // Get the args to add to the URL.
     
    636646 */
    637647function bp_the_notification_mark_unread_link( $user_id = 0 ) {
     648    // Escaping is done in `bp_get_the_notification_mark_unread_link()`.
     649    // phpcs:ignore WordPress.Security.EscapeOutput
    638650    echo bp_get_the_notification_mark_unread_link( $user_id );
    639651}
     
    651663        $user_id = 0 === $user_id ? bp_displayed_user_id() : $user_id;
    652664
    653         $retval = sprintf( '<a href="%1$s" class="mark-unread primary bp-tooltip">%2$s</a>', esc_url( bp_get_the_notification_mark_unread_url( $user_id ) ), __( 'Unread', 'buddypress' ) );
     665        $retval = sprintf( '<a href="%1$s" class="mark-unread primary bp-tooltip">%2$s</a>', esc_url( bp_get_the_notification_mark_unread_url( $user_id ) ), esc_html__( 'Unread', 'buddypress' ) );
    654666
    655667        /**
     
    728740 */
    729741function bp_the_notification_mark_link( $user_id = 0 ) {
     742    // Escaping is made in `bp_get_the_notification_mark_read_link()` & `bp_get_the_notification_mark_unread_link()`.
     743    // phpcs:ignore WordPress.Security.EscapeOutput
    730744    echo bp_get_the_notification_mark_link( $user_id );
    731745}
     
    770784 */
    771785function bp_the_notification_delete_link( $user_id = 0 ) {
     786    // Escaping is made in `bp_get_the_notification_delete_link()`.
     787    // phpcs:ignore WordPress.Security.EscapeOutput
    772788    echo bp_get_the_notification_delete_link( $user_id );
    773789}
     
    785801        $user_id = 0 === $user_id ? bp_displayed_user_id() : $user_id;
    786802
    787         $retval = sprintf( '<a href="%1$s" class="delete secondary confirm bp-tooltip">%2$s</a>', esc_url( bp_get_the_notification_delete_url( $user_id ) ), __( 'Delete', 'buddypress' ) );
     803        $retval = sprintf( '<a href="%1$s" class="delete secondary confirm bp-tooltip">%2$s</a>', esc_url( bp_get_the_notification_delete_url( $user_id ) ), esc_html__( 'Delete', 'buddypress' ) );
    788804
    789805        /**
     
    868884 */
    869885function bp_the_notification_action_links( $args = '' ) {
     886    // phpcs:ignore WordPress.Security.EscapeOutput
    870887    echo bp_get_the_notification_action_links( $args );
    871888}
     
    924941 */
    925942function bp_notifications_pagination_count() {
    926     echo bp_get_notifications_pagination_count();
     943    echo esc_html( bp_get_notifications_pagination_count() );
    927944}
    928945    /**
     
    963980 */
    964981function bp_notifications_pagination_links() {
     982    // Escaping is done in WordPress's `paginate_links()` function.
     983    // phpcs:ignore WordPress.Security.EscapeOutput
    965984    echo bp_get_notifications_pagination_links();
    966985}
     
    10081027
    10091028        <select id="notifications-sort-order-list" name="sort_order" onchange="this.form.submit();">
    1010             <option value="DESC" <?php selected( $selected, 'DESC' ); ?>><?php _e( 'Newest First', 'buddypress' ); ?></option>
    1011             <option value="ASC"  <?php selected( $selected, 'ASC'  ); ?>><?php _e( 'Oldest First', 'buddypress' ); ?></option>
     1029            <option value="DESC" <?php selected( $selected, 'DESC' ); ?>><?php esc_html_e( 'Newest First', 'buddypress' ); ?></option>
     1030            <option value="ASC"  <?php selected( $selected, 'ASC'  ); ?>><?php esc_html_e( 'Oldest First', 'buddypress' ); ?></option>
    10121031        </select>
    10131032
     
    10291048    <label class="bp-screen-reader-text" for="notification-select"><?php
    10301049        /* translators: accessibility text */
    1031         _e( 'Select Bulk Action', 'buddypress' );
     1050        esc_html_e( 'Select Bulk Action', 'buddypress' );
    10321051    ?></label>
    10331052    <select name="notification_bulk_action" id="notification-select">
    1034         <option value="" selected="selected"><?php _e( 'Bulk Actions', 'buddypress' ); ?></option>
     1053        <option value="" selected="selected"><?php esc_html_e( 'Bulk Actions', 'buddypress' ); ?></option>
    10351054
    10361055        <?php if ( bp_is_current_action( 'unread' ) ) : ?>
    1037             <option value="read"><?php _e( 'Mark read', 'buddypress' ); ?></option>
     1056            <option value="read"><?php esc_html_e( 'Mark read', 'buddypress' ); ?></option>
    10381057        <?php elseif ( bp_is_current_action( 'read' ) ) : ?>
    1039             <option value="unread"><?php _e( 'Mark unread', 'buddypress' ); ?></option>
     1058            <option value="unread"><?php esc_html_e( 'Mark unread', 'buddypress' ); ?></option>
    10401059        <?php endif; ?>
    1041         <option value="delete"><?php _e( 'Delete', 'buddypress' ); ?></option>
     1060        <option value="delete"><?php esc_html_e( 'Delete', 'buddypress' ); ?></option>
    10421061    </select>
    10431062    <input type="submit" id="notification-bulk-manage" class="button action" value="<?php esc_attr_e( 'Apply', 'buddypress' ); ?>">
Note: See TracChangeset for help on using the changeset viewer.