LLMS_Post_Types::register_post_type( string $name, array $data )
Register a custom post type.
Description Description
Automatically checks for duplicates and filters data.
Parameters Parameters
- $name
-
(string) (Required) Post type name.
- $data
-
(array) (Required) Post type data.
Return Return
(WP_Post_Type|WP_Error)
Source Source
File: includes/class.llms.post-types.php
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | public static function register_post_type( $name , $data ) { if ( ! post_type_exists( $name ) ) { $unprefixed_name = str_replace ( 'llms_' , '' , $name ); if ( $unprefixed_name !== $name ) { $data = apply_filters_deprecated( "lifterlms_register_post_type_{$name}" , array ( $data ), '5.5.0' , "lifterlms_register_post_type_{$unprefixed_name}" ); } if ( empty ( $data [ 'template' ] ) ) { $data [ 'template' ] = self::get_template( $name ); } /** * Modify post type registration arguments of a LifterLMS custom post type. * * The dynamic portion of this hook refers to the post type's name with the `llms_` prefix * removed (if it exist). For example, to modify the arguments for the membership post type * (`llms_membership`) the full hook would be "lifterlms_register_post_type_membership". * * @since 3.13.0 * * @param array $data Post type registration arguments passed to `register_post_type()`. */ $data = apply_filters( "lifterlms_register_post_type_{$unprefixed_name}" , $data ); return register_post_type( $name , $data ); } return get_post_type_object( $name ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Automatically load templates from the llms-block-templates schema. Added return value. |
5.5.0 | Added lifterlms_register_post_type_${name} filters deprecation where $name is the the post type name, if the unprefixed name (removing 'llms_') is different from $name . E.g. it'll be triggered when registering when using lifterlms_register_post_type_llms_engagement but not when using lifterlms_register_post_type_course , for the latter, both the name and the unprefixed name are the same. |
3.13.0 | Introduced. |