Support » Plugin: Block Logic - Full Gutenberg Block Display Control » Insert blocks via widgets

  • Resolved Douglas Ferraz

    (@douglasferraz89)


    From version 5.8 of WordPress it is possible to insert blocks via widgets.

    However, the plugin does not work by adding conditional tags to blocks via widgets.

    I believe there will be a great demand for this functionality.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Sascha Paukner

    (@landwire)

    Hello Douglas,
    I have just testet it on 5.8 and it does work as expected on blocks inserted in the widgets screen. I have tried 3 different blocks: latest posts, paragraph and heading.

    It does however not work with the “Legacy Widget” block. I assume that this block is quite special and might follow a different rendering logic, why it is ignored by the “render_block” filter that I am using in my plugin.

    WordPress actually recommends migrating old widgets to blocks. Therefore I will not be supporting the “Legacy Widget” block. “Normal” blocks should work as expected.

    Unless you have problems with blocks other than the Legacy Widget block? Then maybe let me know which block are causing you a problem and I will try and reproduce it.

    Thread Starter Douglas Ferraz

    (@douglasferraz89)

    Hi @landwire

    I should have done more testing to be more accurate about the reported issue. I apologize.

    The plugin works perfectly with paragraphs and other blocks I’ve tested.

    The problem I reported to you also happens in the posts editor, that is, it doesn’t only happen in new widgets.

    The plugin that has conflicts is Flex Posts – Widget and Gutenberg Block.

    When I select some options for the block, like the number of posts or layout and insert the conditional tags, they are not saved and when I return to the editor, the Block logic space is empty.

    Also, I visualized in the database and your plugin parameters are not inserted in the block. For example: “blockLogic”:”is_home()”, do not appear.

    I tested this plugin: Block Visibility — Conditional Visibility Controls for all Blocks.

    It had no conflicts and was able to insert parameters, thus:

    <!– wp:flex-posts/list {“layout”:2,”number”:3,”className”:”home”,”blockVisibility”:{“controlSets “:[{“id”:0,”name”:”Control Set”,”enable”:true,”controls”:{“dateTime”:{“schedules”:[{“enable”:true,”start” :”2021-07-24T00:00:00″,”end”:”2021-07-25T00:00:00″}]},”screenSize”:{},”userRole”:{}}}]}} //->

    Finally, I tried to manually enter into the database to do a test

    it was like this:

    <!– wp:flex-posts/list {“layout”:2,”number”:6,”show_categories”:true,”show_date”:false,”show_comments”:false,”show_excerpt”:true} /–>

    And entering manually, like this:

    <!– wp:flex-posts/list {“layout”:2,”number”:6,”show_categories”:true,”show_date”:false,”show_comments”:false,”show_excerpt”:true,”blockLogic”:”is_home()”} /–>

    This way it managed to work correctly, that is, the conditional tags are not saved when I click on the update or publish button.

    Plugin Author Sascha Paukner

    (@landwire)

    Hello Douglas,
    thank you for the detailed report. I will look into it soon. Could not find a solution in the few minutes I had this morning.

    I definitely can reproduce it now.

    Plugin Author Sascha Paukner

    (@landwire)

    Hello Douglas,
    the issue should be fixed with the latest update. It is a core bug unfortunately, which I added a workaround for for now based on a comment here:
    https://github.com/WordPress/gutenberg/issues/9757#issuecomment-486088850

    Please test it and give some feedback, so that I can close the issue.
    I am also happy if you can leave a nice review, if you are happy with the plugin.

    Thread Starter Douglas Ferraz

    (@douglasferraz89)

    Hi @landwire

    So, I read the topic on Github now.

    I did the test here, everything is working fine.

    Thanks.

    Plugin Author Sascha Paukner

    (@landwire)

    Great, glad to hear. Thanks for the review!

    Thread Starter Douglas Ferraz

    (@douglasferraz89)

    Hi @landwire

    Block Logic plugin is loading too many unnecessary javascript files. I believe about 50 files.

    All these files are from the WordPress core.

    This happens because of this:

    add_action( 'init', 'block_logic_enqueue_block_editor_assets', 9999 );

    It’s loading everything in the frontend.

    Another hook would prevent this:

    enqueue_block_editor_assets – This hook can be used to enqueue block scripts and styles in the admin editor only.

    add_action( 'enqueue_block_editor_assets', 'block_logic_enqueue_block_editor_assets' );

    I did a test here and it looks like everything works fine and has no conflicts with upgrading to work with ServerSideRender component.

    Plugin Author Sascha Paukner

    (@landwire)

    Hi @douglasferraz89,

    hopefully the core bug is solved soon and then I can use the filter you suggest. I had used that hook before, but because of the suggestion here (https://github.com/WordPress/gutenberg/issues/9757#issuecomment-486088850) I changed that.

    Current progress in Gutenberg: https://github.com/WordPress/gutenberg/pull/34299

    Once that is merged I will update my plugin.

    Thread Starter Douglas Ferraz

    (@douglasferraz89)

    Hi @landwire ,

    Thanks for sharing progress in Gutenberg.

    I will follow.

    Thanks again.

    Plugin Author Sascha Paukner

    (@landwire)

    I added an is_admin check, so the scripts are not loaded in the frontend at least, so only the admin loads a few scripts more. Core team is working on a fix and hopefully I can eliminate any unnecessary loading soon completely.

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