~canonical-sysadmins/wordpress/5.1

« back to all changes in this revision

Viewing changes to wp-admin/includes/plugin-install.php

  • Committer: Haw Loeung
  • Date: 2016-12-13 06:54:17 UTC
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: haw.loeung@canonical.com-20161213065417-pemlo49o7in8nmkn
New upstream version 4.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
        }
110
110
 
111
111
        if ( ! isset( $args->locale ) ) {
112
 
                $args->locale = get_locale();
 
112
                $args->locale = get_user_locale();
113
113
        }
114
114
 
115
115
        /**
155
155
                $request = wp_remote_post( $url, $http_args );
156
156
 
157
157
                if ( $ssl && is_wp_error( $request ) ) {
158
 
                        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 );
 
158
                        trigger_error(
 
159
                                sprintf(
 
160
                                        /* translators: %s: support forums URL */
 
161
                                        __( '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>.' ),
 
162
                                        __( 'https://wordpress.org/support/' )
 
163
                                ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
 
164
                                headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
 
165
                        );
159
166
                        $request = wp_remote_post( $http_url, $http_args );
160
167
                }
161
168
 
162
169
                if ( is_wp_error($request) ) {
163
 
                        $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() );
 
170
                        $res = new WP_Error( 'plugins_api_failed',
 
171
                                sprintf(
 
172
                                        /* translators: %s: support forums URL */
 
173
                                        __( '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>.' ),
 
174
                                        __( 'https://wordpress.org/support/' )
 
175
                                ),
 
176
                                $request->get_error_message()
 
177
                        );
164
178
                } else {
165
179
                        $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
166
 
                        if ( ! is_object( $res ) && ! is_array( $res ) )
167
 
                                $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 ) );
 
180
                        if ( ! is_object( $res ) && ! is_array( $res ) ) {
 
181
                                $res = new WP_Error( 'plugins_api_failed',
 
182
                                        sprintf(
 
183
                                                /* translators: %s: support forums URL */
 
184
                                                __( '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>.' ),
 
185
                                                __( 'https://wordpress.org/support/' )
 
186
                                        ),
 
187
                                        wp_remote_retrieve_body( $request )
 
188
                                );
 
189
                        }
168
190
                }
169
191
        } elseif ( !is_wp_error($res) ) {
170
192
                $res->external = true;
210
232
 */
211
233
function install_dashboard() {
212
234
        ?>
213
 
        <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>
 
235
        <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>
214
236
 
215
237
        <?php display_plugins_table(); ?>
216
238
 
263
285
                        <option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option>
264
286
                </select>
265
287
                <label><span class="screen-reader-text"><?php _e( 'Search Plugins' ); ?></span>
266
 
                        <input type="search" name="s" value="<?php echo esc_attr( $term ) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search Plugins' ); ?>" />
 
288
                        <input type="search" name="s" value="<?php echo esc_attr( $term ) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search plugins...' ); ?>" />
267
289
                </label>
268
 
                <?php submit_button( __( 'Search Plugins' ), 'button hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?>
 
290
                <?php submit_button( __( 'Search Plugins' ), 'hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?>
269
291
        </form><?php
270
292
}
271
293
 
281
303
                <?php wp_nonce_field( 'plugin-upload' ); ?>
282
304
                <label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label>
283
305
                <input type="file" id="pluginzip" name="pluginzip" />
284
 
                <?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?>
 
306
                <?php submit_button( __( 'Install Now' ), '', 'install-plugin-submit', false ); ?>
285
307
        </form>
286
308
</div>
287
309
<?php
348
370
 *
349
371
 * @since 3.0.0
350
372
 *
351
 
 * @param array|object $api
352
 
 * @param bool        $loop
353
 
 * @return type
 
373
 * @param  array|object $api  Data about the plugin retrieved from the API.
 
374
 * @param  bool         $loop Optional. Disable further loops. Default false.
 
375
 * @return array {
 
376
 *     Plugin installation status data.
 
377
 *
 
378
 *     @type string $status  Status of a plugin. Could be one of 'install', 'update_available', 'latest_installed' or 'newer_installed'.
 
379
 *     @type string $url     Plugin installation URL.
 
380
 *     @type string $version The most recent version of the plugin.
 
381
 *     @type string $file    Plugin filename relative to the plugins directory.
 
382
 * }
354
383
 */
355
384
function install_plugin_install_status($api, $loop = false) {
356
385
        // This function is called recursively, $loop prevents further loops.
423
452
 * @since 2.7.0
424
453
 *
425
454
 * @global string $tab
426
 
 * @global string $wp_version
427
455
 */
428
456
function install_plugin_information() {
429
457
        global $tab;
557
585
                                </li>
558
586
                        <?php } if ( ! empty( $api->tested ) ) { ?>
559
587
                                <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
560
 
                        <?php } if ( ! empty( $api->active_installs ) ) { ?>
 
588
                        <?php } if ( isset( $api->active_installs ) ) { ?>
561
589
                                <li><strong><?php _e( 'Active Installs:' ); ?></strong> <?php
562
590
                                        if ( $api->active_installs >= 1000000 ) {
563
591
                                                _ex( '1+ Million', 'Active plugin installs' );
 
592
                                        } elseif ( 0 == $api->active_installs ) {
 
593
                                                _ex( 'Less Than 10', 'Active plugin installs' );
564
594
                                        } else {
565
595
                                                echo number_format_i18n( $api->active_installs ) . '+';
566
596
                                        }
567
597
                                        ?></li>
568
598
                        <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
569
 
                                <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
 
599
                                <li><a target="_blank" href="<?php echo __( 'https://wordpress.org/plugins/' ) . $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
570
600
                        <?php } if ( ! empty( $api->homepage ) ) { ?>
571
601
                                <li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a></li>
572
602
                        <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
630
660
        </div>
631
661
        <div id="section-holder" class="wrap">
632
662
        <?php
633
 
        if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
 
663
        $wp_version = get_bloginfo( 'version' );
 
664
 
 
665
        if ( ! empty( $api->tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
634
666
                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>';
635
 
        } elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
 
667
        } elseif ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
636
668
                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>';
637
669
        }
638
670