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
/**
* Retrieves the block template for use in post type registration.
*
* @since 6.0.0
*
* @param string $post_type The post type.
* @return array|null Returns the block template array or null if no template is defined for the post type.
*/
private static function get_template( $post_type ) {
if ( empty( self::$templates ) ) {
self::$templates = require LLMS_PLUGIN_DIR . 'includes/schemas/llms-block-templates.php';
}
return self::$templates[ $post_type ] ?? null;
}
/**
* Register a custom post type.
*
* Automatically checks for duplicates and filters data.
*
* @since 3.13.0
* @since 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.
* @since 6.0.0 Automatically load templates from the `llms-block-templates` schema.
* Added return value.
*
* @param string $name Post type name.
* @param array $data Post type data.
* @return WP_Post_Type|WP_Error
*/
public static function register_post_type( $name, $data ) {
if ( ! post_type_exists( $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. |