[wp-trac] [WordPress Trac] #37748: Dynamic Hooks Naming Convention
WordPress Trac
noreply at wordpress.org
Sat Aug 20 12:51:07 UTC 2016
#37748: Dynamic Hooks Naming Convention
-------------------------------+-----------------------------
Reporter: ramiy | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: docs, performance |
-------------------------------+-----------------------------
Currently, WordPress core has no naming-convention for
[https://developer.wordpress.org/?s=%7B&post_type%5B%5D=wp-parser-hook
dynamic hooks]. I'm talking about actions and filters which have
parameters in their name.
=== Proposed Change ===
Dynamic hooks like:
`do_action( 'wp_hook_' . $dynamic_field . '_name' );`
Should be replaced with:
`do_action( "wp_hook_{$dynamic_field}_name" );`
=== New Naming Convention ===
'''Currently, we use both ways to concatenate dynamic fields'''. We need
to have a single standard way to do that.
When hook names have dynamic fields, we should use
"`wp_hook_{$dynamic_field}_name`". It's more readable structure for
developers and has
[http://php.net/manual/en/language.operators.string.php#60035 performance
benefits] with multiple dynamic fields, as PHP is forced to re-concatenate
with every '`.`' operator.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37748>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list