[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/ -> bp-core-blocks.php (source)

   1  <?php
   2  /**
   3   * Core BP Blocks functions.
   4   *
   5   * @package BuddyPress
   6   * @subpackage Core
   7   * @since 6.0.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * BuddyPress blocks require WordPress >= 5.0.0 & the BP REST API.
  15   *
  16   * @since 6.0.0
  17   *
  18   * @return bool True if the current installation supports BP Blocks.
  19   *              False otherwise.
  20   */
  21  function bp_support_blocks() {
  22      return bp_is_running_wp( '5.0.0' ) && bp_rest_api_is_available();
  23  }
  24  
  25  /**
  26   * Registers the BP Block components.
  27   *
  28   * @since 6.0.0
  29   */
  30  function bp_register_block_components() {
  31      wp_register_script(
  32          'bp-block-components',
  33          plugins_url( 'js/block-components.js', __FILE__ ),
  34          array(
  35              'wp-element',
  36              'wp-components',
  37              'wp-i18n',
  38              'wp-api-fetch',
  39              'wp-url',
  40          ),
  41          bp_get_version()
  42      );
  43  }
  44  add_action( 'bp_blocks_init', 'bp_register_block_components', 1 );
  45  
  46  /**
  47   * Filters the Block Editor settings to gather BuddyPress ones into a `bp` key.
  48   *
  49   * @since 6.0.0
  50   *
  51   * @param array $editor_settings Default editor settings.
  52   * @return array The editor settings including BP blocks specific ones.
  53   */
  54  function bp_blocks_editor_settings( $editor_settings = array() ) {
  55      /**
  56       * Filter here to include your BP Blocks specific settings.
  57       *
  58       * @since 6.0.0
  59       *
  60       * @param array $bp_editor_settings BP blocks specific editor settings.
  61       */
  62      $bp_editor_settings = (array) apply_filters( 'bp_blocks_editor_settings', array() );
  63  
  64      if ( $bp_editor_settings ) {
  65          $editor_settings['bp'] = $bp_editor_settings;
  66      }
  67  
  68      return $editor_settings;
  69  }
  70  add_filter( 'block_editor_settings', 'bp_blocks_editor_settings' );
  71  
  72  /**
  73   * Register a BuddyPress block type.
  74   *
  75   * @since 6.0.0
  76   *
  77   * @param array $args The registration arguments for the block type.
  78   * @return BP_Block   The BuddyPress block type object.
  79   */
  80  function bp_register_block( $args = array() ) {
  81      return new BP_Block( $args );
  82  }


Generated: Sat Nov 28 01:01:39 2020 Cross-referenced by PHPXref 0.7.1