BP_Component::setup_globals( array $args = array() )
Set up component global variables.
Description
Parameters
- $args
-
(Optional) All values are optional.
- 'slug'
(string) The component slug. Used to construct certain URLs, such as 'friends' in <a href="http://example.com/members/joe/friends/">http://example.com/members/joe/friends/</a>. Default: the value of $this->id. - 'root_slug'
(string) The component root slug. Note that this value is generally unused if the component has a root directory (the slug will be overridden by the post_name of the directory page). Default: the slug of the directory page if one is found, otherwise an empty string. - 'has_directory'
(bool) Set to true if the component requires an associated WordPress page. - 'notification_callback'
(callable) Optional. The callable function that formats the component's notifications. - 'search_term'
(string) Optional. The placeholder text in the component directory search box. Eg, 'Search Groups...'. - 'global_tables'
(array) Optional. An array of database table names. - 'meta_tables'
(array) Optional. An array of metadata table names.
Default value: array()
- 'slug'
Source
File: bp-core/classes/class-bp-component.php
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | public function setup_globals( $args = array () ) { /** Slugs ************************************************************ */ // If a WP directory page exists for the component, it should // be the default value of 'root_slug'. $default_root_slug = isset( buddypress()->pages->{ $this ->id}->slug ) ? buddypress()->pages->{ $this ->id}->slug : '' ; $r = wp_parse_args( $args , array ( 'slug' => $this ->id, 'root_slug' => $default_root_slug , 'has_directory' => false, 'directory_title' => '' , 'notification_callback' => '' , 'search_string' => '' , 'global_tables' => '' , 'meta_tables' => '' , ) ); /** * Filters the slug to be used for the permalink URI chunk after root. * * @since BuddyPress 1.5.0 * * @param string $value Slug to use in permalink URI chunk. */ $this ->slug = apply_filters( 'bp_' . $this ->id . '_slug' , $r [ 'slug' ] ); /** * Filters the slug used for root directory. * * @since BuddyPress 1.5.0 * * @param string $value Root directory slug. */ $this ->root_slug = apply_filters( 'bp_' . $this ->id . '_root_slug' , $r [ 'root_slug' ] ); /** * Filters the component's top-level directory if available. * * @since BuddyPress 1.5.0 * * @param bool $value Whether or not there is a top-level directory. */ $this ->has_directory = apply_filters( 'bp_' . $this ->id . '_has_directory' , $r [ 'has_directory' ] ); /** * Filters the component's directory title. * * @since BuddyPress 2.0.0 * * @param string $value Title to use for the directory. */ $this ->directory_title = apply_filters( 'bp_' . $this ->id . '_directory_title' , $r [ 'directory_title' ] ); /** * Filters the placeholder text for search inputs for component. * * @since BuddyPress 1.5.0 * * @param string $value Name to use in search input placeholders. */ $this ->search_string = apply_filters( 'bp_' . $this ->id . '_search_string' , $r [ 'search_string' ] ); /** * Filters the callable function that formats the component's notifications. * * @since BuddyPress 1.5.0 * * @param string $value Function callback. */ $this ->notification_callback = apply_filters( 'bp_' . $this ->id . '_notification_callback' , $r [ 'notification_callback' ] ); // Set the global table names, if applicable. if ( ! empty ( $r [ 'global_tables' ] ) ) { $this ->register_global_tables( $r [ 'global_tables' ] ); } // Set the metadata table, if applicable. if ( ! empty ( $r [ 'meta_tables' ] ) ) { $this ->register_meta_tables( $r [ 'meta_tables' ] ); } /** BuddyPress ******************************************************* */ // Register this component in the loaded components array. buddypress()->loaded_components[ $this ->slug] = $this ->id; /** * Fires at the end of the setup_globals method inside BP_Component. * * This is a dynamic hook that is based on the component string ID. * * @since BuddyPress 1.5.0 */ do_action( 'bp_' . $this ->id . '_setup_globals' ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.5.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.