PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11
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 / class-marketing.php

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

789 lines 27.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Marketing class management panel.
4 *
5 * @package Charitable
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.9.1
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Builder_Panel_Marketing' ) ) :
18
19 /**
20 * Design management panel.
21 *
22 * @since 1.8.0
23 */
24 class Charitable_Builder_Panel_Marketing extends Charitable_Builder_Panel {
25
26 /**
27 * Form data and marketing.
28 *
29 * @since 1.8.0
30 *
31 * @var array
32 */
33 public $campaign_data;
34
35 /**
36 * Panels for the submenu campaign builder.
37 *
38 * @since 1.8.0
39 *
40 * @var array
41 */
42 public $submenu_panels;
43
44 /**
45 * All systems go.
46 *
47 * @since 1.8.0
48 */
49 public function init() {
50
51 // Define panel information.
52 $this->name = esc_html__( 'Marketing', 'charitable' );
53 $this->slug = 'marketing';
54 $this->icon = 'panel_marketing.svg';
55 $this->order = 40;
56 $this->sidebar = true;
57
58 // This should never be called unless we are on the campaign builder page.
59 if ( campaign_is_campaign_builder_admin_page() ) {
60 $this->load_submenu_panels();
61 }
62 }
63
64 /**
65 * Enqueue assets for the Design panel.
66 *
67 * @since 1.8.0
68 */
69 public function enqueues() {
70 // Add custom CSS for the upgrade button
71 $this->add_custom_styles();
72 }
73
74 /**
75 * Add custom CSS styles for the upgrade button.
76 *
77 * @since 1.8.0
78 */
79 private function add_custom_styles() {
80 ?>
81 <style>
82 .charitable-upgrade-to-pro-button {
83 background-color: #df7739 !important;
84 color: #ffffff !important;
85 border: 2px solid #df7739 !important;
86 padding: 10px 20px !important;
87 border-radius: 5px !important;
88 text-decoration: none !important;
89 display: inline-block !important;
90 font-weight: 600 !important;
91 transition: all 0.3s ease !important;
92 }
93
94 .charitable-upgrade-to-pro-button:hover {
95 background-color: #c66a32 !important;
96 border-color: #c66a32 !important;
97 color: #ffffff !important;
98 transform: translateY(-2px) !important;
99 box-shadow: 0 4px 8px rgba(223, 119, 57, 0.3) !important;
100 }
101 </style>
102 <?php
103 }
104
105 /**
106 * Load panels.
107 *
108 * @since 1.8.0
109 */
110 public function load_submenu_panels() {
111
112 $this->submenu_panels = apply_filters(
113 'charitable_builder_panels_marketing_',
114 array(
115 'mailchimp',
116 'active-campaign',
117 'campaign-monitor',
118 'mailerlite',
119 'mailpoet',
120 'mailster',
121 'constant-contact',
122 'zapier',
123 'hubspot',
124 'aweber',
125 'convert-kit',
126 'integromat',
127 'zoho-flow',
128 'request',
129 )
130 );
131
132 foreach ( $this->submenu_panels as $panel ) {
133 $panel = sanitize_file_name( $panel );
134 $file = charitable()->get_path( 'includes' ) . "admin/campaign-builder/panels/marketing/class-marketing-{$panel}.php";
135
136 if ( file_exists( $file ) ) {
137 require_once $file;
138 }
139 }
140 }
141
142
143 /**
144 * Output the Field panel sidebar.
145 *
146 * @since 1.8.0
147 */
148 public function panel_sidebar() {
149
150 // This should never be called unless we are on the campaign builder page.
151 if ( ! campaign_is_campaign_builder_admin_page() ) {
152 return;
153 }
154
155 do_action( 'charitable_campaign_builder_marketing_sidebar', $this->campaign_data );
156 }
157
158 /**
159 * Process marketing for campaigns, mostly via the builder.
160 *
161 * @since 1.8.0
162 *
163 * @param string $field Field.
164 * @param string $section Marketing section.
165 * @param string $top_level Level.
166 * @param string $meta_key Alt legacy location to try to pull marketing.
167 */
168 public function campaign_data_marketing( $field = 'title', $section = 'general', $top_level = 'marketing', $meta_key = false ) {
169 }
170
171 /**
172 * Process education marketing text.
173 *
174 * @since 1.8.0
175 *
176 * @param string $label Reader friendly output of object.
177 * @param string $slug Object slug.
178 * @param string $type Type of request.
179 */
180 public function education_marketing_text( $label = false, $slug = false, $type = false ) {
181
182 $learn_more_url = charitable_ga_url(
183 'https://wpcharitable.com/lite-vs-pro/', // base url.
184 rawurlencode( esc_html( $label ) . ' Marketing Page' ), // utm-medium.
185 rawurlencode( 'Learn More' ) // utm-content.
186 );
187
188 $action_css_class = '';
189 $button_label = '';
190 $addon_url = '';
191 $settings_url = '';
192 $addon_information = array(
193 'install' => '',
194 'name' => '',
195 );
196
197 ?>
198
199 <?php
200
201 echo '<img class="charitable-builder-sidebar-icon" src="' . charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/marketing/' . esc_attr( $slug ) . '_big.png" wdith="178" height="178" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
202
203 ?>
204
205 <section class="header-content">
206
207 <?php
208
209 if ( 'charitable-automation-connect' === $type ) :
210
211 ?>
212
213 <?php echo esc_html__( 'Turn one-time donors into ongoing supporters with', 'charitable' ); ?> <span><?php echo esc_html( $label ); ?></span>.</h2>
214
215 <p><strong><?php echo esc_html__( 'Automation Connect', 'charitable' ); ?></strong> <?php echo esc_html__( 'addon allows you to connect', 'charitable' ); ?> <strong><?php echo esc_html__( 'Charitable', 'charitable' ); ?></strong> <?php echo esc_html__( 'with thousands of other apps including', 'charitable' ); ?> <strong><?php echo esc_html( $label ); ?></strong> <?php echo esc_html__( 'by using 3rd party automation platforms like Zapier, Integromat or Zoho Flow.', 'charitable' ); ?></p>
216
217 <?php elseif ( 'request' === $type ) : ?>
218
219 <h2><?php echo esc_html__( 'Don\'t see an integration with', 'charitable' ); ?> <strong><?php echo esc_html__( 'Charitable', 'charitable' ); ?></strong> <?php echo esc_html__( 'and your favorite product or service?', 'charitable' ); ?></h2>
220 <h2><?php echo esc_html__( 'Let us know!', 'charitable' ); ?></h2>
221
222 <?php else : ?>
223
224 <h2><?php echo esc_html__( 'Turn one-time donors into ongoing supporters with ', 'charitable' ); ?> <span><?php echo esc_html( $label ); ?></span>.</h2>
225
226 <p><?php echo esc_html( $label ); ?><?php echo esc_html__( '\'s affordable pricing and excellent reputation have made it the go-to hosted email marketing provider for more millions of people.', 'charitable' ); ?> <?php echo esc_html__( 'Charitable Pro', 'charitable' ); ?> <?php echo esc_html__( 'allows you to integrate seamlessly with ', 'charitable' ); ?><span><?php echo esc_html( $label ); ?></span>.</p>
227
228
229 </section>
230
231 <?php endif; ?>
232
233
234 <?php
235
236 if ( 'charitable-automation-connect' === $type ) :
237
238 ?>
239
240 <div class="education-buttons education-buttons-top">
241 <a class="button-link" target="_blank" href="<?php echo esc_url( $learn_more_url ); ?>"><?php echo esc_html__( 'Learn More', 'charitable' ); ?></a> <button type="button" class="btn btn-confirm update-to-pro-link"><?php echo esc_html__( 'Upgrade to PRO', 'charitable' ); ?></button>
242 </div>
243
244 <div class="education-images type-custom type-<?php echo esc_attr( $type ); ?>">
245
246 <img class="charitable-marketing-image charitable-marketing-image-1 charitable-marketing-image-<?php echo esc_attr( $slug ); ?>" src="<?php echo esc_url( charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/marketing/education/' . esc_attr( $slug ) . '-1.png' ); ?>" alt="<?php echo esc_html( $label ); ?>" />
247
248 </div>
249
250 <section class="main-content">
251
252 <p><?php echo esc_html__( 'Upgrading to <strong>Pro</strong> gives you great capabilities to get more donations...', 'charitable' ); ?></p>
253
254 <ul>
255 <li><?php echo esc_html__( 'Give your donors an attractive end of financial year receipt.', 'charitable' ); ?></li>
256 <li><?php echo esc_html__( 'Fine-tune the processing fees by setting a fixed fee per donation.', 'charitable' ); ?></li>
257 <li><?php echo esc_html__( 'Allow users to raise donations and gain incredible support for their cause.', 'charitable' ); ?></li>
258 <li><?php echo esc_html__( 'Boost your fundraising with recurring donations.', 'charitable' ); ?></li>
259 <li><?php echo esc_html__( 'Set a location for your campaigns, and display them on a Google Map.', 'charitable' ); ?></li>
260 <li><?php echo esc_html__( 'Developer-friendly automation addon that will help you customize it to your needs.', 'charitable' ); ?></li>
261 </ul>
262
263 </section>
264
265 <?php
266 elseif ( 'request' === $type ) :
267
268 // attempt to prefill name and email fields.
269 $current_user = wp_get_current_user();
270 $name = ( $current_user ) ? charitable_get_creator_data() : false;
271 $email = ! empty( $current_user->user_email ) ? $current_user->user_email : false;
272
273 ?>
274
275 <!-- start feedback form -->
276
277 <div class="charitable-feedback-form-container-marketing">
278
279 <div id="charitable-marketing-form" class="charitable-form charitable-feedback-form">
280
281 <div class="charitable-feedback-form-interior">
282
283 <input type="hidden" class="charitable-feedback-form-type" value="marketing" />
284
285 <div class="charitable-form-row charitable-feedback-form-row">
286 <label><?php echo esc_html__( 'Name', 'charitable' ); ?> <span class="charitable-feedback-form-required">*</span></label>
287 <input name="charitable-feedback-form-name" type="text" class="charitable-feedback-form-name" value="<?php echo esc_html( $name ); ?>" />
288 </div>
289 <div class="charitable-form-row charitable-feedback-form-row">
290 <label><?php echo esc_html__( 'Email', 'charitable' ); ?> <span class="charitable-feedback-form-required">*</span></label>
291 <input name="charitable-feedback-form-email" type="email" class="charitable-feedback-form-email" value="<?php echo esc_html( $email ); ?>" />
292 </div>
293 <div class="charitable-form-row charitable-feedback-form-row">
294 <label><?php echo esc_html__( 'What intergration(s) would you like to see?', 'charitable' ); ?><span class="charitable-feedback-form-required">*</span></label>
295 <textarea name="charitable-feedback-form-feedback" class="charitable-feedback-form-feedback"></textarea>
296 </div>
297 <div class="charitable-form-row charitable-feedback-form-row">
298 <p class="charitable-feedback-form-required">* = <?php echo esc_html__( 'Required', 'charitable' ); ?></p>
299 </div>
300 <div class="charitable-form-row charitable-feedback-form-row">
301 <a class="button-link"><?php echo esc_html__( 'Send Request', 'charitable' ); ?></a>
302 </div>
303 <i class="charitable-loading-spinner charitable-loading-black charitable-loading-inline charitable-hidden"></i>
304
305 </div>
306
307 <div class="charitable-feedback-form-interior-confirmation">
308
309 <!-- confirmation -->
310 <div id="charitable-feedback-form-confirmation" class="charitable-form charitable-feedback-form charitable-form-confirmation charitable-hidden">
311 <h2><?php echo esc_html__( 'Thank You!', 'charitable' ); ?></h2>
312 <p><?php echo esc_html__( 'Your feedback has been sent to our team. Stay tuned to our updates on', 'charitable' ); ?> <a href="https://wpcharitable.com" target="_blank">wpcharitable.com</a>.</p>
313 </div>
314
315 </div>
316
317 </div>
318
319 </div>
320
321 <!-- end feedback form -->
322
323 <section class="main-content">
324
325 <?php if ( ! charitable_is_pro() ) { ?>
326
327 <p><?php echo esc_html__( 'Upgrading to', 'charitable' ); ?> <strong><?php echo esc_html__( 'Pro', 'charitable' ); ?></strong> <?php echo esc_html__( 'gives you the following capabilities...', 'charitable' ); ?></p>
328
329 <ul>
330 <li><?php echo esc_html__( 'Set a default list, opt-in mode and label that is used for all campaigns.', 'charitable' ); ?></li>
331 <li><?php echo esc_html__( 'Have donors subscribed to multiple lists when they donate.', 'charitable' ); ?></li>
332 <li><?php echo esc_html__( 'Allow donors automatically added to your mailing list when they give their consent.', 'charitable' ); ?></li>
333 <li><?php echo esc_html__( 'Create your own custom / merge fields and map these fields to your donation forms.', 'charitable' ); ?></li>
334 </ul>
335
336 <h2><?php echo esc_html__( 'Get the most out of your campaigns with ', 'charitable' ); ?><strong><?php echo esc_html__( 'Pro', 'charitable' ); ?></strong>.</h2>
337
338 <p style="margin-top: 20px;"><a class="button-link" href="<?php echo esc_url( $learn_more_url ); ?>"><?php echo esc_html__( 'Learn More', 'charitable' ); ?></a></p>
339
340 <?php } ?>
341
342 </section>
343
344 <?php
345
346 endif;
347 ?>
348
349 <?php if ( $button_label ) : ?>
350
351 <div class="education-buttons education-buttons-bottom">
352 <div class="action-button">
353 <?php echo '<a class="button-link ' . esc_attr( $action_css_class ) . '" data-settings-url="' . esc_url( $settings_url ) . '" data-plugin-url="' . esc_attr( $addon_information['install'] ) . '" data-name="' . esc_attr( $addon_information['name'] ) . '" data-plugin-slug="' . esc_url( $addon_url ) . '" data-field-icon="">' . esc_html( $button_label ) . '</a>'; ?>
354 </div>
355 </div>
356
357 <?php endif; ?>
358
359
360
361 <?php
362 }
363
364 /**
365 * Process education marketing text.
366 *
367 * @since 1.8.1.4
368 *
369 * @param string $marketing_item_label Marketing item label. Example: Mailchimp.
370 * @param string $marketing_item_slug Marketing item slug. Exmaple: campaign-monitor.
371 * @param string $addon_name Addon name.
372 * @param string $button_label Button label.
373 * @param string $button_url Button URL.
374 * @param string $addon_url Addon URL.
375 * @param bool $generic_button Whether to use a generic button label. Default is false.
376 */
377 public function plugin_activated_text( $marketing_item_label = false, $marketing_item_slug = false, $addon_name = '', $button_label = 'View Settings', $button_url = '', $addon_url = '', $generic_button = false ) {
378
379 echo '<img class="charitable-builder-sidebar-icon" src="' . charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/marketing/' . esc_attr( $marketing_item_slug ) . '_big.png" wdith="178" height="178" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
380
381 ?>
382
383 <section class="header-content">
384
385 <h2>
386 <?php
387 // translators: %s is the name of the addon.
388 printf( esc_html__( 'You have the %s addon activated.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>' );
389 ?>
390 </h2>
391
392 <?php
393
394 if ( strpos( $addon_url, 'charitable-automation-connect' ) !== false ) :
395
396 $direct_automation_services = array( 'zapier', 'integromat', 'zoho-flow', 'automateio' );
397
398 if ( in_array( $marketing_item_slug, $direct_automation_services, true ) ) :
399
400 ?>
401
402 <p>
403 <?php
404 // translators: %1$s is the name of the addon, %2$s is the marketing item label, %3$s is the link to the documentation.
405 printf( esc_html__( 'The %1$s addon allows you to integrate seamlessly with %2$s. %3$s for assistance or click the button below to access your webhook settings.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>', '<strong>' . esc_html( $marketing_item_label ) . '</strong>', '<a href="https://www.wpcharitable.com/documentation/charitable-automation-connect/" target="_blank">View our documentation</a>' );
406 ?>
407 </p>
408
409 <?php else : ?>
410 <p>
411 <?php
412 // translators: %1$s is the name of the addon, %2$s is the marketing item label, %3$s is the service name, %4$s is the link to the documentation.
413 printf( esc_html__( 'The %1$s addon allows you to integrate seamlessly with %2$s via services such as %3$s. %4$s for assistance or click the button below to access your webhook settings.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>', '<strong>' . esc_html( $marketing_item_label ) . '</strong>', '<strong>Zapier</strong>', '<a href="https://www.wpcharitable.com/documentation/charitable-automation-connect/" target="_blank">View our documentation</a>' );
414 ?>
415 </p>
416
417 <?php endif; ?>
418
419 <?php else : ?>
420
421 <p>
422 <?php
423 // translators: %s is the name of the addon.
424 printf( esc_html__( 'The %1$s addon allows you to integrate seamlessly with %2$s.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>', '<strong>' . esc_html( $marketing_item_label ) . '</strong>' );
425 ?>
426 </p>
427
428 <?php endif; ?>
429
430
431 </section>
432
433
434 <div class="education-buttons education-buttons-bottom">
435
436 <?php
437
438 $button_label = $generic_button ? $button_label : $button_label . ' ' . $marketing_item_label;
439
440 echo '<a class="button-link" href="' . esc_url( $button_url ) . '" target="_blank">' . esc_html( $button_label ) . '</a>';
441
442 ?>
443
444 </div>
445
446 <?php
447 }
448
449 /**
450 * Process installed text related to plugin installed/installing.
451 *
452 * @since 1.8.1.12
453 *
454 * @param string $marketing_item_label Marketing item label. Example: Mailchimp.
455 * @param string $marketing_item_slug Marketing item slug. Exmaple: campaign-monitor.
456 * @param string $addon_name Addon name.
457 * @param string $button_label Button label.
458 * @param string $button_url Button URL.
459 * @param string $addon_url Addon URL.
460 * @param bool $generic_button Whether to use a generic button label. Default is false.
461 */
462 public function plugin_installed_text( $marketing_item_label = false, $marketing_item_slug = false, $addon_name = '', $button_label = 'View Settings', $button_url = '', $addon_url = '', $generic_button = false ) {
463
464 $learn_more_url = charitable_ga_url(
465 'https://wpcharitable.com/lite-vs-pro/', // base url.
466 rawurlencode( esc_html( $marketing_item_label ) . ' Marketing Page' ), // utm-medium.
467 rawurlencode( 'Learn More' ) // utm-content.
468 );
469
470 echo '<img class="charitable-builder-sidebar-icon" src="' . charitable()->get_path( 'assets', false ) . 'images/campaign-builder/settings/marketing/' . esc_attr( $marketing_item_slug ) . '_big.png" wdith="178" height="178" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
471
472 // Determine if the plugin in question is installed and/or activated.
473 $status = $this->check_plugin_status( $addon_url );
474 $button_label = '';
475 switch ( $status ) {
476 case 'installed':
477 $button_label = esc_html__( 'Activate', 'charitable' );
478 $action_css_class = 'charitable-not-activated-button';
479 break;
480 case 'activated':
481 $button_label = esc_html__( 'View Settings', 'charitable' );
482 $action_css_class = 'charitable-view-settings-button';
483 break;
484 default:
485 // doesn't exist.
486 $button_label = esc_html__( 'Install And Activate', 'charitable' );
487 $action_css_class = 'charitable-not-installed-button';
488 break;
489 }
490
491 // Determine the settings_url.
492 $settings_url = false;
493 if ( strpos( $addon_url, 'charitable-automation-connect' ) !== false ) {
494 $settings_url = admin_url( 'admin.php?page=charitable-settings&tab=advanced' );
495 } elseif ( strpos( $addon_url, 'charitable-newsletter' ) !== false ) {
496 $settings_url = admin_url( 'admin.php?page=charitable-settings&tab=extensions' );
497 }
498
499 // get license stuff once.
500 $charitable_addons = get_transient( '_charitable_addons' ); // @codingStandardsIgnoreLine - testing.
501
502 // Get addons data from transient or perform API query if no transient.
503 if ( false === $charitable_addons ) {
504 $charitable_addons = charitable_get_addons_data_from_server();
505 }
506
507 if ( empty( $addon_url ) ) {
508 return;
509 }
510
511 $addon_url_slug = explode( '/', $addon_url );
512 $addon_url_slug = $addon_url_slug[0]; // example: charitable-newsletter-connect.
513 $addon_information = array();
514
515 if ( ! empty( $charitable_addons ) ) {
516 // Extract the charitable-newsletter-connect data.
517 foreach ( $charitable_addons as $addon ) {
518 if ( (string) $addon_url_slug === (string) $addon['slug'] ) {
519 $addon_information = $addon;
520 break;
521 }
522 }
523 }
524
525 $addon_information_install = ! empty( $addon_information['install'] ) ? $addon_information['install'] : '';
526 $addon_information_name = ! empty( $addon_information['name'] ) ? $addon_information['name'] : '';
527
528 ?>
529
530 <section class="header-content">
531
532 <h2 class="charitable-header-content-installed
533 <?php
534 if ( 'installed' !== $status ) :
535 ?>
536 charitable-hidden<?php endif; ?>">
537 <?php
538 // translators: %s is the name of the addon.
539 printf( esc_html__( 'You have the %s addon installed, but not activated.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>' );
540 ?>
541 </h2>
542 <h2 class="charitable-header-content-activated
543 <?php
544 if ( 'activated' !== $status ) :
545 ?>
546 charitable-hidden<?php endif; ?>">
547 <?php
548 // translators: %s is the name of the addon.
549 printf( esc_html__( 'You have the %s addon installed and activated.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>' );
550 ?>
551 </h2>
552 <h2 class="charitable-header-content-nonexist
553 <?php
554 if ( 'nonexist' !== $status ) :
555 ?>
556 charitable-hidden<?php endif; ?>">
557 <?php
558 // translators: %s is the name of the addon.
559 printf( esc_html__( 'You need to install the %s addon.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>' );
560 ?>
561 </h2>
562
563 <?php
564
565 if ( strpos( $addon_url, 'charitable-automation-connect' ) !== false ) :
566
567 $direct_automation_services = array( 'zapier', 'integromat', 'zoho-flow', 'automateio' );
568
569 if ( in_array( $marketing_item_slug, $direct_automation_services, true ) ) :
570
571 ?>
572
573 <p>
574 <?php
575 // translators: %1$s is the name of the addon, %2$s is the marketing item label, %3$s is the link to the documentation.
576 printf( esc_html__( 'The %1$s addon allows you to integrate seamlessly with %2$s. %3$s for assistance.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>', '<strong>' . esc_html( $marketing_item_label ) . '</strong>', '<a href="https://www.wpcharitable.com/documentation/charitable-automation-connect/" target="_blank">View our documentation</a>' );
577 ?>
578 </p>
579
580 <?php else : ?>
581 <p>
582 <?php
583 // translators: %1$s is the name of the addon, %2$s is the marketing item label, %3$s is the service name, %4$s is the link to the documentation.
584 printf( esc_html__( 'The %1$s addon allows you to integrate seamlessly with %2$s via services such as %3$s. %4$s for assistance.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>', '<strong>' . esc_html( $marketing_item_label ) . '</strong>', '<strong>Zapier</strong>', '<a href="https://www.wpcharitable.com/documentation/charitable-automation-connect/" target="_blank">View our documentation</a>' );
585 ?>
586 </p>
587
588 <?php endif; ?>
589
590 <?php else : ?>
591
592 <p>
593 <?php
594 // translators: %s is the name of the addon.
595 printf( esc_html__( 'The %1$s addon allows you to integrate seamlessly with %2$s.', 'charitable' ), '<strong>' . esc_html( $addon_name ) . '</strong>', '<strong>' . esc_html( $marketing_item_label ) . '</strong>' );
596 ?>
597 </p>
598
599 <?php endif; ?>
600
601
602 </section>
603
604 <?php if ( ! charitable_is_pro() ) : ?>
605
606 <div class="education-buttons education-buttons- bottom">
607
608 <div class="action-button">
609 <?php
610 // Check if this is MailChimp specifically and show upgrade button instead of install button
611 if ( strpos( $addon_url, 'charitable-newsletter-connect' ) !== false && $marketing_item_slug === 'mailchimp' ) {
612 echo '<a class="button-link charitable-upgrade-to-pro-button" target="_blank" href="https://wpcharitable.com/lite-vs-pro/?utm_source=WordPress&utm_campaign=WP+Charitable&utm_medium=Upgrade+From+Lite+Top+Banner+Link&utm_content=To+unlock+more+features+consider+upgrading+to+Pro">' . esc_html__( 'Upgrade to PRO', 'charitable' ) . '</a>';
613 } else {
614 echo '<a class="button-link ' . esc_attr( $action_css_class ) . '" data-settings-url="' . esc_url( $settings_url ) . '" data-plugin-url="' . esc_attr( $addon_information_install ) . '" data-name="' . esc_attr( $addon_information_name ) . '" data-plugin-slug="' . esc_attr( $addon_url ) . '" data-field-icon="">' . esc_html( $button_label ) . '</a>';
615 }
616 ?>
617 </div>
618
619 </div>
620
621 <?php else : ?>
622
623 <div class="education-buttons education-buttons-top">
624 <a class="btn button-link update-to-pro-link" target="_blank" href="<?php echo esc_url( $learn_more_url ); ?>"><?php echo esc_html__( 'Upgrade to PRO', 'charitable' ); ?></a>
625 </div>
626
627 <?php endif; ?>
628
629 <?php
630 }
631
632 /**
633 * Get button label and URL if the newsletter adoon is active.
634 *
635 * @since 1.8.1.4
636 *
637 * @param string $provider_slug Provider slug.
638 * @param string $button_url Default Button URL.
639 * @param string $button_label Default Button label.
640 *
641 * @return array
642 */
643 public function get_newsletter_button_info( $provider_slug = '', $button_url = '', $button_label = '' ) {
644
645 $button_info = array(
646 'button_url' => $button_url,
647 'button_label' => $button_label,
648 );
649
650 if ( class_exists( 'Charitable_Newsletter_Connect_Providers' ) ) :
651
652 $helper = Charitable_Newsletter_Connect_Providers::get_instance(); // phpcs:ignore
653 $providers = $helper->get_available_providers();
654 $found = false;
655
656 foreach ( $providers as $provider ) :
657
658 if ( $provider::ID !== $provider_slug ) {
659 continue;
660 }
661
662 $provider = new $provider();
663 $is_active = $provider->is_active();
664
665 if ( $provider->is_a_wordpress_provider() && ! $is_active ) :
666 if ( $provider->is_installed() ) :
667
668 $found = true;
669 $action_slug = 'activate';
670 $button_url = esc_url(
671 add_query_arg(
672 [
673 'charitable_action' => 'activate_wp_provider',
674 'plugin' => $provider->get_plugin_key(),
675 '_nonce' => wp_create_nonce( 'wp-provider' ),
676 ],
677 admin_url( 'admin.php?page=charitable-settings&tab=extensions' )
678 )
679 );
680
681 else :
682 $found = true;
683 $action_slug = 'install';
684 $button_url = esc_url( $provider->get_install_link() );
685
686 endif;
687 elseif ( count( $provider->provider_settings() ) ) :
688
689 $found = true;
690 $action_slug = 'configure';
691 $button_url = esc_url(
692 add_query_arg(
693 [
694 'group' => 'providers_' . $provider::ID,
695 ],
696 admin_url( 'admin.php?page=charitable-settings&tab=extensions' )
697 )
698 );
699
700 endif;
701
702 endforeach;
703
704 if ( $found ) :
705 $button_info = array(
706 'button_url' => $button_url,
707 'button_label' => ucwords( $action_slug ),
708 );
709 endif;
710
711 endif;
712
713 return $button_info;
714 }
715
716 /**
717 * Output the Field panel primary content.
718 *
719 * @since 1.8.0
720 */
721 public function panel_content() {
722
723 // This should never be called unless we are on the campaign builder page.
724 if ( ! campaign_is_campaign_builder_admin_page() ) {
725 return;
726 }
727
728 do_action( 'charitable_campaign_builder_marketing_panels', $this->campaign_data );
729 }
730
731 /**
732 * Builder field buttons.
733 *
734 * @since 1.8.0
735 */
736 public function fields() {
737 }
738
739 /**
740 * Sort Add Field buttons by order provided.
741 *
742 * @since 1.8.0
743 *
744 * @param array $a First item.
745 * @param array $b Second item.
746 *
747 * @return array
748 */
749 public function field_order( $a, $b ) {
750
751 return $a['order'] - $b['order'];
752 }
753
754 /**
755 * Check the installation and activation status of a plugin.
756 *
757 * @since 1.8.1.12
758 *
759 * @param string $plugin_slug The plugin slug, e.g., 'my-plugin/my-plugin.php'.
760 *
761 * @return string Status message indicating plugin state.
762 */
763 public function check_plugin_status( $plugin_slug = '' ) {
764
765 if ( '' === $plugin_slug ) {
766 return 'nonexist';
767 }
768
769 // Check if the plugin is installed.
770 if ( ! function_exists( 'get_plugins' ) ) {
771 require_once ABSPATH . 'wp-admin/includes/plugin.php';
772 }
773 $all_plugins = get_plugins();
774 $plugin_installed = array_key_exists( $plugin_slug, $all_plugins );
775
776 if ( $plugin_installed && is_plugin_active( $plugin_slug ) ) {
777 return 'activated';
778 } elseif ( $plugin_installed ) {
779 return 'installed';
780 } else {
781 return 'nonexist';
782 }
783 }
784 }
785
786 endif;
787
788 new Charitable_Builder_Panel_Marketing();
789