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-authorize-net.php

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

207 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_AuthorizeNet' ) ) :
18
19 /**
20 * AuthorizeNet subpanel for Marketing Panel for campaign builder.
21 *
22 * @since 1.8.0
23 */
24 class Charitable_Builder_Panel_Payment_AuthorizeNet {
25
26 /**
27 * Slug.
28 *
29 * @since 1.8.0
30 *
31 * @var string
32 */
33 private $slug = 'authorize-net';
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-authorize-net/charitable-authorize-net.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 Authorize.Net';
79
80 /**
81 * The slug for the provider.
82 *
83 * @since 1.8.1.4
84 *
85 * @var string
86 */
87 private $provider_slug = 'authorize_net';
88
89
90 /**
91 * Get things going. Add action hooks for the sidebar menu and the panel itself.
92 *
93 * @since 1.8.0
94 */
95 public function __construct() {
96
97 $this->primary_label = esc_html__( 'Authorize.Net', 'charitable' );
98
99 add_action( 'charitable_campaign_builder_payment_sidebar', array( $this, 'sidebar_tab' ) );
100 add_action( 'charitable_campaign_builder_payment_panels', array( $this, 'panel_content' ) );
101 }
102
103 /**
104 * Generate sidebar html.
105 *
106 * @since 1.8.0
107 * @version 1.8.1.12 Added logic to show popup message if user is on lite version.
108 */
109 public function sidebar_tab() {
110
111 $not_available = ! charitable_is_pro() && $this->not_available_for_lite ? 'charitable-not-available' : '';
112 $css_class = ( '' === $not_available && true === apply_filters( 'charitable_campaign_builder_marketing_sidebar_active', $this->active, esc_attr( $this->slug ) ) ) ? 'active' : $not_available;
113 $data_name = esc_html__( 'ability to use', 'charitable' ) . ' ' . $this->primary_label;
114
115 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 ) . '">'
116 . '<img class="charitable-builder-sidebar-icon" src="' . esc_url( charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/payment/' . esc_attr( $this->slug ) . '.png' ) . '" />'
117 . esc_html( $this->primary_label )
118 . ' <i class="fa fa-angle-right charitable-toggle-arrow"></i></a>';
119 }
120
121 /**
122 * Generate panel content.
123 *
124 * @since 1.8.0
125 * @since 1.8.1.4 - Added logic to check if the plugin/addon is activated and display the appropriate content.
126 *
127 * @return void
128 */
129 public function panel_content() {
130
131 $active = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, esc_attr( $this->slug ) ) ) ? 'active' : false;
132 $style = ( true === apply_filters( 'charitable_campaign_builder_settings_sidebar_active', $this->active, esc_attr( $this->slug ) ) ) ? 'display: block;' : false;
133
134 $panel = new Charitable_Builder_Panel_Payment();
135
136 $button_url = admin_url( 'admin.php?page=charitable-settings&tab=gateways' );
137 $button_label = esc_html__( 'View Gateway Settings', 'charitable' );
138
139 // Set the default URL and label for the button.
140 $button_info = $panel->get_gateway_button_info( $this->provider_slug, $button_url, $button_label );
141
142 $button_url = $button_info['button_url'];
143 $button_label = $button_info['button_label'];
144
145 $slug = esc_attr( $this->slug );
146
147 $status = $panel->check_plugin_status( $this->needed_addon_url );
148
149 ob_start();
150
151 ?>
152
153 <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 ); ?>">
154
155 <div class="charitable-panel-content-section-title"><?php echo esc_html( $this->primary_label ); ?> <?php echo esc_html__( 'Settings', 'charitable' ); ?></div>
156
157 <div class="charitable-panel-content-section-interior">
158
159 <?php
160
161 do_action( 'charitable_campaign_builder_before_payment_' . $slug );
162
163 ?>
164
165 <?php
166
167 // determine if the user is (1) using pro and (2) has the needed addon activated.
168 if ( charitable_is_pro() && 'activated' === $status ) {
169
170 // plugin is activated so proceed with displaying non-marketing, plugin content.
171 $panel->plugin_activated_text( $this->primary_label, esc_attr( $this->slug ), $this->needed_addon_name, $button_label, $button_url, $this->needed_addon_url );
172
173 } elseif ( charitable_is_pro() && 'installed' === $status ) {
174
175 // plugin is installed but not activated so proceed with displaying...
176 $panel->plugin_installed_text( $this->primary_label, esc_attr( $this->slug ), $this->needed_addon_name, $button_label, $button_url, $this->needed_addon_url );
177
178 } else {
179
180 // somehow if the user gets here, present the educational content.
181 $panel->plugin_installed_text( $this->primary_label, esc_attr( $this->slug ), $this->needed_addon_name, $button_label, $button_url, $this->needed_addon_url );
182
183 }
184
185 ?>
186
187 <?php
188
189 do_action( 'charitable_campaign_builder_after_payment_' . $slug );
190
191 ?>
192
193 </div>
194
195 </div>
196
197 <?php
198
199 $html = ob_get_clean();
200
201 echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
202 }
203 }
204
205 new Charitable_Builder_Panel_Payment_AuthorizeNet();
206
207 endif;