Best way to abort plugin in case of insufficient PHP version?

This function and activation hook prevents the plugin from activating and allows you to check for both a minimum PHP and WordPress version. register_activation_hook( __FILE__, array( ‘Your_Plugin_Class_Name’, ‘activate’ ) ); /** * Plugin Activation hook function to check for Minimum PHP and WordPress versions * @param string $wp Minimum version of WordPress required for this … Read more

check if Gutenberg is currently in use

Necessary API Functions/Methods: You’ll need WP_Screen::is_block_editor() method to check if you are currently in the Gutenberg Editor (Since WordPress 5.0). Also, if you install Gutenberg as a separate plugin, then you’ll have the is_gutenberg_page() function available to do the same check. So for an overall solution, you’ll need to combine these two. Of course, this … Read more

Update Option Stored in Multi-Dimensional Array

As far WordPress is concerned – your multi-dimensional array is one option. To update just part of the multi-dimensional array its necessary to retrieve the entire array, alter it accordingly and then update the entire array. Suppose your multi-dimensional array is as follows: my_options = array( ‘option_a’=>’value_a’, ‘option_b’=>’value_b’, ‘inner_array’=>array( ‘foo’ => ‘bar’, ‘hello’ => ‘world’, … Read more

How to include jQuery and JavaScript files correctly?

First rule of thumb: do not deregister core-bundled scripts and replace with other versions, unless you are absolutely certain that no Theme, Plugins, or core itself will break due to the version change. Really, unless you absolutely need an alternate version of a core-bundled script, just use what is bundled with core. Second, I strongly … Read more

What are the common security flaws I need to look for? [closed]

Here is a modified checklist, based on my current (work-in-progress) settings/data security checklist used for reviewing Themes (the principles should be no different for Plugins than they are for Themes): Plugins should prefix all options, custom functions, custom variables, and custom constants with plugin-slug. Plugins should implement Plugin Options and Plugin Settings pages deliberately, rather … Read more

error code: 521