PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.0.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.0.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / addons / marketing / ma-mailchimp / ma-mailchimp.php

ma-mailchimp.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.0.9, at addons/marketing/ma-mailchimp/ma-mailchimp.php

153 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Addons;
4
5 use MasterAddons\Inc\Classes\Base\Master_Widget;
6 use \Elementor\Controls_Manager;
7
8 use MasterAddons\Inc\Classes\Helper;
9 use MasterAddons\Inc\Admin\Config;
10
11 /**
12 * Author Name: Liton Arefin
13 * Author URL: https://jeweltheme.com
14 * Date: 1/1/20
15 */
16
17 if (!defined('ABSPATH')) exit; // If this file is called directly, abort.
18
19 class Mailchimp extends Master_Widget
20 {
21 use \MasterAddons\Inc\Traits\Widget_Notice;
22 use \MasterAddons\Inc\Traits\Widget_Assets_Trait;
23
24 public function get_name()
25 {
26 return 'ma-el-mailchimp';
27 }
28 public function get_title()
29 {
30 return __('Mailchimp', 'master-addons' );
31 }
32
33 public function get_icon()
34 {
35 return 'jltma-icon ' . Config::get_addon_icon('ma-mailchimp');
36 }
37
38 public function jltma_get_forms()
39 {
40
41 $options = array(0 => __('Select Form', 'master-addons' ));
42
43 if (!function_exists('mc4wp_get_forms')) {
44 return $options;
45 }
46 $forms = mc4wp_get_forms();
47 foreach ($forms as $form) {
48 $options[$form->ID] = $form->name;
49 }
50
51 return $options;
52 }
53
54 protected function register_controls()
55 {
56
57 /*
58 * Content Tab
59 */
60 $this->start_controls_section(
61 'jltma_mailchimp_form_section',
62 [
63 'label' => __('Form', 'master-addons' )
64 ]
65 );
66
67 // You can edit your sign-up form in the Mailchimp for WordPress form settings.
68
69 $this->add_control(
70 'jltma_mailchimp_form_type',
71 [
72 'label' => __('Form Type', 'master-addons' ),
73 'type' => Controls_Manager::SELECT,
74 'default' => 'default',
75 'options' => array(
76 'default' => __('Defaults', 'master-addons' ),
77 'custom' => __('Custom', 'master-addons' )
78 )
79 ]
80 );
81
82 $this->add_control(
83 'jltma_mailchimp_form_id',
84 array(
85 'label' => __('MailChimp Sign-Up Form', 'master-addons' ),
86 'label_block' => true,
87 'type' => Controls_Manager::SELECT,
88 'default' => 0,
89 'options' => $this->jltma_get_forms(),
90 'condition' => array(
91 'jltma_mailchimp_form_type' => array('default')
92 )
93 )
94 );
95
96 $this->add_control(
97 'jltma_mailchimp_html',
98 array(
99 'label' => __('Custom Form', 'master-addons' ),
100 'type' => Controls_Manager::CODE,
101 'language' => 'html',
102 'description' => __('Enter your custom form markup', 'master-addons' ),
103 'condition' => array(
104 'jltma_mailchimp_form_type' => array('custom')
105 )
106 )
107 );
108
109 $this->end_controls_section();
110
111 // Help Docs section (links from config.php)
112 $this->jltma_help_docs();
113
114 $this->upgrade_to_pro_message();
115
116 }
117
118 public function jltma_render_custom_form($content)
119 {
120 $settings = $this->get_settings_for_display();
121
122 if (!empty($settings['jltma_mailchimp_html'])) {
123 $content = $settings['jltma_mailchimp_html'];
124 }
125 return $content;
126 }
127
128 protected function render()
129 {
130 $settings = $this->get_settings_for_display();
131
132 // Check whether required resources are available
133 if (!function_exists('mc4wp_show_form')) {
134 Helper::jltma_elementor_plugin_missing_notice(array(
135 'title' => esc_html__('MailChimp for WordPress is Not Activated!', 'master-addons'),
136 'description' => esc_html__('To use this widget, please install and activate the "MC4WP: Mailchimp for WordPress" plugin.', 'master-addons'),
137 ));
138 return;
139 }
140
141 if ($settings['jltma_mailchimp_form_type'] === 'custom') {
142 add_filter('mc4wp_form_content', array($this, 'jltma_render_custom_form'), 10, 1);
143 $settings['jltma_mailchimp_form_id'] = 0;
144 } elseif (get_post_type($settings['jltma_mailchimp_form_id']) !== 'mc4wp-form') {
145 $settings['jltma_mailchimp_form_id'] = 0;
146 }
147
148 echo '<div class="jltma-mailchimp">';
149 mc4wp_show_form($settings['jltma_mailchimp_form_id']);
150 echo '</div>';
151 }
152 }
153