#36452 closed defect (bug) (fixed)
customize_value should be passed $this
Reported by: | nwp_developer | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 4.4.2 |
Component: | Customize | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
In $WP_Customize_Setting->value():
$value = apply_filters( "customize_value_{$id_base}", $value );
should be
$value = apply_filters( "customize_value_{$id_base}", $this);
because only having access to $default severely limits the ability to modify the value for custom settings not handled as theme_mod or option.
For example, if I need access to other setting properties at add_filter(customize_value...) to filter the setting value how do I get access to those properties?
Attachments (2)
Change History (14)
#1
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
You are absolutely right. See #29316 and review patch. I the mean time, I recommend using a WP_Customize_Setting
subclass in lieu of using hooks to handle your custom setting type.
#2
@
9 years ago
- Keywords has-patch added
- Milestone set to Future Release
- Type changed from feature request to defect (bug)
Good catch @nwp_developer!
I think this was an oversight when we started passing $this
with all of the hooks here (hence marking as a bug). Every action and filter in WP_Customize_Setting
passes $this
as its last argument with this change; see 36452.diff. We do need to keep $value
as the first argument for backwards compatibility, so a second parameter with the setting would be passed as well now. See previously #27979.
Per Slack discussion, let's see if we can get this smaller change in without waiting for a full resolution of the proposed new hooks in #29316.
#3
@
9 years ago
Slackbot missed the ticket: https://wordpress.slack.com/archives/core-customize/p1460145042000403
#5
@
9 years ago
- Milestone changed from Future Release to 4.6
36452.diff should be ready for commit.
#6
follow-up:
↓ 7
@
9 years ago
Thanks!
Can anyone give me a start to how to use do_action( "customize_preview_{$this->type}", $this ) if I have a setting that's saved outside of wp_options?
How would I handle the customizer iframe preview similar to how get_theme_mod() works? I can't use transport=>postMessage since content is dynamic.
#7
in reply to:
↑ 6
@
9 years ago
Replying to nwp_developer:
Can anyone give me a start to how to use do_action( "customize_preview_{$this->type}", $this ) if I have a setting that's saved outside of wp_options?
How would I handle the customizer iframe preview similar to how get_theme_mod() works? I can't use transport=>postMessage since content is dynamic.
Please ask this question on the support forums or on the WordPress Dev Stack Exchange.
#8
@
9 years ago
- Keywords commit added
- Owner set to westonruter
- Status changed from reopened to reviewing
Pass $this to the
customize_value_
filter.