[wp-trac] [WordPress Trac] #30448: Customizer Manager/Settings classes do not provide public save method to use outside of customize.php

WordPress Trac noreply at wordpress.org
Fri Jan 2 13:42:03 UTC 2015


#30448: Customizer Manager/Settings classes do not provide public save method to
use outside of customize.php
-------------------------+------------------------------
 Reporter:  CrazyJaco    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Customize    |     Version:  4.0
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:
-------------------------+------------------------------

Comment (by CrazyJaco):

 Replying to [comment:5 westonruter]:
 > What are you trying to do, exactly? What does your
 `filter_customize_save_value` function do?
 >
 > Also, instead of adding a new filter to change the value being saved, I
 think what you actually want is to allow the
 `WP_Customize_Setting::save()` method to allow an argument to be supplied,
 whereas right now it always gets its value from `$_POST`. So you could do
 this:
 >
 > {{{#!php
 > foreach ( $wp_customize->settings() as $setting ) {
 >     $setting->save( $my_override_values[ $setting->id ] );
 > }
 > }}}
 >
 > When a value is passed in to the `save` method, then it could bypass the
 call to `$this->post_value()`.


 I agree. That is a much better approach.

 As for what I'm trying to do:
 I have a plugin that takes all the existing customizer settings for a
 theme and exports them to json.
 In a second plugin that I install on a different blog/server/etc, it reads
 that json and saves those settings to the new blog.

 A pretty basic export/import process.

 The callback function just returns the value of the setting being saved
 from the imported data.

 I'll update the patch for the new approach.

 Thank you for the feedback! Its greatly appreciated.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30448#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list