Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/25/2023 10:17:33 PM (3 years ago)
Author:
imath
Message:

Update all BP Blocks & Modern JS PHP registration code

  • Use the metadata argument of the bp_register_block() function to load all BP Blocks JSON files.
  • Get BP Blocks dependencies using the @wordpress/scripts index.asset.php generated files.
  • Although the BP Blocks category has been replaced by the BP Blocks collection, leave the no more used bp_block_category() function in place in case some third party plugins are using it for their custom blocks.
  • PHPUnit tests: make sure to unregister all BP Blocks when using the BP_UnitTestCase->go_to() method.

See #8842
Fixes #8457
Closes https://github.com/buddypress/buddypress/pull/92

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-component.php

    r13456 r13464  
    12131213         *
    12141214         * @since 6.0.0
     1215         * @since 12.0.0 Use the WP Blocks API v2.
    12151216         *
    12161217         * @param array $blocks Optional. See BP_Component::blocks_init() for
     
    12211222                        array(
    12221223                                'bp/group' => array(
    1223                                         'name'               => 'bp/group',
    1224                                         'editor_script'      => 'bp-group-block',
    1225                                         'editor_script_url'  => plugins_url( 'js/blocks/group.js', dirname(  __FILE__ ) ),
    1226                                         'editor_script_deps' => array(
    1227                                                 'wp-blocks',
    1228                                                 'wp-element',
    1229                                                 'wp-components',
    1230                                                 'wp-i18n',
    1231                                                 'wp-block-editor',
    1232                                                 'wp-server-side-render',
    1233                                                 'bp-block-components',
    1234                                                 'bp-block-data',
    1235                                         ),
    1236                                         'style'              => 'bp-group-block',
    1237                                         'style_url'          => plugins_url( 'css/blocks/group.css', dirname( __FILE__ ) ),
    1238                                         'render_callback'    => 'bp_groups_render_group_block',
    1239                                         'attributes'         => array(
    1240                                                 'itemID'              => array(
    1241                                                         'type'    => 'integer',
    1242                                                         'default' => 0,
    1243                                                 ),
    1244                                                 'avatarSize'          => array(
    1245                                                         'type'    => 'string',
    1246                                                         'default' => 'full',
    1247                                                 ),
    1248                                                 'displayDescription'  => array(
    1249                                                         'type'    => 'boolean',
    1250                                                         'default' => true,
    1251                                                 ),
    1252                                                 'displayActionButton' => array(
    1253                                                         'type'    => 'boolean',
    1254                                                         'default' => true,
    1255                                                 ),
    1256                                                 'displayCoverImage'   => array(
    1257                                                         'type'    => 'boolean',
    1258                                                         'default' => true,
    1259                                                 ),
    1260                                         ),
     1224                                        'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-groups/blocks/group',
     1225                                        'render_callback' => 'bp_groups_render_group_block',
    12611226                                ),
    12621227                                'bp/groups' => array(
    1263                                         'name'               => 'bp/groups',
    1264                                         'editor_script'      => 'bp-groups-block',
    1265                                         'editor_script_url'  => plugins_url( 'js/blocks/groups.js', dirname( __FILE__ ) ),
    1266                                         'editor_script_deps' => array(
    1267                                                 'wp-blocks',
    1268                                                 'wp-element',
    1269                                                 'wp-components',
    1270                                                 'wp-i18n',
    1271                                                 'wp-api-fetch',
    1272                                                 'wp-url',
    1273                                                 'wp-block-editor',
    1274                                                 'bp-block-components',
    1275                                                 'bp-block-data',
    1276                                                 'lodash',
    1277                                         ),
    1278                                         'style'              => 'bp-groups-block',
    1279                                         'style_url'          => plugins_url( 'css/blocks/groups.css', dirname( __FILE__ ) ),
    1280                                         'attributes'         => array(
    1281                                                 'itemIDs'          => array(
    1282                                                         'type'  => 'array',
    1283                                                         'items' => array(
    1284                                                                 'type' => 'integer',
    1285                                                         ),
    1286                                                 ),
    1287                                                 'avatarSize'       => array(
    1288                                                         'type'    => 'string',
    1289                                                         'default' => 'full',
    1290                                                 ),
    1291                                                 'displayGroupName' => array(
    1292                                                         'type'    => 'boolean',
    1293                                                         'default' => true,
    1294                                                 ),
    1295                                                 'extraInfo'        => array(
    1296                                                         'type'    => 'string',
    1297                                                         'default' => 'none',
    1298                                                         'enum'    => array( 'description', 'popular', 'active', 'none' ),
    1299                                                 ),
    1300                                                 'layoutPreference' => array(
    1301                                                         'type'    => 'string',
    1302                                                         'default' => 'list',
    1303                                                         'enum'    => array( 'list', 'grid' ),
    1304                                                 ),
    1305                                                 'columns'          => array(
    1306                                                         'type'    => 'number',
    1307                                                         'default' => 2,
    1308                                                 ),
    1309                                         ),
    1310                                         'render_callback'    => 'bp_groups_render_groups_block',
     1228                                        'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-groups/blocks/groups',
     1229                                        'render_callback' => 'bp_groups_render_groups_block',
    13111230                                ),
    13121231                                'bp/dynamic-groups' => array(
    1313                                         'name'               => 'bp/dynamic-groups',
    1314                                         'editor_script'      => 'bp-dynamic-groups-block',
    1315                                         'editor_script_url'  => plugins_url( 'js/blocks/dynamic-groups.js', dirname( __FILE__ ) ),
    1316                                         'editor_script_deps' => array(
    1317                                                 'wp-blocks',
    1318                                                 'wp-element',
    1319                                                 'wp-components',
    1320                                                 'wp-i18n',
    1321                                                 'wp-block-editor',
    1322                                                 'wp-server-side-render',
    1323                                         ),
    1324                                         'style'              => 'bp-dynamic-groups-block',
    1325                                         'style_url'          => plugins_url( 'css/blocks/dynamic-groups.css', dirname( __FILE__ ) ),
    1326                                         'attributes'         => array(
    1327                                                 'title'        => array(
    1328                                                         'type'    => 'string',
    1329                                                         'default' => __( 'Groups', 'buddypress' ),
    1330                                                 ),
    1331                                                 'maxGroups'    => array(
    1332                                                         'type'    => 'number',
    1333                                                         'default' => 5,
    1334                                                 ),
    1335                                                 'groupDefault' => array(
    1336                                                         'type'    => 'string',
    1337                                                         'default' => 'active',
    1338                                                 ),
    1339                                                 'linkTitle'    => array(
    1340                                                         'type'    => 'boolean',
    1341                                                         'default' => false,
    1342                                                 ),
    1343                                         ),
    1344                                         'render_callback'    => 'bp_groups_render_dynamic_groups_block',
     1232                                        'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-groups/blocks/dynamic-groups',
     1233                                        'render_callback' => 'bp_groups_render_dynamic_groups_block',
    13451234                                ),
    13461235                        )
Note: See TracChangeset for help on using the changeset viewer.