PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.5
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.5
8.0.5 8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 All 47 releases
gamipress / includes / admin / pages / add-ons.php

add-ons.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.5, at includes/admin/pages/add-ons.php

703 lines 24.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Add-ons Pages
4 *
5 * @package GamiPress\Admin\Add_ons
6 * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]>
7 * @since 1.1.0
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Add-ons page
14 *
15 * @since 1.1.0
16 *
17 * @return void
18 */
19 function gamipress_add_ons_page() {
20
21 if( ! function_exists( 'plugins_api' ) ) {
22 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
23 }
24
25 wp_enqueue_script( 'plugin-install' );
26 add_thickbox();
27 wp_enqueue_script( 'updates' );
28
29 ?>
30 <div class="wrap">
31 <div id="icon-options-general" class="icon32"></div>
32 <h1 class="wp-heading-inline"><?php _e( 'GamiPress Add-ons', 'gamipress' ); ?></h1>
33 <hr class="wp-header-end">
34
35 <div class="wp-filter">
36 <ul class="filter-links">
37 <li class="plugins-premium"><a href="#" data-target="gamipress-premium-add-on" class="current"><?php echo gamipress_dashicon( 'gamipress', 'span' ); ?> <?php _e( 'Premium', 'gamipress' ); ?></a></li>
38 <li class="plugins-free"><a href="#" data-target="gamipress-free-add-on"><?php echo gamipress_dashicon( 'heart', 'span' ); ?> <?php _e( 'Free', 'gamipress' ); ?></a></li>
39 <li class="plugins-integrations"><a href="#" data-target="gamipress-integration-add-on"><?php echo gamipress_dashicon( 'admin-plugins', 'span' ); ?> <?php _e( 'Integrations', 'gamipress' ); ?></a></li>
40 <li class="plugins-third-party"><a href="#" data-target="gamipress-third-party-add-on"><?php echo gamipress_dashicon( 'star-filled', 'span' ); ?> <?php _e( '3rd Party', 'gamipress' ); ?></a></li>
41 <li class="plugins-tools"><a href="#" data-target="gamipress-tool-add-on"><?php echo gamipress_dashicon( 'admin-tools', 'span' ); ?> <?php _e( 'Tools', 'gamipress' ); ?></a></li>
42 </ul>
43 </div>
44
45 <p><?php _e( 'Add-ons to extend and expand the functionality of GamiPress.', 'gamipress' ); ?></p>
46
47 <form id="plugin-filter" method="post">
48 <div class="wp-list-table widefat gamipress-add-ons">
49
50 <?php
51
52 $plugins = gamipress_plugins_api();
53
54 if ( is_wp_error( $plugins ) ) {
55 echo $plugins->get_error_message();
56 return;
57 }
58
59 foreach ( $plugins as $plugin ) {
60
61 // Skip if is an asset or pass
62 if( gamipress_is_plugin_asset( $plugin ) || gamipress_is_plugin_pass( $plugin ) )
63 continue;
64
65 gamipress_render_plugin_card( $plugin );
66
67 }
68
69 ?>
70 </div>
71 </form>
72 </div>
73 <?php
74 }
75
76 /**
77 * Return an array of all installed plugins slugs
78 *
79 * @since 1.1.0
80 *
81 * @return array
82 */
83 function gamipress_get_installed_plugins_slugs() {
84
85 $slugs = array();
86
87 $plugin_info = get_site_transient( 'update_plugins' );
88
89 if ( isset( $plugin_info->no_update ) ) {
90 foreach ( $plugin_info->no_update as $plugin ) {
91 $slugs[] = $plugin->slug;
92 }
93 }
94
95 if ( isset( $plugin_info->response ) ) {
96 foreach ( $plugin_info->response as $plugin ) {
97 $slugs[] = $plugin->slug;
98 }
99 }
100
101 return $slugs;
102
103 }
104
105 /**
106 * Helper function to render a plugin card from the add-ons page
107 *
108 * @since 1.1.0
109 *
110 * @param stdClass $plugin
111 *
112 * @return void
113 */
114 function gamipress_render_plugin_card( $plugin ) {
115
116 // Plugin title
117 $name = $plugin->info->title;
118
119 // Plugin slug
120 $slug = $plugin->wp_info ? $plugin->wp_info->slug : $plugin->info->slug;
121
122 // Available actions for this plugin
123 $action_links = array();
124
125 //$details_link = esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $slug . '&TB_iframe=true&width=600&height=550' ) );
126 $details_link = esc_url( 'https://gamipress.com/add-ons/' . $plugin->info->slug );
127
128 if( gamipress_plugin_has_category( $plugin, '3rd-party' ) ) {
129
130 $class = 'gamipress-third-party-add-on';
131
132 // "More Information" action
133 $action_links[] = '<a href="https://gamipress.com/add-ons/' . $plugin->info->slug . '" class="button" target="_blank">' . __( 'More Information', 'gamipress' ) . '</a>';
134
135 } else if( gamipress_plugin_has_category( $plugin, 'integrations' ) ) {
136 $class = 'gamipress-integration-add-on';
137
138 // "More Information" action
139 $action_links[] = '<a href="https://gamipress.com/add-ons/' . $plugin->info->slug . '" class="button" target="_blank">' . __( 'More Information', 'gamipress' ) . '</a>';
140 } else if( $plugin->wp_info ) {
141 // Free add-ons
142
143 if( gamipress_plugin_has_category( $plugin, 'integrations' ) ) {
144 $class = 'gamipress-integration-add-on';
145 } else if( gamipress_plugin_has_category( $plugin, 'tools' ) ) {
146 $class = 'gamipress-tool-add-on';
147 } else {
148 $class = 'gamipress-free-add-on';
149 }
150
151 // Check plugin status
152 if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
153 $status = install_plugin_install_status( $plugin->wp_info );
154
155 switch ( $status['status'] ) {
156 case 'install':
157 if ( $status['url'] ) {
158 $action_links[] = '<a class="install-now button" data-slug="' . esc_attr( $slug ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Install Now' ) . '</a>';
159 }
160 break;
161
162 case 'update_available':
163 if ( $status['url'] ) {
164 $action_links[] = '<a class="update-now button aria-button-if-js" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $slug ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Update Now' ) . '</a>';
165 }
166 break;
167
168 case 'latest_installed':
169 case 'newer_installed':
170 if ( is_plugin_active( $status['file'] ) ) {
171 $action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Active', 'plugin' ) . '</button>';
172 } elseif ( current_user_can( 'activate_plugins' ) ) {
173 $button_text = __( 'Activate' );
174 $button_label = _x( 'Activate %s', 'plugin' );
175 $activate_url = add_query_arg( array(
176 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
177 'action' => 'activate',
178 'plugin' => $status['file'],
179 ), network_admin_url( 'plugins.php' ) );
180
181 if ( is_network_admin() ) {
182 $button_text = __( 'Network Activate' );
183 $button_label = _x( 'Network Activate %s', 'plugin' );
184 $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
185 }
186
187 $action_links[] = sprintf(
188 '<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>',
189 esc_url( $activate_url ),
190 esc_attr( sprintf( $button_label, $name ) ),
191 $button_text
192 );
193 } else {
194 $action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Installed', 'plugin' ) . '</button>';
195 }
196 break;
197 }
198 }
199 } else {
200 // Premium add-ons
201
202 $class = 'gamipress-premium-add-on';
203
204 $plugin_file = $slug . '/' . $slug . '.php';
205
206 // If is installed
207 if ( is_dir( WP_PLUGIN_DIR . '/' . $slug ) ) {
208
209 // If is active
210 if ( is_plugin_active( $slug . '/' . $slug . '.php' ) ) {
211
212 // If has licensing enabled
213 if( $plugin->licensing->enabled ) {
214
215 // Plugin installed and active, so field should be registered
216 $field = cmb2_get_field( $slug . '-license', str_replace( '-', '_', $slug ) . '_license', 'gamipress_settings', 'options-page' );
217
218 if( $field ) {
219 $license_key = $field->escaped_value();
220
221 $license = rgc_cmb2_edd_license_data( $license_key );
222 $license_status = ( $license !== false ) ? $license->license : false;
223
224 if( $license_status !== 'valid' ) {
225 // "Activate License" action
226 $action_links[] = '<a href="' . admin_url( 'admin.php?page=gamipress_licenses' ) . '" class="button">' . __( 'Activate License', 'gamipress' ) . '</a>';
227 } else {
228 // "Active and License Registered" action
229 $action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . __( 'Active and License Registered', 'gamipress' ) . '</button>';
230 }
231 }
232
233 } else {
234 // "Active" action
235 $action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . __( 'Active', 'gamipress' ) . '</button>';
236 }
237
238 } else if ( current_user_can( 'activate_plugins' ) ) {
239 // If not active and current user can activate plugins, then add the "Activate" action
240
241 $button_text = __( 'Activate' );
242 $button_label = _x( 'Activate %s', 'plugin' );
243 $activate_url = add_query_arg( array(
244 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin_file ),
245 'action' => 'activate',
246 'plugin' => $plugin_file,
247 ), network_admin_url( 'plugins.php' ) );
248
249 if ( is_network_admin() ) {
250 $button_text = __( 'Network Activate' );
251 $button_label = _x( 'Network Activate %s', 'plugin' );
252 $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
253 }
254
255 // "Activate" action
256 $action_links[] = sprintf(
257 '<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>',
258 esc_url( $activate_url ),
259 esc_attr( sprintf( $button_label, $name ) ),
260 $button_text
261 );
262 }
263 } else if( gamipress_is_plugin_pass( $plugin ) ) {
264
265 // "Get this pass" action
266 $action_links[] = '<a href="https://gamipress.com/add-ons/' . $plugin->info->slug . '" class="button button-primary" target="_blank">' . __( 'Get this pass', 'gamipress' ) . '</a>';
267
268 } else if( gamipress_is_plugin_asset( $plugin ) ) {
269
270 $class = 'gamipress-asset-add-on';
271
272 // "Get this asset" action
273 $action_links[] = '<a href="https://gamipress.com/add-ons/' . $plugin->info->slug . '" class="button button-primary" target="_blank">' . __( 'Get this asset', 'gamipress' ) . '</a>';
274
275 } else {
276
277 // "Get this add-on" action
278 $action_links[] = '<a href="https://gamipress.com/add-ons/' . $plugin->info->slug . '" class="button button-primary" target="_blank">' . __( 'Get this add-on', 'gamipress' ) . '</a>';
279
280 }
281 }
282
283 if( ! gamipress_plugin_has_category( $plugin, '3rd-party' ) && ! gamipress_plugin_has_category( $plugin, 'integrations' ) ) {
284 // "More Details" action
285 // $action_links[] = '<a href="https://gamipress.com/add-ons/' . $plugin->info->slug . '" class="more-details" aria-label="' . esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '" data-title="' . esc_attr( $name ) . '" target="_blank">' . __( 'More Details' ) . '</a>';
286 }
287
288 /**
289 * Plugin card actions
290 *
291 * @since 1.0.0
292 *
293 * @param array $actions
294 * @param string $slug
295 *
296 * @return array
297 */
298 $action_links = apply_filters( 'gamipress_plugin_card_actions', $action_links, $slug );
299
300 // Status
301 $status = '';
302
303 if( is_plugin_active( $slug . '/' . $slug . '.php' ) ) {
304 $status = 'active';
305 } else if( is_dir( WP_PLUGIN_DIR . '/' . $slug ) ) {
306 $status = 'installed';
307 }
308
309 /**
310 * Plugin card status
311 *
312 * @since 1.0.0
313 *
314 * @param string $status
315 * @param string $slug
316 *
317 * @return string
318 */
319 $status = apply_filters( 'gamipress_plugin_card_status', $status, $slug );
320 $status_label = '';
321
322 switch( $status ) {
323 case 'active': $status_label = __( 'Active', 'gamipress' ); break;
324 case 'inactive': $status_label = __( 'Inactive', 'gamipress' ); break;
325 case 'installed': $status_label = __( 'Installed', 'gamipress' ); break;
326 }
327
328 ?>
329
330 <div class="gamipress-plugin-card plugin-card plugin-card-<?php echo sanitize_html_class( $slug ); ?> <?php echo $class; ?> gamipress-plugin-card-status-<?php echo sanitize_html_class( $status ); ?>">
331
332 <div class="plugin-card-top cmb-tooltip">
333
334 <?php
335
336 ?>
337
338 <?php if( $status !== '' ) : ?>
339 <div class="<?php echo esc_attr( $status ); ?> column-status">
340 <span><?php echo esc_html( $status_label ) ?></span>
341 </div>
342 <?php endif; ?>
343
344 <div class="thumbnail column-thumbnail">
345 <a href="<?php echo esc_url( $details_link ); ?>" class="open-plugin-details-modal" target="_blank">
346 <img src="<?php echo esc_attr( $plugin->info->thumbnail ) ?>" class="plugin-thumbnail" alt="">
347 </a>
348 </div>
349
350 <div class="name column-name">
351 <h3>
352 <a href="<?php echo esc_url( $details_link ); ?>" class="open-plugin-details-modal" target="_blank">
353 <?php echo $name; ?>
354 </a>
355 </h3>
356 </div>
357
358 <div class="desc column-description cmb-tooltip-desc cmb-tooltip-top">
359 <p><?php echo gamipress_esc_plugin_excerpt( $plugin->info->excerpt ); ?></p>
360 </div>
361
362 </div>
363
364 <div class="plugin-card-bottom">
365 <div class="action-links">
366 <?php if ( $action_links ) {
367 echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
368 } ?>
369 </div>
370 </div>
371
372 </div>
373
374 <?php
375 }
376
377 /**
378 * Function to contact with the GamiPress plugins API
379 *
380 * @since 1.1.0
381 *
382 * @return object|WP_Error Object with GamiPress plugins
383 */
384 function gamipress_plugins_api() {
385
386 $cache = gamipress_get_cache( 'gamipress_plugins_api', false, false );
387
388 // If result already cached, return it
389 if( $cache !== false ) {
390 return $cache;
391 }
392
393 // If a plugins api request has been cached already, then use cached plugins
394 if ( false !== ( $res = get_transient( 'gamipress_plugins_api' ) ) ) {
395 return apply_filters( 'gamipress_plugins_api', $res );
396 }
397
398 $url = $http_url = 'https://gamipress.com/wp-json/api/add-ons/';
399
400 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
401 $url = set_url_scheme( $url, 'https' );
402 }
403
404 $http_args = array(
405 'timeout' => 15,
406 );
407
408 $request = wp_remote_get( $url, $http_args );
409
410 if ( $ssl && is_wp_error( $request ) ) {
411 trigger_error(
412 sprintf(
413 __( 'An unexpected error occurred. Something may be wrong with gamipress.com or this server&#8217;s configuration. If you continue to have problems, please try to <a href="%s">contact us</a>.', 'gamipress' ),
414 'https://gamipress.com/contact-us/'
415 ) . ' ' . __( '(WordPress could not establish a secure connection to gamipress.com. Please contact your server administrator.)' ),
416 headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
417 );
418
419 $request = wp_remote_get( $http_url, $http_args );
420 }
421
422 if ( is_wp_error( $request ) ) {
423 $res = new WP_Error( 'gamipress_plugins_api_failed',
424 sprintf(
425 __( 'An unexpected error occurred. Something may be wrong with gamipress.com or this server&#8217;s configuration. If you continue to have problems, please try to <a href="%s">contact us</a>.', 'gamipress' ),
426 'https://gamipress.com/contact-us/'
427 ),
428 $request->get_error_message()
429 );
430 } else {
431 $res = json_decode( $request['body'] );
432
433 $res = (array) $res->products;
434
435 // Set a transient for 1 week with api plugins
436 set_transient( 'gamipress_plugins_api', $res, ( 24 * 7 ) * HOUR_IN_SECONDS );
437
438 gamipress_set_cache( 'gamipress_plugins_api', $res );
439 }
440
441 return apply_filters( 'gamipress_plugins_api', $res );
442
443 }
444
445 /**
446 * Function to contact with the GamiPress website API
447 *
448 * @since 1.1.4
449 *
450 * @param string $action
451 * @param array $data
452 *
453 * @return object|WP_Error Object with GamiPress website API response
454 */
455 function gamipress_api_request( $action, $data ) {
456
457 // Slug is required to meet the plugin to work
458 if( ! isset( $data['slug'] ) ) {
459 return false;
460 }
461
462 $slug = $data['slug'];
463
464 $cache_key = "gamipress_api_request_{$action}_{$slug}";
465
466 // If a GamiPress api request has been cached already, then use cached response
467 if ( false !== ( $response = get_transient( $cache_key ) ) ) {
468 return $response;
469 }
470
471 $api_params = array(
472 'edd_action' => 'get_version',
473 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
474 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
475 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
476 'version' => isset( $data['version'] ) ? $data['version'] : false,
477 'slug' => $data['slug'],
478 'author' => isset( $data['author'] ) ? $data['author'] : '',
479 'url' => home_url(),
480 'beta' => ! empty( $data['beta'] ),
481 );
482
483 $request = wp_remote_post( 'http://gamipress.com/edd-sl-api/', array( 'timeout' => 15, 'sslverify' => true, 'body' => $api_params ) );
484
485 if ( is_wp_error( $request ) ) {
486 // Return the error
487 return $request;
488 }
489
490 $request = json_decode( wp_remote_retrieve_body( $request ) );
491
492 // Unserialize sections
493 if ( $request && isset( $request->sections ) ) {
494 $request->sections = maybe_unserialize( $request->sections );
495 } else {
496 $request = false;
497 }
498
499 // Unserialize banners
500 if ( $request && isset( $request->banners ) ) {
501 $request->banners = maybe_unserialize( $request->banners );
502 }
503
504 // Turn each section into array
505 if( ! empty( $request->sections ) ) {
506 foreach( $request->sections as $key => $section ) {
507 $request->$key = (array) $section;
508 }
509 }
510
511 // Set a transient of 24 hours with GamiPress api response
512 set_transient( $cache_key, $request, 24 * HOUR_IN_SECONDS );
513
514 return $request;
515 }
516
517 /**
518 * Overrides the plugin information when plugin is not stored on WordPress.org just on GamiPress.com
519 *
520 * @since 1.1.4
521 *
522 * @param mixed $data
523 * @param string $action
524 * @param object $args
525 *
526 * @return object $data
527 */
528 function gamipress_override_plugin_information( $data, $action = '', $args = null ) {
529
530 if ( $action != 'plugin_information' ) {
531 return $data;
532 }
533
534 if ( ! isset( $args->slug ) ) {
535 return $data;
536 }
537
538 $plugins = gamipress_plugins_api();
539
540 // Bail if API is not returning any plugin
541 if( ! is_array( $plugins ) ) {
542 return $data;
543 }
544
545 $override_plugin = false;
546
547 foreach( $plugins as $plugin ) {
548 // Just override if plugin has not assigned to a WordPress.org plugin
549 if ( $args->slug === $plugin->info->slug && ! $plugin->wp_info ) {
550
551 $override_plugin = $plugin;
552
553 // Plugin to override found, so exit loop
554 break;
555
556 }
557 }
558
559 // if not plugin to override, return
560 if ( $override_plugin === false ) {
561 return $data;
562 }
563
564 $to_send = array(
565 'slug' => $override_plugin->info->slug,
566 'item_name' => $override_plugin->info->title,
567 'is_ssl' => is_ssl(),
568 'fields' => array(
569 'banners' => array(),
570 'reviews' => false
571 )
572 );
573
574 $api_response = gamipress_api_request( 'plugin_information', $to_send );
575
576 if ( $api_response !== false) {
577 $data = $api_response;
578 }
579
580 // Convert sections into an associative array, since we're getting an object, but Core expects an array.
581 if ( isset( $data->sections ) && is_array( $data->sections ) ) {
582 $new_sections = array();
583 foreach ( $data->sections as $key => $value ) {
584 $new_sections[ $key ] = $value;
585 }
586
587 $data->sections = $new_sections;
588 }
589
590 // Convert banners into an associative array, since we're getting an object, but Core expects an array.
591 if ( isset( $data->banners ) && ! is_array( $data->banners ) ) {
592 $new_banners = array();
593 foreach ( $data->banners as $key => $value ) {
594 $new_banners[ $key ] = $value;
595 }
596
597 $data->banners = $new_banners;
598 }
599
600 return $data;
601
602 }
603 add_filter( 'plugins_api', 'gamipress_override_plugin_information', 10, 3 );
604
605 /**
606 * Escape plugin description
607 *
608 * @since 1.3.9.7
609 *
610 * @param string $excerpt
611 *
612 * @return string
613 */
614 function gamipress_esc_plugin_excerpt( $excerpt ) {
615
616 // To prevent execute shortcodes on website, the are double capsuled on []
617 $excerpt = str_replace( '[[', '[', $excerpt );
618 $excerpt = str_replace( ']]', ']', $excerpt );
619
620 return $excerpt;
621
622 }
623
624 /**
625 * Append custom body classes to plugin information iframe
626 *
627 * @since 1.6.0
628 *
629 * @param string $classes
630 *
631 * @return string
632 */
633 function gamipress_plugin_information_admin_body_class( $classes ) {
634
635 $body_id = ( isset( $GLOBALS['body_id'] ) ? $GLOBALS['body_id'] : '' );
636
637 if( $body_id === 'plugin-information' && isset( $_REQUEST['plugin'] ) ) {
638
639 // Get the plugin queried
640 $plugin_slug = wp_unslash( $_REQUEST['plugin'] );
641
642 // Check if is a gamipress plugin
643 $plugins = gamipress_plugins_api();
644
645 $override_plugin = false;
646
647 foreach( $plugins as $plugin ) {
648
649 // Just override if is a plugin we own
650 if ( $plugin_slug === $plugin->info->slug ) {
651
652 $override_plugin = $plugin;
653
654 // Plugin to override found, so exit loop
655 break;
656
657 }
658 }
659
660 // if not plugin to override, return
661 if ( $override_plugin === false ) {
662 return $classes;
663 }
664
665 $classes .= ' is-gamipress-plugin';
666
667 if( gamipress_is_plugin_asset( $override_plugin ) ) {
668 $classes .= ' is-gamipress-asset';
669 }
670 }
671
672 return $classes;
673 }
674 add_filter( 'admin_body_class', 'gamipress_plugin_information_admin_body_class' );
675
676 /**
677 * Append custom body classes to plugin information iframe
678 *
679 * @since 1.6.3
680 *
681 * @param stdClass $plugin Plugin API object
682 * @param string $category Category slug
683 *
684 * @return string
685 */
686 function gamipress_plugin_has_category( $plugin, $category ) {
687
688 if( is_array( $plugin->info->category ) ) {
689
690 // Loop plugin categories objects
691 foreach( $plugin->info->category as $plugin_cat ) {
692
693 // Check if category slug is equal that category given
694 if( $plugin_cat->slug === $category ) {
695 return true;
696 }
697 }
698
699 }
700
701 return false;
702
703 }