author | ymh <ymh.work@gmail.com> |
Tue, 15 Dec 2020 13:49:49 +0100 | |
changeset 16 | a86126ab1dd4 |
parent 9 | 177826044cd9 |
child 18 | be944660c56a |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress Plugin Install Administration API |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
* Retrieves plugin installer pages from the WordPress.org Plugins API. |
0 | 11 |
* |
12 |
* It is possible for a plugin to override the Plugin API result with three |
|
13 |
* filters. Assume this is for plugins, which can extend on the Plugin Info to |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
* offer more choices. This is very powerful and must be used with care when |
0 | 15 |
* overriding the filters. |
16 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
* The first filter, {@see 'plugins_api_args'}, is for the args and gives the action |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
* as the second parameter. The hook for {@see 'plugins_api_args'} must ensure that |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
* an object is returned. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
* The second filter, {@see 'plugins_api'}, allows a plugin to override the WordPress.org |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
* Plugin Installation API entirely. If `$action` is 'query_plugins' or 'plugin_information', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
* an object MUST be passed. If `$action` is 'hot_tags' or 'hot_categories', an array MUST |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
* be passed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
* Finally, the third filter, {@see 'plugins_api_result'}, makes it possible to filter the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
* response object or array, depending on the `$action` type. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
* Supported arguments per action: |
0 | 30 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
* | Argument Name | query_plugins | plugin_information | hot_tags | hot_categories | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
* | -------------------- | :-----------: | :----------------: | :------: | :------------: | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* | `$slug` | No | Yes | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* | `$per_page` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* | `$page` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* | `$number` | No | No | Yes | Yes | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* | `$search` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
* | `$tag` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
* | `$author` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
* | `$user` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
* | `$browse` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
* | `$locale` | Yes | Yes | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
* | `$installed_plugins` | Yes | No | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
* | `$is_ssl` | Yes | Yes | No | No | |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
* | `$fields` | Yes | Yes | No | No | |
0 | 46 |
* |
47 |
* @since 2.7.0 |
|
48 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
* @param string $action API action to perform: 'query_plugins', 'plugin_information', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
* 'hot_tags' or 'hot_categories'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
* @param array|object $args { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
* Optional. Array or object of arguments to serialize for the Plugin Info API. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
* @type string $slug The plugin slug. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
* @type int $per_page Number of plugins per page. Default 24. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* @type int $page Number of current page. Default 1. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
* @type int $number Number of tags or categories to be queried. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
* @type string $search A search term. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
* @type string $tag Tag to filter plugins. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
* @type string $author Username of an plugin author to filter plugins. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
* @type string $user Username to query for their favorites. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
* @type string $browse Browse view: 'popular', 'new', 'beta', 'recommended'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
* @type string $locale Locale to provide context-sensitive results. Default is the value |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
* of get_locale(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
* @type string $installed_plugins Installed plugins to provide context-sensitive results. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
* @type bool $is_ssl Whether links should be returned with https or not. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
* @type array $fields { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
* Array of fields which should or should not be returned. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
* @type bool $short_description Whether to return the plugin short description. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
* @type bool $description Whether to return the plugin full description. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
* @type bool $sections Whether to return the plugin readme sections: description, installation, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
* FAQ, screenshots, other notes, and changelog. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
* @type bool $tested Whether to return the 'Compatible up to' value. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
* @type bool $requires Whether to return the required WordPress version. Default true. |
16 | 76 |
* @type bool $requires_php Whether to return the required PHP version. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
* @type bool $rating Whether to return the rating in percent and total number of ratings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
* Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
* @type bool $ratings Whether to return the number of rating for each star (1-5). Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
* @type bool $downloaded Whether to return the download count. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
* @type bool $downloadlink Whether to return the download link for the package. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
* @type bool $last_updated Whether to return the date of the last update. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
* @type bool $added Whether to return the date when the plugin was added to the wordpress.org |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
* repository. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
* @type bool $tags Whether to return the assigned tags. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
* @type bool $compatibility Whether to return the WordPress compatibility list. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
* @type bool $homepage Whether to return the plugin homepage link. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
* @type bool $versions Whether to return the list of all available versions. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
* @type bool $donate_link Whether to return the donation link. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
* @type bool $reviews Whether to return the plugin reviews. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
* @type bool $banners Whether to return the banner images links. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
* @type bool $icons Whether to return the icon links. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
* @type bool $active_installs Whether to return the number of active installations. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
* @type bool $group Whether to return the assigned group. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
* @type bool $contributors Whether to return the list of contributors. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
* @return object|array|WP_Error Response object or array on success, WP_Error on failure. See the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
* {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
* for more information on the make-up of possible return values depending on the value of `$action`. |
0 | 101 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
function plugins_api( $action, $args = array() ) { |
16 | 103 |
// Include an unmodified $wp_version. |
104 |
require ABSPATH . WPINC . '/version.php'; |
|
0 | 105 |
|
5 | 106 |
if ( is_array( $args ) ) { |
107 |
$args = (object) $args; |
|
108 |
} |
|
0 | 109 |
|
16 | 110 |
if ( 'query_plugins' === $action ) { |
9 | 111 |
if ( ! isset( $args->per_page ) ) { |
112 |
$args->per_page = 24; |
|
113 |
} |
|
5 | 114 |
} |
115 |
||
116 |
if ( ! isset( $args->locale ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
$args->locale = get_user_locale(); |
5 | 118 |
} |
0 | 119 |
|
9 | 120 |
if ( ! isset( $args->wp_version ) ) { |
16 | 121 |
$args->wp_version = substr( $wp_version, 0, 3 ); // x.y |
9 | 122 |
} |
123 |
||
0 | 124 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
* Filters the WordPress.org Plugin Installation API arguments. |
0 | 126 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
* Important: An object MUST be returned to this filter. |
0 | 128 |
* |
129 |
* @since 2.7.0 |
|
130 |
* |
|
131 |
* @param object $args Plugin API arguments. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
* @param string $action The type of information being requested from the Plugin Installation API. |
0 | 133 |
*/ |
134 |
$args = apply_filters( 'plugins_api_args', $args, $action ); |
|
135 |
||
136 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
* Filters the response for the current WordPress.org Plugin Installation API request. |
0 | 138 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
* Passing a non-false value will effectively short-circuit the WordPress.org API request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
* If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
* If `$action` is 'hot_tags' or 'hot_categories', an array should be passed. |
0 | 143 |
* |
144 |
* @since 2.7.0 |
|
145 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
* @param false|object|array $result The result object or array. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
* @param string $action The type of information being requested from the Plugin Installation API. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
* @param object $args Plugin API arguments. |
0 | 149 |
*/ |
150 |
$res = apply_filters( 'plugins_api', false, $action, $args ); |
|
151 |
||
152 |
if ( false === $res ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
|
9 | 154 |
$url = 'http://api.wordpress.org/plugins/info/1.2/'; |
155 |
$url = add_query_arg( |
|
156 |
array( |
|
157 |
'action' => $action, |
|
158 |
'request' => $args, |
|
159 |
), |
|
160 |
$url |
|
161 |
); |
|
162 |
||
163 |
$http_url = $url; |
|
16 | 164 |
$ssl = wp_http_supports( array( 'ssl' ) ); |
165 |
if ( $ssl ) { |
|
0 | 166 |
$url = set_url_scheme( $url, 'https' ); |
9 | 167 |
} |
0 | 168 |
|
5 | 169 |
$http_args = array( |
9 | 170 |
'timeout' => 15, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
0 | 172 |
); |
9 | 173 |
$request = wp_remote_get( $url, $http_args ); |
0 | 174 |
|
175 |
if ( $ssl && is_wp_error( $request ) ) { |
|
16 | 176 |
if ( ! wp_is_json_request() ) { |
177 |
trigger_error( |
|
178 |
sprintf( |
|
179 |
/* translators: %s: Support forums URL. */ |
|
180 |
__( '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>.' ), |
|
181 |
__( 'https://wordpress.org/support/forums/' ) |
|
182 |
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), |
|
183 |
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
|
184 |
); |
|
185 |
} |
|
186 |
||
9 | 187 |
$request = wp_remote_get( $http_url, $http_args ); |
0 | 188 |
} |
189 |
||
9 | 190 |
if ( is_wp_error( $request ) ) { |
191 |
$res = new WP_Error( |
|
192 |
'plugins_api_failed', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
sprintf( |
16 | 194 |
/* translators: %s: Support forums URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
__( '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>.' ), |
16 | 196 |
__( 'https://wordpress.org/support/forums/' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
$request->get_error_message() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
); |
0 | 200 |
} else { |
9 | 201 |
$res = json_decode( wp_remote_retrieve_body( $request ), true ); |
202 |
if ( is_array( $res ) ) { |
|
203 |
// Object casting is required in order to match the info/1.0 format. |
|
204 |
$res = (object) $res; |
|
205 |
} elseif ( null === $res ) { |
|
206 |
$res = new WP_Error( |
|
207 |
'plugins_api_failed', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
sprintf( |
16 | 209 |
/* translators: %s: Support forums URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
__( '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>.' ), |
16 | 211 |
__( 'https://wordpress.org/support/forums/' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
wp_remote_retrieve_body( $request ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
} |
9 | 216 |
|
217 |
if ( isset( $res->error ) ) { |
|
218 |
$res = new WP_Error( 'plugins_api_failed', $res->error ); |
|
219 |
} |
|
0 | 220 |
} |
9 | 221 |
} elseif ( ! is_wp_error( $res ) ) { |
0 | 222 |
$res->external = true; |
223 |
} |
|
224 |
||
225 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
* Filters the Plugin Installation API response results. |
0 | 227 |
* |
228 |
* @since 2.7.0 |
|
229 |
* |
|
230 |
* @param object|WP_Error $res Response object or WP_Error. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
231 |
* @param string $action The type of information being requested from the Plugin Installation API. |
0 | 232 |
* @param object $args Plugin API arguments. |
233 |
*/ |
|
234 |
return apply_filters( 'plugins_api_result', $res, $action, $args ); |
|
235 |
} |
|
236 |
||
237 |
/** |
|
238 |
* Retrieve popular WordPress plugin tags. |
|
239 |
* |
|
240 |
* @since 2.7.0 |
|
241 |
* |
|
242 |
* @param array $args |
|
243 |
* @return array |
|
244 |
*/ |
|
245 |
function install_popular_tags( $args = array() ) { |
|
16 | 246 |
$key = md5( serialize( $args ) ); |
247 |
$tags = get_site_transient( 'poptags_' . $key ); |
|
248 |
if ( false !== $tags ) { |
|
0 | 249 |
return $tags; |
9 | 250 |
} |
0 | 251 |
|
9 | 252 |
$tags = plugins_api( 'hot_tags', $args ); |
0 | 253 |
|
9 | 254 |
if ( is_wp_error( $tags ) ) { |
0 | 255 |
return $tags; |
9 | 256 |
} |
0 | 257 |
|
258 |
set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS ); |
|
259 |
||
260 |
return $tags; |
|
261 |
} |
|
262 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
*/ |
0 | 266 |
function install_dashboard() { |
267 |
?> |
|
16 | 268 |
<p> |
269 |
<?php |
|
270 |
printf( |
|
271 |
/* translators: %s: https://wordpress.org/plugins/ */ |
|
272 |
__( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ), |
|
273 |
__( 'https://wordpress.org/plugins/' ) |
|
274 |
); |
|
275 |
?> |
|
276 |
</p> |
|
0 | 277 |
|
5 | 278 |
<?php display_plugins_table(); ?> |
0 | 279 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
<div class="plugins-popular-tags-wrapper"> |
9 | 281 |
<h2><?php _e( 'Popular tags' ); ?></h2> |
282 |
<p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p> |
|
0 | 283 |
<?php |
284 |
||
285 |
$api_tags = install_popular_tags(); |
|
286 |
||
287 |
echo '<p class="popular-tags">'; |
|
9 | 288 |
if ( is_wp_error( $api_tags ) ) { |
0 | 289 |
echo $api_tags->get_error_message(); |
290 |
} else { |
|
16 | 291 |
// Set up the tags in a way which can be interpreted by wp_generate_tag_cloud(). |
0 | 292 |
$tags = array(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
foreach ( (array) $api_tags as $tag ) { |
9 | 294 |
$url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ); |
295 |
$data = array( |
|
296 |
'link' => esc_url( $url ), |
|
297 |
'name' => $tag['name'], |
|
298 |
'slug' => $tag['slug'], |
|
299 |
'id' => sanitize_title_with_dashes( $tag['name'] ), |
|
300 |
'count' => $tag['count'], |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
$tags[ $tag['name'] ] = (object) $data; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
} |
9 | 304 |
echo wp_generate_tag_cloud( |
305 |
$tags, |
|
306 |
array( |
|
16 | 307 |
/* translators: %s: Number of plugins. */ |
9 | 308 |
'single_text' => __( '%s plugin' ), |
16 | 309 |
/* translators: %s: Number of plugins. */ |
9 | 310 |
'multiple_text' => __( '%s plugins' ), |
311 |
) |
|
312 |
); |
|
0 | 313 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
echo '</p><br class="clear" /></div>'; |
0 | 315 |
} |
316 |
||
317 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
* Displays a search form for searching plugins. |
0 | 319 |
* |
320 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
* @since 4.6.0 The `$type_selector` parameter was deprecated. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
* @param bool $deprecated Not used. |
0 | 324 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
function install_search_form( $deprecated = true ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
9 | 328 |
?> |
329 |
<form class="search-form search-plugins" method="get"> |
|
0 | 330 |
<input type="hidden" name="tab" value="search" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
<label class="screen-reader-text" for="typeselector"><?php _e( 'Search plugins by:' ); ?></label> |
0 | 332 |
<select name="type" id="typeselector"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
<option value="term"<?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
<option value="author"<?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
<option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option> |
0 | 336 |
</select> |
16 | 337 |
<label class="screen-reader-text" for="search-plugins"><?php _e( 'Search Plugins' ); ?></label> |
338 |
<input type="search" name="s" id="search-plugins" value="<?php echo esc_attr( $term ); ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search plugins...' ); ?>" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
<?php submit_button( __( 'Search Plugins' ), 'hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?> |
9 | 340 |
</form> |
341 |
<?php |
|
0 | 342 |
} |
343 |
||
344 |
/** |
|
345 |
* Upload from zip |
|
9 | 346 |
* |
0 | 347 |
* @since 2.8.0 |
348 |
*/ |
|
5 | 349 |
function install_plugins_upload() { |
9 | 350 |
?> |
5 | 351 |
<div class="upload-plugin"> |
16 | 352 |
<p class="install-help"><?php _e( 'If you have a plugin in a .zip format, you may install or update it by uploading it here.' ); ?></p> |
9 | 353 |
<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-plugin' ); ?>"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
<?php wp_nonce_field( 'plugin-upload' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
<label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label> |
16 | 356 |
<input type="file" id="pluginzip" name="pluginzip" accept=".zip" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
<?php submit_button( __( 'Install Now' ), '', 'install-plugin-submit', false ); ?> |
0 | 358 |
</form> |
5 | 359 |
</div> |
9 | 360 |
<?php |
0 | 361 |
} |
362 |
||
363 |
/** |
|
364 |
* Show a username form for the favorites page |
|
9 | 365 |
* |
0 | 366 |
* @since 3.5.0 |
367 |
*/ |
|
368 |
function install_plugins_favorites_form() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
$user = get_user_option( 'wporg_favorites' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
$action = 'save_wporg_username_' . get_current_user_id(); |
0 | 371 |
?> |
16 | 372 |
<p><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p> |
5 | 373 |
<form method="get"> |
0 | 374 |
<input type="hidden" name="tab" value="favorites" /> |
375 |
<p> |
|
376 |
<label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label> |
|
377 |
<input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" /> |
|
378 |
<input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
<input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( $action ) ); ?>" /> |
0 | 380 |
</p> |
381 |
</form> |
|
382 |
<?php |
|
383 |
} |
|
384 |
||
385 |
/** |
|
386 |
* Display plugin content based on plugin list. |
|
387 |
* |
|
388 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
* @global WP_List_Table $wp_list_table |
0 | 391 |
*/ |
392 |
function display_plugins_table() { |
|
393 |
global $wp_list_table; |
|
394 |
||
5 | 395 |
switch ( current_filter() ) { |
9 | 396 |
case 'install_plugins_favorites': |
5 | 397 |
if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) { |
398 |
return; |
|
399 |
} |
|
400 |
break; |
|
9 | 401 |
case 'install_plugins_recommended': |
5 | 402 |
echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>'; |
403 |
break; |
|
9 | 404 |
case 'install_plugins_beta': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
printf( |
16 | 406 |
/* translators: %s: URL to "Features as Plugins" page. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
'<p>' . __( 'You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.' ) . '</p>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
'https://make.wordpress.org/core/handbook/about/release-cycle/features-as-plugins/' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
break; |
5 | 411 |
} |
0 | 412 |
|
5 | 413 |
?> |
414 |
<form id="plugin-filter" method="post"> |
|
415 |
<?php $wp_list_table->display(); ?> |
|
416 |
</form> |
|
417 |
<?php |
|
0 | 418 |
} |
419 |
||
420 |
/** |
|
421 |
* Determine the status we can perform on a plugin. |
|
422 |
* |
|
423 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
* |
16 | 425 |
* @param array|object $api Data about the plugin retrieved from the API. |
426 |
* @param bool $loop Optional. Disable further loops. Default false. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
* @return array { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
* Plugin installation status data. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
* @type string $status Status of a plugin. Could be one of 'install', 'update_available', 'latest_installed' or 'newer_installed'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
* @type string $url Plugin installation URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
* @type string $version The most recent version of the plugin. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
* @type string $file Plugin filename relative to the plugins directory. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
* } |
0 | 435 |
*/ |
9 | 436 |
function install_plugin_install_status( $api, $loop = false ) { |
5 | 437 |
// This function is called recursively, $loop prevents further loops. |
9 | 438 |
if ( is_array( $api ) ) { |
0 | 439 |
$api = (object) $api; |
9 | 440 |
} |
0 | 441 |
|
16 | 442 |
// Default to a "new" plugin. |
9 | 443 |
$status = 'install'; |
444 |
$url = false; |
|
5 | 445 |
$update_file = false; |
9 | 446 |
$version = ''; |
0 | 447 |
|
5 | 448 |
/* |
449 |
* Check to see if this plugin is known to be installed, |
|
450 |
* and has an update awaiting it. |
|
451 |
*/ |
|
9 | 452 |
$update_plugins = get_site_transient( 'update_plugins' ); |
0 | 453 |
if ( isset( $update_plugins->response ) ) { |
9 | 454 |
foreach ( (array) $update_plugins->response as $file => $plugin ) { |
0 | 455 |
if ( $plugin->slug === $api->slug ) { |
9 | 456 |
$status = 'update_available'; |
0 | 457 |
$update_file = $file; |
9 | 458 |
$version = $plugin->new_version; |
459 |
if ( current_user_can( 'update_plugins' ) ) { |
|
460 |
$url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $update_file ), 'upgrade-plugin_' . $update_file ); |
|
461 |
} |
|
0 | 462 |
break; |
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
||
16 | 467 |
if ( 'install' === $status ) { |
0 | 468 |
if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { |
9 | 469 |
$installed_plugin = get_plugins( '/' . $api->slug ); |
470 |
if ( empty( $installed_plugin ) ) { |
|
471 |
if ( current_user_can( 'install_plugins' ) ) { |
|
472 |
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); |
|
473 |
} |
|
0 | 474 |
} else { |
16 | 475 |
$key = array_keys( $installed_plugin ); |
476 |
// Use the first plugin regardless of the name. |
|
477 |
// Could have issues for multiple plugins in one directory if they share different version numbers. |
|
478 |
$key = reset( $key ); |
|
479 |
||
5 | 480 |
$update_file = $api->slug . '/' . $key; |
9 | 481 |
if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) { |
0 | 482 |
$status = 'latest_installed'; |
9 | 483 |
} elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) { |
484 |
$status = 'newer_installed'; |
|
0 | 485 |
$version = $installed_plugin[ $key ]['Version']; |
486 |
} else { |
|
16 | 487 |
// If the above update check failed, then that probably means that the update checker has out-of-date information, force a refresh. |
0 | 488 |
if ( ! $loop ) { |
9 | 489 |
delete_site_transient( 'update_plugins' ); |
0 | 490 |
wp_update_plugins(); |
9 | 491 |
return install_plugin_install_status( $api, true ); |
0 | 492 |
} |
493 |
} |
|
494 |
} |
|
495 |
} else { |
|
16 | 496 |
// "install" & no directory with that slug. |
9 | 497 |
if ( current_user_can( 'install_plugins' ) ) { |
498 |
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); |
|
499 |
} |
|
0 | 500 |
} |
501 |
} |
|
9 | 502 |
if ( isset( $_GET['from'] ) ) { |
0 | 503 |
$url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); |
9 | 504 |
} |
0 | 505 |
|
5 | 506 |
$file = $update_file; |
507 |
return compact( 'status', 'url', 'version', 'file' ); |
|
0 | 508 |
} |
509 |
||
510 |
/** |
|
511 |
* Display plugin information in dialog box form. |
|
512 |
* |
|
513 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
* @global string $tab |
0 | 516 |
*/ |
517 |
function install_plugin_information() { |
|
518 |
global $tab; |
|
519 |
||
5 | 520 |
if ( empty( $_REQUEST['plugin'] ) ) { |
521 |
return; |
|
522 |
} |
|
0 | 523 |
|
9 | 524 |
$api = plugins_api( |
525 |
'plugin_information', |
|
526 |
array( |
|
527 |
'slug' => wp_unslash( $_REQUEST['plugin'] ), |
|
5 | 528 |
) |
9 | 529 |
); |
5 | 530 |
|
531 |
if ( is_wp_error( $api ) ) { |
|
532 |
wp_die( $api ); |
|
533 |
} |
|
0 | 534 |
|
535 |
$plugins_allowedtags = array( |
|
9 | 536 |
'a' => array( |
537 |
'href' => array(), |
|
538 |
'title' => array(), |
|
539 |
'target' => array(), |
|
540 |
), |
|
541 |
'abbr' => array( 'title' => array() ), |
|
542 |
'acronym' => array( 'title' => array() ), |
|
543 |
'code' => array(), |
|
544 |
'pre' => array(), |
|
545 |
'em' => array(), |
|
546 |
'strong' => array(), |
|
547 |
'div' => array( 'class' => array() ), |
|
548 |
'span' => array( 'class' => array() ), |
|
549 |
'p' => array(), |
|
550 |
'br' => array(), |
|
551 |
'ul' => array(), |
|
552 |
'ol' => array(), |
|
553 |
'li' => array(), |
|
554 |
'h1' => array(), |
|
555 |
'h2' => array(), |
|
556 |
'h3' => array(), |
|
557 |
'h4' => array(), |
|
558 |
'h5' => array(), |
|
559 |
'h6' => array(), |
|
560 |
'img' => array( |
|
561 |
'src' => array(), |
|
562 |
'class' => array(), |
|
563 |
'alt' => array(), |
|
564 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
'blockquote' => array( 'cite' => true ), |
0 | 566 |
); |
567 |
||
568 |
$plugins_section_titles = array( |
|
9 | 569 |
'description' => _x( 'Description', 'Plugin installer section title' ), |
5 | 570 |
'installation' => _x( 'Installation', 'Plugin installer section title' ), |
9 | 571 |
'faq' => _x( 'FAQ', 'Plugin installer section title' ), |
572 |
'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ), |
|
573 |
'changelog' => _x( 'Changelog', 'Plugin installer section title' ), |
|
574 |
'reviews' => _x( 'Reviews', 'Plugin installer section title' ), |
|
575 |
'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ), |
|
0 | 576 |
); |
577 |
||
16 | 578 |
// Sanitize HTML. |
5 | 579 |
foreach ( (array) $api->sections as $section_name => $content ) { |
9 | 580 |
$api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags ); |
5 | 581 |
} |
582 |
||
0 | 583 |
foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) { |
5 | 584 |
if ( isset( $api->$key ) ) { |
0 | 585 |
$api->$key = wp_kses( $api->$key, $plugins_allowedtags ); |
5 | 586 |
} |
587 |
} |
|
588 |
||
589 |
$_tab = esc_attr( $tab ); |
|
590 |
||
16 | 591 |
// Default to the Description tab, Do not translate, API returns English. |
592 |
$section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; |
|
5 | 593 |
if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { |
594 |
$section_titles = array_keys( (array) $api->sections ); |
|
9 | 595 |
$section = reset( $section_titles ); |
0 | 596 |
} |
597 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
iframe_header( __( 'Plugin Installation' ) ); |
5 | 599 |
|
600 |
$_with_banner = ''; |
|
601 |
||
602 |
if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) { |
|
603 |
$_with_banner = 'with-banner'; |
|
9 | 604 |
$low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low']; |
605 |
$high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high']; |
|
5 | 606 |
?> |
607 |
<style type="text/css"> |
|
608 |
#plugin-information-title.with-banner { |
|
609 |
background-image: url( <?php echo esc_url( $low ); ?> ); |
|
610 |
} |
|
611 |
@media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) { |
|
612 |
#plugin-information-title.with-banner { |
|
613 |
background-image: url( <?php echo esc_url( $high ); ?> ); |
|
614 |
} |
|
615 |
} |
|
616 |
</style> |
|
617 |
<?php |
|
618 |
} |
|
619 |
||
620 |
echo '<div id="plugin-information-scrollable">'; |
|
621 |
echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>"; |
|
622 |
echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n"; |
|
623 |
||
624 |
foreach ( (array) $api->sections as $section_name => $content ) { |
|
625 |
if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) { |
|
626 |
continue; |
|
627 |
} |
|
628 |
||
629 |
if ( isset( $plugins_section_titles[ $section_name ] ) ) { |
|
630 |
$title = $plugins_section_titles[ $section_name ]; |
|
631 |
} else { |
|
632 |
$title = ucwords( str_replace( '_', ' ', $section_name ) ); |
|
633 |
} |
|
634 |
||
9 | 635 |
$class = ( $section_name === $section ) ? ' class="current"' : ''; |
636 |
$href = add_query_arg( |
|
637 |
array( |
|
638 |
'tab' => $tab, |
|
639 |
'section' => $section_name, |
|
640 |
) |
|
641 |
); |
|
642 |
$href = esc_url( $href ); |
|
5 | 643 |
$san_section = esc_attr( $section_name ); |
644 |
echo "\t<a name='$san_section' href='$href' $class>$title</a>\n"; |
|
0 | 645 |
} |
646 |
||
5 | 647 |
echo "</div>\n"; |
0 | 648 |
|
649 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
<div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'> |
5 | 651 |
<div class="fyi"> |
0 | 652 |
<ul> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
<?php if ( ! empty( $api->version ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
654 |
<li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
<?php } if ( ! empty( $api->author ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
<li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
<?php } if ( ! empty( $api->last_updated ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
<li><strong><?php _e( 'Last Updated:' ); ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
<?php |
16 | 660 |
/* translators: %s: Human-readable time difference. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
<?php } if ( ! empty( $api->requires ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
<li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
<strong><?php _e( 'Requires WordPress Version:' ); ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
<?php |
16 | 668 |
/* translators: %s: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
printf( __( '%s or higher' ), $api->requires ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
<?php } if ( ! empty( $api->tested ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
<li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
<?php } if ( ! empty( $api->requires_php ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
675 |
<li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
676 |
<strong><?php _e( 'Requires PHP Version:' ); ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
<?php |
16 | 678 |
/* translators: %s: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
printf( __( '%s or higher' ), $api->requires_php ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
<?php } if ( isset( $api->active_installs ) ) { ?> |
9 | 683 |
<li><strong><?php _e( 'Active Installations:' ); ?></strong> |
684 |
<?php |
|
685 |
if ( $api->active_installs >= 1000000 ) { |
|
686 |
$active_installs_millions = floor( $api->active_installs / 1000000 ); |
|
687 |
printf( |
|
16 | 688 |
/* translators: %s: Number of millions. */ |
9 | 689 |
_nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ), |
690 |
number_format_i18n( $active_installs_millions ) |
|
691 |
); |
|
692 |
} elseif ( 0 == $api->active_installs ) { |
|
693 |
_ex( 'Less Than 10', 'Active plugin installations' ); |
|
694 |
} else { |
|
695 |
echo number_format_i18n( $api->active_installs ) . '+'; |
|
696 |
} |
|
697 |
?> |
|
698 |
</li> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
<?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
<li><a target="_blank" href="<?php echo __( 'https://wordpress.org/plugins/' ) . $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page »' ); ?></a></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
<?php } if ( ! empty( $api->homepage ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
<li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage »' ); ?></a></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
<?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
<li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »' ); ?></a></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
<?php } ?> |
0 | 706 |
</ul> |
5 | 707 |
<?php if ( ! empty( $api->rating ) ) { ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
<h3><?php _e( 'Average Rating' ); ?></h3> |
9 | 709 |
<?php |
710 |
wp_star_rating( |
|
711 |
array( |
|
712 |
'rating' => $api->rating, |
|
713 |
'type' => 'percent', |
|
714 |
'number' => $api->num_ratings, |
|
715 |
) |
|
716 |
); |
|
717 |
?> |
|
16 | 718 |
<p aria-hidden="true" class="fyi-description"> |
719 |
<?php |
|
720 |
printf( |
|
721 |
/* translators: %s: Number of ratings. */ |
|
722 |
_n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), |
|
723 |
number_format_i18n( $api->num_ratings ) |
|
724 |
); |
|
725 |
?> |
|
726 |
</p> |
|
9 | 727 |
<?php |
728 |
} |
|
5 | 729 |
|
9 | 730 |
if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { |
731 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
<h3><?php _e( 'Reviews' ); ?></h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
<p class="fyi-description"><?php _e( 'Read all reviews on WordPress.org or write your own!' ); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
735 |
foreach ( $api->ratings as $key => $ratecount ) { |
5 | 736 |
// Avoid div-by-zero. |
16 | 737 |
$_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0; |
9 | 738 |
$aria_label = esc_attr( |
739 |
sprintf( |
|
16 | 740 |
/* translators: 1: Number of stars (used to determine singular/plural), 2: Number of reviews. */ |
741 |
_n( |
|
742 |
'Reviews with %1$d star: %2$s. Opens in a new tab.', |
|
743 |
'Reviews with %1$d stars: %2$s. Opens in a new tab.', |
|
744 |
$key |
|
745 |
), |
|
9 | 746 |
$key, |
747 |
number_format_i18n( $ratecount ) |
|
748 |
) |
|
749 |
); |
|
5 | 750 |
?> |
751 |
<div class="counter-container"> |
|
9 | 752 |
<span class="counter-label"> |
16 | 753 |
<?php |
754 |
printf( |
|
755 |
'<a href="%s" target="_blank" aria-label="%s">%s</a>', |
|
756 |
"https://wordpress.org/support/plugin/{$api->slug}/reviews/?filter={$key}", |
|
757 |
$aria_label, |
|
758 |
/* translators: %s: Number of stars. */ |
|
759 |
sprintf( _n( '%d star', '%d stars', $key ), $key ) |
|
760 |
); |
|
761 |
?> |
|
9 | 762 |
</span> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
<span class="counter-back"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
<span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
765 |
</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
<span class="counter-count" aria-hidden="true"><?php echo number_format_i18n( $ratecount ); ?></span> |
5 | 767 |
</div> |
768 |
<?php |
|
769 |
} |
|
770 |
} |
|
9 | 771 |
if ( ! empty( $api->contributors ) ) { |
772 |
?> |
|
5 | 773 |
<h3><?php _e( 'Contributors' ); ?></h3> |
774 |
<ul class="contributors"> |
|
775 |
<?php |
|
9 | 776 |
foreach ( (array) $api->contributors as $contrib_username => $contrib_details ) { |
777 |
$contrib_name = $contrib_details['display_name']; |
|
778 |
if ( ! $contrib_name ) { |
|
779 |
$contrib_name = $contrib_username; |
|
5 | 780 |
} |
9 | 781 |
$contrib_name = esc_html( $contrib_name ); |
782 |
||
783 |
$contrib_profile = esc_url( $contrib_details['profile'] ); |
|
784 |
$contrib_avatar = esc_url( add_query_arg( 's', '36', $contrib_details['avatar'] ) ); |
|
785 |
||
786 |
echo "<li><a href='{$contrib_profile}' target='_blank'><img src='{$contrib_avatar}' width='18' height='18' alt='' />{$contrib_name}</a></li>"; |
|
5 | 787 |
} |
788 |
?> |
|
789 |
</ul> |
|
9 | 790 |
<?php if ( ! empty( $api->donate_link ) ) { ?> |
5 | 791 |
<a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »' ); ?></a> |
792 |
<?php } ?> |
|
9 | 793 |
<?php } ?> |
0 | 794 |
</div> |
9 | 795 |
<div id="section-holder"> |
0 | 796 |
<?php |
9 | 797 |
$requires_php = isset( $api->requires_php ) ? $api->requires_php : null; |
798 |
$requires_wp = isset( $api->requires ) ? $api->requires : null; |
|
799 |
||
800 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
801 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
802 |
$tested_wp = ( empty( $api->tested ) || version_compare( get_bloginfo( 'version' ), $api->tested, '<=' ) ); |
|
803 |
||
804 |
if ( ! $compatible_php ) { |
|
805 |
echo '<div class="notice notice-error notice-alt"><p>'; |
|
806 |
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' ); |
|
807 |
if ( current_user_can( 'update_php' ) ) { |
|
808 |
printf( |
|
16 | 809 |
/* translators: %s: URL to Update PHP page. */ |
9 | 810 |
' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ), |
811 |
esc_url( wp_get_update_php_url() ) |
|
812 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
|
9 | 814 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
815 |
} else { |
|
816 |
echo '</p>'; |
|
817 |
} |
|
818 |
echo '</div>'; |
|
819 |
} |
|
820 |
||
821 |
if ( ! $tested_wp ) { |
|
822 |
echo '<div class="notice notice-warning notice-alt"><p>'; |
|
823 |
_e( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ); |
|
824 |
echo '</p></div>'; |
|
825 |
} elseif ( ! $compatible_wp ) { |
|
826 |
echo '<div class="notice notice-error notice-alt"><p>'; |
|
827 |
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' ); |
|
828 |
if ( current_user_can( 'update_core' ) ) { |
|
829 |
printf( |
|
16 | 830 |
/* translators: %s: URL to WordPress Updates screen. */ |
9 | 831 |
' ' . __( '<a href="%s" target="_parent">Click here to update WordPress</a>.' ), |
832 |
self_admin_url( 'update-core.php' ) |
|
833 |
); |
|
834 |
} |
|
835 |
echo '</p></div>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
} |
0 | 837 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
838 |
foreach ( (array) $api->sections as $section_name => $content ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
839 |
$content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
840 |
$content = links_add_target( $content, '_blank' ); |
0 | 841 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
842 |
$san_section = esc_attr( $section_name ); |
0 | 843 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
844 |
$display = ( $section_name === $section ) ? 'block' : 'none'; |
0 | 845 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
846 |
echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
echo $content; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
848 |
echo "\t</div>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
} |
0 | 850 |
echo "</div>\n"; |
5 | 851 |
echo "</div>\n"; |
852 |
echo "</div>\n"; // #plugin-information-scrollable |
|
853 |
echo "<div id='$tab-footer'>\n"; |
|
854 |
if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) { |
|
855 |
$status = install_plugin_install_status( $api ); |
|
856 |
switch ( $status['status'] ) { |
|
857 |
case 'install': |
|
858 |
if ( $status['url'] ) { |
|
9 | 859 |
if ( $compatible_php && $compatible_wp ) { |
860 |
echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>'; |
|
861 |
} else { |
|
862 |
printf( |
|
863 |
'<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', |
|
864 |
_x( 'Cannot Install', 'plugin' ) |
|
865 |
); |
|
866 |
} |
|
5 | 867 |
} |
868 |
break; |
|
869 |
case 'update_available': |
|
870 |
if ( $status['url'] ) { |
|
9 | 871 |
if ( $compatible_php ) { |
872 |
echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>'; |
|
873 |
} else { |
|
874 |
printf( |
|
875 |
'<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', |
|
876 |
_x( 'Cannot Update', 'plugin' ) |
|
877 |
); |
|
878 |
} |
|
5 | 879 |
} |
880 |
break; |
|
881 |
case 'newer_installed': |
|
16 | 882 |
/* translators: %s: Plugin version. */ |
9 | 883 |
echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed' ), $status['version'] ) . '</a>'; |
5 | 884 |
break; |
885 |
case 'latest_installed': |
|
886 |
echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>'; |
|
887 |
break; |
|
888 |
} |
|
889 |
} |
|
890 |
echo "</div>\n"; |
|
0 | 891 |
|
892 |
iframe_footer(); |
|
893 |
exit; |
|
894 |
} |