author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
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 |
||
5 | 20 |
public $order = 'ASC'; |
21 |
public $orderby = null; |
|
22 |
public $groups = array(); |
|
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 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
*/ |
5 | 30 |
public function ajax_user_can() { |
0 | 31 |
return current_user_can('install_plugins'); |
32 |
} |
|
33 |
||
5 | 34 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* Return the list of known plugins. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* 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
|
38 |
* installed plugins. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
* @access protected |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
protected function get_installed_plugins() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
$plugins = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
$plugin_info = get_site_transient( 'update_plugins' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
if ( isset( $plugin_info->no_update ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
foreach ( $plugin_info->no_update as $plugin ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
$plugin->upgrade = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
$plugins[ $plugin->slug ] = $plugin; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
if ( isset( $plugin_info->response ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
foreach ( $plugin_info->response as $plugin ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
$plugin->upgrade = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
$plugins[ $plugin->slug ] = $plugin; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
return $plugins; |
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 |
/** |
5 | 67 |
* Return a list of slugs of installed plugins, if known. |
68 |
* |
|
69 |
* Uses the transient data from the updates API to determine the slugs of |
|
70 |
* known installed plugins. This might be better elsewhere, perhaps even |
|
71 |
* within get_plugins(). |
|
72 |
* |
|
73 |
* @since 4.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
* @return array |
5 | 76 |
*/ |
77 |
protected function get_installed_plugin_slugs() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
return array_keys( $this->get_installed_plugins() ); |
5 | 79 |
} |
80 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
* @global array $tabs |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
* @global int $paged |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
* @global string $type |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
* @global string $term |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
*/ |
5 | 89 |
public function prepare_items() { |
0 | 90 |
include( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
91 |
||
92 |
global $tabs, $tab, $paged, $type, $term; |
|
93 |
||
94 |
wp_reset_vars( array( 'tab' ) ); |
|
95 |
||
96 |
$paged = $this->get_pagenum(); |
|
97 |
||
98 |
$per_page = 30; |
|
99 |
||
100 |
// These are the tabs which are shown on the page |
|
101 |
$tabs = array(); |
|
5 | 102 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
if ( 'search' === $tab ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
$tabs['search'] = __( 'Search Results' ); |
5 | 105 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
if ( $tab === 'beta' || false !== strpos( get_bloginfo( 'version' ), '-' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
$tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
$tabs['featured'] = _x( 'Featured', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
$tabs['popular'] = _x( 'Popular', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
$tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
$tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' ); |
5 | 113 |
if ( current_user_can( 'upload_plugins' ) ) { |
114 |
// No longer a real tab. Here for filter compatibility. |
|
115 |
// Gets skipped in get_views(). |
|
116 |
$tabs['upload'] = __( 'Upload Plugin' ); |
|
117 |
} |
|
0 | 118 |
|
5 | 119 |
$nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item. |
0 | 120 |
|
121 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
* Filters the tabs shown on the Plugin Install screen. |
0 | 123 |
* |
124 |
* @since 2.7.0 |
|
125 |
* |
|
5 | 126 |
* @param array $tabs The tabs shown on the Plugin Install screen. Defaults include 'featured', 'popular', |
127 |
* 'recommended', 'favorites', and 'upload'. |
|
0 | 128 |
*/ |
129 |
$tabs = apply_filters( 'install_plugins_tabs', $tabs ); |
|
130 |
||
131 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
* Filters tabs not associated with a menu item on the Plugin Install screen. |
0 | 133 |
* |
134 |
* @since 2.7.0 |
|
135 |
* |
|
136 |
* @param array $nonmenu_tabs The tabs that don't have a Menu item on the Plugin Install screen. |
|
137 |
*/ |
|
138 |
$nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); |
|
139 |
||
140 |
// If a non-valid menu tab has been selected, And it's not a non-menu action. |
|
141 |
if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) |
|
142 |
$tab = key( $tabs ); |
|
143 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
$installed_plugins = $this->get_installed_plugins(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
|
5 | 146 |
$args = array( |
147 |
'page' => $paged, |
|
148 |
'per_page' => $per_page, |
|
149 |
'fields' => array( |
|
150 |
'last_updated' => true, |
|
151 |
'icons' => true, |
|
152 |
'active_installs' => true |
|
153 |
), |
|
154 |
// Send the locale and installed plugin slugs to the API so it can provide context-sensitive results. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
'locale' => get_user_locale(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
'installed_plugins' => array_keys( $installed_plugins ), |
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': |
|
5 | 179 |
$args['fields']['group'] = true; |
180 |
$this->orderby = 'group'; |
|
181 |
// No break! |
|
0 | 182 |
case 'popular': |
183 |
case 'new': |
|
5 | 184 |
case 'beta': |
185 |
case 'recommended': |
|
0 | 186 |
$args['browse'] = $tab; |
187 |
break; |
|
188 |
||
189 |
case 'favorites': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
$action = 'save_wporg_username_' . get_current_user_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
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
|
192 |
$user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
$user = get_user_option( 'wporg_favorites' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
} |
0 | 197 |
if ( $user ) |
198 |
$args['user'] = $user; |
|
199 |
else |
|
200 |
$args = false; |
|
201 |
||
202 |
add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); |
|
203 |
break; |
|
204 |
||
205 |
default: |
|
206 |
$args = false; |
|
207 |
break; |
|
208 |
} |
|
209 |
||
210 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
* Filters API request arguments for each Plugin Install screen tab. |
0 | 212 |
* |
5 | 213 |
* The dynamic portion of the hook name, `$tab`, refers to the plugin install tabs. |
214 |
* Default tabs include 'featured', 'popular', 'recommended', 'favorites', and 'upload'. |
|
0 | 215 |
* |
216 |
* @since 3.7.0 |
|
217 |
* |
|
218 |
* @param array|bool $args Plugin Install API arguments. |
|
219 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
$args = apply_filters( "install_plugins_table_api_args_{$tab}", $args ); |
0 | 221 |
|
222 |
if ( !$args ) |
|
223 |
return; |
|
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 |
||
0 | 238 |
$this->set_pagination_args( array( |
239 |
'total_items' => $api->info['results'], |
|
5 | 240 |
'per_page' => $args['per_page'], |
0 | 241 |
) ); |
5 | 242 |
|
243 |
if ( isset( $api->info['groups'] ) ) { |
|
244 |
$this->groups = $api->info['groups']; |
|
245 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
247 |
if ( $installed_plugins ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
$js_plugins = array_fill_keys( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
array() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
$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
|
254 |
$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
|
255 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
if ( $upgrade_plugins ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
$js_plugins['upgrade'] = array_values( $upgrade_plugins ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
'plugins' => $js_plugins, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
'totals' => wp_get_update_data(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
} |
0 | 265 |
} |
266 |
||
7
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 |
*/ |
5 | 269 |
public function no_items() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
if ( isset( $this->error ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
<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
|
272 |
<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
|
273 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
<?php } else { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
<div class="no-plugin-results"><?php _e( 'No plugins found. Try a different search.' ); ?></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
<?php |
5 | 277 |
} |
0 | 278 |
} |
279 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
* @global array $tabs |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
*/ |
5 | 287 |
protected function get_views() { |
0 | 288 |
global $tabs, $tab; |
289 |
||
290 |
$display_tabs = array(); |
|
291 |
foreach ( (array) $tabs as $action => $text ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
$current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : ''; |
0 | 293 |
$href = self_admin_url('plugin-install.php?tab=' . $action); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
$display_tabs['plugin-install-'.$action] = "<a href='$href'$current_link_attributes>$text</a>"; |
0 | 295 |
} |
5 | 296 |
// No longer a real tab. |
297 |
unset( $display_tabs['plugin-install-upload'] ); |
|
0 | 298 |
|
299 |
return $display_tabs; |
|
300 |
} |
|
301 |
||
5 | 302 |
/** |
303 |
* Override parent views so we can use the filter bar display. |
|
304 |
*/ |
|
305 |
public function views() { |
|
306 |
$views = $this->get_views(); |
|
307 |
||
308 |
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
|
309 |
$views = apply_filters( "views_{$this->screen->id}", $views ); |
|
310 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
$this->screen->render_screen_reader_content( 'heading_views' ); |
5 | 312 |
?> |
313 |
<div class="wp-filter"> |
|
314 |
<ul class="filter-links"> |
|
315 |
<?php |
|
316 |
if ( ! empty( $views ) ) { |
|
317 |
foreach ( $views as $class => $view ) { |
|
318 |
$views[ $class ] = "\t<li class='$class'>$view"; |
|
319 |
} |
|
320 |
echo implode( " </li>\n", $views ) . "</li>\n"; |
|
321 |
} |
|
322 |
?> |
|
323 |
</ul> |
|
324 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
<?php install_search_form(); ?> |
5 | 326 |
</div> |
327 |
<?php |
|
328 |
} |
|
329 |
||
330 |
/** |
|
331 |
* Override the parent display() so we can provide a different container. |
|
332 |
*/ |
|
333 |
public function display() { |
|
334 |
$singular = $this->_args['singular']; |
|
335 |
||
336 |
$data_attr = ''; |
|
337 |
||
338 |
if ( $singular ) { |
|
339 |
$data_attr = " data-wp-lists='list:$singular'"; |
|
340 |
} |
|
341 |
||
342 |
$this->display_tablenav( 'top' ); |
|
343 |
||
344 |
?> |
|
345 |
<div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
$this->screen->render_screen_reader_content( 'heading_list' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
?> |
5 | 349 |
<div id="the-list"<?php echo $data_attr; ?>> |
350 |
<?php $this->display_rows_or_placeholder(); ?> |
|
351 |
</div> |
|
352 |
</div> |
|
353 |
<?php |
|
354 |
$this->display_tablenav( 'bottom' ); |
|
355 |
} |
|
356 |
||
357 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
* @global string $tab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
* |
5 | 360 |
* @param string $which |
361 |
*/ |
|
362 |
protected function display_tablenav( $which ) { |
|
363 |
if ( $GLOBALS['tab'] === 'featured' ) { |
|
364 |
return; |
|
365 |
} |
|
366 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
if ( 'top' === $which ) { |
5 | 368 |
wp_referer_field(); |
369 |
?> |
|
0 | 370 |
<div class="tablenav top"> |
371 |
<div class="alignleft actions"> |
|
372 |
<?php |
|
373 |
/** |
|
374 |
* Fires before the Plugin Install table header pagination is displayed. |
|
375 |
* |
|
376 |
* @since 2.7.0 |
|
377 |
*/ |
|
378 |
do_action( 'install_plugins_table_header' ); ?> |
|
379 |
</div> |
|
380 |
<?php $this->pagination( $which ); ?> |
|
381 |
<br class="clear" /> |
|
382 |
</div> |
|
383 |
<?php } else { ?> |
|
384 |
<div class="tablenav bottom"> |
|
385 |
<?php $this->pagination( $which ); ?> |
|
386 |
<br class="clear" /> |
|
387 |
</div> |
|
388 |
<?php |
|
389 |
} |
|
390 |
} |
|
391 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
*/ |
5 | 395 |
protected function get_table_classes() { |
396 |
return array( 'widefat', $this->_args['plural'] ); |
|
397 |
} |
|
0 | 398 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
*/ |
5 | 402 |
public function get_columns() { |
403 |
return array(); |
|
0 | 404 |
} |
405 |
||
5 | 406 |
/** |
407 |
* @param object $plugin_a |
|
408 |
* @param object $plugin_b |
|
409 |
* @return int |
|
410 |
*/ |
|
411 |
private function order_callback( $plugin_a, $plugin_b ) { |
|
412 |
$orderby = $this->orderby; |
|
413 |
if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) { |
|
414 |
return 0; |
|
415 |
} |
|
416 |
||
417 |
$a = $plugin_a->$orderby; |
|
418 |
$b = $plugin_b->$orderby; |
|
419 |
||
420 |
if ( $a == $b ) { |
|
421 |
return 0; |
|
422 |
} |
|
423 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
if ( 'DESC' === $this->order ) { |
5 | 425 |
return ( $a < $b ) ? 1 : -1; |
426 |
} else { |
|
427 |
return ( $a < $b ) ? -1 : 1; |
|
428 |
} |
|
0 | 429 |
} |
430 |
||
5 | 431 |
public function display_rows() { |
0 | 432 |
$plugins_allowedtags = array( |
433 |
'a' => array( 'href' => array(),'title' => array(), 'target' => array() ), |
|
434 |
'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ), |
|
435 |
'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(), |
|
436 |
'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array() |
|
437 |
); |
|
438 |
||
5 | 439 |
$plugins_group_titles = array( |
440 |
'Performance' => _x( 'Performance', 'Plugin installer group title' ), |
|
441 |
'Social' => _x( 'Social', 'Plugin installer group title' ), |
|
442 |
'Tools' => _x( 'Tools', 'Plugin installer group title' ), |
|
443 |
); |
|
0 | 444 |
|
5 | 445 |
$group = null; |
0 | 446 |
|
447 |
foreach ( (array) $this->items as $plugin ) { |
|
5 | 448 |
if ( is_object( $plugin ) ) { |
0 | 449 |
$plugin = (array) $plugin; |
5 | 450 |
} |
0 | 451 |
|
5 | 452 |
// Display the group heading if there is one |
453 |
if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { |
|
454 |
if ( isset( $this->groups[ $plugin['group'] ] ) ) { |
|
455 |
$group_name = $this->groups[ $plugin['group'] ]; |
|
456 |
if ( isset( $plugins_group_titles[ $group_name ] ) ) { |
|
457 |
$group_name = $plugins_group_titles[ $group_name ]; |
|
458 |
} |
|
459 |
} else { |
|
460 |
$group_name = $plugin['group']; |
|
461 |
} |
|
462 |
||
463 |
// Starting a new group, close off the divs of the last one |
|
464 |
if ( ! empty( $group ) ) { |
|
465 |
echo '</div></div>'; |
|
466 |
} |
|
467 |
||
468 |
echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; |
|
469 |
// needs an extra wrapping div for nth-child selectors to work |
|
470 |
echo '<div class="plugin-items">'; |
|
471 |
||
472 |
$group = $plugin['group']; |
|
473 |
} |
|
0 | 474 |
$title = wp_kses( $plugin['name'], $plugins_allowedtags ); |
5 | 475 |
|
476 |
// Remove any HTML from the description. |
|
477 |
$description = strip_tags( $plugin['short_description'] ); |
|
0 | 478 |
$version = wp_kses( $plugin['version'], $plugins_allowedtags ); |
479 |
||
480 |
$name = strip_tags( $title . ' ' . $version ); |
|
481 |
||
5 | 482 |
$author = wp_kses( $plugin['author'], $plugins_allowedtags ); |
483 |
if ( ! empty( $author ) ) { |
|
484 |
$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; |
|
485 |
} |
|
0 | 486 |
|
487 |
$action_links = array(); |
|
488 |
||
489 |
if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { |
|
490 |
$status = install_plugin_install_status( $plugin ); |
|
491 |
||
492 |
switch ( $status['status'] ) { |
|
493 |
case 'install': |
|
5 | 494 |
if ( $status['url'] ) { |
495 |
/* translators: 1: Plugin name and version. */ |
|
496 |
$action_links[] = '<a class="install-now button" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Install Now' ) . '</a>'; |
|
497 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
break; |
5 | 499 |
|
0 | 500 |
case 'update_available': |
5 | 501 |
if ( $status['url'] ) { |
502 |
/* translators: 1: Plugin name and version */ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
503 |
$action_links[] = '<a class="update-now button aria-button-if-js" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Update Now' ) . '</a>'; |
5 | 504 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
break; |
5 | 506 |
|
0 | 507 |
case 'latest_installed': |
508 |
case 'newer_installed': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
509 |
if ( is_plugin_active( $status['file'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Active', 'plugin' ) . '</button>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
} elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
$button_text = __( 'Activate' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
/* translators: %s: Plugin name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
$button_label = _x( 'Activate %s', 'plugin' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
$activate_url = add_query_arg( array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
'action' => 'activate', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
'plugin' => $status['file'], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
519 |
), network_admin_url( 'plugins.php' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
if ( is_network_admin() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
522 |
$button_text = __( 'Network Activate' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
523 |
/* translators: %s: Plugin name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
524 |
$button_label = _x( 'Network Activate %s', 'plugin' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
525 |
$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
|
526 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
528 |
$action_links[] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
529 |
'<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
|
530 |
esc_url( $activate_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
531 |
esc_attr( sprintf( $button_label, $plugin['name'] ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
$button_text |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Installed', 'plugin' ) . '</button>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
} |
0 | 537 |
break; |
538 |
} |
|
539 |
} |
|
540 |
||
5 | 541 |
$details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . |
542 |
'&TB_iframe=true&width=600&height=550' ); |
|
543 |
||
544 |
/* translators: 1: Plugin name and version. */ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
$action_links[] = '<a href="' . esc_url( $details_link ) . '" class="thickbox open-plugin-details-modal" aria-label="' . esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '" data-title="' . esc_attr( $name ) . '">' . __( 'More Details' ) . '</a>'; |
5 | 546 |
|
547 |
if ( !empty( $plugin['icons']['svg'] ) ) { |
|
548 |
$plugin_icon_url = $plugin['icons']['svg']; |
|
549 |
} elseif ( !empty( $plugin['icons']['2x'] ) ) { |
|
550 |
$plugin_icon_url = $plugin['icons']['2x']; |
|
551 |
} elseif ( !empty( $plugin['icons']['1x'] ) ) { |
|
552 |
$plugin_icon_url = $plugin['icons']['1x']; |
|
553 |
} else { |
|
554 |
$plugin_icon_url = $plugin['icons']['default']; |
|
555 |
} |
|
556 |
||
0 | 557 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
* Filters the install action links for a plugin. |
0 | 559 |
* |
560 |
* @since 2.7.0 |
|
561 |
* |
|
562 |
* @param array $action_links An array of plugin action hyperlinks. Defaults are links to Details and Install Now. |
|
563 |
* @param array $plugin The plugin currently being listed. |
|
564 |
*/ |
|
565 |
$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); |
|
5 | 566 |
|
567 |
$last_updated_timestamp = strtotime( $plugin['last_updated'] ); |
|
0 | 568 |
?> |
5 | 569 |
<div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>"> |
570 |
<div class="plugin-card-top"> |
|
571 |
<div class="name column-name"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
<h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
<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
|
574 |
<?php echo $title; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
<img src="<?php echo esc_attr( $plugin_icon_url ) ?>" class="plugin-icon" alt=""> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
</a> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
</h3> |
5 | 578 |
</div> |
579 |
<div class="action-links"> |
|
580 |
<?php |
|
581 |
if ( $action_links ) { |
|
582 |
echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>'; |
|
583 |
} |
|
584 |
?> |
|
585 |
</div> |
|
586 |
<div class="desc column-description"> |
|
587 |
<p><?php echo $description; ?></p> |
|
588 |
<p class="authors"><?php echo $author; ?></p> |
|
589 |
</div> |
|
590 |
</div> |
|
591 |
<div class="plugin-card-bottom"> |
|
592 |
<div class="vers column-rating"> |
|
593 |
<?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> |
5 | 595 |
</div> |
596 |
<div class="column-updated"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
597 |
<strong><?php _e( 'Last Updated:' ); ?></strong> <?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?> |
0 | 598 |
</div> |
5 | 599 |
<div class="column-downloaded"> |
600 |
<?php |
|
601 |
if ( $plugin['active_installs'] >= 1000000 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
$active_installs_text = _x( '1+ Million', 'Active plugin installations' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
} elseif ( 0 == $plugin['active_installs'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
$active_installs_text = _x( 'Less Than 10', 'Active plugin installations' ); |
5 | 605 |
} else { |
606 |
$active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+'; |
|
607 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
printf( __( '%s Active Installations' ), $active_installs_text ); |
5 | 609 |
?> |
610 |
</div> |
|
611 |
<div class="column-compatibility"> |
|
612 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
$wp_version = get_bloginfo( 'version' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
if ( ! empty( $plugin['tested'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) { |
5 | 616 |
echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
} elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) { |
5 | 618 |
echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; |
619 |
} else { |
|
620 |
echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>'; |
|
621 |
} |
|
622 |
?> |
|
623 |
</div> |
|
624 |
</div> |
|
625 |
</div> |
|
0 | 626 |
<?php |
627 |
} |
|
5 | 628 |
|
629 |
// Close off the group divs of the last one |
|
630 |
if ( ! empty( $group ) ) { |
|
631 |
echo '</div></div>'; |
|
632 |
} |
|
0 | 633 |
} |
634 |
} |