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.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 1.7.0.9 All 211 releases
charitable / includes / admin / campaign-builder / panels / payment / class-payment-gocardless.php

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

206 lines 6.2 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_Gocardless' ) ) :
18
19 /**
20 * Gocardless subpanel for Marketing Panel for campaign builder.
21 *
22 * @since 1.8.0
23 */
24 class Charitable_Builder_Panel_Payment_Gocardless {
25
26 /**
27 * Slug.
28 *
29 * @since 1.8.0
30 *
31 * @var string
32 */
33 private $slug = 'gocardless';
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 = true;
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-gocardless/charitable-gocardless.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 GoCardless';
79
80 /**
81 * The slug for the provider.
82 *
83 * @since 1.8.1.4
84 *
85 * @var string
86 */
87 private $provider_slug = 'gocardless';
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__( 'GoCardless', '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 )
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, esc_attr( $this->slug ) ) ) ? 'active' : false;
131 $style = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, esc_attr( $this->slug ) ) ) ? 'display: block;' : false;
132
133 $panel = new Charitable_Builder_Panel_Payment();
134
135 $button_url = admin_url( 'admin.php?page=charitable-settings&tab=gateways' );
136 $button_label = esc_html__( 'View Gateway Settings', 'charitable' );
137
138 // Set the default URL and label for the button.
139 $button_info = $panel->get_gateway_button_info( $this->provider_slug, $button_url, $button_label );
140
141 $button_url = $button_info['button_url'];
142 $button_label = $button_info['button_label'];
143
144 $slug = esc_attr( $this->slug );
145
146 $status = $panel->check_plugin_status( $this->needed_addon_url );
147
148 ob_start();
149
150 ?>
151
152 <div class="charitable-panel-content-section charitable-panel-content-section-parent-marketing charitable-panel-content-section-<?php echo esc_attr( $this->slug ); ?> <?php echo esc_attr( $active ); ?>" style="<?php echo esc_attr( $style ); ?>">
153
154 <div class="charitable-panel-content-section-title"><?php echo esc_html( $this->primary_label ); ?> <?php echo esc_html__( 'Settings', 'charitable' ); ?></div>
155
156 <div class="charitable-panel-content-section-interior">
157
158 <?php
159
160 do_action( 'charitable_campaign_builder_before_payment_' . $slug );
161
162 ?>
163
164 <?php
165
166 // determine if the user is (1) using pro and (2) has the needed addon activated.
167 if ( charitable_is_pro() && 'activated' === $status ) {
168
169 // plugin is activated so proceed with displaying non-marketing, plugin content.
170 $panel->plugin_activated_text( $this->primary_label, esc_attr( $this->slug ), $this->needed_addon_name, $button_label, $button_url, $this->needed_addon_url );
171
172 } elseif ( charitable_is_pro() && 'installed' === $status ) {
173
174 // plugin is installed but not activated so proceed with displaying...
175 $panel->plugin_installed_text( $this->primary_label, esc_attr( $this->slug ), $this->needed_addon_name, $button_label, $button_url, $this->needed_addon_url );
176
177 } else {
178
179 // somehow if the user gets here, present the educational content.
180 $panel->plugin_installed_text( $this->primary_label, esc_attr( $this->slug ), $this->needed_addon_name, $button_label, $button_url, $this->needed_addon_url );
181
182 }
183
184 ?>
185
186 <?php
187
188 do_action( 'charitable_campaign_builder_after_payment_' . $slug );
189
190 ?>
191
192 </div>
193
194 </div>
195
196 <?php
197
198 $html = ob_get_clean();
199
200 echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
201 }
202 }
203
204 new Charitable_Builder_Panel_Payment_Gocardless();
205
206 endif;