author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
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 |
* |
19 | 139 |
* Returning a non-false value will effectively short-circuit the WordPress.org API request. |
7
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 |
/** |
|
19 | 238 |
* Retrieves popular WordPress plugin tags. |
0 | 239 |
* |
240 |
* @since 2.7.0 |
|
241 |
* |
|
242 |
* @param array $args |
|
18 | 243 |
* @return array|WP_Error |
0 | 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 |
/** |
19 | 264 |
* Displays the Featured tab of Add Plugins screen. |
265 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
*/ |
0 | 268 |
function install_dashboard() { |
19 | 269 |
display_plugins_table(); |
0 | 270 |
?> |
271 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
<div class="plugins-popular-tags-wrapper"> |
9 | 273 |
<h2><?php _e( 'Popular tags' ); ?></h2> |
274 |
<p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p> |
|
0 | 275 |
<?php |
276 |
||
277 |
$api_tags = install_popular_tags(); |
|
278 |
||
279 |
echo '<p class="popular-tags">'; |
|
9 | 280 |
if ( is_wp_error( $api_tags ) ) { |
0 | 281 |
echo $api_tags->get_error_message(); |
282 |
} else { |
|
16 | 283 |
// Set up the tags in a way which can be interpreted by wp_generate_tag_cloud(). |
0 | 284 |
$tags = array(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
foreach ( (array) $api_tags as $tag ) { |
9 | 286 |
$url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ); |
287 |
$data = array( |
|
288 |
'link' => esc_url( $url ), |
|
289 |
'name' => $tag['name'], |
|
290 |
'slug' => $tag['slug'], |
|
291 |
'id' => sanitize_title_with_dashes( $tag['name'] ), |
|
292 |
'count' => $tag['count'], |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
$tags[ $tag['name'] ] = (object) $data; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
} |
9 | 296 |
echo wp_generate_tag_cloud( |
297 |
$tags, |
|
298 |
array( |
|
16 | 299 |
/* translators: %s: Number of plugins. */ |
9 | 300 |
'single_text' => __( '%s plugin' ), |
16 | 301 |
/* translators: %s: Number of plugins. */ |
9 | 302 |
'multiple_text' => __( '%s plugins' ), |
303 |
) |
|
304 |
); |
|
0 | 305 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
echo '</p><br class="clear" /></div>'; |
0 | 307 |
} |
308 |
||
309 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
* Displays a search form for searching plugins. |
0 | 311 |
* |
312 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
* @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
|
314 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
* @param bool $deprecated Not used. |
0 | 316 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
function install_search_form( $deprecated = true ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
9 | 320 |
?> |
321 |
<form class="search-form search-plugins" method="get"> |
|
0 | 322 |
<input type="hidden" name="tab" value="search" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
<label class="screen-reader-text" for="typeselector"><?php _e( 'Search plugins by:' ); ?></label> |
0 | 324 |
<select name="type" id="typeselector"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
<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
|
326 |
<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
|
327 |
<option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option> |
0 | 328 |
</select> |
16 | 329 |
<label class="screen-reader-text" for="search-plugins"><?php _e( 'Search Plugins' ); ?></label> |
330 |
<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
|
331 |
<?php submit_button( __( 'Search Plugins' ), 'hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?> |
9 | 332 |
</form> |
333 |
<?php |
|
0 | 334 |
} |
335 |
||
336 |
/** |
|
19 | 337 |
* Displays a form to upload plugins from zip files. |
9 | 338 |
* |
0 | 339 |
* @since 2.8.0 |
340 |
*/ |
|
5 | 341 |
function install_plugins_upload() { |
9 | 342 |
?> |
5 | 343 |
<div class="upload-plugin"> |
16 | 344 |
<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 | 345 |
<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
|
346 |
<?php wp_nonce_field( 'plugin-upload' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
<label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label> |
16 | 348 |
<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
|
349 |
<?php submit_button( __( 'Install Now' ), '', 'install-plugin-submit', false ); ?> |
0 | 350 |
</form> |
5 | 351 |
</div> |
9 | 352 |
<?php |
0 | 353 |
} |
354 |
||
355 |
/** |
|
19 | 356 |
* Shows a username form for the favorites page. |
9 | 357 |
* |
0 | 358 |
* @since 3.5.0 |
359 |
*/ |
|
360 |
function install_plugins_favorites_form() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
$user = get_user_option( 'wporg_favorites' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
$action = 'save_wporg_username_' . get_current_user_id(); |
0 | 363 |
?> |
16 | 364 |
<p><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p> |
5 | 365 |
<form method="get"> |
0 | 366 |
<input type="hidden" name="tab" value="favorites" /> |
367 |
<p> |
|
368 |
<label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label> |
|
369 |
<input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" /> |
|
370 |
<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
|
371 |
<input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( $action ) ); ?>" /> |
0 | 372 |
</p> |
373 |
</form> |
|
374 |
<?php |
|
375 |
} |
|
376 |
||
377 |
/** |
|
19 | 378 |
* Displays plugin content based on plugin list. |
0 | 379 |
* |
380 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
* @global WP_List_Table $wp_list_table |
0 | 383 |
*/ |
384 |
function display_plugins_table() { |
|
385 |
global $wp_list_table; |
|
386 |
||
5 | 387 |
switch ( current_filter() ) { |
9 | 388 |
case 'install_plugins_beta': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
printf( |
16 | 390 |
/* translators: %s: URL to "Features as Plugins" page. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
'<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
|
392 |
'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
|
393 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
break; |
19 | 395 |
case 'install_plugins_featured': |
396 |
printf( |
|
397 |
/* translators: %s: https://wordpress.org/plugins/ */ |
|
398 |
'<p>' . __( '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.' ) . '</p>', |
|
399 |
__( 'https://wordpress.org/plugins/' ) |
|
400 |
); |
|
401 |
break; |
|
402 |
case 'install_plugins_recommended': |
|
403 |
echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>'; |
|
404 |
break; |
|
405 |
case 'install_plugins_favorites': |
|
406 |
if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) { |
|
407 |
return; |
|
408 |
} |
|
409 |
break; |
|
5 | 410 |
} |
411 |
?> |
|
412 |
<form id="plugin-filter" method="post"> |
|
413 |
<?php $wp_list_table->display(); ?> |
|
414 |
</form> |
|
415 |
<?php |
|
0 | 416 |
} |
417 |
||
418 |
/** |
|
19 | 419 |
* Determines the status we can perform on a plugin. |
0 | 420 |
* |
421 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
* |
16 | 423 |
* @param array|object $api Data about the plugin retrieved from the API. |
424 |
* @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
|
425 |
* @return array { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
* Plugin installation status data. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
* @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
|
429 |
* @type string $url Plugin installation URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
* @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
|
431 |
* @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
|
432 |
* } |
0 | 433 |
*/ |
9 | 434 |
function install_plugin_install_status( $api, $loop = false ) { |
5 | 435 |
// This function is called recursively, $loop prevents further loops. |
9 | 436 |
if ( is_array( $api ) ) { |
0 | 437 |
$api = (object) $api; |
9 | 438 |
} |
0 | 439 |
|
16 | 440 |
// Default to a "new" plugin. |
9 | 441 |
$status = 'install'; |
442 |
$url = false; |
|
5 | 443 |
$update_file = false; |
9 | 444 |
$version = ''; |
0 | 445 |
|
5 | 446 |
/* |
447 |
* Check to see if this plugin is known to be installed, |
|
448 |
* and has an update awaiting it. |
|
449 |
*/ |
|
9 | 450 |
$update_plugins = get_site_transient( 'update_plugins' ); |
0 | 451 |
if ( isset( $update_plugins->response ) ) { |
9 | 452 |
foreach ( (array) $update_plugins->response as $file => $plugin ) { |
0 | 453 |
if ( $plugin->slug === $api->slug ) { |
9 | 454 |
$status = 'update_available'; |
0 | 455 |
$update_file = $file; |
9 | 456 |
$version = $plugin->new_version; |
457 |
if ( current_user_can( 'update_plugins' ) ) { |
|
458 |
$url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $update_file ), 'upgrade-plugin_' . $update_file ); |
|
459 |
} |
|
0 | 460 |
break; |
461 |
} |
|
462 |
} |
|
463 |
} |
|
464 |
||
16 | 465 |
if ( 'install' === $status ) { |
0 | 466 |
if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { |
9 | 467 |
$installed_plugin = get_plugins( '/' . $api->slug ); |
468 |
if ( empty( $installed_plugin ) ) { |
|
469 |
if ( current_user_can( 'install_plugins' ) ) { |
|
470 |
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); |
|
471 |
} |
|
0 | 472 |
} else { |
16 | 473 |
$key = array_keys( $installed_plugin ); |
474 |
// Use the first plugin regardless of the name. |
|
475 |
// Could have issues for multiple plugins in one directory if they share different version numbers. |
|
476 |
$key = reset( $key ); |
|
477 |
||
5 | 478 |
$update_file = $api->slug . '/' . $key; |
9 | 479 |
if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) { |
0 | 480 |
$status = 'latest_installed'; |
9 | 481 |
} elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) { |
482 |
$status = 'newer_installed'; |
|
0 | 483 |
$version = $installed_plugin[ $key ]['Version']; |
484 |
} else { |
|
16 | 485 |
// If the above update check failed, then that probably means that the update checker has out-of-date information, force a refresh. |
0 | 486 |
if ( ! $loop ) { |
9 | 487 |
delete_site_transient( 'update_plugins' ); |
0 | 488 |
wp_update_plugins(); |
9 | 489 |
return install_plugin_install_status( $api, true ); |
0 | 490 |
} |
491 |
} |
|
492 |
} |
|
493 |
} else { |
|
16 | 494 |
// "install" & no directory with that slug. |
9 | 495 |
if ( current_user_can( 'install_plugins' ) ) { |
496 |
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); |
|
497 |
} |
|
0 | 498 |
} |
499 |
} |
|
9 | 500 |
if ( isset( $_GET['from'] ) ) { |
0 | 501 |
$url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); |
9 | 502 |
} |
0 | 503 |
|
5 | 504 |
$file = $update_file; |
505 |
return compact( 'status', 'url', 'version', 'file' ); |
|
0 | 506 |
} |
507 |
||
508 |
/** |
|
19 | 509 |
* Displays plugin information in dialog box form. |
0 | 510 |
* |
511 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
* @global string $tab |
0 | 514 |
*/ |
515 |
function install_plugin_information() { |
|
516 |
global $tab; |
|
517 |
||
5 | 518 |
if ( empty( $_REQUEST['plugin'] ) ) { |
519 |
return; |
|
520 |
} |
|
0 | 521 |
|
9 | 522 |
$api = plugins_api( |
523 |
'plugin_information', |
|
524 |
array( |
|
525 |
'slug' => wp_unslash( $_REQUEST['plugin'] ), |
|
5 | 526 |
) |
9 | 527 |
); |
5 | 528 |
|
529 |
if ( is_wp_error( $api ) ) { |
|
530 |
wp_die( $api ); |
|
531 |
} |
|
0 | 532 |
|
533 |
$plugins_allowedtags = array( |
|
9 | 534 |
'a' => array( |
535 |
'href' => array(), |
|
536 |
'title' => array(), |
|
537 |
'target' => array(), |
|
538 |
), |
|
539 |
'abbr' => array( 'title' => array() ), |
|
540 |
'acronym' => array( 'title' => array() ), |
|
541 |
'code' => array(), |
|
542 |
'pre' => array(), |
|
543 |
'em' => array(), |
|
544 |
'strong' => array(), |
|
545 |
'div' => array( 'class' => array() ), |
|
546 |
'span' => array( 'class' => array() ), |
|
547 |
'p' => array(), |
|
548 |
'br' => array(), |
|
549 |
'ul' => array(), |
|
550 |
'ol' => array(), |
|
551 |
'li' => array(), |
|
552 |
'h1' => array(), |
|
553 |
'h2' => array(), |
|
554 |
'h3' => array(), |
|
555 |
'h4' => array(), |
|
556 |
'h5' => array(), |
|
557 |
'h6' => array(), |
|
558 |
'img' => array( |
|
559 |
'src' => array(), |
|
560 |
'class' => array(), |
|
561 |
'alt' => array(), |
|
562 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
'blockquote' => array( 'cite' => true ), |
0 | 564 |
); |
565 |
||
566 |
$plugins_section_titles = array( |
|
9 | 567 |
'description' => _x( 'Description', 'Plugin installer section title' ), |
5 | 568 |
'installation' => _x( 'Installation', 'Plugin installer section title' ), |
9 | 569 |
'faq' => _x( 'FAQ', 'Plugin installer section title' ), |
570 |
'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ), |
|
571 |
'changelog' => _x( 'Changelog', 'Plugin installer section title' ), |
|
572 |
'reviews' => _x( 'Reviews', 'Plugin installer section title' ), |
|
573 |
'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ), |
|
0 | 574 |
); |
575 |
||
16 | 576 |
// Sanitize HTML. |
5 | 577 |
foreach ( (array) $api->sections as $section_name => $content ) { |
9 | 578 |
$api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags ); |
5 | 579 |
} |
580 |
||
0 | 581 |
foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) { |
5 | 582 |
if ( isset( $api->$key ) ) { |
0 | 583 |
$api->$key = wp_kses( $api->$key, $plugins_allowedtags ); |
5 | 584 |
} |
585 |
} |
|
586 |
||
587 |
$_tab = esc_attr( $tab ); |
|
588 |
||
16 | 589 |
// Default to the Description tab, Do not translate, API returns English. |
590 |
$section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; |
|
5 | 591 |
if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { |
592 |
$section_titles = array_keys( (array) $api->sections ); |
|
9 | 593 |
$section = reset( $section_titles ); |
0 | 594 |
} |
595 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
596 |
iframe_header( __( 'Plugin Installation' ) ); |
5 | 597 |
|
598 |
$_with_banner = ''; |
|
599 |
||
600 |
if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) { |
|
601 |
$_with_banner = 'with-banner'; |
|
9 | 602 |
$low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low']; |
603 |
$high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high']; |
|
5 | 604 |
?> |
605 |
<style type="text/css"> |
|
606 |
#plugin-information-title.with-banner { |
|
607 |
background-image: url( <?php echo esc_url( $low ); ?> ); |
|
608 |
} |
|
609 |
@media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) { |
|
610 |
#plugin-information-title.with-banner { |
|
611 |
background-image: url( <?php echo esc_url( $high ); ?> ); |
|
612 |
} |
|
613 |
} |
|
614 |
</style> |
|
615 |
<?php |
|
616 |
} |
|
617 |
||
618 |
echo '<div id="plugin-information-scrollable">'; |
|
619 |
echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>"; |
|
620 |
echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n"; |
|
621 |
||
622 |
foreach ( (array) $api->sections as $section_name => $content ) { |
|
623 |
if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) { |
|
624 |
continue; |
|
625 |
} |
|
626 |
||
627 |
if ( isset( $plugins_section_titles[ $section_name ] ) ) { |
|
628 |
$title = $plugins_section_titles[ $section_name ]; |
|
629 |
} else { |
|
630 |
$title = ucwords( str_replace( '_', ' ', $section_name ) ); |
|
631 |
} |
|
632 |
||
9 | 633 |
$class = ( $section_name === $section ) ? ' class="current"' : ''; |
634 |
$href = add_query_arg( |
|
635 |
array( |
|
636 |
'tab' => $tab, |
|
637 |
'section' => $section_name, |
|
638 |
) |
|
639 |
); |
|
640 |
$href = esc_url( $href ); |
|
5 | 641 |
$san_section = esc_attr( $section_name ); |
642 |
echo "\t<a name='$san_section' href='$href' $class>$title</a>\n"; |
|
0 | 643 |
} |
644 |
||
5 | 645 |
echo "</div>\n"; |
0 | 646 |
|
647 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
<div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'> |
5 | 649 |
<div class="fyi"> |
0 | 650 |
<ul> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
<?php if ( ! empty( $api->version ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
<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
|
653 |
<?php } if ( ! empty( $api->author ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
654 |
<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
|
655 |
<?php } if ( ! empty( $api->last_updated ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
<li><strong><?php _e( 'Last Updated:' ); ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
<?php |
16 | 658 |
/* translators: %s: Human-readable time difference. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
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
|
660 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
<?php } if ( ! empty( $api->requires ) ) { ?> |
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 |
<strong><?php _e( 'Requires WordPress Version:' ); ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
<?php |
16 | 666 |
/* translators: %s: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
printf( __( '%s or higher' ), $api->requires ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
668 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
<?php } if ( ! empty( $api->tested ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
<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
|
672 |
<?php } if ( ! empty( $api->requires_php ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
<li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
<strong><?php _e( 'Requires PHP Version:' ); ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
675 |
<?php |
16 | 676 |
/* translators: %s: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
printf( __( '%s or higher' ), $api->requires_php ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
678 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
<?php } if ( isset( $api->active_installs ) ) { ?> |
9 | 681 |
<li><strong><?php _e( 'Active Installations:' ); ?></strong> |
682 |
<?php |
|
683 |
if ( $api->active_installs >= 1000000 ) { |
|
684 |
$active_installs_millions = floor( $api->active_installs / 1000000 ); |
|
685 |
printf( |
|
16 | 686 |
/* translators: %s: Number of millions. */ |
9 | 687 |
_nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ), |
688 |
number_format_i18n( $active_installs_millions ) |
|
689 |
); |
|
18 | 690 |
} elseif ( $api->active_installs < 10 ) { |
9 | 691 |
_ex( 'Less Than 10', 'Active plugin installations' ); |
692 |
} else { |
|
693 |
echo number_format_i18n( $api->active_installs ) . '+'; |
|
694 |
} |
|
695 |
?> |
|
696 |
</li> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
<?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?> |
19 | 698 |
<li><a target="_blank" href="<?php echo esc_url( __( 'https://wordpress.org/plugins/' ) . $api->slug ); ?>/"><?php _e( 'WordPress.org Plugin Page »' ); ?></a></li> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
<?php } if ( ! empty( $api->homepage ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
<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
|
701 |
<?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?> |
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->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
|
703 |
<?php } ?> |
0 | 704 |
</ul> |
5 | 705 |
<?php if ( ! empty( $api->rating ) ) { ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
<h3><?php _e( 'Average Rating' ); ?></h3> |
9 | 707 |
<?php |
708 |
wp_star_rating( |
|
709 |
array( |
|
710 |
'rating' => $api->rating, |
|
711 |
'type' => 'percent', |
|
712 |
'number' => $api->num_ratings, |
|
713 |
) |
|
714 |
); |
|
715 |
?> |
|
16 | 716 |
<p aria-hidden="true" class="fyi-description"> |
717 |
<?php |
|
718 |
printf( |
|
719 |
/* translators: %s: Number of ratings. */ |
|
720 |
_n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), |
|
721 |
number_format_i18n( $api->num_ratings ) |
|
722 |
); |
|
723 |
?> |
|
724 |
</p> |
|
9 | 725 |
<?php |
726 |
} |
|
5 | 727 |
|
9 | 728 |
if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { |
729 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
<h3><?php _e( 'Reviews' ); ?></h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
<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
|
732 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
foreach ( $api->ratings as $key => $ratecount ) { |
5 | 734 |
// Avoid div-by-zero. |
16 | 735 |
$_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0; |
9 | 736 |
$aria_label = esc_attr( |
737 |
sprintf( |
|
16 | 738 |
/* translators: 1: Number of stars (used to determine singular/plural), 2: Number of reviews. */ |
739 |
_n( |
|
740 |
'Reviews with %1$d star: %2$s. Opens in a new tab.', |
|
741 |
'Reviews with %1$d stars: %2$s. Opens in a new tab.', |
|
742 |
$key |
|
743 |
), |
|
9 | 744 |
$key, |
745 |
number_format_i18n( $ratecount ) |
|
746 |
) |
|
747 |
); |
|
5 | 748 |
?> |
749 |
<div class="counter-container"> |
|
9 | 750 |
<span class="counter-label"> |
16 | 751 |
<?php |
752 |
printf( |
|
753 |
'<a href="%s" target="_blank" aria-label="%s">%s</a>', |
|
754 |
"https://wordpress.org/support/plugin/{$api->slug}/reviews/?filter={$key}", |
|
755 |
$aria_label, |
|
756 |
/* translators: %s: Number of stars. */ |
|
757 |
sprintf( _n( '%d star', '%d stars', $key ), $key ) |
|
758 |
); |
|
759 |
?> |
|
9 | 760 |
</span> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
<span class="counter-back"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
<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
|
763 |
</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
<span class="counter-count" aria-hidden="true"><?php echo number_format_i18n( $ratecount ); ?></span> |
5 | 765 |
</div> |
766 |
<?php |
|
767 |
} |
|
768 |
} |
|
9 | 769 |
if ( ! empty( $api->contributors ) ) { |
770 |
?> |
|
5 | 771 |
<h3><?php _e( 'Contributors' ); ?></h3> |
772 |
<ul class="contributors"> |
|
773 |
<?php |
|
9 | 774 |
foreach ( (array) $api->contributors as $contrib_username => $contrib_details ) { |
775 |
$contrib_name = $contrib_details['display_name']; |
|
776 |
if ( ! $contrib_name ) { |
|
777 |
$contrib_name = $contrib_username; |
|
5 | 778 |
} |
9 | 779 |
$contrib_name = esc_html( $contrib_name ); |
780 |
||
781 |
$contrib_profile = esc_url( $contrib_details['profile'] ); |
|
782 |
$contrib_avatar = esc_url( add_query_arg( 's', '36', $contrib_details['avatar'] ) ); |
|
783 |
||
784 |
echo "<li><a href='{$contrib_profile}' target='_blank'><img src='{$contrib_avatar}' width='18' height='18' alt='' />{$contrib_name}</a></li>"; |
|
5 | 785 |
} |
786 |
?> |
|
787 |
</ul> |
|
9 | 788 |
<?php if ( ! empty( $api->donate_link ) ) { ?> |
5 | 789 |
<a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »' ); ?></a> |
790 |
<?php } ?> |
|
9 | 791 |
<?php } ?> |
0 | 792 |
</div> |
9 | 793 |
<div id="section-holder"> |
0 | 794 |
<?php |
9 | 795 |
$requires_php = isset( $api->requires_php ) ? $api->requires_php : null; |
796 |
$requires_wp = isset( $api->requires ) ? $api->requires : null; |
|
797 |
||
798 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
799 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
800 |
$tested_wp = ( empty( $api->tested ) || version_compare( get_bloginfo( 'version' ), $api->tested, '<=' ) ); |
|
801 |
||
802 |
if ( ! $compatible_php ) { |
|
803 |
echo '<div class="notice notice-error notice-alt"><p>'; |
|
804 |
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' ); |
|
805 |
if ( current_user_can( 'update_php' ) ) { |
|
806 |
printf( |
|
16 | 807 |
/* translators: %s: URL to Update PHP page. */ |
9 | 808 |
' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ), |
809 |
esc_url( wp_get_update_php_url() ) |
|
810 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
811 |
|
9 | 812 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
813 |
} else { |
|
814 |
echo '</p>'; |
|
815 |
} |
|
816 |
echo '</div>'; |
|
817 |
} |
|
818 |
||
819 |
if ( ! $tested_wp ) { |
|
820 |
echo '<div class="notice notice-warning notice-alt"><p>'; |
|
821 |
_e( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ); |
|
822 |
echo '</p></div>'; |
|
823 |
} elseif ( ! $compatible_wp ) { |
|
824 |
echo '<div class="notice notice-error notice-alt"><p>'; |
|
825 |
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' ); |
|
826 |
if ( current_user_can( 'update_core' ) ) { |
|
827 |
printf( |
|
16 | 828 |
/* translators: %s: URL to WordPress Updates screen. */ |
9 | 829 |
' ' . __( '<a href="%s" target="_parent">Click here to update WordPress</a>.' ), |
830 |
self_admin_url( 'update-core.php' ) |
|
831 |
); |
|
832 |
} |
|
833 |
echo '</p></div>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
834 |
} |
0 | 835 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
foreach ( (array) $api->sections as $section_name => $content ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
837 |
$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
|
838 |
$content = links_add_target( $content, '_blank' ); |
0 | 839 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
840 |
$san_section = esc_attr( $section_name ); |
0 | 841 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
842 |
$display = ( $section_name === $section ) ? 'block' : 'none'; |
0 | 843 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
844 |
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
|
845 |
echo $content; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
846 |
echo "\t</div>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
} |
0 | 848 |
echo "</div>\n"; |
5 | 849 |
echo "</div>\n"; |
850 |
echo "</div>\n"; // #plugin-information-scrollable |
|
851 |
echo "<div id='$tab-footer'>\n"; |
|
852 |
if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) { |
|
853 |
$status = install_plugin_install_status( $api ); |
|
854 |
switch ( $status['status'] ) { |
|
855 |
case 'install': |
|
856 |
if ( $status['url'] ) { |
|
9 | 857 |
if ( $compatible_php && $compatible_wp ) { |
858 |
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>'; |
|
859 |
} else { |
|
860 |
printf( |
|
861 |
'<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', |
|
862 |
_x( 'Cannot Install', 'plugin' ) |
|
863 |
); |
|
864 |
} |
|
5 | 865 |
} |
866 |
break; |
|
867 |
case 'update_available': |
|
868 |
if ( $status['url'] ) { |
|
9 | 869 |
if ( $compatible_php ) { |
870 |
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>'; |
|
871 |
} else { |
|
872 |
printf( |
|
873 |
'<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', |
|
874 |
_x( 'Cannot Update', 'plugin' ) |
|
875 |
); |
|
876 |
} |
|
5 | 877 |
} |
878 |
break; |
|
879 |
case 'newer_installed': |
|
16 | 880 |
/* translators: %s: Plugin version. */ |
18 | 881 |
echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed' ), esc_html( $status['version'] ) ) . '</a>'; |
5 | 882 |
break; |
883 |
case 'latest_installed': |
|
884 |
echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>'; |
|
885 |
break; |
|
886 |
} |
|
887 |
} |
|
888 |
echo "</div>\n"; |
|
0 | 889 |
|
890 |
iframe_footer(); |
|
891 |
exit; |
|
892 |
} |