| @@ -16,14 +16,22 @@ | ||
| 16 | 16 | * @version 1.8.9 |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | $charitable_active_tab = isset( $_GET['tab'] ) ? esc_html( $_GET['tab'] ) : 'general'; // phpcs:ignore |
| 20 | +$charitable_active_sub_tab = isset( $_GET['sub_tab'] ) ? esc_html( $_GET['sub_tab'] ) : ''; // phpcs:ignore | |
| 20 | 21 | $charitable_tab_no_form_tag = array( 'import', 'export', 'tools' ); |
| 21 | 22 | $charitable_group = isset( $_GET['group'] ) ? esc_html( $_GET['group'] ) : $charitable_active_tab; // phpcs:ignore |
| 22 | 23 | $charitable_sections = charitable_get_admin_settings()->get_sections(); |
| 24 | +$charitable_sub_sections = 'marketing' === $charitable_active_tab ? charitable_get_admin_settings()->get_sub_sections_marketing() : array(); | |
| 25 | +$charitable_newsletter_addon_active = class_exists( 'Charitable_Newsletter_Connect' ); | |
| 23 | 26 | $charitable_show_return = $charitable_group !== $charitable_active_tab; |
| 24 | 27 | $charitable_css = ''; |
| 25 | 28 | |
| 29 | +// Resolve the effective sub_tab for routing. Marketing always has a sub_tab; default to newsletters. | |
| 30 | +if ( 'marketing' === $charitable_active_tab && '' === $charitable_active_sub_tab ) { | |
| 31 | + $charitable_active_sub_tab = 'newsletters'; | |
| 32 | +} | |
| 33 | + | |
| 26 | 34 | if ( $charitable_show_return ) { |
| 27 | 35 | /** |
| 28 | 36 | * Filter the return link text. |
| 29 | 37 | * |
| @@ -73,12 +81,32 @@ | ||
| 73 | 81 | <h2 class="nav-tab-wrapper"> |
| 74 | 82 | <?php foreach ( $charitable_sections as $charitable_section_key => $charitable_section_name ) : ?> |
| 75 | 83 | <?php |
| 76 | 84 | $charitable_url_query_arg_array = array( 'tab' => $charitable_section_key ); |
| 85 | + if ( 'marketing' === $charitable_section_key ) { | |
| 86 | + $charitable_url_query_arg_array['sub_tab'] = 'newsletters'; | |
| 87 | + } | |
| 77 | 88 | ?> |
| 78 | 89 | <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 | 90 | <?php endforeach ?> |
| 80 | 91 | </h2> |
| 92 | + <?php if ( 'marketing' === $charitable_active_tab && ! empty( $charitable_sub_sections ) ) : ?> | |
| 93 | + <h3 class="nav-sub-tab-wrapper"> | |
| 94 | + <?php foreach ( $charitable_sub_sections as $charitable_sub_section_key => $charitable_sub_section_label ) : | |
| 95 | + $charitable_sub_tab_slug = str_replace( 'marketing__', '', $charitable_sub_section_key ); | |
| 96 | + $charitable_is_active = ( $charitable_active_sub_tab === $charitable_sub_tab_slug ); | |
| 97 | + ?> | |
| 98 | + <a href="<?php echo esc_url( add_query_arg( array( 'tab' => 'marketing', 'sub_tab' => $charitable_sub_tab_slug ), admin_url( 'admin.php?page=charitable-settings' ) ) ); ?>" class="nav-tab nav-tab-marketing nav-sub-tab-<?php echo esc_attr( $charitable_sub_tab_slug ); ?><?php echo $charitable_is_active ? ' nav-tab-active' : ''; ?>"><?php | |
| 99 | + echo wp_kses( | |
| 100 | + $charitable_sub_section_label, | |
| 101 | + array( | |
| 102 | + 'span' => array( 'class' => array() ), | |
| 103 | + ) | |
| 104 | + ); | |
| 105 | + ?></a> | |
| 106 | + <?php endforeach ?> | |
| 107 | + </h3> | |
| 108 | + <?php endif; ?> | |
| 81 | 109 | <?php if ( $charitable_show_return ) : ?> |
| 82 | 110 | <?php /* translators: %s: active settings tab label */ ?> |
| 83 | 111 | <p><a href="<?php echo esc_url( $charitable_return_tab_url ); ?>"><?php echo $charitable_return_tab_text; // phpcs:ignore ?></a></p> |
| 84 | 112 | <?php endif ?> |
| @@ -94,11 +122,27 @@ | ||
| 94 | 122 | |
| 95 | 123 | ?> |
| 96 | 124 | |
| 97 | 125 | <?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 ) : | |
| 126 | + // Donors → always show CTA in Lite. | |
| 127 | + // Marketing → render the real form only on Newsletters sub-tab when the Newsletter | |
| 128 | + // Connect addon is active (it works on Lite). All other Marketing sub-tabs | |
| 129 | + // (conversion_tracking, google_analytics) — and Newsletters with no addon — | |
| 130 | + // render their CTA via the charitable_pro_settings_cta action. | |
| 131 | + $charitable_show_cta = 'donors' === $charitable_active_tab | |
| 132 | + || ( 'marketing' === $charitable_active_tab | |
| 133 | + && ( 'newsletters' !== $charitable_active_sub_tab || ! $charitable_newsletter_addon_active ) | |
| 134 | + ); | |
| 135 | + | |
| 136 | + // When rendering the real form for the Newsletters sub-tab, route fields to the | |
| 137 | + // marketing__newsletters group. The legacy addon still hooks into the extensions | |
| 138 | + // section, so we use 'extensions' as the field-group key for the form (see the | |
| 139 | + // bridge in Charitable_Settings::register_settings()). | |
| 140 | + if ( 'marketing' === $charitable_active_tab && 'newsletters' === $charitable_active_sub_tab && $charitable_newsletter_addon_active && empty( $_GET['group'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 141 | + $charitable_group = 'extensions'; | |
| 142 | + } | |
| 143 | + | |
| 144 | + if ( $charitable_show_cta ) : | |
| 101 | 145 | ?> |
| 102 | 146 | <?php do_action( 'charitable_pro_settings_cta', $charitable_active_tab ); ?> |
| 103 | 147 | <?php else : ?> |
| 104 | 148 | |