| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Display the table of emails. |
| 10 |
* |
| 11 |
* @author David Bisset |
| 12 |
* @package Charitable/Admin View/Settings |
| 13 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 14 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 15 |
* @since 1.0.0 |
| 16 |
* @version 1.8.2 Added checklist querystring value to action_url. |
| 17 |
* @version 1.8.7 Removed cf class from the email settings table. |
| 18 |
* @version 1.8.8.6 |
| 19 |
*/ |
| 20 |
|
| 21 |
$charitable_helper = charitable_get_helper( 'emails' ); |
| 22 |
$charitable_emails = $charitable_helper->get_available_emails(); |
| 23 |
|
| 24 |
if ( count( $charitable_emails ) ) : |
| 25 |
|
| 26 |
foreach ( $charitable_emails as $charitable_email ) : |
| 27 |
|
| 28 |
$charitable_email = new $charitable_email(); |
| 29 |
$charitable_is_enabled = $charitable_helper->is_enabled_email( $charitable_email->get_email_id() ); |
| 30 |
$charitable_action_url = esc_url( |
| 31 |
add_query_arg( |
| 32 |
array( |
| 33 |
'charitable_action' => $charitable_is_enabled ? 'disable_email' : 'enable_email', |
| 34 |
'email_id' => $charitable_email->get_email_id(), |
| 35 |
'_nonce' => wp_create_nonce( 'email' ), |
| 36 |
), |
| 37 |
admin_url( 'admin.php?page=charitable-settings&tab=emails' ) |
| 38 |
) |
| 39 |
); |
| 40 |
// if the querystring value of checklist exists then add it to the action_url. |
| 41 |
if ( isset( $_GET['checklist'] ) ) { // phpcs:ignore |
| 42 |
$charitable_action_url .= '&checklist=' . esc_attr( $_GET['checklist'] ); // phpcs:ignore |
| 43 |
} |
| 44 |
|
| 45 |
?> |
| 46 |
<div class="charitable-settings-object charitable-email"> |
| 47 |
<h4><?php echo esc_html( $charitable_email->get_name() ); ?></h4> |
| 48 |
<span class="actions"> |
| 49 |
<?php |
| 50 |
if ( $charitable_is_enabled ) : |
| 51 |
$charitable_settings_url = esc_url( |
| 52 |
add_query_arg( |
| 53 |
array( |
| 54 |
'group' => 'emails_' . $charitable_email->get_email_id(), |
| 55 |
), |
| 56 |
admin_url( 'admin.php?page=charitable-settings&tab=emails' ) |
| 57 |
) |
| 58 |
); |
| 59 |
?> |
| 60 |
<a href="<?php echo esc_url( $charitable_settings_url ); ?>" class="button button-primary"><?php esc_html_e( 'Email Settings', 'charitable' ); ?></a> |
| 61 |
<?php endif ?> |
| 62 |
<?php if ( ! $charitable_email->is_required() ) : ?> |
| 63 |
<?php if ( $charitable_is_enabled ) : ?> |
| 64 |
<a href="<?php echo esc_url( $charitable_action_url ); ?>" class="button"><?php esc_html_e( 'Disable Email', 'charitable' ); ?></a> |
| 65 |
<?php else : ?> |
| 66 |
<a href="<?php echo esc_url( $charitable_action_url ); ?>" class="button"><?php esc_html_e( 'Enable Email', 'charitable' ); ?></a> |
| 67 |
<?php endif ?> |
| 68 |
<?php endif ?> |
| 69 |
</span> |
| 70 |
</div> |
| 71 |
<?php endforeach ?> |
| 72 |
<?php |
| 73 |
else : |
| 74 |
esc_html_e( 'There are no emails available in your system.', 'charitable' ); |
| 75 |
endif; |
| 76 |
|