slider i want move 4 images every button click
slider i want move 4 images every button click
slider i want move 4 images every button click
I finally found it out. You can access current comment settings by using wp.data.select(‘core/editor’).getEditedPostAttribute(‘comment_status’) So the complete solution is: function isCommentsEnabledInBlockEditor() { return wp.data.select(‘core/editor’).getEditedPostAttribute(‘comment_status’) === ‘open’; } function registerPublishBtnHandler() { const publishBtnArray = document.getElementsByClassName(“editor-post-publish-button__button”); if (publishBtnArray && publishBtnArray.length > 0) { const publishBtn = publishBtnArray[0]; if (publishBtn) { publishBtn.addEventListener(“click”, function (e) { if (!isCommentsEnabledInBlockEditor()) { … Read more
Based on the information you’ve provided, there are a few potential reasons why your script might not be enqueued properly in WordPress. Let’s troubleshoot: Try cache busting: It is possible the file is loading but the code is not loading because the file is cached. Try the below code. The $version variable changes every page … Read more
Thanks for MVE, @helgatheviking! It was beneficial. When wp.data caches the resolvers, it also considers arguments. Here’s what happens when following the reproduction steps for the bug: Selecting the first product resolves data, creates a cache for getProduct(1), and sets a value for the product state. Selecting second does the same (cache: getProduct(2)) and sets … Read more
wp_add_inline_script can be used to insert a tiny trigger script that executes after the script specified in script and any instance defined by that script will be available. // When this js executes `Masonry` is sure to be defined wp_add_inline_script( ‘masonry’, ‘if (window.top !== window) doItNow()’); This will end up being executed twice when the … Read more
Better way is to listen to Gutenberg events. Template change can be observed with something like this: wp.data.subscribe(() => { console.log(wp.data.select( ‘core/editor’ ).getEditedPostAttribute(‘template’)); }); It will fire on many wp.data events, not only for template change. But you can add some checks and do your actions only when it’s needed. Example: const editor = wp.data.select( … Read more
I’m sharing my solution here in case it can help someone, as I believe this type of shortcode transform is a common use case. As fetching data inside a transform is not possible right now, I’m creating the block inside the transform by passing just the carousel id attribute from the carousel shortcode. I then … Read more
This approach should work, Modify it for your use case. //JQuery Code jQuery( document ).on( ‘change’, ‘.from-this’, function( e ) { e.preventDefault(); jQuery( ‘.change-this’ ).text( this.value ); } ) HTML Code: <input type=”search” class=”from-this” /> <div class=”change-this”></div>
You’re not actually updating the block. You’re just updating the current state of the block component in the editor. To have an option persist you need an attribute to store whether the option is toggled, and then you need to call setAttributes() to save that attribute. This is what the editor will recognise as a … Read more
Actually, you do not need to worry about adding the Masonry’s script handle to the dependencies array in the asset file (index.asset.php). All you needed to do to make your Masonry code work properly is by using the script property to add the masonry (and imagesloaded) as dependencies for your editor and view/front-end scripts. “editorScript”: … Read more