Support » Plugin: Insert Pages » shortcode inside a page with another shortcode infinite load

  • Resolved masterbip

    (@masterbip)


    Hi there. A weird issue.
    Scenario:
    I am using this to disable “nesting check”

    function your_theme_init() {
        // Disable nesting check to allow inserted pages within inserted pages.
        add_filter( 'insert_pages_apply_nesting_check', '__return_false' );
    }
    add_action( 'init', 'your_theme_init' );

    Now:
    I got 4 pages with normal content plain short demo test text:
    1.- Index
    2.- Page-2
    3.- Page-3
    4.- Page-3-Child

    In INDEX I [Insert Page-2] and [Insert Page-3]

    Browse Index: All is fine till here.

    If in Page-3 I [Insert Page-3-Child]
    Browse Index: I got the infinite loop and the page load down infinity….

    Using a simple template:

    <?php
    /*
    Template Name: Demo_Template
    */
    while ( have_posts() ) : the_post();
    ?>
    <section>
    	<div class="insert-page-wrap">
    		<div class="insert-page-content">
    		<?php the_content(); ?>
    		</div>
    	</div>
    </section>
    <?php endwhile; ?>

    Logically I am not nesting anything
    I got like
    A
    -B
    -C
    –D

    Is this a normal behavior if I disable nesting check?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Paul Ryan

    (@figureone)

    Thanks for the detailed steps to reproduce. That scenario should work, we’ll look into it!

    Plugin Author Paul Ryan

    (@figureone)

    Ok, tracked down the issue. Using Custom Templates in Insert Pages relies on the old query_posts() WordPress function, which has some drawbacks. If you look at the docs, it will try to save the global $wp_query variable into a backup global variable, $wp_the_query. However, This immediately gets overwritten when you insert your nested page, so WordPress is unable to restore the original query.
    https://developer.wordpress.org/reference/functions/query_posts/
    https://developer.wordpress.org/reference/functions/wp_reset_query/
    https://developer.wordpress.org/reference/functions/wp_reset_postdata/

    I’ve updated Insert Pages to cache it’s own version of $wp_query that we restore, which allows for nested pages all using Custom Templates.
    https://github.com/uhm-coe/insert-pages/commit/cc002fc0f2cf80ef01285404ed5c5342011cb22c

    This fix is included in version 3.4.5, just released. Thanks for the report!

    masterbip

    (@masterbip)

    Updating now Ill let you know.
    By the way.
    Where can I “buy you” a “coffee cup”?
    Paypal … something?

    THANKS A LOT

    masterbip

    (@masterbip)

    YOU ARE MY BEST FRIEND NOW!
    Working perfect, THANKS! It is absolutely pure magic what we can do with your plugin!

    For real, let me buy you a Coffee Cup

    Thanks, AWESOME!!!!

    (When finished I’ll give you my project URL so you can show as portfolio -> It will be LEGENDARY!)

    Plugin Author pkarjala

    (@pkarjala)

    @masterbip Thank you for the feedback! We fortunately get paid to work on and support this plugin through our regular job. If you would like to add to this support, please consider a donation at https://coe.hawaii.edu/alumni-giving

    funsail

    (@funsail)

    Hi, with the new update, we still need to use this?
    add_filter( ‘insert_pages_apply_nesting_check’, ‘__return_false’ );

    You could say I’m scared of doing this and making a loop

    Plugin Author Paul Ryan

    (@figureone)

    You’ll need to add that code if you want the nesting level to go deeper than 1 (e.g., A inserted in B, B inserted in C, so when you view C, you see B including A’s content inside it). If you make a loop, you’ll probably get the WSOD when trying to load the page. Simply remove (or comment out) the code for insert_pages_apply_nesting_check, and it will go back to only allowing one level of nesting, which will prevent the loop.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.