Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/25/2019 12:35:00 PM (5 years ago)
Author:
imath
Message:

Site Wide Notices: improve layout and possible customizations

By using existing BP Notices template tags into the bp_message_get_notices() function we are:

  • improving the way notices containing line feeds are displayed,
  • improving customization possibilities using the template tags filters.

Props Venutius, kristianngve

Fixes #8079

File:
1 edited

Legend:

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

    r11791 r12415  
    11561156/**
    11571157 * Output the subject of the current notice in the loop.
    1158  */
    1159 function bp_message_notice_subject() {
    1160     echo bp_get_message_notice_subject();
     1158 *
     1159 * @since 5.0.0 The $notice parameter has been added.
     1160 *
     1161 * @param BP_Messages_Notice $notice The notice object.
     1162 */
     1163function bp_message_notice_subject( $notice = null ) {
     1164    echo bp_get_message_notice_subject( $notice );
    11611165}
    11621166    /**
    11631167     * Get the subject of the current notice in the loop.
    11641168     *
    1165      * @return string
    1166      */
    1167     function bp_get_message_notice_subject() {
     1169     * @since 5.0.0 The $notice parameter has been added.
     1170     *
     1171     * @param BP_Messages_Notice $notice The notice object.
     1172     * @return string
     1173     */
     1174    function bp_get_message_notice_subject( $notice = null ) {
    11681175        global $messages_template;
    11691176
     1177        if ( ! isset( $notice->subject ) ) {
     1178            $notice =& $messages_template->thread;
     1179        }
     1180
    11701181        /**
    11711182         * Filters the subject of the current notice in the loop.
     
    11751186         * @param string $subject Subject of the current notice in the loop.
    11761187         */
    1177         return apply_filters( 'bp_get_message_notice_subject', $messages_template->thread->subject );
     1188        return apply_filters( 'bp_get_message_notice_subject', $notice->subject );
    11781189    }
    11791190
    11801191/**
    11811192 * Output the text of the current notice in the loop.
    1182  */
    1183 function bp_message_notice_text() {
    1184     echo bp_get_message_notice_text();
     1193 *
     1194 * @since 5.0.0 The $notice parameter has been added.
     1195 *
     1196 * @param BP_Messages_Notice $notice The notice object.
     1197 */
     1198function bp_message_notice_text( $notice = null ) {
     1199    echo bp_get_message_notice_text( $notice );
    11851200}
    11861201    /**
    11871202     * Get the text of the current notice in the loop.
    11881203     *
    1189      * @return string
    1190      */
    1191     function bp_get_message_notice_text() {
     1204     * @since 5.0.0 The $notice parameter has been added.
     1205     *
     1206     * @param BP_Messages_Notice $notice The notice object.
     1207     * @return string
     1208     */
     1209    function bp_get_message_notice_text( $notice = null ) {
    11921210        global $messages_template;
    11931211
     1212        if ( ! isset( $notice->subject ) ) {
     1213            $notice =& $messages_template->thread;
     1214        }
     1215
    11941216        /**
    11951217         * Filters the text of the current notice in the loop.
     
    11991221         * @param string $message Text for the current notice in the loop.
    12001222         */
    1201         return apply_filters( 'bp_get_message_notice_text', $messages_template->thread->message );
     1223        return apply_filters( 'bp_get_message_notice_text', $notice->message );
    12021224    }
    12031225
     
    13351357            ?>
    13361358            <div id="message" class="info notice" rel="n-<?php echo esc_attr( $notice->id ); ?>">
    1337                 <p>
    1338                     <strong><?php echo stripslashes( wp_filter_kses( $notice->subject ) ) ?></strong><br />
    1339                     <?php echo stripslashes( wp_filter_kses( $notice->message) ) ?>
    1340                     <button type="button" id="close-notice" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'Dismiss this notice', 'buddypress' ) ?>"><span class="bp-screen-reader-text"><?php _e( 'Dismiss this notice', 'buddypress' ) ?></span> <span aria-hidden="true">&Chi;</span></button>
    1341                     <?php wp_nonce_field( 'bp_messages_close_notice', 'close-notice-nonce' ); ?>
    1342                 </p>
     1359                <strong><?php bp_message_notice_subject( $notice ); ?></strong>
     1360                <button type="button" id="close-notice" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'Dismiss this notice', 'buddypress' ) ?>"><span class="bp-screen-reader-text"><?php _e( 'Dismiss this notice', 'buddypress' ) ?></span> <span aria-hidden="true">&Chi;</span></button>
     1361                <?php bp_message_notice_text( $notice ); ?>
     1362                <?php wp_nonce_field( 'bp_messages_close_notice', 'close-notice-nonce' ); ?>
    13431363            </div>
    13441364            <?php
Note: See TracChangeset for help on using the changeset viewer.