IP : 13.58.74.190Hostname : server86.web-hosting.comKernel : Linux server86.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64Disable Function : None :) OS : Linux
PATH:
/
home/
servlmvm/
./
./
www/
wp-includes/
class-wp-block-templates-registry.php/
/
/** * Core class used for interacting with templates. * * @since 6.7.0 */ final class WP_Block_Templates_Registry { /** * Registered templates, as `$name => $instance` pairs. * * @since 6.7.0 * @var WP_Block_Template[] $registered_block_templates Registered templates. */ private $registered_templates = array();
/** * Container for the main instance of the class. * * @since 6.7.0 * @var WP_Block_Templates_Registry|null */ private static $instance = null;
/** * Registers a template. * * @since 6.7.0 * * @param string $template_name Template name including namespace. * @param array $args Optional. Array of template arguments. * @return WP_Block_Template|WP_Error The registered template on success, or WP_Error on failure. */ public function register( $template_name, $args = array() ) {
/** * Retrieves all registered templates. * * @since 6.7.0 * * @return WP_Block_Template[] Associative array of `$template_name => $template` pairs. */ public function get_all_registered() { return $this->registered_templates; }
/** * Retrieves a registered template by its name. * * @since 6.7.0 * * @param string $template_name Template name including namespace. * @return WP_Block_Template|null The registered template, or null if it is not registered. */ public function get_registered( $template_name ) { if ( ! $this->is_registered( $template_name ) ) { return null; }
/** * Retrieves a registered template by its slug. * * @since 6.7.0 * * @param string $template_slug Slug of the template. * @return WP_Block_Template|null The registered template, or null if it is not registered. */ public function get_by_slug( $template_slug ) { $all_templates = $this->get_all_registered();
if ( ! $all_templates ) { return null; }
foreach ( $all_templates as $template ) { if ( $template->slug === $template_slug ) { return $template; } }
return null; }
/** * Retrieves registered templates matching a query. * * @since 6.7.0 * * @param array $query { * Arguments to retrieve templates. Optional, empty by default. * * @type string[] $slug__in List of slugs to include. * @type string[] $slug__not_in List of slugs to skip. * @type string $post_type Post type to get the templates for. * } * @return WP_Block_Template[] Associative array of `$template_name => $template` pairs. */ public function get_by_query( $query = array() ) { $all_templates = $this->get_all_registered();
/** * Utility method to retrieve the main instance of the class. * * The instance will be created if it does not exist yet. * * @since 6.7.0 * * @return WP_Block_Templates_Registry The main instance. */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); }