Make WordPress Core

Opened 8 years ago

Last modified 6 years ago

#38935 new enhancement

Proposition to add the theme mod name as a param to the dynamic theme_mod_{$name} filters

Reported by: nikeo's profile nikeo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch
Focuses: Cc:

Description

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
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
  // ...
}

Attachments (1)

38935.patch (855 bytes) - added by nikeo 8 years ago.
add the theme mod name to the dynamic theme_mod_{$name} filters

Download all attachments as: .zip

Change History (3)

@nikeo
8 years ago

add the theme mod name to the dynamic theme_mod_{$name} filters

#1 @swissspidy
8 years ago

  • Keywords has-patch added
  • Version trunk deleted

#2 @joyously
6 years ago

Wouldn't this apply to all dynamically named filters?

Note: See TracTickets for help on using tickets.