WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. willgladstone
    Member
    Posted 8 months 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.

    http://wordpress.org/plugins/wp-content-filter/

  2. David Gwyer
    Member
    Plugin Author

    Posted 8 months 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
    Member
    Posted 8 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.