]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/plugin-install.php
WordPress 4.7
[autoinstalls/wordpress.git] / wp-admin / includes / plugin-install.php
index 4d558cf0eefab779bb379cd5bb1aef71bda4dfbc..0d932c2618cafc494153d1bf2d3ef3ea0ad1879b 100644 (file)
@@ -109,7 +109,7 @@ function plugins_api( $action, $args = array() ) {
        }
 
        if ( ! isset( $args->locale ) ) {
-               $args->locale = get_locale();
+               $args->locale = get_user_locale();
        }
 
        /**
@@ -155,16 +155,38 @@ function plugins_api( $action, $args = array() ) {
                $request = wp_remote_post( $url, $http_args );
 
                if ( $ssl && is_wp_error( $request ) ) {
-                       trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
+                       trigger_error(
+                               sprintf(
+                                       /* translators: %s: support forums URL */
+                                       __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
+                                       __( 'https://wordpress.org/support/' )
+                               ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
+                               headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
+                       );
                        $request = wp_remote_post( $http_url, $http_args );
                }
 
                if ( is_wp_error($request) ) {
-                       $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );
+                       $res = new WP_Error( 'plugins_api_failed',
+                               sprintf(
+                                       /* translators: %s: support forums URL */
+                                       __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
+                                       __( 'https://wordpress.org/support/' )
+                               ),
+                               $request->get_error_message()
+                       );
                } else {
                        $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
-                       if ( ! is_object( $res ) && ! is_array( $res ) )
-                               $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );
+                       if ( ! is_object( $res ) && ! is_array( $res ) ) {
+                               $res = new WP_Error( 'plugins_api_failed',
+                                       sprintf(
+                                               /* translators: %s: support forums URL */
+                                               __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
+                                               __( 'https://wordpress.org/support/' )
+                                       ),
+                                       wp_remote_retrieve_body( $request )
+                               );
+                       }
                }
        } elseif ( !is_wp_error($res) ) {
                $res->external = true;
@@ -210,7 +232,7 @@ function install_popular_tags( $args = array() ) {
  */
 function install_dashboard() {
        ?>
-       <p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ), 'https://wordpress.org/plugins/' ); ?></p>
+       <p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ), __( 'https://wordpress.org/plugins/' ) ); ?></p>
 
        <?php display_plugins_table(); ?>
 
@@ -263,9 +285,9 @@ function install_search_form( $deprecated = true ) {
                        <option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option>
                </select>
                <label><span class="screen-reader-text"><?php _e( 'Search Plugins' ); ?></span>
-                       <input type="search" name="s" value="<?php echo esc_attr( $term ) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search Plugins' ); ?>" />
+                       <input type="search" name="s" value="<?php echo esc_attr( $term ) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search plugins...' ); ?>" />
                </label>
-               <?php submit_button( __( 'Search Plugins' ), 'button hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?>
+               <?php submit_button( __( 'Search Plugins' ), 'hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?>
        </form><?php
 }
 
@@ -281,7 +303,7 @@ function install_plugins_upload() {
                <?php wp_nonce_field( 'plugin-upload' ); ?>
                <label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label>
                <input type="file" id="pluginzip" name="pluginzip" />
-               <?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?>
+               <?php submit_button( __( 'Install Now' ), '', 'install-plugin-submit', false ); ?>
        </form>
 </div>
 <?php
@@ -348,9 +370,16 @@ function display_plugins_table() {
  *
  * @since 3.0.0
  *
- * @param array|object $api
- * @param bool        $loop
- * @return type
+ * @param  array|object $api  Data about the plugin retrieved from the API.
+ * @param  bool         $loop Optional. Disable further loops. Default false.
+ * @return array {
+ *     Plugin installation status data.
+ *
+ *     @type string $status  Status of a plugin. Could be one of 'install', 'update_available', 'latest_installed' or 'newer_installed'.
+ *     @type string $url     Plugin installation URL.
+ *     @type string $version The most recent version of the plugin.
+ *     @type string $file    Plugin filename relative to the plugins directory.
+ * }
  */
 function install_plugin_install_status($api, $loop = false) {
        // This function is called recursively, $loop prevents further loops.
@@ -423,7 +452,6 @@ function install_plugin_install_status($api, $loop = false) {
  * @since 2.7.0
  *
  * @global string $tab
- * @global string $wp_version
  */
 function install_plugin_information() {
        global $tab;
@@ -557,16 +585,18 @@ function install_plugin_information() {
                                </li>
                        <?php } if ( ! empty( $api->tested ) ) { ?>
                                <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
-                       <?php } if ( ! empty( $api->active_installs ) ) { ?>
+                       <?php } if ( isset( $api->active_installs ) ) { ?>
                                <li><strong><?php _e( 'Active Installs:' ); ?></strong> <?php
                                        if ( $api->active_installs >= 1000000 ) {
                                                _ex( '1+ Million', 'Active plugin installs' );
+                                       } elseif ( 0 == $api->active_installs ) {
+                                               _ex( 'Less Than 10', 'Active plugin installs' );
                                        } else {
                                                echo number_format_i18n( $api->active_installs ) . '+';
                                        }
                                        ?></li>
                        <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
-                               <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
+                               <li><a target="_blank" href="<?php echo __( 'https://wordpress.org/plugins/' ) . $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
                        <?php } if ( ! empty( $api->homepage ) ) { ?>
                                <li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
                        <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
@@ -630,9 +660,11 @@ function install_plugin_information() {
        </div>
        <div id="section-holder" class="wrap">
        <?php
-       if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
+       $wp_version = get_bloginfo( 'version' );
+
+       if ( ! empty( $api->tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
                echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) . '</p></div>';
-       } elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
+       } elseif ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
                echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) . '</p></div>';
        }