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