No longer possible to get nggallery content from admin-ajax context??
-
After updating to the latest Nextgen gallery, it seems there is no workaround to activate the shortcode from an admin-ajax context. As an example, try the following in a plugin:
add_action(‘wp_ajax_testaction’, ‘testNG’);
function testNG()
{
echo apply_filters(“the_content”,”Hello [nggallery id=1]”);
exit;
}Now go to wp-admin/admin-ajax.php?action=testaction and note that the post content is not changed at all.
Apparently this is caused by the new optimizations in 2.0.7x where it only adds shortcodes when is_admin() is false. You would think you could fake the $GLOBALS[‘current_screen’] object to make it return false, but apparently it actually runs too soon for that, and that’s probably not the best way to do this?
Is there any documented way to be able to get the final the_content from wp-admin-ajax context?
- The topic ‘No longer possible to get nggallery content from admin-ajax context??’ is closed to new replies.