Plugin Directory

Changeset 3491564


Ignore:
Timestamp:
03/26/2026 08:21:24 AM (2 days ago)
Author:
wpdevelop
Message:

Update 10.15.2

Location:
booking/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • booking/trunk/includes/page-form-builder/save-load/bfb-activate.php

    r3491521 r3491564  
    184184}
    185185
     186
     187/**
     188 * Force a safe template for the BFB Preview page.
     189 *
     190 * Why:
     191 * - The Preview page is a technical/service page.
     192 * - It should not inherit decorative page templates like "Page with wide Image".
     193 * - For block themes, prefer a clean template like "page-no-title" or "page".
     194 * - For classic themes, use the default page template.  // FixIn: 10.15.2.1
     195 *
     196 * @param int $page_id Page ID.
     197 *
     198 * @return bool
     199 */
     200function wpbc_bfb_preview__force_safe_template( $page_id ) {
     201
     202    $page_id = absint( $page_id );
     203
     204    if ( $page_id <= 0 ) {
     205        return false;
     206    }
     207
     208    /*
     209     * Always clear any previously assigned template first.
     210     * This is important when an existing Preview page was previously using
     211     * an unwanted template, for example "Page with wide Image".
     212     */
     213    delete_post_meta( $page_id, '_wp_page_template' );
     214
     215    // Block themes: prefer a cleaner built-in page template, if available.
     216    if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() && function_exists( 'get_block_templates' ) ) {
     217
     218        $theme_slug        = get_stylesheet();
     219        $templates         = get_block_templates(
     220            array(
     221                'post_type' => 'page',
     222            ),
     223            'wp_template'
     224        );
     225        $safe_template_slug = '';
     226
     227        foreach ( $templates as $template ) {
     228
     229            if ( empty( $template->slug ) || empty( $template->theme ) ) {
     230                continue;
     231            }
     232
     233            if ( $theme_slug !== $template->theme ) {
     234                continue;
     235            }
     236
     237            if ( 'page-no-title' === $template->slug ) {
     238                $safe_template_slug = 'page-no-title';
     239                break;
     240            }
     241
     242            if ( ( '' === $safe_template_slug ) && ( 'page' === $template->slug ) ) {
     243                $safe_template_slug = 'page';
     244            }
     245        }
     246
     247        if ( '' !== $safe_template_slug ) {
     248            $result = wp_update_post(
     249                array(
     250                    'ID'            => $page_id,
     251                    'page_template' => $safe_template_slug,
     252                ),
     253                true
     254            );
     255
     256            return ( ! is_wp_error( $result ) );
     257        }
     258    }
     259
     260    return true;
     261}
     262
     263
    186264/**
    187265 * The preview page has status 'publish', because the secure the output by your nonce + cap
     
    213291    if ( ( ! is_wp_error( $page_id ) ) && ( ! empty( $page_id ) ) ) {
    214292        // Success.
    215         wpbc_try_assign_full_width_template(
    216             $page_id,
    217             array(
    218                 'excluded_title_parts'             => array( 'wide image' ),
    219                 'excluded_classic_template_files'  => array( 'elementor_header_footer' ),
    220                 'force_elementor_default_template' => true,
    221             )
    222         );
     293        wpbc_bfb_preview__force_safe_template( $page_id );
    223294    } else {
    224295        if ( is_wp_error( $page_id ) ) {
     
    236307
    237308/**
    238  * Create the private "Booking Form Preview" page and store option.
     309 * Create the "Booking Form Preview" page and store option.
    239310 *
    240311 * @return int|false Page ID on success, false on failure.
     
    249320    wpbc_bfb_activation__restore_user( $prev_user_id );
    250321
    251     if ( is_wp_error( $page_id ) ) {
     322    if ( empty( $page_id ) || is_wp_error( $page_id ) ) {
    252323        return false;
    253324    }
     
    292363
    293364        // Ensure meta marker exists.
     365        wpbc_bfb_preview__force_safe_template( (int) $page_id );
    294366        add_post_meta( (int) $page_id, wpbc_bfb_activation__get_preview_page_meta_key(), '1', true );
    295367
     
    300372    $found_id = wpbc_bfb_activation__find_preview_page_by_meta();
    301373    if ( $found_id > 0 && wpbc_bfb_activation__is_valid_page_id( $found_id ) ) {
     374        $found_page = get_post( $found_id );
     375        if ( $found_page instanceof WP_Post && 'publish' !== $found_page->post_status ) {
     376            wp_update_post( array(
     377                'ID'          => (int) $found_id,
     378                'post_status' => 'publish',
     379            ) );
     380        }
     381        wpbc_bfb_preview__force_safe_template( (int) $found_id );
    302382        update_option( $option_key, (int) $found_id );
    303383        return (int) $found_id;
     
    307387    $found_id = wpbc_bfb_activation__find_preview_page_by_slug();
    308388    if ( $found_id > 0 && wpbc_bfb_activation__is_valid_page_id( $found_id ) ) {
     389        $found_page = get_post( $found_id );
     390        if ( $found_page instanceof WP_Post && 'publish' !== $found_page->post_status ) {
     391            wp_update_post( array(
     392                'ID'          => (int) $found_id,
     393                'post_status' => 'publish',
     394            ) );
     395        }
     396        wpbc_bfb_preview__force_safe_template( (int) $found_id );
    309397        // Mark it as ours (so next time meta lookup works).
    310398        add_post_meta( (int) $found_id, wpbc_bfb_activation__get_preview_page_meta_key(), '1', true );
  • booking/trunk/includes/publish/wpbc-create-pages.php

    r3491521 r3491564  
    223223            wp_update_post(
    224224                array(
    225                     'ID'       => $post_id,
    226                     'template' => $template->slug,
     225                    'ID'            => $post_id,
     226                    'page_template' => $template->slug,
    227227                )
    228228            );
  • booking/trunk/readme.txt

    r3491528 r3491564  
    66Requires PHP: 5.6
    77Tested up to: 7.0
    8 Stable tag: 10.15.1
     8Stable tag: 10.15.2
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    336336
    337337== Changelog ==
     338= 10.15.2 =
     339- Changes in **all** versions:
     340    * **New**: Force a safe template for the BFB Preview page. (10.15.2.1)
     341
    338342= 10.15.1 =
    339343- Changes in **all** versions:
  • booking/trunk/wpdev-booking.php

    r3491521 r3491564  
    88Text Domain: booking
    99Domain Path: /languages/
    10 Version: 10.15.1
     10Version: 10.15.2
    1111License: GPLv2 or later
    1212*/
     
    3535
    3636if ( ! defined( 'WP_BK_VERSION_NUM' ) ) {
    37     define( 'WP_BK_VERSION_NUM', '10.15.1' );
     37    define( 'WP_BK_VERSION_NUM', '10.15.2' );
    3838}
    3939if ( ! defined( 'WP_BK_MINOR_UPDATE' ) ) {
Note: See TracChangeset for help on using the changeset viewer.