{"id":12292297,"date":"2020-01-04T14:14:11","date_gmt":"2020-01-04T14:14:11","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/not-working-in-admin-ajax\/"},"modified":"2020-01-04T14:19:43","modified_gmt":"2020-01-04T14:19:43","slug":"not-working-in-admin-ajax","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/not-working-in-admin-ajax\/","title":{"rendered":"Not Working in admin-ajax"},"content":{"rendered":"<p>Hi,<br \/>\nI am the author of the <a href=\"https:\/\/wordpress.org\/plugins\/ajax-load-more\/\">Ajax Load More<\/a> plugin, I have users unable to use our two plugins together.<\/p>\n<p>After running some tests and debugging the plugin code it appears the issue is related to the fact Ajax Load More uses <code>admin-ajax.php<\/code> for the Ajax requests and your plugin wraps the <code>add_shortcode<\/code> methods and script enqueues in <code>!is_admin()<\/code> check functions.<\/p>\n<p>This results in users are being shown plain text shortcodes as they are not loaded in Ajax requests.<\/p>\n<p>I was able to fix this on a local copy of <code>youtube-embed-plus<\/code> by also checking for <code>wp_doing_ajax()<\/code> and loading these scripts and shortcodes if so.<\/p>\n<p>for example, line 1970 of youtube.php<br \/>\n<code>if (!is_admin() || (self::$alloptions[self::$opt_frontend_only] != 1))<\/code><br \/>\nbecomes:<br \/>\n<code>if (!is_admin() || (self::$alloptions[self::$opt_frontend_only] != 1) || wp_doing_ajax())<\/code><\/p>\n<p>Let me know if this is something you have come across before and if it&#8217;s possible to get our plugins working together. If the plugin is on Github I could send in a pull request.<\/p>\n<p>Let me know if you have any questions.<\/p>\n<p>thanks,<\/p>\n","protected":false},"template":"","class_list":["post-12292297","topic","type-topic","status-publish","hentry","topic-tag-admin-ajax","topic-tag-ajax"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12292297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12292297\/revisions"}],"predecessor-version":[{"id":12292307,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12292297\/revisions\/12292307"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12292297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}