getMessage() ) ); } } /** * Unregisters the specified layout component from the Component Registry * for use in the Layouts block. * * @return mixed Boolean true if component unregistered. WP_Error object if an error occurs. * @param string $type The component type to be unregistered. * @param string $key The unique layout key to be unregistered. */ function blockspare_unregister_layout_component( $type, $key ) { $registry = Component_Registry::instance(); try { $registry::remove( $type, $key ); return true; } catch ( Exception $exception ) { return new WP_Error( esc_html( $exception->getMessage() ) ); } } /** * Retrieves the specified layout component. * * @param string $type The layout component type. * @param string $key The layout component's unique key. * * @return mixed|WP_Error */ function blockspare_get_layout_component( $type, $key ) { if ( empty( $type ) ) { return new WP_Error( esc_html__( 'You must supply a type to retrieve a layout component.', 'blockspare' ) ); } if ( empty( $key ) ) { return new WP_Error( esc_html__( 'You must supply a key to retrieve a layout component.', 'blockspare' ) ); } $type = sanitize_key( $type ); $key = sanitize_key( $key ); $registry = Component_Registry::instance(); try { return $registry::get( $type, $key ); } catch ( Exception $exception ) { return new WP_Error( esc_html( $exception->getMessage() ) ); } } /** * Gets the registered layouts. * * @return array Array of registered layouts. */ function blockspare_get_layouts() { $registry = Component_Registry::instance(); return $registry::layouts(); } /** * Gets the registered sections. * * @return array Array of registered sections. */ function blockspare_get_sections() { $registry = Component_Registry::instance(); return $registry::sections(); } /** * Gets the registered blocks. * * @return array Array of registered blocks. */ function blockspare_get_blocks() { $registry = Component_Registry::instance(); return $registry::blocks(); } /** * Gets the registered pages. * * @return array Array of registered pages. */ function blockspare_get_pages() { $registry = Component_Registry::instance(); return $registry::pages(); }