Close TinyMCE plugin window on click away

You asked the question a long ago but I was looking for something similar and found a solution. Enqueue an admin side script on post edit screens(where we have tinyMCE). Then use the code below: (function($) { ‘use strict’; $(document).ready(function() { $(document).on( ‘click’, ‘#mce-modal-block’, function() { tinyMCE.activeEditor.windowManager.close(); }); }); })(jQuery); This way you can close … Read more

Should a WordPress plugin polyfill the global JS environment?

Does WordPress ship any polyfills of its own for the global environment? No, as far as I remember WP core doesn’t ship with any polyfills. What are best practices around handling/shipping polyfills in WordPress plugins? The typical practice for JS in public WP extensions is to either: stick with core–provided scripts/environment; isolate your code and … Read more

@wordpress/components Button variants not styled

The WordPress components docs are pulled from the development branch of the repository, meaning they may describe features and functionality that have yet to be released. With the current version of the library used in WordPress, you declare the variant with the isPrimary, isSecondary, or isTertiary property: <Button isSecondary onClick={open}> Select image… </Button>

Only loads on the contact template page

First a bit of advise (since the solution is based on it) – always “enqueue” your scripts, don’t just add them in the footer. Read this, for example . Now the solution for loading scripts on specific template, since this is what you asked for: function enqueue_themescrits() { if ( is_page_template(‘contact.php’) ) { //the file … Read more

How do I access site and block editor state data and use `useSelect()` or `withSelect()` to bind it to my components?

✨ Intro to the Gutenberg Data Module ✨ Gutenberg’s core data model shares a lot of the API and ideology of the state-management library Redux, with a number of differences. Reading up on Redux can provide a lot of insight into how Gutenberg’s data management functions. This lecture will be on the final exam. Application … Read more