| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Display the main settings page wrapper. |
| 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.9 |
| 17 |
*/ |
| 18 |
|
| 19 |
$charitable_active_tab = isset( $_GET['tab'] ) ? esc_html( $_GET['tab'] ) : 'general'; // phpcs:ignore |
| 20 |
$charitable_tab_no_form_tag = array( 'import', 'export', 'tools' ); |
| 21 |
$charitable_group = isset( $_GET['group'] ) ? esc_html( $_GET['group'] ) : $charitable_active_tab; // phpcs:ignore |
| 22 |
$charitable_sections = charitable_get_admin_settings()->get_sections(); |
| 23 |
$charitable_show_return = $charitable_group !== $charitable_active_tab; |
| 24 |
$charitable_css = ''; |
| 25 |
|
| 26 |
if ( $charitable_show_return ) { |
| 27 |
/** |
| 28 |
* Filter the return link text. |
| 29 |
* |
| 30 |
* @since 1.6.19 |
| 31 |
* |
| 32 |
* @param string $default The default return link text. |
| 33 |
* @param string $active_tab The active tab. |
| 34 |
* @param string $group The current group. |
| 35 |
*/ |
| 36 |
$charitable_return_tab_text = apply_filters( |
| 37 |
'charitable_settings_return_tab_text', |
| 38 |
sprintf( |
| 39 |
/* translators: %s: tab name */ |
| 40 |
__( '← Return to %s', 'charitable' ), |
| 41 |
$charitable_active_tab |
| 42 |
), |
| 43 |
$charitable_active_tab, |
| 44 |
$charitable_group |
| 45 |
); |
| 46 |
|
| 47 |
/** |
| 48 |
* Filter the return link URL. |
| 49 |
* |
| 50 |
* @since 1.6.19 |
| 51 |
* |
| 52 |
* @param string $default The default return link URL |
| 53 |
* @param string $active_tab The active tab. |
| 54 |
* @param string $group The current group. |
| 55 |
*/ |
| 56 |
$charitable_return_tab_url = apply_filters( |
| 57 |
'charitable_settings_return_tab_url', |
| 58 |
add_query_arg( |
| 59 |
array( 'tab' => $charitable_active_tab ), |
| 60 |
admin_url( 'admin.php?page=charitable-settings' ) |
| 61 |
), |
| 62 |
$charitable_active_tab, |
| 63 |
$charitable_group |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
ob_start(); |
| 68 |
?> |
| 69 |
<div id="charitable-settings" class="wrap"> |
| 70 |
<h1 class="screen-reader-text"><?php echo get_admin_page_title(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h1> |
| 71 |
<h1><?php echo get_admin_page_title(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h1> |
| 72 |
<?php do_action( 'charitable_maybe_show_notification' ); ?> |
| 73 |
<h2 class="nav-tab-wrapper"> |
| 74 |
<?php foreach ( $charitable_sections as $charitable_section_key => $charitable_section_name ) : ?> |
| 75 |
<?php |
| 76 |
$charitable_url_query_arg_array = array( 'tab' => $charitable_section_key ); |
| 77 |
?> |
| 78 |
<a href="<?php echo esc_url( add_query_arg( $charitable_url_query_arg_array, admin_url( 'admin.php?page=charitable-settings' ) ) ); ?>" class="nav-tab nav-tab-<?php echo esc_attr( $charitable_section_key ); ?> <?php echo ( esc_attr( $charitable_active_tab ) === esc_attr( $charitable_section_key ) ) ? ' nav-tab-active' : ''; ?>"><?php echo esc_html( $charitable_section_name ); ?></a> |
| 79 |
<?php endforeach ?> |
| 80 |
</h2> |
| 81 |
<?php if ( $charitable_show_return ) : ?> |
| 82 |
<?php /* translators: %s: active settings tab label */ ?> |
| 83 |
<p><a href="<?php echo esc_url( $charitable_return_tab_url ); ?>"><?php echo $charitable_return_tab_text; // phpcs:ignore ?></a></p> |
| 84 |
<?php endif ?> |
| 85 |
<?php |
| 86 |
/** |
| 87 |
* Do or render something right before the settings form. |
| 88 |
* |
| 89 |
* @since 1.0.0 |
| 90 |
* |
| 91 |
* @param string $group The settings group we are viewing. |
| 92 |
*/ |
| 93 |
do_action( 'charitable_before_admin_settings', $charitable_group ); |
| 94 |
|
| 95 |
?> |
| 96 |
|
| 97 |
<?php |
| 98 |
// Show CTA only for marketing and donors tabs. |
| 99 |
// Security tab will show actual settings (either from spam blocker or core). |
| 100 |
if ( 'marketing' === $charitable_active_tab || 'donors' === $charitable_active_tab ) : |
| 101 |
?> |
| 102 |
<?php do_action( 'charitable_pro_settings_cta', $charitable_active_tab ); ?> |
| 103 |
<?php else : ?> |
| 104 |
|
| 105 |
<?php if ( ! in_array( strtolower( $charitable_active_tab ), $charitable_tab_no_form_tag ) ) : // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict ?> |
| 106 |
<form method="post" action="options.php"> |
| 107 |
<?php endif; ?> |
| 108 |
<table class="form-table"> |
| 109 |
<?php |
| 110 |
if ( ! in_array( strtolower( $charitable_active_tab ), $charitable_tab_no_form_tag ) ) : // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict |
| 111 |
settings_fields( 'charitable_settings' ); |
| 112 |
endif; |
| 113 |
|
| 114 |
charitable_do_settings_fields( 'charitable_settings_' . $charitable_group, 'charitable_settings_' . $charitable_group ); |
| 115 |
?> |
| 116 |
</table> |
| 117 |
<?php if ( ! in_array( strtolower( $charitable_active_tab ), $charitable_tab_no_form_tag ) ) : // phpcs:ignore ?> |
| 118 |
<?php |
| 119 |
/** |
| 120 |
* Filter the submit button at the bottom of the settings table. |
| 121 |
* |
| 122 |
* @since 1.6.0 |
| 123 |
* |
| 124 |
* @param string $button The button output. |
| 125 |
*/ |
| 126 |
echo apply_filters( 'charitable_settings_button_' . $charitable_group, get_submit_button( null, 'primary', 'submit', true, null ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 127 |
?> |
| 128 |
<?php endif; ?> |
| 129 |
<?php if ( ! in_array( strtolower( $charitable_active_tab ), $charitable_tab_no_form_tag ) ) : // phpcs:ignore ?> |
| 130 |
</form> |
| 131 |
<?php endif; ?> |
| 132 |
|
| 133 |
<?php endif; ?> |
| 134 |
|
| 135 |
<?php if ( 'security' === $charitable_active_tab) : ?> |
| 136 |
<?php do_action( 'charitable_pro_settings_cta', $charitable_active_tab ); ?> |
| 137 |
<?php endif; ?> |
| 138 |
|
| 139 |
<?php |
| 140 |
/** |
| 141 |
* Do or render something right after the settings form. |
| 142 |
* |
| 143 |
* @since 1.0.0 |
| 144 |
* |
| 145 |
* @param string $group The settings group we are viewing. |
| 146 |
*/ |
| 147 |
do_action( 'charitable_after_admin_settings', $charitable_group ); |
| 148 |
?> |
| 149 |
</div> |
| 150 |
<?php |
| 151 |
|
| 152 |
echo ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 153 |
|