mpp_register_component( $args )
Register a new component type.
Description
This function is used to register new component types. In core, we use it to register “sitewide”, “members” and “groups” component.
Parameters
$args
- key (string) (Required) Unique identifier for this component. Example “sitewide”, “members”,”groups”, “events” etc.
- label (string) (Required) A name for this component. Example:- “Sitewide Gallery”, “User Gallery”, “Group Gallery”
- labels (array) (Required ) An associative array with two keys, “singular_name”, “plural_name” the values represent labels.
- description (string) (Optional) A textual description of this component.
Returns
It does not return anything.
Examples
The code shows how we register the Sitewide gallery component
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function mpp_custom_register_component() { mpp_register_component( array( 'key' => 'sitewide', 'label' => __( 'Sitewide Galleries', 'mediapress' ), 'labels' => array( 'singular_name' => __( 'Sitewide Gallery', 'mediapress' ), 'plural_name' => __( 'Sitewide Galleries', 'mediapress' ) ), 'description' => __( 'Sitewide Galleries', 'mediapress' ), ) ); } add_action( 'mpp_setup', 'mpp_custom_register_component' ); |
please note that a component dictates the url permalink for a gallery/media and the url handling needs additional code not covered here.
Note:-
It must be used on or after “mpp_setup_core” action.
See also:-
Changelog
- Since 1.0.0
Source
medisapress/core/api/mpp-api.php