Opened 13 years ago
Last modified 4 years ago
#23040 assigned enhancement
Deprecate magic methods __isset() & __get() method of WP_Theme object
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | 3.4 |
| Component: | Themes | Keywords: | has-patch needs-refresh |
| Focuses: | Cc: |
Description
Currently, a user can do the following:
$theme = wp_get_theme(); $version = $theme->Version; $name = $theme->Name; $author = $theme->Author; $version = $theme->Version;
So, when I tried to get the other data in the same method, I was getting nothing. However, to get the other data, one must do this:
$theme->{'Author URI'}; // per Codex;
$theme->get( 'AuthorURI' ); // $theme->AuthorURI doesn't work
$theme->get( 'ThemeURI' ); // $theme->ThemeURI & $theme->{'Theme URI'}; doesn't work
$theme->get( 'TextDomain' ); // $theme->TextDomain & $theme->{'Text Domain'}; doesn't work
get() is a great method to get the other data; however, shouldn't we make this consistent for developers?
Attachments (2)
Change History (13)
#1
in reply to:
↑ description
@
13 years ago
#2
@
13 years ago
- Summary changed from Expand use of WP_Theme object to Expand __get() method of WP_Theme object
#4
@
13 years ago
The doc block for __get() says it is "for properties formerly returned by current_theme_info()". What it should also mention is this is deprecated functionality. So is offsetExists(), which implements ArrayAccess.
get() and display() are the proper methods to use. The property ($theme->property) and key ($theme['property']) ways of getting data should realistically be deprecated, as they have ambiguous and inconsistent behavior.
#5
@
12 years ago
Updated Codex to only use the get() method. Added _doing_it_wrong() notifications to the magic methods __isset() & __get() and _deprecated_function() notification to offsetExists().
#6
@
12 years ago
- Summary changed from Expand __get() method of WP_Theme object to Deprecate magic methods __isset() & __get() method of WP_Theme object
#7
@
12 years ago
- Keywords needs-refresh added; 2nd-opinion dev-feedback removed
- Milestone changed from Awaiting Review to Future Release
- Version set to 3.4
Updated the Codex Examples