[wp-trac] [WordPress Trac] #49678: do_action default first parameter
WordPress Trac
noreply at wordpress.org
Mon May 4 17:19:49 UTC 2020
#49678: do_action default first parameter
--------------------------+------------------------------
Reporter: Tkama | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 5.3.2
Severity: normal | Resolution:
Keywords: dev-feedback | Focuses:
--------------------------+------------------------------
Comment (by Tkama):
@donmhico thanks. There is no difficulties to find the reason and fix it
for me. The idea of this ticket: maybe it's better to fix core code for
more predictable behavior of such code.
For example:
{{{#!php
<?php
add_action( 'action_name', function( $first = 'foo' ){
// some logic
echo $first
} );
do_action( 'action_name' );
}}}
As we can see. We don't pass any params to
{{{
do_action( 'action_name' );
}}}
and we expect the code print `foo` but not `''`.
Such hook-call logic we can use, for example, for plugins when we want
wrap some plugin function, for save plugin deactivation when plugin
function is used inside the theme template files.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49678#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list