author | ymh <ymh.work@gmail.com> |
Wed, 21 Sep 2022 18:19:35 +0200 | |
changeset 18 | be944660c56a |
parent 16 | a86126ab1dd4 |
child 19 | 3d72ae0968f4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* List Table API: WP_Plugin_Install_List_Table class |
0 | 4 |
* |
5 |
* @package WordPress |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
* @subpackage Administration |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
7 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
8 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
9 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
* Core class used to implement displaying plugins to install in a list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
* |
0 | 13 |
* @since 3.1.0 |
14 |
* @access private |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* @see WP_List_Table |
0 | 17 |
*/ |
18 |
class WP_Plugin_Install_List_Table extends WP_List_Table { |
|
19 |
||
9 | 20 |
public $order = 'ASC'; |
5 | 21 |
public $orderby = null; |
9 | 22 |
public $groups = array(); |
5 | 23 |
|
24 |
private $error; |
|
25 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
*/ |
5 | 29 |
public function ajax_user_can() { |
9 | 30 |
return current_user_can( 'install_plugins' ); |
0 | 31 |
} |
32 |
||
5 | 33 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* Return the list of known plugins. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* Uses the transient data from the updates API to determine the known |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* installed plugins. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
* @access protected |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
protected function get_installed_plugins() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
$plugins = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
$plugin_info = get_site_transient( 'update_plugins' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
if ( isset( $plugin_info->no_update ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
foreach ( $plugin_info->no_update as $plugin ) { |
18 | 50 |
if ( isset( $plugin->slug ) ) { |
51 |
$plugin->upgrade = false; |
|
52 |
$plugins[ $plugin->slug ] = $plugin; |
|
53 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
if ( isset( $plugin_info->response ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
foreach ( $plugin_info->response as $plugin ) { |
18 | 59 |
if ( isset( $plugin->slug ) ) { |
60 |
$plugin->upgrade = true; |
|
61 |
$plugins[ $plugin->slug ] = $plugin; |
|
62 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
return $plugins; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
/** |
5 | 70 |
* Return a list of slugs of installed plugins, if known. |
71 |
* |
|
72 |
* Uses the transient data from the updates API to determine the slugs of |
|
73 |
* known installed plugins. This might be better elsewhere, perhaps even |
|
74 |
* within get_plugins(). |
|
75 |
* |
|
76 |
* @since 4.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
* @return array |
5 | 79 |
*/ |
80 |
protected function get_installed_plugin_slugs() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
return array_keys( $this->get_installed_plugins() ); |
5 | 82 |
} |
83 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
* @global array $tabs |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
* @global int $paged |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
* @global string $type |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
* @global string $term |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
*/ |
5 | 91 |
public function prepare_items() { |
16 | 92 |
include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
0 | 93 |
|
94 |
global $tabs, $tab, $paged, $type, $term; |
|
95 |
||
96 |
wp_reset_vars( array( 'tab' ) ); |
|
97 |
||
98 |
$paged = $this->get_pagenum(); |
|
99 |
||
9 | 100 |
$per_page = 36; |
0 | 101 |
|
16 | 102 |
// These are the tabs which are shown on the page. |
0 | 103 |
$tabs = array(); |
5 | 104 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
if ( 'search' === $tab ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
$tabs['search'] = __( 'Search Results' ); |
5 | 107 |
} |
18 | 108 |
|
16 | 109 |
if ( 'beta' === $tab || false !== strpos( get_bloginfo( 'version' ), '-' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
$tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
} |
18 | 112 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
$tabs['featured'] = _x( 'Featured', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
$tabs['popular'] = _x( 'Popular', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
$tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
$tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' ); |
18 | 117 |
|
5 | 118 |
if ( current_user_can( 'upload_plugins' ) ) { |
119 |
// No longer a real tab. Here for filter compatibility. |
|
120 |
// Gets skipped in get_views(). |
|
121 |
$tabs['upload'] = __( 'Upload Plugin' ); |
|
122 |
} |
|
0 | 123 |
|
5 | 124 |
$nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item. |
0 | 125 |
|
126 |
/** |
|
16 | 127 |
* Filters the tabs shown on the Add Plugins screen. |
0 | 128 |
* |
129 |
* @since 2.7.0 |
|
130 |
* |
|
16 | 131 |
* @param string[] $tabs The tabs shown on the Add Plugins screen. Defaults include |
132 |
* 'featured', 'popular', 'recommended', 'favorites', and 'upload'. |
|
0 | 133 |
*/ |
134 |
$tabs = apply_filters( 'install_plugins_tabs', $tabs ); |
|
135 |
||
136 |
/** |
|
16 | 137 |
* Filters tabs not associated with a menu item on the Add Plugins screen. |
0 | 138 |
* |
139 |
* @since 2.7.0 |
|
140 |
* |
|
16 | 141 |
* @param string[] $nonmenu_tabs The tabs that don't have a menu item on the Add Plugins screen. |
0 | 142 |
*/ |
143 |
$nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); |
|
144 |
||
145 |
// If a non-valid menu tab has been selected, And it's not a non-menu action. |
|
16 | 146 |
if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs, true ) ) ) { |
0 | 147 |
$tab = key( $tabs ); |
9 | 148 |
} |
0 | 149 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
$installed_plugins = $this->get_installed_plugins(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
|
5 | 152 |
$args = array( |
9 | 153 |
'page' => $paged, |
5 | 154 |
'per_page' => $per_page, |
9 | 155 |
// Send the locale to the API so it can provide context-sensitive results. |
156 |
'locale' => get_user_locale(), |
|
5 | 157 |
); |
0 | 158 |
|
159 |
switch ( $tab ) { |
|
160 |
case 'search': |
|
161 |
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
|
162 |
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
|
163 |
||
164 |
switch ( $type ) { |
|
165 |
case 'tag': |
|
166 |
$args['tag'] = sanitize_title_with_dashes( $term ); |
|
167 |
break; |
|
168 |
case 'term': |
|
169 |
$args['search'] = $term; |
|
170 |
break; |
|
171 |
case 'author': |
|
172 |
$args['author'] = $term; |
|
173 |
break; |
|
174 |
} |
|
175 |
||
176 |
break; |
|
177 |
||
178 |
case 'featured': |
|
179 |
case 'popular': |
|
180 |
case 'new': |
|
5 | 181 |
case 'beta': |
9 | 182 |
$args['browse'] = $tab; |
183 |
break; |
|
5 | 184 |
case 'recommended': |
0 | 185 |
$args['browse'] = $tab; |
9 | 186 |
// Include the list of installed plugins so we can get relevant results. |
187 |
$args['installed_plugins'] = array_keys( $installed_plugins ); |
|
0 | 188 |
break; |
189 |
||
190 |
case 'favorites': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
$action = 'save_wporg_username_' . get_current_user_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), $action ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
$user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
9 | 194 |
|
195 |
// If the save url parameter is passed with a falsey value, don't save the favorite user. |
|
196 |
if ( ! isset( $_GET['save'] ) || $_GET['save'] ) { |
|
197 |
update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); |
|
198 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
$user = get_user_option( 'wporg_favorites' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
} |
9 | 202 |
if ( $user ) { |
0 | 203 |
$args['user'] = $user; |
9 | 204 |
} else { |
0 | 205 |
$args = false; |
9 | 206 |
} |
0 | 207 |
|
208 |
add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); |
|
209 |
break; |
|
210 |
||
211 |
default: |
|
212 |
$args = false; |
|
213 |
break; |
|
214 |
} |
|
215 |
||
216 |
/** |
|
16 | 217 |
* Filters API request arguments for each Add Plugins screen tab. |
0 | 218 |
* |
5 | 219 |
* The dynamic portion of the hook name, `$tab`, refers to the plugin install tabs. |
18 | 220 |
* |
221 |
* Possible hook names include: |
|
222 |
* |
|
223 |
* - `install_plugins_table_api_args_favorites` |
|
224 |
* - `install_plugins_table_api_args_featured` |
|
225 |
* - `install_plugins_table_api_args_popular` |
|
226 |
* - `install_plugins_table_api_args_recommended` |
|
227 |
* - `install_plugins_table_api_args_upload` |
|
0 | 228 |
* |
229 |
* @since 3.7.0 |
|
230 |
* |
|
16 | 231 |
* @param array|false $args Plugin install API arguments. |
0 | 232 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
233 |
$args = apply_filters( "install_plugins_table_api_args_{$tab}", $args ); |
0 | 234 |
|
9 | 235 |
if ( ! $args ) { |
0 | 236 |
return; |
9 | 237 |
} |
0 | 238 |
|
239 |
$api = plugins_api( 'query_plugins', $args ); |
|
240 |
||
5 | 241 |
if ( is_wp_error( $api ) ) { |
242 |
$this->error = $api; |
|
243 |
return; |
|
244 |
} |
|
0 | 245 |
|
246 |
$this->items = $api->plugins; |
|
247 |
||
5 | 248 |
if ( $this->orderby ) { |
249 |
uasort( $this->items, array( $this, 'order_callback' ) ); |
|
250 |
} |
|
251 |
||
9 | 252 |
$this->set_pagination_args( |
253 |
array( |
|
254 |
'total_items' => $api->info['results'], |
|
255 |
'per_page' => $args['per_page'], |
|
256 |
) |
|
257 |
); |
|
5 | 258 |
|
259 |
if ( isset( $api->info['groups'] ) ) { |
|
260 |
$this->groups = $api->info['groups']; |
|
261 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
if ( $installed_plugins ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
$js_plugins = array_fill_keys( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
array() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
$js_plugins['all'] = array_values( wp_list_pluck( $installed_plugins, 'plugin' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
$upgrade_plugins = wp_filter_object_list( $installed_plugins, array( 'upgrade' => true ), 'and', 'plugin' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
if ( $upgrade_plugins ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
$js_plugins['upgrade'] = array_values( $upgrade_plugins ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
|
9 | 276 |
wp_localize_script( |
277 |
'updates', |
|
278 |
'_wpUpdatesItemCounts', |
|
279 |
array( |
|
280 |
'plugins' => $js_plugins, |
|
281 |
'totals' => wp_get_update_data(), |
|
282 |
) |
|
283 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
} |
0 | 285 |
} |
286 |
||
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 |
*/ |
5 | 289 |
public function no_items() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
if ( isset( $this->error ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
<div class="inline error"><p><?php echo $this->error->get_error_message(); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
<p class="hide-if-no-js"><button class="button try-again"><?php _e( 'Try Again' ); ?></button></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
<?php } else { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
<div class="no-plugin-results"><?php _e( 'No plugins found. Try a different search.' ); ?></div> |
9 | 296 |
<?php |
5 | 297 |
} |
0 | 298 |
} |
299 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
* @global array $tabs |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
*/ |
5 | 306 |
protected function get_views() { |
0 | 307 |
global $tabs, $tab; |
308 |
||
309 |
$display_tabs = array(); |
|
310 |
foreach ( (array) $tabs as $action => $text ) { |
|
9 | 311 |
$current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : ''; |
312 |
$href = self_admin_url( 'plugin-install.php?tab=' . $action ); |
|
313 |
$display_tabs[ 'plugin-install-' . $action ] = "<a href='$href'$current_link_attributes>$text</a>"; |
|
0 | 314 |
} |
5 | 315 |
// No longer a real tab. |
316 |
unset( $display_tabs['plugin-install-upload'] ); |
|
0 | 317 |
|
318 |
return $display_tabs; |
|
319 |
} |
|
320 |
||
5 | 321 |
/** |
322 |
* Override parent views so we can use the filter bar display. |
|
323 |
*/ |
|
324 |
public function views() { |
|
325 |
$views = $this->get_views(); |
|
326 |
||
327 |
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
|
328 |
$views = apply_filters( "views_{$this->screen->id}", $views ); |
|
329 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
$this->screen->render_screen_reader_content( 'heading_views' ); |
9 | 331 |
?> |
5 | 332 |
<div class="wp-filter"> |
333 |
<ul class="filter-links"> |
|
334 |
<?php |
|
335 |
if ( ! empty( $views ) ) { |
|
336 |
foreach ( $views as $class => $view ) { |
|
337 |
$views[ $class ] = "\t<li class='$class'>$view"; |
|
338 |
} |
|
339 |
echo implode( " </li>\n", $views ) . "</li>\n"; |
|
340 |
} |
|
341 |
?> |
|
342 |
</ul> |
|
343 |
||
9 | 344 |
<?php install_search_form(); ?> |
5 | 345 |
</div> |
9 | 346 |
<?php |
5 | 347 |
} |
348 |
||
349 |
/** |
|
16 | 350 |
* Displays the plugin install table. |
351 |
* |
|
352 |
* Overrides the parent display() method to provide a different container. |
|
353 |
* |
|
354 |
* @since 4.0.0 |
|
5 | 355 |
*/ |
356 |
public function display() { |
|
357 |
$singular = $this->_args['singular']; |
|
358 |
||
359 |
$data_attr = ''; |
|
360 |
||
361 |
if ( $singular ) { |
|
362 |
$data_attr = " data-wp-lists='list:$singular'"; |
|
363 |
} |
|
364 |
||
365 |
$this->display_tablenav( 'top' ); |
|
366 |
||
9 | 367 |
?> |
5 | 368 |
<div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
9 | 369 |
<?php |
370 |
$this->screen->render_screen_reader_content( 'heading_list' ); |
|
371 |
?> |
|
5 | 372 |
<div id="the-list"<?php echo $data_attr; ?>> |
373 |
<?php $this->display_rows_or_placeholder(); ?> |
|
374 |
</div> |
|
375 |
</div> |
|
9 | 376 |
<?php |
5 | 377 |
$this->display_tablenav( 'bottom' ); |
378 |
} |
|
379 |
||
380 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
* |
5 | 383 |
* @param string $which |
384 |
*/ |
|
385 |
protected function display_tablenav( $which ) { |
|
16 | 386 |
if ( 'featured' === $GLOBALS['tab'] ) { |
5 | 387 |
return; |
388 |
} |
|
389 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
if ( 'top' === $which ) { |
5 | 391 |
wp_referer_field(); |
9 | 392 |
?> |
0 | 393 |
<div class="tablenav top"> |
394 |
<div class="alignleft actions"> |
|
395 |
<?php |
|
396 |
/** |
|
397 |
* Fires before the Plugin Install table header pagination is displayed. |
|
398 |
* |
|
399 |
* @since 2.7.0 |
|
400 |
*/ |
|
9 | 401 |
do_action( 'install_plugins_table_header' ); |
402 |
?> |
|
0 | 403 |
</div> |
404 |
<?php $this->pagination( $which ); ?> |
|
405 |
<br class="clear" /> |
|
406 |
</div> |
|
407 |
<?php } else { ?> |
|
408 |
<div class="tablenav bottom"> |
|
409 |
<?php $this->pagination( $which ); ?> |
|
410 |
<br class="clear" /> |
|
411 |
</div> |
|
9 | 412 |
<?php |
0 | 413 |
} |
414 |
} |
|
415 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
*/ |
5 | 419 |
protected function get_table_classes() { |
420 |
return array( 'widefat', $this->_args['plural'] ); |
|
421 |
} |
|
0 | 422 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
*/ |
5 | 426 |
public function get_columns() { |
427 |
return array(); |
|
0 | 428 |
} |
429 |
||
5 | 430 |
/** |
431 |
* @param object $plugin_a |
|
432 |
* @param object $plugin_b |
|
433 |
* @return int |
|
434 |
*/ |
|
435 |
private function order_callback( $plugin_a, $plugin_b ) { |
|
436 |
$orderby = $this->orderby; |
|
437 |
if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) { |
|
438 |
return 0; |
|
439 |
} |
|
440 |
||
441 |
$a = $plugin_a->$orderby; |
|
442 |
$b = $plugin_b->$orderby; |
|
443 |
||
18 | 444 |
if ( $a === $b ) { |
5 | 445 |
return 0; |
446 |
} |
|
447 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
if ( 'DESC' === $this->order ) { |
5 | 449 |
return ( $a < $b ) ? 1 : -1; |
450 |
} else { |
|
451 |
return ( $a < $b ) ? -1 : 1; |
|
452 |
} |
|
0 | 453 |
} |
454 |
||
5 | 455 |
public function display_rows() { |
0 | 456 |
$plugins_allowedtags = array( |
9 | 457 |
'a' => array( |
458 |
'href' => array(), |
|
459 |
'title' => array(), |
|
460 |
'target' => array(), |
|
461 |
), |
|
462 |
'abbr' => array( 'title' => array() ), |
|
463 |
'acronym' => array( 'title' => array() ), |
|
464 |
'code' => array(), |
|
465 |
'pre' => array(), |
|
466 |
'em' => array(), |
|
467 |
'strong' => array(), |
|
468 |
'ul' => array(), |
|
469 |
'ol' => array(), |
|
470 |
'li' => array(), |
|
471 |
'p' => array(), |
|
472 |
'br' => array(), |
|
0 | 473 |
); |
474 |
||
5 | 475 |
$plugins_group_titles = array( |
476 |
'Performance' => _x( 'Performance', 'Plugin installer group title' ), |
|
9 | 477 |
'Social' => _x( 'Social', 'Plugin installer group title' ), |
478 |
'Tools' => _x( 'Tools', 'Plugin installer group title' ), |
|
5 | 479 |
); |
0 | 480 |
|
5 | 481 |
$group = null; |
0 | 482 |
|
483 |
foreach ( (array) $this->items as $plugin ) { |
|
5 | 484 |
if ( is_object( $plugin ) ) { |
0 | 485 |
$plugin = (array) $plugin; |
5 | 486 |
} |
0 | 487 |
|
16 | 488 |
// Display the group heading if there is one. |
18 | 489 |
if ( isset( $plugin['group'] ) && $plugin['group'] !== $group ) { |
5 | 490 |
if ( isset( $this->groups[ $plugin['group'] ] ) ) { |
491 |
$group_name = $this->groups[ $plugin['group'] ]; |
|
492 |
if ( isset( $plugins_group_titles[ $group_name ] ) ) { |
|
493 |
$group_name = $plugins_group_titles[ $group_name ]; |
|
494 |
} |
|
495 |
} else { |
|
496 |
$group_name = $plugin['group']; |
|
497 |
} |
|
498 |
||
16 | 499 |
// Starting a new group, close off the divs of the last one. |
5 | 500 |
if ( ! empty( $group ) ) { |
501 |
echo '</div></div>'; |
|
502 |
} |
|
503 |
||
504 |
echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; |
|
16 | 505 |
// Needs an extra wrapping div for nth-child selectors to work. |
5 | 506 |
echo '<div class="plugin-items">'; |
507 |
||
508 |
$group = $plugin['group']; |
|
509 |
} |
|
18 | 510 |
|
0 | 511 |
$title = wp_kses( $plugin['name'], $plugins_allowedtags ); |
5 | 512 |
|
513 |
// Remove any HTML from the description. |
|
514 |
$description = strip_tags( $plugin['short_description'] ); |
|
9 | 515 |
$version = wp_kses( $plugin['version'], $plugins_allowedtags ); |
0 | 516 |
|
517 |
$name = strip_tags( $title . ' ' . $version ); |
|
518 |
||
5 | 519 |
$author = wp_kses( $plugin['author'], $plugins_allowedtags ); |
520 |
if ( ! empty( $author ) ) { |
|
16 | 521 |
/* translators: %s: Plugin author. */ |
5 | 522 |
$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; |
523 |
} |
|
0 | 524 |
|
9 | 525 |
$requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null; |
526 |
$requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null; |
|
527 |
||
528 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
529 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
530 |
$tested_wp = ( empty( $plugin['tested'] ) || version_compare( get_bloginfo( 'version' ), $plugin['tested'], '<=' ) ); |
|
531 |
||
0 | 532 |
$action_links = array(); |
533 |
||
534 |
if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { |
|
535 |
$status = install_plugin_install_status( $plugin ); |
|
536 |
||
537 |
switch ( $status['status'] ) { |
|
538 |
case 'install': |
|
5 | 539 |
if ( $status['url'] ) { |
9 | 540 |
if ( $compatible_php && $compatible_wp ) { |
541 |
$action_links[] = sprintf( |
|
542 |
'<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', |
|
543 |
esc_attr( $plugin['slug'] ), |
|
544 |
esc_url( $status['url'] ), |
|
16 | 545 |
/* translators: %s: Plugin name and version. */ |
546 |
esc_attr( sprintf( _x( 'Install %s now', 'plugin' ), $name ) ), |
|
9 | 547 |
esc_attr( $name ), |
548 |
__( 'Install Now' ) |
|
549 |
); |
|
550 |
} else { |
|
551 |
$action_links[] = sprintf( |
|
552 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
553 |
_x( 'Cannot Install', 'plugin' ) |
|
554 |
); |
|
555 |
} |
|
5 | 556 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
557 |
break; |
5 | 558 |
|
0 | 559 |
case 'update_available': |
5 | 560 |
if ( $status['url'] ) { |
9 | 561 |
if ( $compatible_php && $compatible_wp ) { |
562 |
$action_links[] = sprintf( |
|
563 |
'<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', |
|
564 |
esc_attr( $status['file'] ), |
|
565 |
esc_attr( $plugin['slug'] ), |
|
566 |
esc_url( $status['url'] ), |
|
16 | 567 |
/* translators: %s: Plugin name and version. */ |
568 |
esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $name ) ), |
|
9 | 569 |
esc_attr( $name ), |
570 |
__( 'Update Now' ) |
|
571 |
); |
|
572 |
} else { |
|
573 |
$action_links[] = sprintf( |
|
574 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
575 |
_x( 'Cannot Update', 'plugin' ) |
|
576 |
); |
|
577 |
} |
|
5 | 578 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
break; |
5 | 580 |
|
0 | 581 |
case 'latest_installed': |
582 |
case 'newer_installed': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
if ( is_plugin_active( $status['file'] ) ) { |
9 | 584 |
$action_links[] = sprintf( |
585 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
586 |
_x( 'Active', 'plugin' ) |
|
587 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
588 |
} elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) { |
9 | 589 |
$button_text = __( 'Activate' ); |
16 | 590 |
/* translators: %s: Plugin name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
591 |
$button_label = _x( 'Activate %s', 'plugin' ); |
9 | 592 |
$activate_url = add_query_arg( |
593 |
array( |
|
594 |
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ), |
|
595 |
'action' => 'activate', |
|
596 |
'plugin' => $status['file'], |
|
597 |
), |
|
598 |
network_admin_url( 'plugins.php' ) |
|
599 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
601 |
if ( is_network_admin() ) { |
9 | 602 |
$button_text = __( 'Network Activate' ); |
16 | 603 |
/* translators: %s: Plugin name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
$button_label = _x( 'Network Activate %s', 'plugin' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
$activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
$action_links[] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
'<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
esc_url( $activate_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
esc_attr( sprintf( $button_label, $plugin['name'] ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
$button_text |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
} else { |
9 | 615 |
$action_links[] = sprintf( |
616 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
617 |
_x( 'Installed', 'plugin' ) |
|
618 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
} |
0 | 620 |
break; |
621 |
} |
|
622 |
} |
|
623 |
||
9 | 624 |
$details_link = self_admin_url( |
625 |
'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . |
|
626 |
'&TB_iframe=true&width=600&height=550' |
|
627 |
); |
|
5 | 628 |
|
9 | 629 |
$action_links[] = sprintf( |
630 |
'<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', |
|
631 |
esc_url( $details_link ), |
|
16 | 632 |
/* translators: %s: Plugin name and version. */ |
9 | 633 |
esc_attr( sprintf( __( 'More information about %s' ), $name ) ), |
634 |
esc_attr( $name ), |
|
635 |
__( 'More Details' ) |
|
636 |
); |
|
637 |
||
638 |
if ( ! empty( $plugin['icons']['svg'] ) ) { |
|
5 | 639 |
$plugin_icon_url = $plugin['icons']['svg']; |
9 | 640 |
} elseif ( ! empty( $plugin['icons']['2x'] ) ) { |
5 | 641 |
$plugin_icon_url = $plugin['icons']['2x']; |
9 | 642 |
} elseif ( ! empty( $plugin['icons']['1x'] ) ) { |
5 | 643 |
$plugin_icon_url = $plugin['icons']['1x']; |
644 |
} else { |
|
645 |
$plugin_icon_url = $plugin['icons']['default']; |
|
646 |
} |
|
647 |
||
0 | 648 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
* Filters the install action links for a plugin. |
0 | 650 |
* |
651 |
* @since 2.7.0 |
|
652 |
* |
|
9 | 653 |
* @param string[] $action_links An array of plugin action links. Defaults are links to Details and Install Now. |
654 |
* @param array $plugin The plugin currently being listed. |
|
0 | 655 |
*/ |
656 |
$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); |
|
5 | 657 |
|
658 |
$last_updated_timestamp = strtotime( $plugin['last_updated'] ); |
|
9 | 659 |
?> |
5 | 660 |
<div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>"> |
9 | 661 |
<?php |
662 |
if ( ! $compatible_php || ! $compatible_wp ) { |
|
663 |
echo '<div class="notice inline notice-error notice-alt"><p>'; |
|
664 |
if ( ! $compatible_php && ! $compatible_wp ) { |
|
665 |
_e( 'This plugin doesn’t work with your versions of WordPress and PHP.' ); |
|
666 |
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
|
667 |
printf( |
|
16 | 668 |
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
9 | 669 |
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
670 |
self_admin_url( 'update-core.php' ), |
|
671 |
esc_url( wp_get_update_php_url() ) |
|
672 |
); |
|
673 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
674 |
} elseif ( current_user_can( 'update_core' ) ) { |
|
675 |
printf( |
|
16 | 676 |
/* translators: %s: URL to WordPress Updates screen. */ |
9 | 677 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
678 |
self_admin_url( 'update-core.php' ) |
|
679 |
); |
|
680 |
} elseif ( current_user_can( 'update_php' ) ) { |
|
681 |
printf( |
|
16 | 682 |
/* translators: %s: URL to Update PHP page. */ |
9 | 683 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
684 |
esc_url( wp_get_update_php_url() ) |
|
685 |
); |
|
686 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
687 |
} |
|
688 |
} elseif ( ! $compatible_wp ) { |
|
689 |
_e( 'This plugin doesn’t work with your version of WordPress.' ); |
|
690 |
if ( current_user_can( 'update_core' ) ) { |
|
691 |
printf( |
|
16 | 692 |
/* translators: %s: URL to WordPress Updates screen. */ |
9 | 693 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
694 |
self_admin_url( 'update-core.php' ) |
|
695 |
); |
|
696 |
} |
|
697 |
} elseif ( ! $compatible_php ) { |
|
698 |
_e( 'This plugin doesn’t work with your version of PHP.' ); |
|
699 |
if ( current_user_can( 'update_php' ) ) { |
|
700 |
printf( |
|
16 | 701 |
/* translators: %s: URL to Update PHP page. */ |
9 | 702 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
703 |
esc_url( wp_get_update_php_url() ) |
|
704 |
); |
|
705 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
706 |
} |
|
707 |
} |
|
708 |
echo '</p></div>'; |
|
709 |
} |
|
710 |
?> |
|
5 | 711 |
<div class="plugin-card-top"> |
712 |
<div class="name column-name"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
<h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
<a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
<?php echo $title; ?> |
18 | 716 |
<img src="<?php echo esc_url( $plugin_icon_url ); ?>" class="plugin-icon" alt="" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
</a> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
</h3> |
5 | 719 |
</div> |
720 |
<div class="action-links"> |
|
721 |
<?php |
|
9 | 722 |
if ( $action_links ) { |
723 |
echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>'; |
|
724 |
} |
|
5 | 725 |
?> |
726 |
</div> |
|
727 |
<div class="desc column-description"> |
|
728 |
<p><?php echo $description; ?></p> |
|
729 |
<p class="authors"><?php echo $author; ?></p> |
|
730 |
</div> |
|
731 |
</div> |
|
732 |
<div class="plugin-card-bottom"> |
|
733 |
<div class="vers column-rating"> |
|
9 | 734 |
<?php |
735 |
wp_star_rating( |
|
736 |
array( |
|
737 |
'rating' => $plugin['rating'], |
|
738 |
'type' => 'percent', |
|
739 |
'number' => $plugin['num_ratings'], |
|
740 |
) |
|
741 |
); |
|
742 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
743 |
<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> |
5 | 744 |
</div> |
745 |
<div class="column-updated"> |
|
16 | 746 |
<strong><?php _e( 'Last Updated:' ); ?></strong> |
747 |
<?php |
|
748 |
/* translators: %s: Human-readable time difference. */ |
|
749 |
printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); |
|
750 |
?> |
|
0 | 751 |
</div> |
5 | 752 |
<div class="column-downloaded"> |
753 |
<?php |
|
754 |
if ( $plugin['active_installs'] >= 1000000 ) { |
|
9 | 755 |
$active_installs_millions = floor( $plugin['active_installs'] / 1000000 ); |
756 |
$active_installs_text = sprintf( |
|
16 | 757 |
/* translators: %s: Number of millions. */ |
9 | 758 |
_nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ), |
759 |
number_format_i18n( $active_installs_millions ) |
|
760 |
); |
|
18 | 761 |
} elseif ( 0 === $plugin['active_installs'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
$active_installs_text = _x( 'Less Than 10', 'Active plugin installations' ); |
5 | 763 |
} else { |
764 |
$active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+'; |
|
765 |
} |
|
16 | 766 |
/* translators: %s: Number of installations. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
printf( __( '%s Active Installations' ), $active_installs_text ); |
5 | 768 |
?> |
769 |
</div> |
|
770 |
<div class="column-compatibility"> |
|
771 |
<?php |
|
9 | 772 |
if ( ! $tested_wp ) { |
5 | 773 |
echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>'; |
9 | 774 |
} elseif ( ! $compatible_wp ) { |
5 | 775 |
echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; |
776 |
} else { |
|
777 |
echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>'; |
|
778 |
} |
|
779 |
?> |
|
780 |
</div> |
|
781 |
</div> |
|
782 |
</div> |
|
9 | 783 |
<?php |
0 | 784 |
} |
5 | 785 |
|
16 | 786 |
// Close off the group divs of the last one. |
5 | 787 |
if ( ! empty( $group ) ) { |
788 |
echo '</div></div>'; |
|
789 |
} |
|
0 | 790 |
} |
791 |
} |