[wp-trac] [WordPress Trac] #57887: The WordPress core does not support calling non-static methods for hook filters and actions within a namespace

WordPress Trac noreply at wordpress.org
Wed Mar 8 15:31:58 UTC 2023


#57887: The WordPress core does not support calling non-static methods for hook
filters and actions within a namespace
-------------------------------+-----------------------------------------
 Reporter:  markcarbonell2013  |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  General            |     Version:  6.1.1
 Severity:  normal             |  Resolution:
 Keywords:  close              |     Focuses:  rest-api, coding-standards
-------------------------------+-----------------------------------------
Changes (by jrf):

 * keywords:  changes-requested needs-refresh needs-patch needs-testing =>
     close
 * severity:  blocker => normal


Comment:

 @markcarbonell2013 I haven't tested your code, but I know from experience
 that your statement that ''"only static methods are supported when using
 namespaced classes"'' just isn't true.

 There are plenty of plugins out there - including in the official WP
 repository - which use namespaces and non-static methods and everything
 works perfectly fine.

 There is ''one'' restriction, and that is that methods being used as
 callbacks need to be `public`, but that's a limitation in PHP, not WP.

 Based on your code example, however, that doesn't seem to be the problem
 here.

 To figure out what's going wrong with your plugin, I think you'll need to
 dig a little deeper as this report doesn't contain the right information
 to help you.

 Also please note: if you are looking for support when building a plugin,
 the support forums are the channel to use. Trac is really only for bugs in
 WP Core and this is not one of them.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57887#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list