| | 272 | $update_url = add_query_arg( array( |
| | 273 | 'action' => 'upgrade-theme', |
| | 274 | 'theme' => $theme->slug, |
| | 275 | ), self_admin_url( 'update.php' ) ); |
| | 276 | |
| | 277 | $status = 'install'; |
| | 278 | |
| | 279 | // Check to see if the theme is already installed |
| | 280 | $installed_theme = wp_get_theme( $theme->slug ); |
| | 281 | if ( $installed_theme->exists() ) { |
| | 282 | if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) ) |
| | 283 | $status = 'latest_installed'; |
| | 284 | elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) ) |
| | 285 | $status = 'newer_installed'; |
| | 286 | else |
| | 287 | $status = 'update_available'; |
| | 288 | } |
| | 289 | |
| 273 | | <div class="install-theme-info"> |
| 274 | | <a class="theme-install button-primary" href="<?php echo wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ); ?>"><?php _e( 'Install' ); ?></a> |
| | 291 | <div class="install-theme-info"><?php |
| | 292 | switch ( $status ) { |
| | 293 | default: |
| | 294 | case 'install': |
| | 295 | echo '<a class="theme-install button-primary" href="' . wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) . '">' . __( 'Install' ) . '</a>'; |
| | 296 | break; |
| | 297 | case 'update_available': |
| | 298 | 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>'; |
| | 299 | break; |
| | 300 | case 'newer_installed': |
| | 301 | case 'latest_installed': |
| | 302 | echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'theme' ) . '</span>'; |
| | 303 | break; |
| | 304 | } ?> |