| 202 | $update_url = add_query_arg( array( |
| 203 | 'action' => 'upgrade-theme', |
| 204 | 'theme' => $theme->slug, |
| 205 | ), self_admin_url( 'update.php' ) ); |
| 206 | |
| 207 | $status = $this->_get_theme_status( $theme ); |
| 208 | |
| 209 | switch ( $status ) { |
| 210 | default: |
| 211 | case 'install': |
| 212 | $actions[] = '<a class="install-now" href="' . wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>'; |
| 213 | break; |
| 214 | case 'update_available': |
| 215 | $actions[] = '<a class="install-now" href="' . wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>'; |
| 216 | break; |
| 217 | case 'newer_installed': |
| 218 | case 'latest_installed': |
| 219 | $actions[] = '<span class="install-now" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>'; |
| 220 | break; |
| 221 | } |
| 222 | |
294 | | <div class="install-theme-info"> |
295 | | <a class="theme-install button-primary" href="<?php echo wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ); ?>"><?php _e( 'Install' ); ?></a> |
| 321 | <div class="install-theme-info"><?php |
| 322 | switch ( $status ) { |
| 323 | default: |
| 324 | case 'install': |
| 325 | echo '<a class="theme-install button-primary" href="' . wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) . '">' . __( 'Install' ) . '</a>'; |
| 326 | break; |
| 327 | case 'update_available': |
| 328 | echo '<a class="theme-install button-primary" href="' . wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>'; |
| 329 | break; |
| 330 | case 'newer_installed': |
| 331 | case 'latest_installed': |
| 332 | echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>'; |
| 333 | break; |
| 334 | } ?> |
| 370 | |
| 371 | /** |
| 372 | * Check to see if the theme is already installed. |
| 373 | * |
| 374 | * @since 3.4 |
| 375 | * @access private |
| 376 | * |
| 377 | * @param object $theme - A WordPress.org Theme API object. |
| 378 | * @return string Theme status. |
| 379 | */ |
| 380 | function _get_theme_status( $theme ) { |
| 381 | $status = 'install'; |
| 382 | |
| 383 | $installed_theme = wp_get_theme( $theme->slug ); |
| 384 | if ( $installed_theme->exists() ) { |
| 385 | if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) ) |
| 386 | $status = 'latest_installed'; |
| 387 | elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) ) |
| 388 | $status = 'newer_installed'; |
| 389 | else |
| 390 | $status = 'update_available'; |
| 391 | } |
| 392 | |
| 393 | return $status; |
| 394 | } |