<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13920] trunk: Rename Install to More Information,
Add an Install Now action link to the Plugin Installer search results.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13920">13920</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-04-01 23:17:53 +0000 (Thu, 01 Apr 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Rename Install to More Information, Add an Install Now action link to the Plugin Installer search results. See <a href="http://trac.wordpress.org/ticket/11050">#11050</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincssplugininstallcss">trunk/wp-admin/css/plugin-install.css</a></li>
<li><a href="#trunkwpadmincssplugininstalldevcss">trunk/wp-admin/css/plugin-install.dev.css</a></li>
<li><a href="#trunkwpadminincludesplugininstallphp">trunk/wp-admin/includes/plugin-install.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincssplugininstallcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/plugin-install.css (13919 => 13920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/plugin-install.css        2010-04-01 21:22:48 UTC (rev 13919)
+++ trunk/wp-admin/css/plugin-install.css        2010-04-01 23:17:53 UTC (rev 13920)
</span><span class="lines">@@ -1 +1 @@
</span><del>-div.star-holder{position:relative;height:19px;width:100px;font-size:19px;}div.action-links{font-weight:normal;margin:6px 0 0;}div.star{height:100%;position:absolute;top:0;left:0;background-color:transparent;letter-spacing:1ex;border:none;}.star1{width:20%;}.star2{width:40%;}.star3{width:60%;}.star4{width:80%;}.star5{width:100%;}.star img,div.star a,div.star a:hover,div.star a:visited{display:block;position:absolute;right:0;border:none;text-decoration:none;}div.star img{width:19px;height:19px;border-left:1px solid #fff;border-right:1px solid #fff;}#plugin-information-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}#plugin-information ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}#plugin-information p.action-button{width:100%;padding-bottom:0;margin-bottom:0;margin-top:10px;-moz-border-radius:3px 0 0 3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}#plugin-information .action-button a{text-align:center;font-weight:bold;text-decoration:none;display:block;line-height:2em;}#plugin-information h2{clear:none!important;margin-right:200px;}#plugin-information .fyi{margin:0 10px 50px;width:210px;}#plugin-information .fyi h2{font-size:.9em;margin-bottom:0;margin-right:0;}#plugin-information .fyi h2.mainheader{padding:5px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;}#plugin-information .fyi ul{padding:10px 5px 10px 7px;margin:0;list-style:none;-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}#plugin-information .fyi li{margin-right:0;}#plugin-information #section-holder{padding:10px;}#plugin-information .section ul,#plugin-information .section ol{margin-left:16px;list-style-type:square;list-style-image:none;}#plugin-information #section-screenshots li img{vertical-align:text-top;}#plugin-information #section-screenshots li p{font-style:italic;padding-left:20px;padding-bottom:2em;}#plugin-information .updated,#plugin-information pre{margin-right:215px;}#plugin-information pre{padding:7px;}
</del><span class="cx">\ No newline at end of file
</span><ins>+div.star-holder{position:relative;height:19px;width:100px;font-size:19px;}div.action-links{font-weight:normal;margin:6px 0 0;}div.star{height:100%;position:absolute;top:0;left:0;background-color:transparent;letter-spacing:1ex;border:none;}.star1{width:20%;}.star2{width:40%;}.star3{width:60%;}.star4{width:80%;}.star5{width:100%;}.star img,div.star a,div.star a:hover,div.star a:visited{display:block;position:absolute;right:0;border:none;text-decoration:none;}div.star img{width:19px;height:19px;border-left:1px solid #fff;border-right:1px solid #fff;}table#install-plugins th.num{white-space:nowrap;}#plugin-information-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}#plugin-information ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}#plugin-information p.action-button{width:100%;padding-bottom:0;margin-bottom:0;margin-top:10px;-moz-border-radius:3px 0 0 3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}#plugin-information .action-button a{text-align:center;font-weight:bold;text-decoration:none;display:block;line-height:2em;}#plugin-information h2{clear:none!important;margin-right:200px;}#plugin-information .fyi{margin:0 10px 50px;width:210px;}#plugin-information .fyi h2{font-size:.9em;margin-bottom:0;margin-right:0;}#plugin-information .fyi h2.mainheader{padding:5px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;}#plugin-information .fyi ul{padding:10px 5px 10px 7px;margin:0;list-style:none;-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}#plugin-information .fyi li{margin-right:0;}#plugin-information #section-holder{padding:10px;}#plugin-information .section ul,#plugin-information .section ol{margin-left:16px;list-style-type:square;list-style-image:none;}#plugin-information #section-screenshots li img{vertical-align:text-top;}#plugin-information #section-screenshots li p{font-style:italic;padding-left:20px;padding-bottom:2em;}#plugin-information .updated,#plugin-information pre{margin-right:215px;}#plugin-information pre{padding:7px;}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadmincssplugininstalldevcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/plugin-install.dev.css (13919 => 13920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/plugin-install.dev.css        2010-04-01 21:22:48 UTC (rev 13919)
+++ trunk/wp-admin/css/plugin-install.dev.css        2010-04-01 23:17:53 UTC (rev 13920)
</span><span class="lines">@@ -42,7 +42,11 @@
</span><span class="cx">         border-right: 1px solid #fff;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-/* Start custom CSS */
</del><ins>+/* Table layout CSS */
+table#install-plugins th.num {
+        white-space: nowrap; /* Prevents long plugin titles from causing the version column to wrap */
+}
+
</ins><span class="cx"> /* Header on thickbox */
</span><span class="cx"> #plugin-information-header {
</span><span class="cx">         margin: 0;
</span></span></pre></div>
<a id="trunkwpadminincludesplugininstallphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/plugin-install.php (13919 => 13920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/plugin-install.php        2010-04-01 21:22:48 UTC (rev 13919)
+++ trunk/wp-admin/includes/plugin-install.php        2010-04-01 23:17:53 UTC (rev 13920)
</span><span class="lines">@@ -354,9 +354,28 @@
</span><span class="cx">
</span><span class="cx">                                 $action_links = array();
</span><span class="cx">                                 $action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
</span><del>-                                                                        '&amp;TB_iframe=true&amp;width=600&amp;height=550') . '" class="thickbox onclick" title="' .
-                                                                        esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __('Install') . '</a>';
</del><ins>+                                                                        '&amp;TB_iframe=true&amp;width=600&amp;height=550') . '" class="thickbox" title="' .
+                                                                        esc_attr( sprintf( __( 'Information about %s' ), $name ) ) . '">' . __('More Information') . '</a>';
</ins><span class="cx">
</span><ins>+                                if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) {
+                                        $status = install_plugin_install_status($plugin);
+
+                                        switch ( $status['status'] ) {
+                                                case 'install':
+                                                        if ( $url )
+                                                                $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __('Install Now') . '</a>';
+                                                        break;
+                                                case 'update_available':
+                                                        if ( $url )
+                                                                $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to %s' ), $status['version'] ) ) . '">' . sprintf(__('Update to version %s'), $status['version']) . '</a>';
+                                                        break;
+                                                case 'latest_installed':
+                                                case 'newer_installed':
+                                                        $action_links[] = '<span>' . __('This plugin is already installed') . '</span>';
+                                                        break;
+                                        }
+                                }
+
</ins><span class="cx">                                 $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
</span><span class="cx">                         ?>
</span><span class="cx">                         <tr>
</span><span class="lines">@@ -394,6 +413,67 @@
</span><span class="cx"> add_action('install_plugins_pre_plugin-information', 'install_plugin_information');
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Determine the status we can perform on a plugin.
+ *
+ * @since 3.0.0
+ */
+function install_plugin_install_status($api, $loop = false) {
+        // this function is called recursivly, $loop prevents futhur loops.
+        if ( is_array($api) )
+                $api = (object) $api;
+
+        //Default to a "new" plugin
+        $status = 'install';
+        $url = false;
+
+        //Check to see if this plugin is known to be installed, and has an update awaiting it.
+        $update_plugins = get_site_transient('update_plugins');
+        if ( is_object( $update_plugins ) ) {
+                foreach ( (array)$update_plugins->response as $file => $plugin ) {
+                        if ( $plugin->slug === $api->slug ) {
+                                $status = 'update_available';
+                                $update_file = $file;
+                                $version = $plugin->new_version;
+                                if ( current_user_can('update_plugins') )
+                                        $url = wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file);
+                                break;
+                        }
+                }
+        }
+
+        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(admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
+                        } else {
+                                $key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
+                                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);
+                                        }
+                                }
+                        }
+                } else {
+                        // "install" & no directory with that slug
+                        if ( current_user_can('install_plugins') )
+                                $url = wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
+                }
+        }
+
+        return compact('status', 'url', 'version');
+}
+
+/**
</ins><span class="cx"> * Display plugin information in dialog box form.
</span><span class="cx"> *
</span><span class="cx"> * @since 2.7.0
</span><span class="lines">@@ -440,63 +520,27 @@
</span><span class="cx">         echo "</div>\n";
</span><span class="cx">         ?>
</span><span class="cx">         <div class="alignright fyi">
</span><del>-                <?php if ( ! empty($api->download_link) ) : ?>
</del><ins>+                <?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?>
</ins><span class="cx">                 <p class="action-button">
</span><span class="cx">                 <?php
</span><del>-                        //Default to a "new" plugin
-                        $type = 'install';
-                        //Check to see if this plugin is known to be installed, and has an update awaiting it.
-                        $update_plugins = get_site_transient('update_plugins');
-                        if ( is_object( $update_plugins ) ) {
-                                foreach ( (array)$update_plugins->response as $file => $plugin ) {
-                                        if ( $plugin->slug === $api->slug ) {
-                                                $type = 'update_available';
-                                                $update_file = $file;
-                                                break;
-                                        }
-                                }
-                        }
-                        if ( 'install' == $type && is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
-                                $installed_plugin = get_plugins('/' . $api->slug);
-                                if ( ! empty($installed_plugin) ) {
-                                        $key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
-                                        if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
-                                                $type = 'latest_installed';
-                                        } elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
-                                                $type = 'newer_installed';
-                                                $newer_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
-                                                delete_site_transient('update_plugins');
-                                                $update_file = $api->slug . '/' . $key; //This code branch only deals with a plugin which is in a folder the same name as its slug, Doesnt support plugins which have 'non-standard' names
-                                                $type = 'update_available';
-                                        }
-                                }
-                        }
-
-                        switch ( $type ) :
-                                default:
-                                case 'install':
-                                        if ( current_user_can('install_plugins') ) :
-                                ?><a href="<?php echo wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug) ?>" target="_parent"><?php _e('Install Now') ?></a><?php
-                                        endif;
</del><ins>+                $status = install_plugin_install_status($api);
+                switch ( $status['status'] ) {
+                        case 'install':
+                                if ( $url )
+                                        echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
</ins><span class="cx">                                 break;
</span><del>-                                case 'update_available':
-                                        if ( current_user_can('update_plugins') ) :
-                                                ?><a href="<?php echo wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file) ?>" target="_parent"><?php _e('Install Update Now') ?></a><?php
-                                        endif;
</del><ins>+                        case 'update_available':
+                                if ( $url )
+                                        echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>';
</ins><span class="cx">                                 break;
</span><del>-                                case 'newer_installed':
-                                        if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) :
-                                        ?><a><?php printf(__('Newer Version (%s) Installed'), $newer_version) ?></a><?php
-                                        endif;
</del><ins>+                        case 'newer_installed':
+                                echo '<a>' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
</ins><span class="cx">                                 break;
</span><del>-                                case 'latest_installed':
-                                        if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) :
-                                        ?><a><?php _e('Latest Version Installed') ?></a><?php
-                                        endif;
</del><ins>+                        case 'latest_installed':
+                                echo '<a>' . __('Latest Version Installed') . '</a>';
</ins><span class="cx">                                 break;
</span><del>-                        endswitch; ?>
</del><ins>+                }
+                ?>
</ins><span class="cx">                 </p>
</span><span class="cx">                 <?php endif; ?>
</span><span class="cx">                 <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI') ?></h2>
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (13919 => 13920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-04-01 21:22:48 UTC (rev 13919)
+++ trunk/wp-includes/script-loader.php        2010-04-01 23:17:53 UTC (rev 13920)
</span><span class="lines">@@ -472,7 +472,7 @@
</span><span class="cx">         $styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array(), '20091022' );
</span><span class="cx">         $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20090514' );
</span><span class="cx">         $styles->add( 'login', "/wp-admin/css/login$suffix.css", array(), '20100326' );
</span><del>-        $styles->add( 'plugin-install', "/wp-admin/css/plugin-install$suffix.css", array(), '20100228' );
</del><ins>+        $styles->add( 'plugin-install', "/wp-admin/css/plugin-install$suffix.css", array(), '20100402' );
</ins><span class="cx">         $styles->add( 'theme-install', "/wp-admin/css/theme-install$suffix.css", array(), '20090610' );
</span><span class="cx">         $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' );
</span><span class="cx">         $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
</span></span></pre>
</div>
</div>
</body>
</html>