WordPress.org

Plugin Directory

Opened 4 years ago

#2218 new defect

Feed JSON references $this inside static method, causes PHP warning

Reported by: rohnjeynolds Owned by: wokamoto
Priority: highest Severity: blocker
Plugin: not-listed Keywords: feed-json
Cc:

Description

Around line 81:

static public function add_feed_json() { 
  add_feed('json', array($this, 'do_feed_json')); 
}


The variable $this isn't available inside static functions. Because $this doesn't reference a valid class instance, call_user_func_array() -- called within the WP core function do_action() -- rejects array($this, 'do_feed_json') for being an invalid callable, and a PHP warning is thrown.

Removing 'static' solves the problem without side effect, as far as I can tell. I don't see an instance in the plugin where this method is, or would need to be, called statically.

Change History (0)

Note: See TracTickets for help on using tickets.