| 1 |
<?php |
| 2 |
/** |
| 3 |
* The class that defines a subpanel for the payment area for the campaign builder. |
| 4 |
* |
| 5 |
* @package Charitable/Admin/Charitable_Campaign_Meta_Boxes |
| 6 |
* @author David Bisset |
| 7 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.8.0 |
| 10 |
* @version 1.8.8.3 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! class_exists( 'Charitable_Builder_Panel_Payment_Request' ) ) : |
| 18 |
|
| 19 |
/** |
| 20 |
* Request subpanel for Marketing Panel for campaign builder. |
| 21 |
* |
| 22 |
* @since 1.8.0 |
| 23 |
*/ |
| 24 |
class Charitable_Builder_Panel_Payment_Request { |
| 25 |
|
| 26 |
/** |
| 27 |
* Slug. |
| 28 |
* |
| 29 |
* @since 1.8.0 |
| 30 |
* |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
private $slug = 'request'; |
| 34 |
|
| 35 |
/** |
| 36 |
* The label/headline at the top of the panel. |
| 37 |
* |
| 38 |
* @since 1.8.0 |
| 39 |
* |
| 40 |
* @var string |
| 41 |
*/ |
| 42 |
private $primary_label = ''; |
| 43 |
|
| 44 |
/** |
| 45 |
* Determines if the tab is initially active on a fresh new page load. |
| 46 |
* |
| 47 |
* @since 1.8.0 |
| 48 |
* |
| 49 |
* @var string |
| 50 |
*/ |
| 51 |
private $active = false; |
| 52 |
|
| 53 |
/** |
| 54 |
* Determines if the tab is available for the lite version. If not, the CTA popup will be displayed when clicked in the submenu. |
| 55 |
* |
| 56 |
* @since 1.8.1.12 |
| 57 |
* |
| 58 |
* @var string |
| 59 |
*/ |
| 60 |
private $not_available_for_lite = false; |
| 61 |
|
| 62 |
/** |
| 63 |
* Get things going. Add action hooks for the sidebar menu and the panel itself. |
| 64 |
* |
| 65 |
* @since 1.8.0 |
| 66 |
*/ |
| 67 |
public function __construct() { |
| 68 |
|
| 69 |
$this->primary_label = esc_html__( 'Don’t See Yours?', 'charitable' ); |
| 70 |
|
| 71 |
add_action( 'charitable_campaign_builder_payment_sidebar', array( $this, 'sidebar_tab' ) ); |
| 72 |
add_action( 'charitable_campaign_builder_payment_panels', array( $this, 'panel_content' ) ); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Generate sidebar html. |
| 77 |
* |
| 78 |
* @since 1.8.0 |
| 79 |
*/ |
| 80 |
public function sidebar_tab() { |
| 81 |
|
| 82 |
$active = ( true === apply_filters( 'charitable_campaign_builder_payment_sidebar_active', $this->active, $this->slug ) ) ? 'active' : false; |
| 83 |
|
| 84 |
printf( |
| 85 |
'<a href="#" class="charitable-panel-sidebar-section charitable-panel-sidebar-section-%1$s %2$s payment-request" data-section="%1$s">' |
| 86 |
. '<img class="charitable-builder-sidebar-icon" width="44" height="44" src="%3$s" />' |
| 87 |
. '%4$s' |
| 88 |
. ' <i class="fa fa-angle-right charitable-toggle-arrow"></i></a>', |
| 89 |
esc_attr( $this->slug ), |
| 90 |
esc_attr( $active ), |
| 91 |
esc_url( charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/payment/' . $this->slug . '.png' ), |
| 92 |
esc_html( $this->primary_label ) |
| 93 |
); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
/** |
| 98 |
* Generate panel content. |
| 99 |
* |
| 100 |
* @since 1.8.0 |
| 101 |
*/ |
| 102 |
public function panel_content() { |
| 103 |
|
| 104 |
$active = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'active' : false; |
| 105 |
$style = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'display: block;' : false; |
| 106 |
|
| 107 |
$panel = new Charitable_Builder_Panel_Payment(); |
| 108 |
|
| 109 |
ob_start(); |
| 110 |
|
| 111 |
?> |
| 112 |
|
| 113 |
<div class="charitable-panel-content-section charitable-panel-content-section-parent-payment charitable-panel-content-section-<?php echo esc_attr( $this->slug ); ?> <?php echo esc_attr( $active ); ?>" style="<?php echo esc_attr( $style ); ?>"> |
| 114 |
|
| 115 |
<div class="charitable-panel-content-section-title"><?php echo esc_html( $this->primary_label ); ?></div> |
| 116 |
|
| 117 |
<div class="charitable-panel-content-section-interior"> |
| 118 |
|
| 119 |
<?php |
| 120 |
|
| 121 |
do_action( 'charitable_campaign_builder_before_payment_' . $this->slug ); |
| 122 |
|
| 123 |
?> |
| 124 |
|
| 125 |
<?php $panel->education_payment_text( $this->primary_label, $this->slug, 'request' ); ?> |
| 126 |
|
| 127 |
|
| 128 |
<?php |
| 129 |
|
| 130 |
do_action( 'charitable_campaign_builder_after_payment_' . $this->slug ); |
| 131 |
|
| 132 |
?> |
| 133 |
|
| 134 |
</div> |
| 135 |
|
| 136 |
</div> |
| 137 |
|
| 138 |
<?php |
| 139 |
|
| 140 |
$html = ob_get_clean(); |
| 141 |
|
| 142 |
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
new Charitable_Builder_Panel_Payment_Request(); |
| 147 |
|
| 148 |
endif; |