WordPress.org

Make WordPress Core

Opened 12 months ago

Last modified 12 months ago

#38935 new enhancement

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

Reported by: 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 12 months ago.
add the theme mod name to the dynamic theme_mod_{$name} filters

Download all attachments as: .zip

Change History (2)

@nikeo
12 months ago

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

#1 @swissspidy
12 months ago

  • Keywords has-patch added
  • Version trunk deleted
Note: See TracTickets for help on using tickets.