PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / admin / campaign-builder / panels / payment / class-payment-square.php

class-payment-square.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/admin/campaign-builder/panels/payment/class-payment-square.php

177 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_Square' ) ) :
18
19 /**
20 * Square subpanel for Marketing Panel for campaign builder.
21 *
22 * @since 1.8.0
23 */
24 class Charitable_Builder_Panel_Payment_Square {
25
26 /**
27 * Slug.
28 *
29 * @since 1.8.0
30 *
31 * @var string
32 */
33 private $slug = 'square';
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 * The URL to the plugin/addon in the local install.
64 *
65 * @since 1.8.1.4
66 *
67 * @var string
68 */
69 private $needed_addon_url = 'charitable-square/charitable-square.php';
70
71 /**
72 * The name of the plugin/addon.
73 *
74 * @since 1.8.1.4
75 *
76 * @var string
77 */
78 private $needed_addon_name = 'Charitable Square';
79
80 /**
81 * The slug for the provider.
82 *
83 * @since 1.8.1.4
84 *
85 * @var string
86 */
87 private $provider_slug = 'square';
88
89 /**
90 * Get things going. Add action hooks for the sidebar menu and the panel itself.
91 *
92 * @since 1.8.0
93 */
94 public function __construct() {
95
96 $this->primary_label = esc_html__( 'Square', 'charitable' );
97
98 add_action( 'charitable_campaign_builder_payment_sidebar', array( $this, 'sidebar_tab' ) );
99 add_action( 'charitable_campaign_builder_payment_panels', array( $this, 'panel_content' ) );
100 }
101
102 /**
103 * Generate sidebar html.
104 *
105 * @since 1.8.0
106 * @version 1.8.1.12 Added logic to show popup message if user is on lite version.
107 */
108 public function sidebar_tab() {
109
110 $not_available = ! charitable_is_pro() && $this->not_available_for_lite ? 'charitable-not-available' : '';
111 $css_class = ( '' === $not_available && true === apply_filters( 'charitable_campaign_builder_marketing_sidebar_active', $this->active, esc_attr( $this->slug ) ) ) ? 'active' : $not_available;
112 $data_name = esc_html__( 'ability to use', 'charitable' ) . ' ' . $this->primary_label;
113
114 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 ) . '">'
115 . '<img class="charitable-builder-sidebar-icon" src="' . esc_url( charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/payment/' . esc_attr( $this->slug ) . '.png' ) . '" />'
116 . 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>'
117 . ' <i class="fa fa-angle-right charitable-toggle-arrow"></i></a>';
118 }
119
120 /**
121 * Generate panel content.
122 *
123 * @since 1.8.0
124 * @since 1.8.1.4 - Added logic to check if the plugin/addon is activated and display the appropriate content.
125 *
126 * @return void
127 */
128 public function panel_content() {
129
130 $active = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'active' : false;
131 $style = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, $this->slug ) ) ? 'display: block;' : false;
132
133 $panel = new Charitable_Builder_Panel_Payment();
134
135 ob_start();
136
137 ?>
138
139 <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 ); ?>">
140
141 <div class="charitable-panel-content-section-title"><?php echo esc_html( $this->primary_label ); ?> <?php echo esc_html__( 'Settings', 'charitable' ); ?></div>
142
143 <div class="charitable-panel-content-section-interior">
144
145 <?php
146
147 do_action( 'charitable_campaign_builder_before_payment_' . $this->slug );
148
149 ?>
150
151 <?php $panel->education_payment_text( $this->primary_label, $this->slug ); ?>
152
153
154 <?php
155
156 do_action( 'charitable_campaign_builder_after_payment_' . $this->slug );
157
158 ?>
159
160 </div>
161
162 </div>
163
164 <?php
165
166 $html = ob_get_clean();
167
168 echo $html; // phpcs:ignore
169 }
170 }
171
172 // Only instantiate if PHP version is compatible and Square gateway class exists
173 if ( version_compare( PHP_VERSION, '8.1.0', '>=' ) && class_exists( 'Charitable_Gateway_Square' ) ) {
174 new Charitable_Builder_Panel_Payment_Square();
175 }
176
177 endif;