I have noticed that some plugins such as Contact-form-7, Nextgen-gallery, possibly others, have an interesting anti-feature of not registering their shortcodes when is_admin()
is true.
The problematic thing is, if you want to generate some dynamic content (which may have shortcode) from ajax, and use the "correct" wp way of doing it, admin-ajax.php, it is impossible to not have WP_ADMIN be true. See the first lines of admin-ajax.php:
define( 'DOING_AJAX', true );
if ( ! defined( 'WP_ADMIN' ) ) {
define( 'WP_ADMIN', true );
}
Now, it seems there are PHP extensions that will let you un-set a defined constant (hacky), or there may be a way to mess with the undocumented WP_Screen system and $GLOBALS['current_screen']
to make is_admin()
function return false?? The most usable workaround seems to be posting to the page or the site root.
Is it common for plugins to register their shortcodes when is_admin()
is false? If so, I couldn't find any documentation or reason for it other than that it may be a premature optimization.