PHP Warning When Applying Additional the_excerpt_rss Filter
-
I’m trying to filter the RSS excerpt, but when I do, I get this PHP Warning:
Warning: Attempt to read property "post_type" on null in \wp-content\plugins\events-manager\classes\em-event-post.php on line 110
Somehow(???) when I add a filter for the_excerpt_rss, then suddenly this function can’t use the global $post?? I really have no ideas, except that maybe the function should make sure it has a valid global $post object before doing anything else?
This is the function where the error is:
public static function the_excerpt_rss( $content ){ global $post; if( $post->post_type == EM_POST_TYPE_EVENT ){ if( get_option('dbem_cp_events_formats') ){ $EM_Event = em_get_event($post); $content = $EM_Event->output( get_option ( 'dbem_rss_description_format' ), "rss"); $content = ent2ncr(convert_chars($content)); //Some RSS filtering } } return $content; }
This code works for making sure I don’t get the warning, but I don’t know why it doesn’t have a global $post when I add an additional filter to the_excerpt_rss.
No warning:
public static function the_excerpt_rss( $content ){ global $post; if( is_object($post) && $post->post_type == EM_POST_TYPE_EVENT ){ if( get_option('dbem_cp_events_formats') ){ $EM_Event = em_get_event($post); $content = $EM_Event->output( get_option ( 'dbem_rss_description_format' ), "rss"); $content = ent2ncr(convert_chars($content)); //Some RSS filtering } } return $content; }
It does seem like this check would be good there, even if it doesn’t get to the root of the issue.
Any ideas about what’s happened with the filter?
Thanks!
- The topic ‘PHP Warning When Applying Additional the_excerpt_rss Filter’ is closed to new replies.