Plugin Directory

Changeset 3416861


Ignore:
Timestamp:
12/10/2025 10:48:04 PM (4 months ago)
Author:
courane01
Message:

Release 1.1.1 - Fix critical template chooser issue

Fixed: Format templates were hiding theme templates in Template dropdown.

Format templates now apply automatically via template hierarchy but don't
appear as selectable options in the post editor's Template chooser.

Location:
post-formats-for-block-themes/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • post-formats-for-block-themes/trunk/post-formats-for-block-themes.php

    r3413728 r3416861  
    44 * Plugin URI: https://wordpress.org/plugins/post-formats-for-block-themes/
    55 * Description: Modernizes WordPress post formats for block themes with format-specific patterns, auto-detection, and enhanced editor experience.
    6  * Version: 1.1.0
     6 * Version: 1.1.1
    77 * Requires at least: 6.8
    88 * Tested up to: 6.9
     
    3939 * Plugin constants
    4040 */
    41 define( 'PFBT_VERSION', '1.1.0' );
     41define( 'PFBT_VERSION', '1.1.1' );
    4242define( 'PFBT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    4343define( 'PFBT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     
    7676}
    7777add_filter( 'default_template_types', 'pfbt_register_template_types_early', 1 );
     78
     79/**
     80 * Hide format templates from template chooser dropdown
     81 *
     82 * Format templates should apply automatically via template hierarchy,
     83 * not appear as selectable options in the Template dropdown.
     84 * This prevents them from hiding/replacing the theme's templates.
     85 *
     86 * @since 1.0.4
     87 * @param array $query_result Array of block template objects
     88 * @param array $query Block templates query parameters
     89 * @param string $template_type wp_template or wp_template_part
     90 * @return array Filtered array of block templates
     91 */
     92function pfbt_filter_format_templates_from_chooser( $query_result, $query, $template_type ) {
     93    // Only filter templates (not template parts) in the post editor
     94    if ( 'wp_template' !== $template_type ) {
     95        return $query_result;
     96    }
     97
     98    // Don't filter if we're in the site editor or template admin
     99    if ( is_admin() && isset( $_GET['page'] ) && 'gutenberg-edit-site' === $_GET['page'] ) {
     100        return $query_result;
     101    }
     102
     103    // Filter out format templates from the chooser
     104    $format_template_slugs = array(
     105        'single-format-aside',
     106        'single-format-gallery',
     107        'single-format-link',
     108        'single-format-image',
     109        'single-format-quote',
     110        'single-format-status',
     111        'single-format-video',
     112        'single-format-audio',
     113        'single-format-chat',
     114    );
     115
     116    return array_filter(
     117        $query_result,
     118        function( $template ) use ( $format_template_slugs ) {
     119            return ! in_array( $template->slug, $format_template_slugs, true );
     120        }
     121    );
     122}
     123add_filter( 'get_block_templates', 'pfbt_filter_format_templates_from_chooser', 10, 3 );
    78124
    79125/**
  • post-formats-for-block-themes/trunk/readme.txt

    r3413728 r3416861  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.1.0
     8Stable tag: 1.1.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    347347
    348348== Changelog ==
     349
     350= 1.1.1 - 2025-12-09 =
     351
     352**Bug Fixes**
     353
     354* **Fixed:** Critical issue where format templates (Chat Format, Gallery Format, etc.) were appearing in the Template dropdown and hiding/replacing theme templates. Format templates now apply automatically via template hierarchy but don't show as selectable options in the editor.
    349355
    350356= 1.1.0 - 2025-12-08 =
Note: See TracChangeset for help on using the changeset viewer.