| 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.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! class_exists( 'Charitable_Builder_Panel_Payment_Stripe' ) ) : |
| 18 |
|
| 19 |
/** |
| 20 |
* Stripe subpanel for Marketing Panel for campaign builder. |
| 21 |
* |
| 22 |
* @since 1.8.0 |
| 23 |
*/ |
| 24 |
class Charitable_Builder_Panel_Payment_Stripe { |
| 25 |
|
| 26 |
/** |
| 27 |
* Slug. |
| 28 |
* |
| 29 |
* @since 1.8.0 |
| 30 |
* |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
private $slug = 'stripe'; |
| 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__( 'Stripe', '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 |
* @version 1.8.1.12 Added logic to show popup message if user is on lite version. |
| 80 |
*/ |
| 81 |
public function sidebar_tab() { |
| 82 |
|
| 83 |
$not_available = ! charitable_is_pro() && $this->not_available_for_lite ? 'charitable-not-available' : ''; |
| 84 |
$css_class = ( '' === $not_available && true === apply_filters( 'charitable_campaign_builder_marketing_sidebar_active', $this->active, esc_attr( $this->slug ) ) ) ? 'active' : $not_available; |
| 85 |
$data_name = esc_html__( 'ability to use', 'charitable' ) . ' ' . $this->primary_label; |
| 86 |
|
| 87 |
echo '<a href="#" class="charitable-panel-sidebar-section charitable-panel-sidebar-section-' . esc_attr( $this->slug ) . ' ' . esc_attr( $css_class ) . '" data-name="' . esc_html( $data_name ) . '" data-section="' . esc_attr( $this->slug ) . '">' |
| 88 |
. '<img class="charitable-builder-sidebar-icon" src="' . esc_url( charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/payment/' . esc_attr( $this->slug ) . '.png' ) . '" />' |
| 89 |
. esc_html( $this->primary_label ) . '<span class="charitable-badge charitable-badge-sm charitable-badge-inline charitable-badge-green charitable-badge-rounded"><i class="fa fa-star" aria-hidden="true"></i>' . esc_html__( 'Recommended', 'charitable' ) . '</span>' |
| 90 |
. ' <i class="fa fa-angle-right charitable-toggle-arrow"></i></a>'; |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Generate panel content. |
| 95 |
* |
| 96 |
* @since 1.8.0 |
| 97 |
*/ |
| 98 |
public function panel_content() { |
| 99 |
|
| 100 |
$active = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'active' : false; |
| 101 |
$style = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'display: block;' : false; |
| 102 |
|
| 103 |
$panel = new Charitable_Builder_Panel_Payment(); |
| 104 |
|
| 105 |
ob_start(); |
| 106 |
|
| 107 |
?> |
| 108 |
|
| 109 |
<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 ); ?>"> |
| 110 |
|
| 111 |
<div class="charitable-panel-content-section-title"><?php echo esc_html( $this->primary_label ); ?> <?php echo esc_html__( 'Settings', 'charitable' ); ?></div> |
| 112 |
|
| 113 |
<div class="charitable-panel-content-section-interior"> |
| 114 |
|
| 115 |
<?php |
| 116 |
|
| 117 |
do_action( 'charitable_campaign_builder_before_payment_' . $this->slug ); |
| 118 |
|
| 119 |
?> |
| 120 |
|
| 121 |
<?php $panel->education_payment_text( $this->primary_label, $this->slug ); ?> |
| 122 |
|
| 123 |
|
| 124 |
<?php |
| 125 |
|
| 126 |
do_action( 'charitable_campaign_builder_after_payment_' . $this->slug ); |
| 127 |
|
| 128 |
?> |
| 129 |
|
| 130 |
</div> |
| 131 |
|
| 132 |
</div> |
| 133 |
|
| 134 |
<?php |
| 135 |
|
| 136 |
$html = ob_get_clean(); |
| 137 |
|
| 138 |
echo $html; // phpcs:ignore |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
new Charitable_Builder_Panel_Payment_Stripe(); |
| 143 |
|
| 144 |
endif; |