Skip to:
Content

BuddyPress.org

Changeset 13005


Ignore:
Timestamp:
07/14/2021 08:29:34 PM (5 years ago)
Author:
imath
Message:

Merge the BP Blocks plugin's 'bp/sitewide-notices' Block

  • Add a front-end script to the Messages component to manage dismissible notices displayed into the Widget Block.
  • Adapt Grunt sass tasks.
  • Add the Block JavaScript source files into src/js/bp-messages/js/blocks.
  • Add the Block Scss source file into src/bp-messages/sass.
  • Generate the development files to ease testing.

Props dcavins

Fixes #8525

Location:
trunk
Files:
19 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/.jshintignore

    r13004 r13005  
    1313src/**/js/dynamic-groups.js
    1414src/**/js/dynamic-widget-block.js
     15src/**/js/sitewide-notices.js
  • trunk/Gruntfile.js

    r13004 r13005  
    2727                        '!**/js/dynamic-members.js',
    2828                        '!**/js/dynamic-groups.js',
    29                         '!**/js/dynamic-widget-block.js'
     29                        '!**/js/dynamic-widget-block.js',
     30                        '!**/js/sitewide-notices.js'
    3031                ],
    3132
    … …  
    4849                        '!bp-friends/css/blocks/friends.css',
    4950                        '!bp-members/css/blocks/dynamic-members.css',
    50                         '!bp-groups/css/blocks/dynamic-groups.css'
     51                        '!bp-groups/css/blocks/dynamic-groups.css',
     52                        '!bp-messages/css/blocks/sitewide-notices.css'
    5153                ],
    5254
    … …  
    185187                                src: ['bp-friends/sass/blocks/*.scss'],
    186188                                dest: SOURCE_DIR + 'bp-friends/css/blocks/'
     189                        },
     190                        messages_blocks: {
     191                                cwd: SOURCE_DIR,
     192                                extDot: 'last',
     193                                expand: true,
     194                                ext: '.css',
     195                                flatten: true,
     196                                src: ['bp-messages/sass/blocks/*.scss'],
     197                                dest: SOURCE_DIR + 'bp-messages/css/blocks/'
    187198                        }
    188199                },
  • trunk/src/bp-messages/bp-messages-cssjs.php

    r12401 r13005  
    7474<?php
    7575}
     76
     77/**
     78 * Registers a new script to manage the dismissal action for the Sitewide notice widget/block.
     79 *
     80 * @since 9.0.0
     81 *
     82 * @param array $scripts Data about the scripts to register.
     83 * @return array Data about the scripts to register.
     84 */
     85function bp_messages_register_scripts( $scripts = array() ) {
     86        $scripts['bp-sitewide-notices-script'] = array(
     87                'file'         => plugins_url( 'js/sitewide-notices.js', __FILE__ ),
     88                'dependencies' => array(),
     89                'footer'       => true,
     90        );
     91
     92        return $scripts;
     93}
     94add_filter( 'bp_core_register_common_scripts', 'bp_messages_register_scripts', 9, 1 );
  • trunk/src/bp-messages/classes/class-bp-messages-component.php

    r12994 r13005  
    6363                        'functions',
    6464                        'widgets',
     65                        'blocks',
    6566                );
    6667
    … …  
    456457         */
    457458        public function blocks_init( $blocks = array() ) {
    458                 parent::blocks_init( array() );
     459                parent::blocks_init(
     460                        array(
     461                                'bp/sitewide-notices' => array(
     462                                        'name'               => 'bp/sitewide-notices',
     463                                        'editor_script'      => 'bp-sitewide-notices-block',
     464                                        'editor_script_url'  => plugins_url( 'js/blocks/sitewide-notices.js', dirname( __FILE__ ) ),
     465                                        'editor_script_deps' => array(
     466                                                'wp-blocks',
     467                                                'wp-element',
     468                                                'wp-components',
     469                                                'wp-i18n',
     470                                                'wp-block-editor',
     471                                                'bp-block-data',
     472                                                'bp-block-components',
     473                                        ),
     474                                        'style'              => 'bp-sitewide-notices-block',
     475                                        'style_url'          => plugins_url( 'css/blocks/sitewide-notices.css', dirname( __FILE__ ) ),
     476                                        'attributes'         => array(
     477                                                'title' => array(
     478                                                        'type'    => 'string',
     479                                                        'default' => '',
     480                                                ),
     481                                        ),
     482                                        'render_callback'    => 'bp_messages_render_sitewide_notices_block',
     483                                ),
     484                        )
     485                );
    459486        }
    460487}
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r12997 r13005  
    491491        public function sitewide_notices() {
    492492                // Do not show notices if user is not logged in.
    493                 if ( ! is_user_logged_in() )
     493                if ( ! is_user_logged_in() || is_admin() ) {
    494494                        return;
     495                }
    495496
    496497                // Add a class to determine if the admin bar is on or not.
Note: See TracChangeset for help on using the changeset viewer.