Plugin Directory

Changeset 3443636


Ignore:
Timestamp:
01/20/2026 11:37:48 PM (2 months ago)
Author:
figureone
Message:

Preparing for 3.11.2 release

Location:
insert-pages/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • insert-pages/trunk/insert-pages.php

    r3425590 r3443636  
    99 * License: GPL2
    1010 * Requires at least: 3.3.0
    11  * Version: 3.11.1
     11 * Version: 3.11.2
    1212 *
    1313 * @package insert-pages
     
    277277         */
    278278        public function insert_pages_handle_shortcode_insert( $atts, $content = null ) {
    279             global $wp_query, $post, $wp_current_filter;
     279            global $post, $current_screen;
    280280
    281281            // Shortcode attributes.
     
    398398                // title search.
    399399                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                    );
    406408                    if ( ! empty( $inserted_pages ) ) {
    407409                        $inserted_page = $inserted_pages[0];
     
    561563                    // retrieve generated styles for that post. Reset $post to null
    562564                    // 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 ) ) {
    564572                        $old_post_id = null;
    565573                        $post = $inserted_page; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    566574                    } elseif ( is_int( $post ) ) {
    567575                        $old_post_id = $post;
    568                         $post = $inserted_page->ID;
     576                        $post = $inserted_page->ID; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    569577                    } else {
    570578                        $old_post_id = $post->ID;
     
    656664                    do_action( 'gdlr_core_print_page_builder' );
    657665
    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 ) ) {
    659673                        $post = null; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    660674                    } else {
     
    877891                        // retrieve generated styles for that post. Reset $post to null
    878892                        // 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 ) ) {
    880900                            $old_post_id = null;
    881901                            $post = $inserted_page; // phpcs:ignore WordPress.WP.GlobalVariablesOverride
     
    974994                        do_action( 'gdlr_core_print_page_builder' );
    975995
    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 ) ) {
    9771003                            $post = null; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    9781004                        } elseif ( is_int( $post ) ) {
    979                             $post = $old_post_id;
     1005                            $post = $old_post_id; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    9801006                        } else {
    9811007                            $post->ID = $old_post_id;
  • insert-pages/trunk/readme.txt

    r3425590 r3443636  
    33Tags: insert, pages, shortcode, embed
    44Tested up to: 6.9
    5 Stable tag: 3.11.1
     5Stable tag: 3.11.2
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    110110
    111111== 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)!
    112115
    113116= 3.11.1 =
Note: See TracChangeset for help on using the changeset viewer.