Changeset 3491564
- Timestamp:
- 03/26/2026 08:21:24 AM (2 days ago)
- Location:
- booking/trunk
- Files:
-
- 4 edited
-
includes/page-form-builder/save-load/bfb-activate.php (modified) (7 diffs)
-
includes/publish/wpbc-create-pages.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
wpdev-booking.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
booking/trunk/includes/page-form-builder/save-load/bfb-activate.php
r3491521 r3491564 184 184 } 185 185 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 */ 200 function 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 186 264 /** 187 265 * The preview page has status 'publish', because the secure the output by your nonce + cap … … 213 291 if ( ( ! is_wp_error( $page_id ) ) && ( ! empty( $page_id ) ) ) { 214 292 // 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 ); 223 294 } else { 224 295 if ( is_wp_error( $page_id ) ) { … … 236 307 237 308 /** 238 * Create the private"Booking Form Preview" page and store option.309 * Create the "Booking Form Preview" page and store option. 239 310 * 240 311 * @return int|false Page ID on success, false on failure. … … 249 320 wpbc_bfb_activation__restore_user( $prev_user_id ); 250 321 251 if ( is_wp_error( $page_id ) ) {322 if ( empty( $page_id ) || is_wp_error( $page_id ) ) { 252 323 return false; 253 324 } … … 292 363 293 364 // Ensure meta marker exists. 365 wpbc_bfb_preview__force_safe_template( (int) $page_id ); 294 366 add_post_meta( (int) $page_id, wpbc_bfb_activation__get_preview_page_meta_key(), '1', true ); 295 367 … … 300 372 $found_id = wpbc_bfb_activation__find_preview_page_by_meta(); 301 373 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 ); 302 382 update_option( $option_key, (int) $found_id ); 303 383 return (int) $found_id; … … 307 387 $found_id = wpbc_bfb_activation__find_preview_page_by_slug(); 308 388 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 ); 309 397 // Mark it as ours (so next time meta lookup works). 310 398 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 223 223 wp_update_post( 224 224 array( 225 'ID' => $post_id,226 ' template' => $template->slug,225 'ID' => $post_id, 226 'page_template' => $template->slug, 227 227 ) 228 228 ); -
booking/trunk/readme.txt
r3491528 r3491564 6 6 Requires PHP: 5.6 7 7 Tested up to: 7.0 8 Stable tag: 10.15. 18 Stable tag: 10.15.2 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 336 336 337 337 == 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 338 342 = 10.15.1 = 339 343 - Changes in **all** versions: -
booking/trunk/wpdev-booking.php
r3491521 r3491564 8 8 Text Domain: booking 9 9 Domain Path: /languages/ 10 Version: 10.15. 110 Version: 10.15.2 11 11 License: GPLv2 or later 12 12 */ … … 35 35 36 36 if ( ! defined( 'WP_BK_VERSION_NUM' ) ) { 37 define( 'WP_BK_VERSION_NUM', '10.15. 1' );37 define( 'WP_BK_VERSION_NUM', '10.15.2' ); 38 38 } 39 39 if ( ! defined( 'WP_BK_MINOR_UPDATE' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.