charitable
/
includes
/
admin
/
campaign-builder
/
panels
/
settings
/
class-settings-campaign-summary.php
class-settings-campaign-summary.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11, at includes/admin/campaign-builder/panels/settings/class-settings-campaign-summary.php
| 1 | <?php |
| 2 | /** |
| 3 | * The class that defines a subpanel for the settings area for the campaign builder. |
| 4 | * |
| 5 | * @author David Bisset |
| 6 | * @copyright Copyright (c) 2023, WP Charitable LLC |
| 7 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 8 | * @since 1.8.0 |
| 9 | * @version. 1.8.9.1 |
| 10 | */ |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | if ( ! class_exists( 'Charitable_Builder_Panel_Settings_Campaign_Summary' ) ) : |
| 17 | |
| 18 | /** |
| 19 | * General subpanel for Settings Panel for campaign builder. |
| 20 | * |
| 21 | * @since 1.8.0 |
| 22 | */ |
| 23 | class Charitable_Builder_Panel_Settings_Campaign_Summary { |
| 24 | |
| 25 | /** |
| 26 | * Slug. |
| 27 | * |
| 28 | * @since 1.8.0 |
| 29 | * |
| 30 | * @var string |
| 31 | */ |
| 32 | private $slug = 'campaign-summary'; |
| 33 | |
| 34 | /** |
| 35 | * The label/headline at the top of the panel. |
| 36 | * |
| 37 | * @since 1.8.0 |
| 38 | * |
| 39 | * @var string |
| 40 | */ |
| 41 | private $primary_label = ''; |
| 42 | |
| 43 | /** |
| 44 | * Determines if the tab is initially active on a fresh new page load. |
| 45 | * |
| 46 | * @since 1.8.0 |
| 47 | * |
| 48 | * @var string |
| 49 | */ |
| 50 | private $active = false; |
| 51 | |
| 52 | |
| 53 | /** |
| 54 | * Get things going. Add action hooks for the sidebar menu and the panel itself. |
| 55 | * |
| 56 | * @since 1.8.0 |
| 57 | */ |
| 58 | public function __construct() { |
| 59 | |
| 60 | $this->primary_label = esc_html__( 'Campaign Summary', 'charitable' ); |
| 61 | |
| 62 | add_action( 'charitable_campaign_builder_settings_sidebar', array( $this, 'sidebar_tab' ) ); |
| 63 | add_action( 'charitable_campaign_builder_settings_panels', array( $this, 'panel_content' ) ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Generate sidebar html. |
| 68 | * |
| 69 | * @since 1.8.0 |
| 70 | */ |
| 71 | public function sidebar_tab() { |
| 72 | |
| 73 | $active = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'active' : false; |
| 74 | |
| 75 | echo '<a href="#" class="charitable-panel-sidebar-section charitable-panel-sidebar-section-' . esc_attr( $this->slug ) . ' ' . esc_attr( $active ) . '" data-section="' . esc_attr( $this->slug ) . '">' . esc_html( $this->primary_label ) . ' <i class="fa fa-angle-right charitable-toggle-arrow"></i></a>'; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Generate panel content. |
| 80 | * |
| 81 | * @since 1.8.0 |
| 82 | */ |
| 83 | public function panel_content() { |
| 84 | |
| 85 | $charitable_builder_form_fields = new Charitable_Builder_Form_Fields(); |
| 86 | $settings = new Charitable_Builder_Panel_Settings(); |
| 87 | |
| 88 | $active = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'active' : false; |
| 89 | $style = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'display: block;' : false; |
| 90 | |
| 91 | ob_start(); |
| 92 | |
| 93 | ?> |
| 94 | |
| 95 | <div class="charitable-panel-content-section charitable-panel-content-section-<?php echo esc_attr( $this->slug ); ?> <?php echo esc_attr( $active ); ?>" style="<?php echo esc_attr( $style ); ?>"> |
| 96 | <div class="charitable-panel-content-section-title"><?php echo esc_html( $this->primary_label ); ?></div> |
| 97 | |
| 98 | <?php |
| 99 | |
| 100 | echo $charitable_builder_form_fields->generate_checkboxes( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 101 | $settings->campaign_data_settings( '', 'campaign-summary' ), |
| 102 | esc_html__( 'Hide Information', 'charitable' ), |
| 103 | array( |
| 104 | 'id' => 'charitable-campaign-suggested-donations', |
| 105 | 'name' => array( 'settings', esc_attr( $this->slug ) ), |
| 106 | 'options' => array( |
| 107 | 'Amount Donated' => 'campaign_hide_amount_donated', |
| 108 | 'Number of Donors' => 'campaign_hide_number_of_donors', |
| 109 | 'Percent Raised' => 'campaign_hide_percent_raised', |
| 110 | 'Time Remaining' => 'campaign_hide_time_remaining', |
| 111 | ), |
| 112 | ) |
| 113 | ); |
| 114 | |
| 115 | echo $charitable_builder_form_fields->generate_text( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 116 | $settings->campaign_data_settings( 'donation_button_text', 'campaign-summary' ), |
| 117 | esc_html__( 'Donation Button Text', 'charitable' ), |
| 118 | array( |
| 119 | 'id' => 'campaign_donation_button_text', |
| 120 | 'name' => array( 'settings', esc_attr( $this->slug ), 'donation_button_text' ), |
| 121 | 'placeholder' => 'Donate', |
| 122 | ) |
| 123 | ); |
| 124 | |
| 125 | ?> |
| 126 | |
| 127 | </div> |
| 128 | |
| 129 | <?php |
| 130 | |
| 131 | $html = ob_get_clean(); |
| 132 | |
| 133 | echo wp_kses_post( $html ); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | new Charitable_Builder_Panel_Settings_Campaign_Summary(); |
| 138 | |
| 139 | endif; |