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