[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-members/classes/ -> class-bp-members-component.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Member Loader.
   4   *
   5   * @package BuddyPress
   6   * @subpackage Members
   7   * @since 1.5.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Defines the BuddyPress Members Component.
  15   *
  16   * @since 1.5.0
  17   */
  18  class BP_Members_Component extends BP_Component {
  19  
  20      /**
  21       * Member types.
  22       *
  23       * @see bp_register_member_type()
  24       *
  25       * @since 2.2.0
  26       * @var array
  27       */
  28      public $types = array();
  29  
  30      /**
  31       * Start the members component creation process.
  32       *
  33       * @since 1.5.0
  34       */
  35  	public function __construct() {
  36          parent::start(
  37              'members',
  38              __( 'Members', 'buddypress' ),
  39              buddypress()->plugin_dir,
  40              array(
  41                  'adminbar_myaccount_order' => 20,
  42                  'search_query_arg' => 'members_search',
  43              )
  44          );
  45      }
  46  
  47      /**
  48       * Include bp-members files.
  49       *
  50       * @since 1.5.0
  51       *
  52       * @see BP_Component::includes() for description of parameters.
  53       *
  54       * @param array $includes See {@link BP_Component::includes()}.
  55       */
  56  	public function includes( $includes = array() ) {
  57  
  58          // Always include these files.
  59          $includes = array(
  60              'filters',
  61              'template',
  62              'adminbar',
  63              'functions',
  64              'blocks',
  65              'widgets',
  66              'cache',
  67          );
  68  
  69          if ( bp_is_active( 'activity' ) ) {
  70              $includes[] = 'activity';
  71          }
  72  
  73          // Include these only if in admin.
  74          if ( is_admin() ) {
  75              $includes[] = 'admin';
  76          }
  77  
  78          parent::includes( $includes );
  79      }
  80  
  81      /**
  82       * Late includes method.
  83       *
  84       * Only load up certain code when on specific pages.
  85       *
  86       * @since 3.0.0
  87       */
  88  	public function late_includes() {
  89          // Bail if PHPUnit is running.
  90          if ( defined( 'BP_TESTS_DIR' ) ) {
  91              return;
  92          }
  93  
  94          // Members.
  95          if ( bp_is_members_component() ) {
  96              // Actions - Random member handler.
  97              if ( isset( $_GET['random-member'] ) ) {
  98                  require $this->path . 'bp-members/actions/random.php';
  99              }
 100  
 101              // Screens - Directory.
 102              if ( bp_is_members_directory() ) {
 103                  require $this->path . 'bp-members/screens/directory.php';
 104              }
 105          }
 106  
 107          // Members - User main nav screen.
 108          if ( bp_is_user() ) {
 109              require $this->path . 'bp-members/screens/profile.php';
 110  
 111              // Action - Delete avatar.
 112              if ( is_user_logged_in()&& bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) {
 113                  require $this->path . 'bp-members/actions/delete-avatar.php';
 114              }
 115  
 116              // Sub-nav items.
 117              if ( is_user_logged_in() &&
 118                  in_array( bp_current_action(), array( 'change-avatar', 'change-cover-image' ), true )
 119              ) {
 120                  require $this->path . 'bp-members/screens/' . bp_current_action() . '.php';
 121              }
 122          }
 123  
 124          // Members - Theme compatibility.
 125          if ( bp_is_members_component() || bp_is_user() ) {
 126              new BP_Members_Theme_Compat();
 127          }
 128  
 129          // Registration / Activation.
 130          if ( bp_is_register_page() || bp_is_activation_page() ) {
 131              if ( bp_is_register_page() ) {
 132                  require $this->path . 'bp-members/screens/register.php';
 133              } else {
 134                  require $this->path . 'bp-members/screens/activate.php';
 135              }
 136  
 137              // Theme compatibility.
 138              new BP_Registration_Theme_Compat();
 139          }
 140      }
 141  
 142      /**
 143       * Set up bp-members global settings.
 144       *
 145       * The BP_MEMBERS_SLUG constant is deprecated, and only used here for
 146       * backwards compatibility.
 147       *
 148       * @since 1.5.0
 149       *
 150       * @see BP_Component::setup_globals() for description of parameters.
 151       *
 152       * @param array $args See {@link BP_Component::setup_globals()}.
 153       */
 154  	public function setup_globals( $args = array() ) {
 155          global $wpdb;
 156  
 157          $bp = buddypress();
 158  
 159          /** Component Globals ************************************************
 160           */
 161  
 162          // Define a slug, as a fallback for backpat.
 163          if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
 164              define( 'BP_MEMBERS_SLUG', $this->id );
 165          }
 166  
 167          // Fetch the default directory title.
 168          $default_directory_titles = bp_core_get_directory_page_default_titles();
 169          $default_directory_title  = $default_directory_titles[$this->id];
 170  
 171          // Override any passed args.
 172          $args = array(
 173              'slug'            => BP_MEMBERS_SLUG,
 174              'root_slug'       => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
 175              'has_directory'   => true,
 176              'directory_title' => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title,
 177              'search_string'   => __( 'Search Members...', 'buddypress' ),
 178              'global_tables'   => array(
 179                  'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',
 180                  'table_name_signups'       => $wpdb->base_prefix . 'signups', // Signups is a global WordPress table.
 181              )
 182          );
 183  
 184          parent::setup_globals( $args );
 185  
 186          /** Logged in user ***************************************************
 187           */
 188  
 189          // The core userdata of the user who is currently logged in.
 190          $bp->loggedin_user->userdata       = bp_core_get_core_userdata( bp_loggedin_user_id() );
 191  
 192          // Fetch the full name for the logged in user.
 193          $bp->loggedin_user->fullname       = isset( $bp->loggedin_user->userdata->display_name ) ? $bp->loggedin_user->userdata->display_name : '';
 194  
 195          // Hits the DB on single WP installs so get this separately.
 196          $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
 197  
 198          // The domain for the user currently logged in. eg: http://example.com/members/andy.
 199          $bp->loggedin_user->domain         = bp_core_get_user_domain( bp_loggedin_user_id() );
 200  
 201          /** Displayed user ***************************************************
 202           */
 203  
 204          // The core userdata of the user who is currently being displayed.
 205          $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
 206  
 207          // Fetch the full name displayed user.
 208          $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : '';
 209  
 210          // The domain for the user currently being displayed.
 211          $bp->displayed_user->domain   = bp_core_get_user_domain( bp_displayed_user_id() );
 212  
 213          // Initialize the nav for the members component.
 214          $this->nav = new BP_Core_Nav();
 215  
 216          // If A user is displayed, check if there is a front template
 217          if ( bp_get_displayed_user() ) {
 218              $bp->displayed_user->front_template = bp_displayed_user_get_front_template();
 219          }
 220  
 221          /** Signup ***********************************************************
 222           */
 223  
 224          $bp->signup = new stdClass;
 225  
 226          /** Profiles Fallback ************************************************
 227           */
 228  
 229          if ( ! bp_is_active( 'xprofile' ) ) {
 230              $bp->profile       = new stdClass;
 231              $bp->profile->slug = 'profile';
 232              $bp->profile->id   = 'profile';
 233          }
 234      }
 235  
 236      /**
 237       * Set up canonical stack for this component.
 238       *
 239       * @since 2.1.0
 240       */
 241  	public function setup_canonical_stack() {
 242          $bp = buddypress();
 243  
 244          /** Default Profile Component ****************************************
 245           */
 246          if ( bp_displayed_user_has_front_template() ) {
 247              $bp->default_component = 'front';
 248          } elseif ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
 249              $bp->default_component = bp_get_activity_slug();
 250          } else {
 251              $bp->default_component = ( 'xprofile' === $bp->profile->id ) ? 'profile' : $bp->profile->id;
 252          }
 253  
 254          if ( defined( 'BP_DEFAULT_COMPONENT' ) && BP_DEFAULT_COMPONENT ) {
 255              $default_component = BP_DEFAULT_COMPONENT;
 256              if ( 'profile' === $default_component ) {
 257                  $default_component = 'xprofile';
 258              }
 259  
 260              if ( bp_is_active( $default_component ) ) {
 261                  $bp->default_component = BP_DEFAULT_COMPONENT;
 262              }
 263          }
 264  
 265          /** Canonical Component Stack ****************************************
 266           */
 267  
 268          if ( bp_displayed_user_id() ) {
 269              $bp->canonical_stack['base_url'] = bp_displayed_user_domain();
 270  
 271              if ( bp_current_component() ) {
 272                  $bp->canonical_stack['component'] = bp_current_component();
 273              }
 274  
 275              if ( bp_current_action() ) {
 276                  $bp->canonical_stack['action'] = bp_current_action();
 277              }
 278  
 279              if ( !empty( $bp->action_variables ) ) {
 280                  $bp->canonical_stack['action_variables'] = bp_action_variables();
 281              }
 282  
 283              // Looking at the single member root/home, so assume the default.
 284              if ( ! bp_current_component() ) {
 285                  $bp->current_component = $bp->default_component;
 286  
 287              // The canonical URL will not contain the default component.
 288              } elseif ( bp_is_current_component( $bp->default_component ) && ! bp_current_action() ) {
 289                  unset( $bp->canonical_stack['component'] );
 290              }
 291  
 292              // If we're on a spammer's profile page, only users with the 'bp_moderate' cap
 293              // can view subpages on the spammer's profile.
 294              //
 295              // users without the cap trying to access a spammer's subnav page will get
 296              // redirected to the root of the spammer's profile page.  this occurs by
 297              // by removing the component in the canonical stack.
 298              if ( bp_is_user_spammer( bp_displayed_user_id() ) && ! bp_current_user_can( 'bp_moderate' ) ) {
 299                  unset( $bp->canonical_stack['component'] );
 300              }
 301          }
 302      }
 303  
 304      /**
 305       * Get the Avatar and Cover image subnavs.
 306       *
 307       * @since 6.0.0
 308       *
 309       * @return array The Avatar and Cover image subnavs.
 310       */
 311  	public function get_avatar_cover_image_subnavs() {
 312          $subnavs = array();
 313  
 314          $access       = bp_core_can_edit_settings();
 315          $slug         = bp_get_profile_slug();
 316          $profile_link = bp_get_members_component_link( $slug );
 317  
 318          // Change Avatar.
 319          if ( buddypress()->avatar->show_avatars ) {
 320              $subnavs[] = array(
 321                  'name'            => _x( 'Change Profile Photo', 'Profile header sub menu', 'buddypress' ),
 322                  'slug'            => 'change-avatar',
 323                  'parent_url'      => $profile_link,
 324                  'parent_slug'     => $slug,
 325                  'screen_function' => 'bp_members_screen_change_avatar',
 326                  'position'        => 30,
 327                  'user_has_access' => $access
 328              );
 329          }
 330  
 331          // Change Cover image.
 332          if ( bp_displayed_user_use_cover_image_header() ) {
 333              $subnavs[] = array(
 334                  'name'            => _x( 'Change Cover Image', 'Profile header sub menu', 'buddypress' ),
 335                  'slug'            => 'change-cover-image',
 336                  'parent_url'      => $profile_link,
 337                  'parent_slug'     => $slug,
 338                  'screen_function' => 'bp_members_screen_change_cover_image',
 339                  'position'        => 40,
 340                  'user_has_access' => $access
 341              );
 342          }
 343  
 344          return $subnavs;
 345      }
 346  
 347      /**
 348       * Set up fall-back component navigation if XProfile is inactive.
 349       *
 350       * @since 1.5.0
 351       *
 352       * @see BP_Component::setup_nav() for a description of arguments.
 353       *
 354       * @param array $main_nav Optional. See BP_Component::setup_nav() for
 355       *                        description.
 356       * @param array $sub_nav  Optional. See BP_Component::setup_nav() for
 357       *                        description.
 358       */
 359  	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
 360  
 361          // Don't set up navigation if there's no member.
 362          if ( ! is_user_logged_in() && ! bp_is_user() ) {
 363              return;
 364          }
 365  
 366          $is_xprofile_active = bp_is_active( 'xprofile' );
 367  
 368          // Bail if XProfile component is active and there's no custom front page for the user.
 369          if ( ! bp_displayed_user_has_front_template() && $is_xprofile_active ) {
 370              add_action( 'bp_xprofile_setup_nav', array( $this, 'setup_xprofile_nav' ) );
 371              return;
 372          }
 373  
 374          // Determine user to use.
 375          if ( bp_displayed_user_domain() ) {
 376              $user_domain = bp_displayed_user_domain();
 377          } elseif ( bp_loggedin_user_domain() ) {
 378              $user_domain = bp_loggedin_user_domain();
 379          } else {
 380              return;
 381          }
 382  
 383          // Set slug to profile in case the xProfile component is not active
 384          $slug = bp_get_profile_slug();
 385  
 386          // Defaults to empty navs
 387          $this->main_nav = array();
 388          $this->sub_nav  = array();
 389  
 390          if ( ! $is_xprofile_active ) {
 391              $this->main_nav = array(
 392                  'name'                => _x( 'Profile', 'Member profile main navigation', 'buddypress' ),
 393                  'slug'                => $slug,
 394                  'position'            => 20,
 395                  'screen_function'     => 'bp_members_screen_display_profile',
 396                  'default_subnav_slug' => 'public',
 397                  'item_css_id'         => buddypress()->profile->id
 398              );
 399  
 400          /**
 401           * The xProfile component is active.
 402           *
 403           * We need to make sure the Change Avatar and Change Cover Image subnavs are
 404           * added just like it was the case before.
 405           */
 406          } else {
 407              add_action( 'bp_xprofile_setup_nav', array( $this, 'setup_xprofile_nav' ) );
 408          }
 409  
 410          /**
 411           * Setup the subnav items for the member profile.
 412           *
 413           * This is required in case there's a custom front or in case the xprofile component
 414           * is not active.
 415           */
 416          $this->sub_nav = array(
 417              'name'            => _x( 'View', 'Member profile view', 'buddypress' ),
 418              'slug'            => 'public',
 419              'parent_url'      => trailingslashit( $user_domain . $slug ),
 420              'parent_slug'     => $slug,
 421              'screen_function' => 'bp_members_screen_display_profile',
 422              'position'        => 10
 423          );
 424  
 425          /**
 426           * If there's a front template the members component nav
 427           * will be there to display the user's front page.
 428           */
 429          if ( bp_displayed_user_has_front_template() ) {
 430              $main_nav = array(
 431                  'name'                => _x( 'Home', 'Member Home page', 'buddypress' ),
 432                  'slug'                => 'front',
 433                  'position'            => 5,
 434                  'screen_function'     => 'bp_members_screen_display_profile',
 435                  'default_subnav_slug' => 'public',
 436              );
 437  
 438              // We need a dummy subnav for the front page to load.
 439              $front_subnav = $this->sub_nav;
 440              $front_subnav['parent_slug'] = 'front';
 441  
 442              // In case the subnav is displayed in the front template
 443              $front_subnav['parent_url'] = trailingslashit( $user_domain . 'front' );
 444  
 445              // Set the subnav
 446              $sub_nav[] = $front_subnav;
 447  
 448              /**
 449               * If the profile component is not active, we need to create a new
 450               * nav to display the WordPress profile.
 451               */
 452              if ( ! $is_xprofile_active ) {
 453                  add_action( 'bp_members_setup_nav', array( $this, 'setup_profile_nav' ) );
 454              }
 455  
 456          /**
 457           * If there's no front template and xProfile is not active, the members
 458           * component nav will be there to display the WordPress profile
 459           */
 460          } else {
 461              $main_nav  = $this->main_nav;
 462              $sub_nav   = array( $this->sub_nav );
 463  
 464              if ( ! $is_xprofile_active ) {
 465                  $sub_nav = array_merge( $sub_nav, $this->get_avatar_cover_image_subnavs() );
 466              }
 467          }
 468  
 469  
 470          parent::setup_nav( $main_nav, $sub_nav );
 471      }
 472  
 473      /**
 474       * Set up a profile nav in case the xProfile
 475       * component is not active and a front template is
 476       * used.
 477       *
 478       * @since 2.6.0
 479       */
 480  	public function setup_profile_nav() {
 481          if ( empty( $this->main_nav ) || empty( $this->sub_nav ) ) {
 482              return;
 483          }
 484  
 485          // Add the main nav
 486          bp_core_new_nav_item( $this->main_nav, 'members' );
 487  
 488          // Add the sub nav item.
 489          bp_core_new_subnav_item( $this->sub_nav, 'members' );
 490  
 491          // Get the Avatar and cover image subnavs.
 492          $this->setup_xprofile_nav();
 493      }
 494  
 495      /**
 496       * Set up the xProfile nav.
 497       *
 498       * @since 6.0.0
 499       */
 500  	public function setup_xprofile_nav() {
 501          // Get the Avatar and cover image subnavs.
 502          $items = $this->get_avatar_cover_image_subnavs();
 503  
 504          foreach ( $items as $item ) {
 505              bp_core_new_subnav_item( $item, 'members' );
 506          }
 507      }
 508  
 509      /**
 510       * Get the Avatar and Cover image admin navs.
 511       *
 512       * @since 6.0.0
 513       *
 514       * @param  string $admin_bar_menu_id The Admin bar menu ID to attach sub items to.
 515       * @return array                     The Avatar and Cover image admin navs.
 516       */
 517  	public function get_avatar_cover_image_admin_navs( $admin_bar_menu_id = '' ) {
 518          $wp_admin_nav = array();
 519          $profile_link = trailingslashit( bp_loggedin_user_domain() . bp_get_profile_slug() );
 520  
 521          if ( ! $admin_bar_menu_id ) {
 522              $admin_bar_menu_id = $this->id;
 523          }
 524  
 525          // Edit Avatar.
 526          if ( buddypress()->avatar->show_avatars ) {
 527              $wp_admin_nav[] = array(
 528                  'parent'   => 'my-account-' . $admin_bar_menu_id,
 529                  'id'       => 'my-account-' . $admin_bar_menu_id . '-change-avatar',
 530                  'title'    => _x( 'Change Profile Photo', 'My Account Profile sub nav', 'buddypress' ),
 531                  'href'     => trailingslashit( $profile_link . 'change-avatar' ),
 532                  'position' => 30
 533              );
 534          }
 535  
 536          // Edit Cover Image
 537          if ( bp_displayed_user_use_cover_image_header() ) {
 538              $wp_admin_nav[] = array(
 539                  'parent'   => 'my-account-' . $admin_bar_menu_id,
 540                  'id'       => 'my-account-' . $admin_bar_menu_id . '-change-cover-image',
 541                  'title'    => _x( 'Change Cover Image', 'My Account Profile sub nav', 'buddypress' ),
 542                  'href'     => trailingslashit( $profile_link . 'change-cover-image' ),
 543                  'position' => 40
 544              );
 545          }
 546  
 547          return $wp_admin_nav;
 548      }
 549  
 550      /**
 551       * Set up the Admin Bar.
 552       *
 553       * @since 6.0.0
 554       *
 555       * @param array $wp_admin_nav Admin Bar items.
 556       */
 557  	public function setup_admin_bar( $wp_admin_nav = array() ) {
 558          // Menus for logged in user.
 559          if ( is_user_logged_in() ) {
 560              $profile_link = trailingslashit( bp_loggedin_user_domain() . bp_get_profile_slug() );
 561  
 562              if ( ! bp_is_active( 'xprofile' ) ) {
 563                  // Add the "Profile" sub menu.
 564                  $wp_admin_nav[] = array(
 565                      'parent' => buddypress()->my_account_menu_id,
 566                      'id'     => 'my-account-' . $this->id,
 567                      'title'  => _x( 'Profile', 'My Account Profile', 'buddypress' ),
 568                      'href'   => $profile_link
 569                  );
 570  
 571                  // View Profile.
 572                  $wp_admin_nav[] = array(
 573                      'parent'   => 'my-account-' . $this->id,
 574                      'id'       => 'my-account-' . $this->id . '-public',
 575                      'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
 576                      'href'     => $profile_link,
 577                      'position' => 10
 578                  );
 579  
 580                  $wp_admin_nav = array_merge( $wp_admin_nav, $this->get_avatar_cover_image_admin_navs() );
 581  
 582              /**
 583               * The xProfile is active.
 584               *
 585               * Add the Change Avatar and Change Cover Image Admin Bar items
 586               * to the xProfile Admin Bar Menu.
 587               */
 588              } else {
 589                  add_filter( 'bp_xprofile_admin_nav', array( $this, 'setup_xprofile_admin_nav' ), 2 );
 590              }
 591          }
 592  
 593          parent::setup_admin_bar( $wp_admin_nav );
 594      }
 595  
 596      /**
 597       * Adds "Profile > Change Avatar" & "Profile > Change Cover Image" subnav item
 598       * under the "Profile" adminbar menu.
 599       *
 600       * @since 6.0.0
 601       *
 602       * @param array $wp_admin_nav The Profile adminbar nav array.
 603       * @return array
 604       */
 605  	public function setup_xprofile_admin_nav( $wp_admin_nav ) {
 606          $items = $this->get_avatar_cover_image_admin_navs( buddypress()->profile->id );
 607  
 608          if ( $items ) {
 609              $wp_admin_nav = array_merge( $wp_admin_nav, $items );
 610          }
 611  
 612          return $wp_admin_nav;
 613      }
 614  
 615      /**
 616       * Set up the title for pages and <title>.
 617       *
 618       * @since 1.5.0
 619       */
 620  	public function setup_title() {
 621          $bp = buddypress();
 622  
 623          if ( bp_is_my_profile() ) {
 624              $bp->bp_options_title = __( 'You', 'buddypress' );
 625          } elseif ( bp_is_user() ) {
 626              $bp->bp_options_title  = bp_get_displayed_user_fullname();
 627              $bp->bp_options_avatar = bp_core_fetch_avatar( array(
 628                  'item_id' => bp_displayed_user_id(),
 629                  'type'    => 'thumb',
 630                  'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), $bp->bp_options_title )
 631              ) );
 632          }
 633  
 634          parent::setup_title();
 635      }
 636  
 637      /**
 638       * Setup cache groups.
 639       *
 640       * @since 2.2.0
 641       */
 642  	public function setup_cache_groups() {
 643  
 644          // Global groups.
 645          wp_cache_add_global_groups( array(
 646              'bp_last_activity',
 647              'bp_member_type'
 648          ) );
 649  
 650          parent::setup_cache_groups();
 651      }
 652  
 653      /**
 654       * Init the BP REST API.
 655       *
 656       * @since 5.0.0
 657       * @since 6.0.0 Adds the Member Cover and Signup REST endpoints.
 658       *
 659       * @param array $controllers Optional. See BP_Component::rest_api_init() for
 660       *                           description.
 661       */
 662  	public function rest_api_init( $controllers = array() ) {
 663          $controllers = array(
 664              /**
 665               * As the Members component is always loaded,
 666               * let's register the Components endpoint here.
 667               */
 668              'BP_REST_Components_Endpoint',
 669              'BP_REST_Members_Endpoint',
 670              'BP_REST_Attachments_Member_Avatar_Endpoint',
 671          );
 672  
 673          if ( bp_is_active( 'members', 'cover_image' ) ) {
 674              $controllers[] = 'BP_REST_Attachments_Member_Cover_Endpoint';
 675          }
 676  
 677          if ( bp_get_signup_allowed() ) {
 678              $controllers[] = 'BP_REST_Signup_Endpoint';
 679          }
 680  
 681          parent::rest_api_init( $controllers );
 682      }
 683  
 684      /**
 685       * Register the BP Members Blocks.
 686       *
 687       * @since 6.0.0
 688       *
 689       * @param array $blocks Optional. See BP_Component::blocks_init() for
 690       *                      description.
 691       */
 692  	public function blocks_init( $blocks = array() ) {
 693          parent::blocks_init(
 694              array(
 695                  'bp/member' => array(
 696                      'name'               => 'bp/member',
 697                      'editor_script'      => 'bp-member-block',
 698                      'editor_script_url'  => plugins_url( 'js/blocks/member.js', dirname( __FILE__ ) ),
 699                      'editor_script_deps' => array(
 700                          'wp-blocks',
 701                          'wp-element',
 702                          'wp-components',
 703                          'wp-i18n',
 704                          'wp-editor',
 705                          'wp-compose',
 706                          'wp-data',
 707                          'wp-block-editor',
 708                          'bp-block-components',
 709                      ),
 710                      'style'              => 'bp-member-block',
 711                      'style_url'          => plugins_url( 'css/blocks/member.css', dirname( __FILE__ ) ),
 712                      'render_callback'    => 'bp_members_render_member_block',
 713                      'attributes'         => array(
 714                          'itemID'              => array(
 715                              'type'    => 'integer',
 716                              'default' => 0,
 717                          ),
 718                          'avatarSize'          => array(
 719                              'type'    => 'string',
 720                              'default' => 'full',
 721                          ),
 722                          'displayMentionSlug'  => array(
 723                              'type'    => 'boolean',
 724                              'default' => true,
 725                          ),
 726                          'displayActionButton' => array(
 727                              'type'    => 'boolean',
 728                              'default' => true,
 729                          ),
 730                          'displayCoverImage'   => array(
 731                              'type'    => 'boolean',
 732                              'default' => true,
 733                          ),
 734                      ),
 735                  ),
 736              )
 737          );
 738      }
 739  }


Generated: Sun Sep 20 01:01:32 2020 Cross-referenced by PHPXref 0.7.1