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