slug => label */ public static function all( string $post_type = 'page' ): array { $templates = array(); foreach ( get_page_templates( null, $post_type ) as $label => $slug ) { $templates[ $slug ] = $label; } if ( function_exists( 'get_block_templates' ) ) { foreach ( get_block_templates( array(), 'wp_template' ) as $block_template ) { $slug = (string) $block_template->slug; $title = '' !== (string) $block_template->title ? (string) $block_template->title : $slug; if ( '' !== $slug ) { $templates[ $slug ] = $title; } } } /** * Filters the list of page templates available for location rules. * * @param array $templates */ return (array) apply_filters( 'acez_seo_page_templates', $templates ); } public static function current_slug( \WP_Post $post ): string { $slug = get_page_template_slug( $post->ID ); return is_string( $slug ) ? $slug : ''; } }