| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Display the Addons section of About tab. |
| 10 |
* |
| 11 |
* @author David Bisset |
| 12 |
* @package Charitable/Admin View/About |
| 13 |
* @copyright Copyright (c) 2024, WP Charitable LLC |
| 14 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 15 |
* @since 1.8.7.6 |
| 16 |
* @version 1.8.7.6 |
| 17 |
* @version 1.8.8.6 |
| 18 |
*/ |
| 19 |
|
| 20 |
if ( ! charitable_current_user_can( 'manage_charitable_settings' ) ) { |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
// Ensure functions are loaded. |
| 25 |
if ( ! function_exists( 'charitable_get_am_plugins' ) || ! function_exists( 'charitable_get_plugin_data' ) ) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
$charitable_all_plugins = get_plugins(); |
| 30 |
$charitable_am_plugins = charitable_get_am_plugins(); |
| 31 |
$charitable_can_install_plugins = charitable_can_install( 'plugin' ); |
| 32 |
$charitable_can_activate_plugins = charitable_can_activate( 'plugin' ); |
| 33 |
|
| 34 |
?> |
| 35 |
<div id="charitable-admin-addons"> |
| 36 |
<div class="addons-container"> |
| 37 |
<?php |
| 38 |
foreach ( $charitable_am_plugins as $charitable_plugin => $charitable_details ) : |
| 39 |
|
| 40 |
$charitable_plugin_data = charitable_get_plugin_data( $charitable_plugin, $charitable_details, $charitable_all_plugins ); |
| 41 |
$charitable_plugin_ready_to_activate = $charitable_can_activate_plugins |
| 42 |
&& isset( $charitable_plugin_data['status_class'] ) |
| 43 |
&& $charitable_plugin_data['status_class'] === 'status-installed'; |
| 44 |
$charitable_plugin_not_activated = ! isset( $charitable_plugin_data['status_class'] ) |
| 45 |
|| $charitable_plugin_data['status_class'] !== 'status-active'; |
| 46 |
|
| 47 |
?> |
| 48 |
<div class="addon-container"> |
| 49 |
<div class="addon-item"> |
| 50 |
<div class="details charitable-clear"> |
| 51 |
<img src="<?php echo esc_url( $charitable_plugin_data['details']['icon'] ); ?>" alt="<?php echo esc_attr( $charitable_plugin_data['details']['name'] ); ?>"> |
| 52 |
<h5 class="addon-name"> |
| 53 |
<?php echo esc_html( $charitable_plugin_data['details']['name'] ); ?> |
| 54 |
</h5> |
| 55 |
<p class="addon-desc"> |
| 56 |
<?php echo wp_kses_post( $charitable_plugin_data['details']['desc'] ); ?> |
| 57 |
</p> |
| 58 |
</div> |
| 59 |
<div class="actions charitable-clear"> |
| 60 |
<div class="status"> |
| 61 |
<strong> |
| 62 |
<?php |
| 63 |
printf( /* translators: %s - status label. */ |
| 64 |
esc_html__( 'Status: %s', 'charitable' ), |
| 65 |
'<span class="status-label ' . esc_attr( $charitable_plugin_data['status_class'] ) . '">' . wp_kses_post( $charitable_plugin_data['status_text'] ) . '</span>' |
| 66 |
); |
| 67 |
?> |
| 68 |
</strong> |
| 69 |
</div> |
| 70 |
<div class="action-button"> |
| 71 |
<?php if ( $charitable_can_install_plugins || $charitable_plugin_ready_to_activate || ! $charitable_details['wporg'] ) { ?> |
| 72 |
<button class="<?php echo esc_attr( $charitable_plugin_data['action_class'] ); ?>" data-plugin="<?php echo esc_attr( $charitable_plugin_data['plugin_src'] ); ?>" data-type="plugin"> |
| 73 |
<?php echo wp_kses_post( $charitable_plugin_data['action_text'] ); ?> |
| 74 |
</button> |
| 75 |
<?php } elseif ( $charitable_plugin_not_activated ) { ?> |
| 76 |
<a href="<?php echo esc_url( $charitable_details['wporg'] ); ?>" target="_blank" rel="noopener noreferrer"> |
| 77 |
<?php esc_html_e( 'WordPress.org', 'charitable' ); ?> |
| 78 |
<span aria-hidden="true" class="dashicons dashicons-external"></span> |
| 79 |
</a> |
| 80 |
<?php } ?> |
| 81 |
</div> |
| 82 |
</div> |
| 83 |
</div> |
| 84 |
</div> |
| 85 |
<?php endforeach; ?> |
| 86 |
</div> |
| 87 |
</div> |
| 88 |
|