Opened 14 years ago
Last modified 5 years ago
#23040 assigned enhancement
Deprecate magic methods __isset() & __get() method of WP_Theme object
| Reported by: | wpsmith | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Themes | Version: | 3.4 |
| Severity: | normal | Keywords: | has-patch needs-refresh |
| Cc: | Focuses: |
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
@
14 years ago
#4
@
14 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
@
13 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
@
13 years ago
- Summary Expand __get() method of WP_Theme object → Deprecate magic methods __isset() & __get() method of WP_Theme object
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Updated the Codex Examples