Changeset 3443636
- Timestamp:
- 01/20/2026 11:37:48 PM (2 months ago)
- Location:
- insert-pages/trunk
- Files:
-
- 2 edited
-
insert-pages.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
insert-pages/trunk/insert-pages.php
r3425590 r3443636 9 9 * License: GPL2 10 10 * Requires at least: 3.3.0 11 * Version: 3.11. 111 * Version: 3.11.2 12 12 * 13 13 * @package insert-pages … … 277 277 */ 278 278 public function insert_pages_handle_shortcode_insert( $atts, $content = null ) { 279 global $ wp_query, $post, $wp_current_filter;279 global $post, $current_screen; 280 280 281 281 // Shortcode attributes. … … 398 398 // title search. 399 399 if ( is_null( $inserted_page ) ) { 400 $inserted_pages = get_posts( array( 401 'title' => sanitize_text_field( $attributes['page'] ), 402 'post_type' => 'any', 403 'post_status' => 'any', 404 'posts_per_page' => 1, 405 ) ); 400 $inserted_pages = get_posts( 401 array( 402 'title' => sanitize_text_field( $attributes['page'] ), 403 'post_type' => 'any', 404 'post_status' => 'any', 405 'posts_per_page' => 1, 406 ) 407 ); 406 408 if ( ! empty( $inserted_pages ) ) { 407 409 $inserted_page = $inserted_pages[0]; … … 561 563 // retrieve generated styles for that post. Reset $post to null 562 564 // after we're done. 563 if ( is_null( $post ) ) { 565 if ( isset( $current_screen->base ) && 'post' === $current_screen->base ) { 566 // Note: some page builders (e.g., Divi) will try to process 567 // shortcodes while in the editor, and overwriting the global $post 568 // can cause issues where the editor will load the inserted page. 569 // Skip overwriting $post if we are in the editor. 570 assert( true ); // No-op. 571 } elseif ( is_null( $post ) ) { 564 572 $old_post_id = null; 565 573 $post = $inserted_page; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 566 574 } elseif ( is_int( $post ) ) { 567 575 $old_post_id = $post; 568 $post = $inserted_page->ID; 576 $post = $inserted_page->ID; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 569 577 } else { 570 578 $old_post_id = $post->ID; … … 656 664 do_action( 'gdlr_core_print_page_builder' ); 657 665 658 if ( is_null( $old_post_id ) ) { 666 if ( isset( $current_screen->base ) && 'post' === $current_screen->base ) { 667 // Note: some page builders (e.g., Divi) will try to process 668 // shortcodes while in the editor, and overwriting the global $post 669 // can cause issues where the editor will load the inserted page. Skip 670 // this if we are in the editor. 671 assert( true ); // No-op. 672 } elseif ( is_null( $old_post_id ) ) { 659 673 $post = null; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 660 674 } else { … … 877 891 // retrieve generated styles for that post. Reset $post to null 878 892 // after we're done. 879 if ( is_null( $post ) ) { 893 if ( isset( $current_screen->base ) && 'post' === $current_screen->base ) { 894 // Note: some page builders (e.g., Divi) will try to process 895 // shortcodes while in the editor, and overwriting the global $post 896 // can cause issues where the editor will load the inserted page. 897 // Skip overwriting $post if we are in the editor. 898 assert( true ); // No-op. 899 } elseif ( is_null( $post ) ) { 880 900 $old_post_id = null; 881 901 $post = $inserted_page; // phpcs:ignore WordPress.WP.GlobalVariablesOverride … … 974 994 do_action( 'gdlr_core_print_page_builder' ); 975 995 976 if ( is_null( $old_post_id ) ) { 996 if ( isset( $current_screen->base ) && 'post' === $current_screen->base ) { 997 // Note: some page builders (e.g., Divi) will try to process 998 // shortcodes while in the editor, and overwriting the global $post 999 // can cause issues where the editor will load the inserted page. 1000 // Skip overwriting $post if we are in the editor. 1001 assert( true ); // No-op. 1002 } elseif ( is_null( $old_post_id ) ) { 977 1003 $post = null; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 978 1004 } elseif ( is_int( $post ) ) { 979 $post = $old_post_id; 1005 $post = $old_post_id; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 980 1006 } else { 981 1007 $post->ID = $old_post_id; -
insert-pages/trunk/readme.txt
r3425590 r3443636 3 3 Tags: insert, pages, shortcode, embed 4 4 Tested up to: 6.9 5 Stable tag: 3.11. 15 Stable tag: 3.11.2 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 110 110 111 111 == Changelog == 112 113 = 3.11.2 = 114 * Fix for Divi redirecting to inserted page when an Insert Pages shortcode exists in the classic editor. Props airflo for the [report](https://github.com/uhm-coe/insert-pages/issues/65)! 112 115 113 116 = 3.11.1 =
Note: See TracChangeset
for help on using the changeset viewer.