author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
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` |
|
19 | 228 |
* - `install_plugins_table_api_args_search` |
229 |
* - `install_plugins_table_api_args_beta` |
|
0 | 230 |
* |
231 |
* @since 3.7.0 |
|
232 |
* |
|
16 | 233 |
* @param array|false $args Plugin install API arguments. |
0 | 234 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
$args = apply_filters( "install_plugins_table_api_args_{$tab}", $args ); |
0 | 236 |
|
9 | 237 |
if ( ! $args ) { |
0 | 238 |
return; |
9 | 239 |
} |
0 | 240 |
|
241 |
$api = plugins_api( 'query_plugins', $args ); |
|
242 |
||
5 | 243 |
if ( is_wp_error( $api ) ) { |
244 |
$this->error = $api; |
|
245 |
return; |
|
246 |
} |
|
0 | 247 |
|
248 |
$this->items = $api->plugins; |
|
249 |
||
5 | 250 |
if ( $this->orderby ) { |
251 |
uasort( $this->items, array( $this, 'order_callback' ) ); |
|
252 |
} |
|
253 |
||
9 | 254 |
$this->set_pagination_args( |
255 |
array( |
|
256 |
'total_items' => $api->info['results'], |
|
257 |
'per_page' => $args['per_page'], |
|
258 |
) |
|
259 |
); |
|
5 | 260 |
|
261 |
if ( isset( $api->info['groups'] ) ) { |
|
262 |
$this->groups = $api->info['groups']; |
|
263 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
if ( $installed_plugins ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
$js_plugins = array_fill_keys( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
array() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
$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
|
272 |
$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
|
273 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
if ( $upgrade_plugins ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
$js_plugins['upgrade'] = array_values( $upgrade_plugins ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
|
9 | 278 |
wp_localize_script( |
279 |
'updates', |
|
280 |
'_wpUpdatesItemCounts', |
|
281 |
array( |
|
282 |
'plugins' => $js_plugins, |
|
283 |
'totals' => wp_get_update_data(), |
|
284 |
) |
|
285 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
} |
0 | 287 |
} |
288 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
*/ |
5 | 291 |
public function no_items() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
if ( isset( $this->error ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
<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
|
294 |
<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
|
295 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
<?php } else { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
<div class="no-plugin-results"><?php _e( 'No plugins found. Try a different search.' ); ?></div> |
9 | 298 |
<?php |
5 | 299 |
} |
0 | 300 |
} |
301 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
* @global array $tabs |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
*/ |
5 | 308 |
protected function get_views() { |
0 | 309 |
global $tabs, $tab; |
310 |
||
311 |
$display_tabs = array(); |
|
312 |
foreach ( (array) $tabs as $action => $text ) { |
|
9 | 313 |
$current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : ''; |
314 |
$href = self_admin_url( 'plugin-install.php?tab=' . $action ); |
|
315 |
$display_tabs[ 'plugin-install-' . $action ] = "<a href='$href'$current_link_attributes>$text</a>"; |
|
0 | 316 |
} |
5 | 317 |
// No longer a real tab. |
318 |
unset( $display_tabs['plugin-install-upload'] ); |
|
0 | 319 |
|
320 |
return $display_tabs; |
|
321 |
} |
|
322 |
||
5 | 323 |
/** |
324 |
* Override parent views so we can use the filter bar display. |
|
325 |
*/ |
|
326 |
public function views() { |
|
327 |
$views = $this->get_views(); |
|
328 |
||
329 |
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
|
330 |
$views = apply_filters( "views_{$this->screen->id}", $views ); |
|
331 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
$this->screen->render_screen_reader_content( 'heading_views' ); |
9 | 333 |
?> |
5 | 334 |
<div class="wp-filter"> |
335 |
<ul class="filter-links"> |
|
336 |
<?php |
|
337 |
if ( ! empty( $views ) ) { |
|
338 |
foreach ( $views as $class => $view ) { |
|
339 |
$views[ $class ] = "\t<li class='$class'>$view"; |
|
340 |
} |
|
341 |
echo implode( " </li>\n", $views ) . "</li>\n"; |
|
342 |
} |
|
343 |
?> |
|
344 |
</ul> |
|
345 |
||
9 | 346 |
<?php install_search_form(); ?> |
5 | 347 |
</div> |
9 | 348 |
<?php |
5 | 349 |
} |
350 |
||
351 |
/** |
|
16 | 352 |
* Displays the plugin install table. |
353 |
* |
|
354 |
* Overrides the parent display() method to provide a different container. |
|
355 |
* |
|
356 |
* @since 4.0.0 |
|
5 | 357 |
*/ |
358 |
public function display() { |
|
359 |
$singular = $this->_args['singular']; |
|
360 |
||
361 |
$data_attr = ''; |
|
362 |
||
363 |
if ( $singular ) { |
|
364 |
$data_attr = " data-wp-lists='list:$singular'"; |
|
365 |
} |
|
366 |
||
367 |
$this->display_tablenav( 'top' ); |
|
368 |
||
9 | 369 |
?> |
5 | 370 |
<div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
9 | 371 |
<?php |
372 |
$this->screen->render_screen_reader_content( 'heading_list' ); |
|
373 |
?> |
|
5 | 374 |
<div id="the-list"<?php echo $data_attr; ?>> |
375 |
<?php $this->display_rows_or_placeholder(); ?> |
|
376 |
</div> |
|
377 |
</div> |
|
9 | 378 |
<?php |
5 | 379 |
$this->display_tablenav( 'bottom' ); |
380 |
} |
|
381 |
||
382 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
* |
5 | 385 |
* @param string $which |
386 |
*/ |
|
387 |
protected function display_tablenav( $which ) { |
|
16 | 388 |
if ( 'featured' === $GLOBALS['tab'] ) { |
5 | 389 |
return; |
390 |
} |
|
391 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
if ( 'top' === $which ) { |
5 | 393 |
wp_referer_field(); |
9 | 394 |
?> |
0 | 395 |
<div class="tablenav top"> |
396 |
<div class="alignleft actions"> |
|
397 |
<?php |
|
398 |
/** |
|
399 |
* Fires before the Plugin Install table header pagination is displayed. |
|
400 |
* |
|
401 |
* @since 2.7.0 |
|
402 |
*/ |
|
9 | 403 |
do_action( 'install_plugins_table_header' ); |
404 |
?> |
|
0 | 405 |
</div> |
406 |
<?php $this->pagination( $which ); ?> |
|
407 |
<br class="clear" /> |
|
408 |
</div> |
|
409 |
<?php } else { ?> |
|
410 |
<div class="tablenav bottom"> |
|
411 |
<?php $this->pagination( $which ); ?> |
|
412 |
<br class="clear" /> |
|
413 |
</div> |
|
9 | 414 |
<?php |
0 | 415 |
} |
416 |
} |
|
417 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
*/ |
5 | 421 |
protected function get_table_classes() { |
422 |
return array( 'widefat', $this->_args['plural'] ); |
|
423 |
} |
|
0 | 424 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
*/ |
5 | 428 |
public function get_columns() { |
429 |
return array(); |
|
0 | 430 |
} |
431 |
||
5 | 432 |
/** |
433 |
* @param object $plugin_a |
|
434 |
* @param object $plugin_b |
|
435 |
* @return int |
|
436 |
*/ |
|
437 |
private function order_callback( $plugin_a, $plugin_b ) { |
|
438 |
$orderby = $this->orderby; |
|
439 |
if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) { |
|
440 |
return 0; |
|
441 |
} |
|
442 |
||
443 |
$a = $plugin_a->$orderby; |
|
444 |
$b = $plugin_b->$orderby; |
|
445 |
||
18 | 446 |
if ( $a === $b ) { |
5 | 447 |
return 0; |
448 |
} |
|
449 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
if ( 'DESC' === $this->order ) { |
5 | 451 |
return ( $a < $b ) ? 1 : -1; |
452 |
} else { |
|
453 |
return ( $a < $b ) ? -1 : 1; |
|
454 |
} |
|
0 | 455 |
} |
456 |
||
5 | 457 |
public function display_rows() { |
0 | 458 |
$plugins_allowedtags = array( |
9 | 459 |
'a' => array( |
460 |
'href' => array(), |
|
461 |
'title' => array(), |
|
462 |
'target' => array(), |
|
463 |
), |
|
464 |
'abbr' => array( 'title' => array() ), |
|
465 |
'acronym' => array( 'title' => array() ), |
|
466 |
'code' => array(), |
|
467 |
'pre' => array(), |
|
468 |
'em' => array(), |
|
469 |
'strong' => array(), |
|
470 |
'ul' => array(), |
|
471 |
'ol' => array(), |
|
472 |
'li' => array(), |
|
473 |
'p' => array(), |
|
474 |
'br' => array(), |
|
0 | 475 |
); |
476 |
||
5 | 477 |
$plugins_group_titles = array( |
478 |
'Performance' => _x( 'Performance', 'Plugin installer group title' ), |
|
9 | 479 |
'Social' => _x( 'Social', 'Plugin installer group title' ), |
480 |
'Tools' => _x( 'Tools', 'Plugin installer group title' ), |
|
5 | 481 |
); |
0 | 482 |
|
5 | 483 |
$group = null; |
0 | 484 |
|
485 |
foreach ( (array) $this->items as $plugin ) { |
|
5 | 486 |
if ( is_object( $plugin ) ) { |
0 | 487 |
$plugin = (array) $plugin; |
5 | 488 |
} |
0 | 489 |
|
16 | 490 |
// Display the group heading if there is one. |
18 | 491 |
if ( isset( $plugin['group'] ) && $plugin['group'] !== $group ) { |
5 | 492 |
if ( isset( $this->groups[ $plugin['group'] ] ) ) { |
493 |
$group_name = $this->groups[ $plugin['group'] ]; |
|
494 |
if ( isset( $plugins_group_titles[ $group_name ] ) ) { |
|
495 |
$group_name = $plugins_group_titles[ $group_name ]; |
|
496 |
} |
|
497 |
} else { |
|
498 |
$group_name = $plugin['group']; |
|
499 |
} |
|
500 |
||
16 | 501 |
// Starting a new group, close off the divs of the last one. |
5 | 502 |
if ( ! empty( $group ) ) { |
503 |
echo '</div></div>'; |
|
504 |
} |
|
505 |
||
506 |
echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; |
|
16 | 507 |
// Needs an extra wrapping div for nth-child selectors to work. |
5 | 508 |
echo '<div class="plugin-items">'; |
509 |
||
510 |
$group = $plugin['group']; |
|
511 |
} |
|
18 | 512 |
|
0 | 513 |
$title = wp_kses( $plugin['name'], $plugins_allowedtags ); |
5 | 514 |
|
515 |
// Remove any HTML from the description. |
|
516 |
$description = strip_tags( $plugin['short_description'] ); |
|
19 | 517 |
|
518 |
/** |
|
519 |
* Filters the plugin card description on the Add Plugins screen. |
|
520 |
* |
|
521 |
* @since 6.0.0 |
|
522 |
* |
|
523 |
* @param string $description Plugin card description. |
|
524 |
* @param array $plugin An array of plugin data. See {@see plugins_api()} |
|
525 |
* for the list of possible values. |
|
526 |
*/ |
|
527 |
$description = apply_filters( 'plugin_install_description', $description, $plugin ); |
|
528 |
||
529 |
$version = wp_kses( $plugin['version'], $plugins_allowedtags ); |
|
0 | 530 |
|
531 |
$name = strip_tags( $title . ' ' . $version ); |
|
532 |
||
5 | 533 |
$author = wp_kses( $plugin['author'], $plugins_allowedtags ); |
534 |
if ( ! empty( $author ) ) { |
|
16 | 535 |
/* translators: %s: Plugin author. */ |
5 | 536 |
$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; |
537 |
} |
|
0 | 538 |
|
9 | 539 |
$requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null; |
540 |
$requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null; |
|
541 |
||
542 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
543 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
544 |
$tested_wp = ( empty( $plugin['tested'] ) || version_compare( get_bloginfo( 'version' ), $plugin['tested'], '<=' ) ); |
|
545 |
||
0 | 546 |
$action_links = array(); |
547 |
||
548 |
if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { |
|
549 |
$status = install_plugin_install_status( $plugin ); |
|
550 |
||
551 |
switch ( $status['status'] ) { |
|
552 |
case 'install': |
|
5 | 553 |
if ( $status['url'] ) { |
9 | 554 |
if ( $compatible_php && $compatible_wp ) { |
555 |
$action_links[] = sprintf( |
|
556 |
'<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', |
|
557 |
esc_attr( $plugin['slug'] ), |
|
558 |
esc_url( $status['url'] ), |
|
16 | 559 |
/* translators: %s: Plugin name and version. */ |
560 |
esc_attr( sprintf( _x( 'Install %s now', 'plugin' ), $name ) ), |
|
9 | 561 |
esc_attr( $name ), |
562 |
__( 'Install Now' ) |
|
563 |
); |
|
564 |
} else { |
|
565 |
$action_links[] = sprintf( |
|
566 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
567 |
_x( 'Cannot Install', 'plugin' ) |
|
568 |
); |
|
569 |
} |
|
5 | 570 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
break; |
5 | 572 |
|
0 | 573 |
case 'update_available': |
5 | 574 |
if ( $status['url'] ) { |
9 | 575 |
if ( $compatible_php && $compatible_wp ) { |
576 |
$action_links[] = sprintf( |
|
577 |
'<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>', |
|
578 |
esc_attr( $status['file'] ), |
|
579 |
esc_attr( $plugin['slug'] ), |
|
580 |
esc_url( $status['url'] ), |
|
16 | 581 |
/* translators: %s: Plugin name and version. */ |
582 |
esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $name ) ), |
|
9 | 583 |
esc_attr( $name ), |
584 |
__( 'Update Now' ) |
|
585 |
); |
|
586 |
} else { |
|
587 |
$action_links[] = sprintf( |
|
588 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
589 |
_x( 'Cannot Update', 'plugin' ) |
|
590 |
); |
|
591 |
} |
|
5 | 592 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
593 |
break; |
5 | 594 |
|
0 | 595 |
case 'latest_installed': |
596 |
case 'newer_installed': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
597 |
if ( is_plugin_active( $status['file'] ) ) { |
9 | 598 |
$action_links[] = sprintf( |
599 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
600 |
_x( 'Active', 'plugin' ) |
|
601 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
} elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) { |
19 | 603 |
if ( $compatible_php && $compatible_wp ) { |
604 |
$button_text = __( 'Activate' ); |
|
605 |
/* translators: %s: Plugin name. */ |
|
606 |
$button_label = _x( 'Activate %s', 'plugin' ); |
|
607 |
$activate_url = add_query_arg( |
|
608 |
array( |
|
609 |
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ), |
|
610 |
'action' => 'activate', |
|
611 |
'plugin' => $status['file'], |
|
612 |
), |
|
613 |
network_admin_url( 'plugins.php' ) |
|
614 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
|
19 | 616 |
if ( is_network_admin() ) { |
617 |
$button_text = __( 'Network Activate' ); |
|
618 |
/* translators: %s: Plugin name. */ |
|
619 |
$button_label = _x( 'Network Activate %s', 'plugin' ); |
|
620 |
$activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url ); |
|
621 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
|
19 | 623 |
$action_links[] = sprintf( |
624 |
'<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>', |
|
625 |
esc_url( $activate_url ), |
|
626 |
esc_attr( sprintf( $button_label, $plugin['name'] ) ), |
|
627 |
$button_text |
|
628 |
); |
|
629 |
} else { |
|
630 |
$action_links[] = sprintf( |
|
631 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
632 |
_x( 'Cannot Activate', 'plugin' ) |
|
633 |
); |
|
634 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
} else { |
9 | 636 |
$action_links[] = sprintf( |
637 |
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
|
638 |
_x( 'Installed', 'plugin' ) |
|
639 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
640 |
} |
0 | 641 |
break; |
642 |
} |
|
643 |
} |
|
644 |
||
9 | 645 |
$details_link = self_admin_url( |
646 |
'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . |
|
647 |
'&TB_iframe=true&width=600&height=550' |
|
648 |
); |
|
5 | 649 |
|
9 | 650 |
$action_links[] = sprintf( |
651 |
'<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', |
|
652 |
esc_url( $details_link ), |
|
16 | 653 |
/* translators: %s: Plugin name and version. */ |
9 | 654 |
esc_attr( sprintf( __( 'More information about %s' ), $name ) ), |
655 |
esc_attr( $name ), |
|
656 |
__( 'More Details' ) |
|
657 |
); |
|
658 |
||
659 |
if ( ! empty( $plugin['icons']['svg'] ) ) { |
|
5 | 660 |
$plugin_icon_url = $plugin['icons']['svg']; |
9 | 661 |
} elseif ( ! empty( $plugin['icons']['2x'] ) ) { |
5 | 662 |
$plugin_icon_url = $plugin['icons']['2x']; |
9 | 663 |
} elseif ( ! empty( $plugin['icons']['1x'] ) ) { |
5 | 664 |
$plugin_icon_url = $plugin['icons']['1x']; |
665 |
} else { |
|
666 |
$plugin_icon_url = $plugin['icons']['default']; |
|
667 |
} |
|
668 |
||
0 | 669 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
* Filters the install action links for a plugin. |
0 | 671 |
* |
672 |
* @since 2.7.0 |
|
673 |
* |
|
19 | 674 |
* @param string[] $action_links An array of plugin action links. |
675 |
* Defaults are links to Details and Install Now. |
|
676 |
* @param array $plugin An array of plugin data. See {@see plugins_api()} |
|
677 |
* for the list of possible values. |
|
0 | 678 |
*/ |
679 |
$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); |
|
5 | 680 |
|
681 |
$last_updated_timestamp = strtotime( $plugin['last_updated'] ); |
|
9 | 682 |
?> |
5 | 683 |
<div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>"> |
9 | 684 |
<?php |
685 |
if ( ! $compatible_php || ! $compatible_wp ) { |
|
686 |
echo '<div class="notice inline notice-error notice-alt"><p>'; |
|
687 |
if ( ! $compatible_php && ! $compatible_wp ) { |
|
19 | 688 |
_e( 'This plugin does not work with your versions of WordPress and PHP.' ); |
9 | 689 |
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
690 |
printf( |
|
16 | 691 |
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
9 | 692 |
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
693 |
self_admin_url( 'update-core.php' ), |
|
694 |
esc_url( wp_get_update_php_url() ) |
|
695 |
); |
|
696 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
697 |
} elseif ( current_user_can( 'update_core' ) ) { |
|
698 |
printf( |
|
16 | 699 |
/* translators: %s: URL to WordPress Updates screen. */ |
9 | 700 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
701 |
self_admin_url( 'update-core.php' ) |
|
702 |
); |
|
703 |
} elseif ( current_user_can( 'update_php' ) ) { |
|
704 |
printf( |
|
16 | 705 |
/* translators: %s: URL to Update PHP page. */ |
9 | 706 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
707 |
esc_url( wp_get_update_php_url() ) |
|
708 |
); |
|
709 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
710 |
} |
|
711 |
} elseif ( ! $compatible_wp ) { |
|
19 | 712 |
_e( 'This plugin does not work with your version of WordPress.' ); |
9 | 713 |
if ( current_user_can( 'update_core' ) ) { |
714 |
printf( |
|
16 | 715 |
/* translators: %s: URL to WordPress Updates screen. */ |
9 | 716 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
717 |
self_admin_url( 'update-core.php' ) |
|
718 |
); |
|
719 |
} |
|
720 |
} elseif ( ! $compatible_php ) { |
|
19 | 721 |
_e( 'This plugin does not work with your version of PHP.' ); |
9 | 722 |
if ( current_user_can( 'update_php' ) ) { |
723 |
printf( |
|
16 | 724 |
/* translators: %s: URL to Update PHP page. */ |
9 | 725 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
726 |
esc_url( wp_get_update_php_url() ) |
|
727 |
); |
|
728 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
729 |
} |
|
730 |
} |
|
731 |
echo '</p></div>'; |
|
732 |
} |
|
733 |
?> |
|
5 | 734 |
<div class="plugin-card-top"> |
735 |
<div class="name column-name"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
<h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
<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
|
738 |
<?php echo $title; ?> |
18 | 739 |
<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
|
740 |
</a> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
</h3> |
5 | 742 |
</div> |
743 |
<div class="action-links"> |
|
744 |
<?php |
|
9 | 745 |
if ( $action_links ) { |
746 |
echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>'; |
|
747 |
} |
|
5 | 748 |
?> |
749 |
</div> |
|
750 |
<div class="desc column-description"> |
|
751 |
<p><?php echo $description; ?></p> |
|
752 |
<p class="authors"><?php echo $author; ?></p> |
|
753 |
</div> |
|
754 |
</div> |
|
755 |
<div class="plugin-card-bottom"> |
|
756 |
<div class="vers column-rating"> |
|
9 | 757 |
<?php |
758 |
wp_star_rating( |
|
759 |
array( |
|
760 |
'rating' => $plugin['rating'], |
|
761 |
'type' => 'percent', |
|
762 |
'number' => $plugin['num_ratings'], |
|
763 |
) |
|
764 |
); |
|
765 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> |
5 | 767 |
</div> |
768 |
<div class="column-updated"> |
|
16 | 769 |
<strong><?php _e( 'Last Updated:' ); ?></strong> |
770 |
<?php |
|
771 |
/* translators: %s: Human-readable time difference. */ |
|
772 |
printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); |
|
773 |
?> |
|
0 | 774 |
</div> |
5 | 775 |
<div class="column-downloaded"> |
776 |
<?php |
|
777 |
if ( $plugin['active_installs'] >= 1000000 ) { |
|
9 | 778 |
$active_installs_millions = floor( $plugin['active_installs'] / 1000000 ); |
779 |
$active_installs_text = sprintf( |
|
16 | 780 |
/* translators: %s: Number of millions. */ |
9 | 781 |
_nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ), |
782 |
number_format_i18n( $active_installs_millions ) |
|
783 |
); |
|
18 | 784 |
} elseif ( 0 === $plugin['active_installs'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
$active_installs_text = _x( 'Less Than 10', 'Active plugin installations' ); |
5 | 786 |
} else { |
787 |
$active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+'; |
|
788 |
} |
|
16 | 789 |
/* translators: %s: Number of installations. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
printf( __( '%s Active Installations' ), $active_installs_text ); |
5 | 791 |
?> |
792 |
</div> |
|
793 |
<div class="column-compatibility"> |
|
794 |
<?php |
|
9 | 795 |
if ( ! $tested_wp ) { |
5 | 796 |
echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>'; |
9 | 797 |
} elseif ( ! $compatible_wp ) { |
5 | 798 |
echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; |
799 |
} else { |
|
800 |
echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>'; |
|
801 |
} |
|
802 |
?> |
|
803 |
</div> |
|
804 |
</div> |
|
805 |
</div> |
|
9 | 806 |
<?php |
0 | 807 |
} |
5 | 808 |
|
16 | 809 |
// Close off the group divs of the last one. |
5 | 810 |
if ( ! empty( $group ) ) { |
811 |
echo '</div></div>'; |
|
812 |
} |
|
0 | 813 |
} |
814 |
} |