Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'd like to know whether anybody has heard of , or created a workaround to the following problem:

let's say there is a plugin which has code like this,

add_filter('the_content'.'some_func');
some_func($content)
{
    if(is_singular())
    {
    //do something and return the content
    }
    else
    {
    //just return the content,dont modify it in any way.
    }
}

now in my plugin there is code like this

    $doggy = apply_filters('the_content',$content)

but because the author of the earlier plugin has specified the is_singular, my $doggy WILL NOT get the content with the changes that the earlier plugin would have applied otherwise. As a result i wont be able to use the actual final content to do whatever i want in my plugin.

Any help is appreciated, since i just read an article where the author says, "the is singular has been designed so that the filters apply only within the main WP query." So i have an additional question - as to whether there is any way to intercept this. I would like to use this apply filters action inside my code like this,

wp_insert_post_data($data,$postarr)
{
$data["post_content"] = apply_filters('the_content',$data["post_content"])
$data["post_content"] = my_func($data["post_content"]);
return $data;
}

and manipulate the story content, after applying all the filters that would be eventually applied to the content, and then returning the data.

I hope i have explained things clearly. I need a workaround, since i dont think an official solution exists. AND-- doing what i need to do ---using--- save post or publish post is NOT AN OPTION FOR MY PURPOSE. Also i cannot do this on the_content filter. I NEED A SOLUTION THAT WORKS BEFORE THE POST DATA IS INSERTED INTO THE DATABASE. SO please do not suggest that.

Best Regards, app_maniac.

share|improve this question
1  
it's not clear why you'd want to do this, filters on the_content are not supposed to be used on data being inserted into the database, it's only for output to the page –  Milo Feb 8 '13 at 17:46
    
do you have any suggestions on how i could do what i want to do? it would really help. –  user1895623 Feb 8 '13 at 18:19
add comment

1 Answer

You can try to remove the filter

remove_filter('the_content', 'some_func');

and add it again with your customized version of some_func() called some_func_mod():

add_filter('the_content', 'some_func_mod');
share|improve this answer
    
hello birgire,could you please elaborate a bit?? i dont quite understand how this will help me get the modified content( by the other plugin) –  user1895623 Feb 8 '13 at 21:13
    
the idea is to use your own function instead of some_func(), so you can overwrite it that way ;-) –  birgire Feb 9 '13 at 20:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.