[wp-trac] [WordPress Trac] #14721: set_theme_mod() needs a filter

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 28 17:56:13 UTC 2010


#14721: set_theme_mod() needs a filter
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:                 
 Severity:  normal        |    Keywords:                 
--------------------------+-------------------------------------------------
 '''`set_theme_mod()`''' '''needs a filter'''!!!

 '''Background:''' I was answering
 [http://wordpress.stackexchange.com/questions/972/ this question on
 WordPress Answers] about how to create a second background option in the
 admin.  I was able to do so relatively easily except for the fact that the
 only hook available for swapping the value to save for `set_theme_mod()`
 is within `get_option()` and `get_option()` has no context for the name of
 the theme mod so I had to resort to the highly brittle technique of
 determining what was being saved based on the order it was called. One
 small change to `/wp-admin/custom-background.php` and it all breaks.

 '''Prospective Update:'''
 Here's what the filters might look like:

 {{{
 function set_theme_mod($name, $value) {
         $theme = get_current_theme();

         $mods = get_option("mods_$theme");

         $value = apply_filters( "set_theme_mod", $value, $name );
         $value = apply_filters( "set_theme_mod_$name", $value );
         $mods[$name] = $value;

         update_option("mods_$theme", $mods);
         wp_cache_delete("mods_$theme", 'options');
 }

 }}}


 I would submit a patch but I always struggle with that. I even asked
 others to [http://wordpress.stackexchange.com/questions/990/ help me
 streamline and understand the patching process a bit better].

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14721>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list