Permalink
Browse files

Fixed deprecated get_themes_call

  • Loading branch information...
conover committed Jul 31, 2012
1 parent 8b6fd1e commit 0a52377095f02100616d68ccd68a19d9c6611eb6
Showing with 4 additions and 2 deletions.
  1. +4 −2 updater.php
View
@@ -21,12 +21,14 @@ function github_extra_theme_headers( $headers ) {
function transient_update_themes_filter($data){
global $wp_version;
- $installed_themes = get_themes( );
+ $wp_34 = version_compare($wp_version, '3.4', '>=');
+
+ $installed_themes = $wp_34 ? wp_get_themes() : get_themes();
foreach ( (array) $installed_themes as $theme_title => $_theme ) {
// the WP_Theme object is very different now...
// This whole function should be refactored to not directly
// rely on the $theme variable the way it does
- if(version_compare($wp_version, '3.4', '>=')) {
+ if($wp_34) {
if(!$_theme->get('Github Theme URI')) {
continue;
} else {

4 comments on commit 0a52377

@scarstens

This comment has been minimized.

Show comment Hide comment
@scarstens

scarstens Aug 1, 2012

is line 26 considered shorthand? what if shorthand option for PHP is turned off on the server... does this fail?

is line 26 considered shorthand? what if shorthand option for PHP is turned off on the server... does this fail?

@afragen

This comment has been minimized.

Show comment Hide comment
@afragen

afragen Aug 1, 2012

Shorthand is PHP ternary if statement identical to
if ( $wp_34) {
$installed_themes = wp_get_themes();
} else {
$installed_themes = get_themes();
}

Shorthand is PHP ternary if statement identical to
if ( $wp_34) {
$installed_themes = wp_get_themes();
} else {
$installed_themes = get_themes();
}

@scarstens

This comment has been minimized.

Show comment Hide comment
@scarstens

scarstens Aug 1, 2012

right... so if the PHP option (http://www.php.net/manual/en/ini.core.php#ini.short-open-tag) for shorthand is off (which many servers have by default) does that mean this ternary if statement will fail?

right... so if the PHP option (http://www.php.net/manual/en/ini.core.php#ini.short-open-tag) for shorthand is off (which many servers have by default) does that mean this ternary if statement will fail?

@afragen

This comment has been minimized.

Show comment Hide comment
@afragen

afragen Aug 1, 2012

http://php.net/manual/en/language.operators.comparison.php

The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.

http://php.net/manual/en/language.operators.comparison.php

The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.

Please sign in to comment.