Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Template is being rendered in Edit Mode even though I use "never display" for "CODE OUTPUT IN EDITOR" #298

Open
janwidmer opened this issue Sep 30, 2023 · 0 comments

Comments

@janwidmer
Copy link
Contributor

janwidmer commented Sep 30, 2023

Issue description:

I am using a setup, where every uploaded image has up to 10 renditions (different dimensions of the same image) depending on the screen and the context, where the image is used. To not always render all images in all renditions, I use a plugin, which only renders and then chaches the renditions of the requested image, the first time, that image url is being requested from the server.

Additionally, I am using the option Theme Template to define all my block contents as part of my theme.

This works well so far, but out of some reason, the first rendering already happens in Edit Mode, when the author saves the page. Therefore, saving a page with several Blocks having images takes a long time and sometimes results in a request timeout.

My Blocks all use the option CODE OUTPUT IN EDITOR with the Value Never display. Still, I see a log Message (placed in my block's template) in my debug.log after I save the page (Never opened the page in the frontend).

I would expect, that by using the mentioned Option, no Block Rendering occurs in the Edit mode. Is that a Bug or a limitation of wordpress itself, that the block get's anyway rendered in edit mode?

Lazy Blocks Version: 3.5.1

WordPress Version: 6.3.1

Any helpful information to reproduce the issue (screenshots, code parts)

You can find my test block attached to this ticket, also the php template used for the test block. I have setup a demo site using the wordpress theme twentytwentyone and just one lazy block. If it helps, I could give access to this site to see a live example.
lzb-export-blocks-2023-09-30.json.zip
block.php.zip

Steps to reproduce

  1. Setup a wordpress
  2. Install Lazy Blocks
  3. Import the attached block
  4. Copy the attached php file and add it in the folder wp-content/themes/twentytwentyone/blocks/lazyblock-test-block/
  5. Enable debugging in your wp-config.php by adding define('WP_DEBUG', true); and define( 'WP_DEBUG_LOG', true );
  6. Add the write-log function to your functions.php
if ( ! function_exists('write_log')) {
    function write_log ( $log )  {
        if ( is_array( $log ) || is_object( $log ) ) {
            error_log( print_r( $log, true ) );
        } else {
            error_log( $log );
        }
    }
}
  1. Create a new page and add the block Test Block
  2. Save the page
  3. Notice, that the file debug.log in wp-content/debug.log already contains a log entry coming from the block template file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant