WP Content Filter
Filter on AJAX calls. (3 posts)

  1. willgladstone
    Posted 3 years ago #

    Content being pulled with an ajax call are not filtered. Changing to

    if( is_admin() && !( defined('DOING_AJAX') && DOING_AJAX ) ) return; /* Only filter front end content. */

    of the pccf_contfilt function fixes this.


  2. David Gwyer
    Plugin Author

    Posted 3 years ago #

    Hi, thanks for the code snippet.

    Can you tell me how you are actively testing this (i.e. with an Ajax Plugin?) so I can confirm my end that this fixes Ajax requested content.

  3. willgladstone
    Posted 3 years ago #

    I'm making a javascript call to /wp-admin/admin-ajax.php to dynamically pull post content and update a page. This triggers the built in wordpress ajax handlers. But this ajax call will be flagged as admin. Since your filters are all on front end functions, checking if you are doing an ajax call shouldn't affect the core set of ajax calls on the admin end. Looking at the $core_actions_get & $core_actions_post variables in /wp-admin/admin-ajax.php, it seems it might be possible there will be issues with get-tagcloud & get-comments but looking at them further it seems like it should be ok with the filters you are setting hooks with.

    As a workaround, I've just set the filters externally in my functions.php file but it would be nice if the content that was filtered within the plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.