Localize plugin name

Just add the full string of the plugin name into the plugin’s text domain. WordPress looks this up automatically. Same with Description, PluginURI, Author and AuthorURI. See the internal function _get_plugin_data_markup_translate. The string extractor in Glotpress (and my own plugin Loco Translate) adds these header strings automatically to new POT files.

I need help locating a URL that is on my site map, but that I can’t find in my WordPress dashboard

Keep in mind there’s really only a few actual pages in WordPress. Most URLs are getting redirected to index.php, parsed for the request information, and then processed accordingly. They are mostly posts in the end, which are pulled from the database and displayed according to one or more template files. The reason that’s important is … Read more

Conditional tag doesn’t work in WordPress plugin

Both those hooks are too early to use is_page(). WordPress hasn’t determined which page is being loaded yet, so it can’t check the current page. Try template_redirect for both: /** * Plugin Name: Test1234 */ function replace_image_content(){ if ( is_page( ‘img’ ) ) { header( ‘Content-Type: image/jpg’ ); $image = plugin_dir_url(__FILE__) . ‘1404-1.jpg’; readfile( $image … Read more

How can I test plugin activation using phpunit?

Testing of WP plugins and themes with phpunit is absolutely proper and widely used. You can see an example of pure phpunit tests in our plugin Cyr2Lat (please look at test folder). What you can find there, it is an example of pure phpunit tests, which work with testing class only and mock everything other. … Read more

WP_Http response throws “Cannot use object of type WP_Error as array”

Your logic for your updated if statement is wrong. if( !is_wp_error($response) && $response[‘response’][‘code’] != 200 ) Here you are saying; if NOT wp_error AND response code NOT 200 return false. So your not actually catching the WP_Error I believe what you are after is something like: if ( is_wp_error($response) || $response[‘response’][‘code’] != 200 ) return … Read more

Can’t get Gutenberg InspectorControls to work

I got it… I just was missing to enqueue ‘wp-editor’… Here my example code: wp_register_script( ‘mir-shortcodes-plugin-msc-rotating-icon-circle’, plugins_url($index_js, __FILE__), array( ‘wp-blocks’, ‘wp-i18n’, ‘wp-element’, ‘wp-components’, ‘wp-editor’ ), filemtime(“$dir/$index_js”) );

How to apply lazy loading in background images [closed]

That is nothing that can be installed by a plugin or, at least, would be necessary for you to work on it. However, you can build this yourself. Step 1: Enqueue the IntersectionObserver polyfill you can find here: https://github.com/w3c/IntersectionObserver/blob/master/polyfill/intersection-observer.js to get Support for older Browsers. Step 2: Change the code of your HTML-Elements which use … Read more

Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?

In my opinion, a best practice would be to clean everything on uninstallation. It’s also mentioned as a best practice in the docs: When your plugin is uninstalled, you’ll want to clear out any plugin options and/or settings specific to to the plugin, and/or other database entities such as tables. However, if you’re struggling to … Read more