Skip to:
Content

BuddyPress.org

Changeset 12415


Ignore:
Timestamp:
07/25/2019 12:35:00 PM (6 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

Location:
trunk/src
Files:
3 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
  • trunk/src/bp-templates/bp-legacy/css/buddypress-rtl.css

    r12136 r12415  
    625625
    626626#buddypress div#message p,
    627 #sitewide-notice p {
     627#sitewide-notice p,
     628#sitewide-notice strong:first-child {
    628629    font-size: 90%;
    629630    display: block;
     
    13931394}
    13941395
     1396#sitewide-notice,
     1397.bp-site-wide-message {
     1398    position: relative;
     1399}
     1400
    13951401#buddypress div#message p,
    1396 #sitewide-notice p {
     1402#sitewide-notice #message {
    13971403    background-color: #ffd;
    13981404    border: 1px solid #cb2;
     
    14061412.admin-bar-on #message p {
    14071413    padding-left: 25px;
    1408     position: relative;
    14091414}
    14101415
  • trunk/src/bp-templates/bp-legacy/css/buddypress.css

    r12136 r12415  
    625625
    626626#buddypress div#message p,
    627 #sitewide-notice p {
     627#sitewide-notice p,
     628#sitewide-notice strong:first-child {
    628629    font-size: 90%;
    629630    display: block;
     
    13931394}
    13941395
     1396#sitewide-notice,
     1397.bp-site-wide-message {
     1398    position: relative;
     1399}
     1400
    13951401#buddypress div#message p,
    1396 #sitewide-notice p {
     1402#sitewide-notice #message {
    13971403    background-color: #ffd;
    13981404    border: 1px solid #cb2;
     
    14061412.admin-bar-on #message p {
    14071413    padding-right: 25px;
    1408     position: relative;
    14091414}
    14101415
Note: See TracChangeset for help on using the changeset viewer.