[wp-trac] [WordPress Trac] #38935: Proposition to add the theme mod name as a param to the dynamic theme_mod_{$name} filters
WordPress Trac
noreply at wordpress.org
Thu Nov 24 15:07:21 UTC 2016
#38935: Proposition to add the theme mod name as a param to the dynamic
theme_mod_{$name} filters
-------------------------+-----------------------------
Reporter: nikeo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
Hi !
It would be convenient to be able to target a specific theme mod name when
applying the same callback to all theme mods with `add_filter(
"theme_mod_{$name}", '_my_generic_callback' )`.
Right now we need to extract the theme mod with a code looking like this :
{{{#!php
<?php
function _my_generic_callback( $theme_mod_value ) {
//extract theme mod name
$_filter = current_filter();
$_ptrn = 'theme_mod_';
if ( $_ptrn !== substr( $_filter, 0, strlen($_ptrn) ) )
return $theme_mod_value;
$_mod_name = str_replace($_ptrn, '', $_filter);
//do things now
// ...
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38935>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list