-?>
- <div class="tablenav">
- <div class="alignleft actions">
- <?php do_action('install_plugins_table_header'); ?>
- </div>
- <?php
- $url = esc_url($_SERVER['REQUEST_URI']);
- if ( ! empty($term) )
- $url = add_query_arg('s', $term, $url);
- if ( ! empty($type) )
- $url = add_query_arg('type', $type, $url);
-
- $page_links = paginate_links( array(
- 'base' => add_query_arg('paged', '%#%', $url),
- 'format' => '',
- 'prev_text' => __('«'),
- 'next_text' => __('»'),
- 'total' => $totalpages,
- 'current' => $page
- ));
-
- if ( $page_links )
- echo "\t\t<div class='tablenav-pages'>$page_links</div>";
-?>
- <br class="clear" />
- </div>
- <table class="widefat" id="install-plugins" cellspacing="0">
- <thead>
- <tr>
- <th scope="col" class="name"><?php _e('Name'); ?></th>
- <th scope="col" class="num"><?php _e('Version'); ?></th>
- <th scope="col" class="num"><?php _e('Rating'); ?></th>
- <th scope="col" class="desc"><?php _e('Description'); ?></th>
- <th scope="col" class="action-links"><?php _e('Actions'); ?></th>
- </tr>
- </thead>
-
- <tfoot>
- <tr>
- <th scope="col" class="name"><?php _e('Name'); ?></th>
- <th scope="col" class="num"><?php _e('Version'); ?></th>
- <th scope="col" class="num"><?php _e('Rating'); ?></th>
- <th scope="col" class="desc"><?php _e('Description'); ?></th>
- <th scope="col" class="action-links"><?php _e('Actions'); ?></th>
- </tr>
- </tfoot>
-
- <tbody class="plugins">
- <?php
- if( empty($plugins) )
- echo '<tr><td colspan="5">', __('No plugins match your request.'), '</td></tr>';
-
- foreach( (array) $plugins as $plugin ){
- if ( is_object($plugin) )
- $plugin = (array) $plugin;
-
- $title = wp_kses($plugin['name'], $plugins_allowedtags);
- //Limit description to 400char, and remove any HTML.
- $description = strip_tags($plugin['description']);
- if ( strlen($description) > 400 )
- $description = mb_substr($description, 0, 400) . '…';
- //remove any trailing entities
- $description = preg_replace('/&[^;\s]{0,6}$/', '', $description);
- //strip leading/trailing & multiple consecutive lines
- $description = trim($description);
- $description = preg_replace("|(\r?\n)+|", "\n", $description);
- //\n => <br>
- $description = nl2br($description);
- $version = wp_kses($plugin['version'], $plugins_allowedtags);
-
- $name = strip_tags($title . ' ' . $version);
-
- $author = $plugin['author'];
- if( ! empty($plugin['author']) )
- $author = ' <cite>' . sprintf( __('By %s'), $author ) . '.</cite>';
-
- $author = wp_kses($author, $plugins_allowedtags);
-
- if( isset($plugin['homepage']) )
- $title = '<a target="_blank" href="' . esc_attr($plugin['homepage']) . '">' . $title . '</a>';
-
- $action_links = array();
- $action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] .
- '&TB_iframe=true&width=600&height=550') . '" class="thickbox onclick" title="' .
- esc_attr($name) . '">' . __('Install') . '</a>';
-
- $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin);
- ?>
- <tr>
- <td class="name"><?php echo $title; ?></td>
- <td class="vers"><?php echo $version; ?></td>
- <td class="vers">
- <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings']), number_format_i18n($plugin['num_ratings'])) ?>">
- <div class="star star-rating" style="width: <?php echo esc_attr($plugin['rating']) ?>px"></div>
- <div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div>
- <div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div>
- <div class="star star3"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('3 stars') ?>" /></div>
- <div class="star star2"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('2 stars') ?>" /></div>
- <div class="star star1"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('1 star') ?>" /></div>
- </div>
- </td>
- <td class="desc"><?php echo $description, $author; ?></td>
- <td class="action-links"><?php if ( !empty($action_links) ) echo implode(' | ', $action_links); ?></td>
- </tr>
- <?php
+ if ( 'install' == $status ) {
+ if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
+ $installed_plugin = get_plugins('/' . $api->slug);
+ if ( empty($installed_plugin) ) {
+ if ( current_user_can('install_plugins') )
+ $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
+ } else {
+ $key = array_keys( $installed_plugin );
+ $key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
+ $update_file = $api->slug . '/' . $key;
+ if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
+ $status = 'latest_installed';
+ } elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
+ $status = 'newer_installed';
+ $version = $installed_plugin[ $key ]['Version'];
+ } else {
+ //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
+ if ( ! $loop ) {
+ delete_site_transient('update_plugins');
+ wp_update_plugins();
+ return install_plugin_install_status($api, true);
+ }
+ }