mpp_register_type ( $args )
Register a new media/gallery type.
Description
This function is used to register new gallery or media type.
Parameters
$args
- key (string) (Required) Unique identifier for this type. Example “photo”, “audio”,”video” etc.
- label (string) (Required) A name for this status. Example:- “Photo”, “Audio”, “Video”
- 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 status
- extensions (array) (Required ) An array of file extensions allowed for the media of this type.
Returns
It does not return anything.
Examples
The code shows how we register the Friends only privacy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function mpp_custom_register_presentation_type() { //video mpp_register_type( array( 'key' => 'presentation', 'label' => __( 'Presentation', 'mediapress' ), 'labels' => array( 'singular_name' => __( 'Presentation', 'mediapress' ), 'plural_name' => __( 'Presentations', 'mediapress' ) ), 'description' => __( 'Presentation media type taxonomy', 'mediapress' ), 'extensions' => array( 'ppt', 'pps', 'pptx', 'odp' ) ) ); } add_action( 'mpp_setup', 'mpp_custom_register_presentation_type', 11 ); |
In the above code, we have created a new media/gallery type called presentation and have allowed file types with extensions “ppt”, “pps”, “pptx”, “odp” to be uploadable to this type of gallery.
To make this media type available to a component, we need to tell the system that this type is supported for a component type. We can use the following code to make presentations available to sitewide and user component.
1 2 3 4 5 6 7 8 9 | function mpp_custom_register_presentation_type_support() { mpp_component_add_type_support( 'sitewide', 'presentation'); mpp_component_add_type_support( 'members', 'presentation'); } add_action( 'mpp_setup', 'mpp_custom_register_presentation_type', 12 ); |
The above code lets the system know that this type is available for the sitewide and members component. MediaPress will let admin choose whether to allow users to use this type or not.
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