[wp-trac] [WordPress Trac] #27315: Easier adding of custom class variables when extending WP_Customize_Section
WordPress Trac
noreply at wordpress.org
Wed Jun 18 05:24:56 UTC 2014
#27315: Easier adding of custom class variables when extending WP_Customize_Section
----------------------------------------+-----------------------------
Reporter: rhurling | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Appearance | Version: 3.4
Severity: normal | Resolution:
Keywords: good-first-bug needs-patch | Focuses: administration
----------------------------------------+-----------------------------
Changes (by westonruter):
* keywords: => good-first-bug needs-patch
* version: 3.8.1 => 3.4
* milestone: Awaiting Review => Future Release
Old description:
> WP_Customize_Section uses `$keys = array_keys( get_class_vars( __CLASS__
> ) );` to set class variables, but WP_Customize_Control uses `$keys =
> array_keys( get_object_vars( $this ) );` to set class variables.
>
> The difference is that if you extend WP_Customize_Control you can add new
> class variables by setting them in the extended class and passing them to
> the args array in the constructor.
> In WP_Customize_Section one has to override the constructor to do the
> same.
>
> changing
> `$keys = array_keys( get_class_vars( __CLASS__ ) );`
> to
> `$keys = array_keys( get_object_vars( $this ) );`
> in WP_Customize_Section would solve the problem (or use the static
> keyword which would raise the requirements to PHP 5.3)
New description:
`WP_Customize_Section` uses `$keys = array_keys( get_class_vars( __CLASS__
) );` to set class variables, but `WP_Customize_Control` uses `$keys =
array_keys( get_object_vars( $this ) );` to set class variables.
The difference is that if you extend `WP_Customize_Control` you can add
new class variables by setting them in the extended class and passing them
to the args array in the constructor.
In `WP_Customize_Section` one has to override the constructor to do the
same.
changing
{{{
$keys = array_keys( get_class_vars( __CLASS__ ) );
}}}
to
{{{
$keys = array_keys( get_object_vars( $this ) );
}}}
in `WP_Customize_Section` would solve the problem (or use the static
keyword which would raise the requirements to PHP 5.3)
--
Comment:
Agreed. `get_class_vars( __CLASS__ )` should be replaced with
`get_object_vars( $this )`. This would actually bring
`WP_Customize_Section` in line `WP_Customize_Control` which initially did
use `get_class_vars()` but in [20319] was changed to use
`get_object_vars()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27315#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list