155
155
$request = wp_remote_post( $url, $http_args );
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’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 );
160
/* translators: %s: support forums URL */
161
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’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
159
166
$request = wp_remote_post( $http_url, $http_args );
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’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',
172
/* translators: %s: support forums URL */
173
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
174
__( 'https://wordpress.org/support/' )
176
$request->get_error_message()
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’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',
183
/* translators: %s: support forums URL */
184
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
185
__( 'https://wordpress.org/support/' )
187
wp_remote_retrieve_body( $request )
169
191
} elseif ( !is_wp_error($res) ) {
170
192
$res->external = true;
211
233
function install_dashboard() {
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>
215
237
<?php display_plugins_table(); ?>
263
285
<option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option>
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...' ); ?>" />
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' ) ); ?>
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 ); ?>
351
* @param array|object $api
373
* @param array|object $api Data about the plugin retrieved from the API.
374
* @param bool $loop Optional. Disable further loops. Default false.
376
* Plugin installation status data.
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.
355
384
function install_plugin_install_status($api, $loop = false) {
356
385
// This function is called recursively, $loop prevents further loops.
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' );
565
595
echo number_format_i18n( $api->active_installs ) . '+';
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 »' ); ?></a></li>
599
<li><a target="_blank" href="<?php echo __( 'https://wordpress.org/plugins/' ) . $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page »' ); ?></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 »' ); ?></a></li>
572
602
<?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
631
661
<div id="section-holder" class="wrap">
633
if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
663
$wp_version = get_bloginfo( 'version' );
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>';