Version Description
Metform 1.3.0-beta1 is a major update. We have reconstructed the widgets with react and huge optimization for future proof. If you faced any issue please contact our support team from here https://help.wpmet.com/
Download this release
Release Info
Developer | ataurr |
Plugin | Metform Elementor Contact Form Builder – Flexible and Design-Friendly Contact Form builder plugin for WordPress |
Version | 1.3.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.3.5
- core/entries/action.php +11 -9
- core/entries/meta-data.php +181 -118
- metform.php +1 -1
- plugin.php +1 -1
- readme.txt +6 -3
- utils/rating-notice.php +362 -172
- utils/rating.php +111 -79
core/entries/action.php
CHANGED
@@ -403,16 +403,7 @@ class Action
|
|
403 |
}
|
404 |
}
|
405 |
|
406 |
-
/**
|
407 |
-
* Woocommerce
|
408 |
-
*/
|
409 |
|
410 |
-
if(class_exists('WooCommerce')){
|
411 |
-
if(class_exists('\MetForm_Pro\Core\Integrations\Ecommerce\Woocommerce\Pay')){
|
412 |
-
$woo_pay = new \MetForm_Pro\Core\Integrations\Ecommerce\Woocommerce\Pay();
|
413 |
-
$woo_pay->action($form_data);
|
414 |
-
}
|
415 |
-
}
|
416 |
|
417 |
if (defined('MAILPOET_VERSION') && class_exists('\MetForm_Pro\Core\Integrations\Mail_Poet')) {
|
418 |
if (isset($this->form_settings['mf_mail_poet']) && $this->form_settings['mf_mail_poet'] == '1' && $this->email_name != null && $form_data[$this->email_name] != '') {
|
@@ -546,6 +537,17 @@ class Action
|
|
546 |
}
|
547 |
}
|
548 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
return $this->response;
|
550 |
}
|
551 |
|
403 |
}
|
404 |
}
|
405 |
|
|
|
|
|
|
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
|
408 |
if (defined('MAILPOET_VERSION') && class_exists('\MetForm_Pro\Core\Integrations\Mail_Poet')) {
|
409 |
if (isset($this->form_settings['mf_mail_poet']) && $this->form_settings['mf_mail_poet'] == '1' && $this->email_name != null && $form_data[$this->email_name] != '') {
|
537 |
}
|
538 |
}
|
539 |
|
540 |
+
/**
|
541 |
+
* Woocommerce
|
542 |
+
*/
|
543 |
+
|
544 |
+
if(class_exists('WooCommerce')){
|
545 |
+
if(class_exists('\MetForm_Pro\Core\Integrations\Ecommerce\Woocommerce\Pay')){
|
546 |
+
|
547 |
+
$woo_pay = new \MetForm_Pro\Core\Integrations\Ecommerce\Woocommerce\Pay();
|
548 |
+
$woo_pay->action($form_data, $this->entry_id);
|
549 |
+
}
|
550 |
+
}
|
551 |
return $this->response;
|
552 |
}
|
553 |
|
core/entries/meta-data.php
CHANGED
@@ -26,6 +26,7 @@ class Meta_Data
|
|
26 |
add_action('add_meta_boxes', [$this, 'add_browser_data_cmb']);
|
27 |
add_action('add_meta_boxes', [$this, 'add_file_upload_cmb']);
|
28 |
add_action('add_meta_boxes', [$this, 'add_form_payment_status_cmb']);
|
|
|
29 |
}
|
30 |
|
31 |
function add_form_id_cmb()
|
@@ -47,147 +48,148 @@ class Meta_Data
|
|
47 |
$this->form_id = get_post_meta($post->ID, 'metform_entries__form_id', true);
|
48 |
// get fields by form id for further use
|
49 |
$this->fields = Action::instance()->get_fields($this->form_id);
|
50 |
-
$form_title = get_the_title((int)
|
51 |
|
52 |
?>
|
53 |
|
54 |
<div class="metform-entry-data container">
|
55 |
<table class='mf-entry-data' cellpadding="5" cellspacing="0">
|
56 |
<tbody>
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
</tbody>
|
71 |
</table>
|
72 |
</div>
|
73 |
|
74 |
<?php
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
add_meta_box(
|
102 |
-
'metform_form__entry_browser_data',
|
103 |
-
esc_html__('Browser Data'),
|
104 |
-
[$this, 'show_browser_data_cmb'],
|
105 |
-
$this->cpt->get_name(),
|
106 |
-
'side',
|
107 |
-
'low'
|
108 |
-
);
|
109 |
-
}
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
<div class="metform-entry-data container">
|
116 |
<table class='mf-entry-data' cellpadding="5" cellspacing="0">
|
117 |
<?php
|
118 |
-
|
119 |
-
|
120 |
<tbody>
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
</tbody>
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
</table>
|
132 |
</div>
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
$this->file_meta_data = get_post_meta($post_id, 'metform_entries__file_upload', true);
|
145 |
-
if (!is_array($this->file_meta_data)) {
|
146 |
-
return;
|
147 |
-
}
|
148 |
-
|
149 |
-
add_meta_box(
|
150 |
-
'metform_entries__file_upload',
|
151 |
-
esc_html__('Files'),
|
152 |
-
[$this, 'show_file_upload_cmb'],
|
153 |
-
$this->cpt->get_name(),
|
154 |
-
'normal',
|
155 |
-
'low'
|
156 |
-
);
|
157 |
-
}
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
$this->form_data = get_post_meta($post->ID, 'metform_entries__form_data', true);
|
164 |
-
$this->form_data = (isset($this->form_data)) ? $this->form_data : "";
|
165 |
-
// format all form data into html table
|
166 |
-
if ($this->form_data != '') {
|
167 |
-
$form_html = \MetForm\Core\Entries\Form_Data::format_form_data($this->form_id, $this->form_data);
|
168 |
-
echo $form_html;
|
169 |
-
}
|
170 |
-
}
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
if ($file_url != '') {
|
182 |
-
echo esc_html(((isset($this->fields[$key]->mf_input_label)) ? $this->fields[$key]->mf_input_label : $key) . " : ") . "<a target='_blank' class='mf-file-url' href=" . esc_url($file_url) . ">" . esc_html__('Download', 'elementskit') . "</a>";
|
183 |
-
echo ((in_array($file_type, ['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'image/ico'])) ? ' | <a href="#" class="" data-toggle="modal" data-target="#mfFileUploadModal' . $key . '">' . esc_html__('View', 'metform') . '</a>' : '');
|
184 |
-
} else {
|
185 |
-
echo esc_html(((isset($this->fields[$key]->mf_input_label)) ? $this->fields[$key]->mf_input_label : $key) . " : ") . esc_html__('This file is not uploaded.', 'metform');
|
186 |
-
}
|
187 |
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
<!-- Modal -->
|
190 |
-
<div class="attr-modal attr-fade mf-modal-container" id="mfFileUploadModal<?php echo $key ?>" tabindex="-1"
|
|
|
191 |
<div class="attr-modal-dialog" role="document">
|
192 |
<div class="attr-modal-content">
|
193 |
<div class="attr-modal-header">
|
@@ -201,7 +203,7 @@ class Meta_Data
|
|
201 |
</div>
|
202 |
</div>
|
203 |
</div>
|
204 |
-
<?php
|
205 |
}
|
206 |
echo "</p></div>";
|
207 |
}
|
@@ -213,6 +215,67 @@ class Meta_Data
|
|
213 |
|
214 |
}
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
function add_form_payment_status_cmb()
|
217 |
{
|
218 |
|
@@ -229,12 +292,12 @@ class Meta_Data
|
|
229 |
|
230 |
function show_form_payment_status_cmb($post)
|
231 |
{
|
232 |
-
echo "Status : " .get_post_meta($post->ID, 'metform_entries__payment_status', true) . "<br>";
|
233 |
|
234 |
-
if(get_post_meta($post->ID, 'metform_entries__payment_invoice', true)){
|
235 |
echo "Invoice : ";
|
236 |
echo get_post_meta($post->ID, 'metform_entries__payment_invoice', true) . "<br>";
|
237 |
}
|
238 |
-
|
239 |
}
|
240 |
}
|
26 |
add_action('add_meta_boxes', [$this, 'add_browser_data_cmb']);
|
27 |
add_action('add_meta_boxes', [$this, 'add_file_upload_cmb']);
|
28 |
add_action('add_meta_boxes', [$this, 'add_form_payment_status_cmb']);
|
29 |
+
add_action('add_meta_boxes', [$this, 'add_woo_payment_status_cmb']);
|
30 |
}
|
31 |
|
32 |
function add_form_id_cmb()
|
48 |
$this->form_id = get_post_meta($post->ID, 'metform_entries__form_id', true);
|
49 |
// get fields by form id for further use
|
50 |
$this->fields = Action::instance()->get_fields($this->form_id);
|
51 |
+
$form_title = get_the_title((int)$this->form_id);
|
52 |
|
53 |
?>
|
54 |
|
55 |
<div class="metform-entry-data container">
|
56 |
<table class='mf-entry-data' cellpadding="5" cellspacing="0">
|
57 |
<tbody>
|
58 |
+
<tr class="mf-data-label">
|
59 |
+
<td colspan='2'><strong><?php esc_html_e('Form Name ', 'metform'); ?></strong></td>
|
60 |
+
</tr>
|
61 |
+
<tr class='mf-data-value'>
|
62 |
+
<td><?php echo esc_attr($form_title); ?></td>
|
63 |
+
</tr>
|
64 |
+
<tr class="mf-data-label">
|
65 |
+
<td colspan='2'><strong><?php esc_html_e('Entry ID', 'metform'); ?></strong></td>
|
66 |
+
</tr>
|
67 |
+
<tr class='mf-data-value'>
|
68 |
+
<td><?php echo esc_attr($post->ID); ?></td>
|
69 |
+
</tr>
|
70 |
|
71 |
</tbody>
|
72 |
</table>
|
73 |
</div>
|
74 |
|
75 |
<?php
|
76 |
+
}
|
77 |
|
78 |
+
function add_form_data_cmb()
|
79 |
+
{
|
80 |
+
add_meta_box(
|
81 |
+
'metform_entries__form_data',
|
82 |
+
esc_html__('Data'),
|
83 |
+
[$this, 'show_form_data_cmb'],
|
84 |
+
$this->cpt->get_name(),
|
85 |
+
'normal',
|
86 |
+
'high'
|
87 |
+
);
|
88 |
+
}
|
89 |
|
90 |
+
function add_browser_data_cmb()
|
91 |
+
{
|
92 |
+
// call browser data meta when browser data present
|
93 |
+
$post_id = (isset($_GET['post']) ? $_GET['post'] : '');
|
94 |
+
$form_id = get_post_meta($post_id, 'metform_entries__form_id', true);
|
95 |
+
$form_settings = \MetForm\Core\Forms\Action::instance()->get_all_data($form_id);
|
96 |
+
|
97 |
+
$this->browser_data = get_post_meta($post_id, 'metform_form__entry_browser_data', true);
|
98 |
+
if ($this->browser_data == '' && !isset($form_settings['capture_user_browser_data'])) {
|
99 |
+
return;
|
100 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
+
add_meta_box(
|
103 |
+
'metform_form__entry_browser_data',
|
104 |
+
esc_html__('Browser Data'),
|
105 |
+
[$this, 'show_browser_data_cmb'],
|
106 |
+
$this->cpt->get_name(),
|
107 |
+
'side',
|
108 |
+
'low'
|
109 |
+
);
|
110 |
+
}
|
111 |
+
|
112 |
+
function show_browser_data_cmb($post)
|
113 |
+
{
|
114 |
+
if ($this->browser_data != '') {
|
115 |
+
?>
|
116 |
<div class="metform-entry-data container">
|
117 |
<table class='mf-entry-data' cellpadding="5" cellspacing="0">
|
118 |
<?php
|
119 |
+
foreach ($this->browser_data as $key => $value) {
|
120 |
+
?>
|
121 |
<tbody>
|
122 |
+
<tr class="mf-data-label">
|
123 |
+
<td colspan='2'><strong><?php echo esc_attr($key); ?></strong></td>
|
124 |
+
</tr>
|
125 |
+
<tr class='mf-data-value'>
|
126 |
+
<td><?php echo esc_attr($value); ?></td>
|
127 |
+
</tr>
|
128 |
</tbody>
|
129 |
+
<?php
|
130 |
+
}
|
131 |
+
?>
|
132 |
</table>
|
133 |
</div>
|
134 |
+
<?php
|
135 |
+
} else {
|
136 |
+
echo esc_html__('Browser data not captured.', 'metform');
|
137 |
+
}
|
138 |
+
}
|
139 |
|
140 |
+
function add_file_upload_cmb()
|
141 |
+
{
|
142 |
+
// call file meta when file data present
|
143 |
+
$post_id = (isset($_GET['post']) ? $_GET['post'] : '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
+
$this->file_meta_data = get_post_meta($post_id, 'metform_entries__file_upload', true);
|
146 |
+
if (!is_array($this->file_meta_data)) {
|
147 |
+
return;
|
148 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
+
add_meta_box(
|
151 |
+
'metform_entries__file_upload',
|
152 |
+
esc_html__('Files'),
|
153 |
+
[$this, 'show_file_upload_cmb'],
|
154 |
+
$this->cpt->get_name(),
|
155 |
+
'normal',
|
156 |
+
'low'
|
157 |
+
);
|
158 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
+
function show_form_data_cmb($post)
|
161 |
+
{
|
162 |
+
wp_nonce_field('meta_nonce', 'meta_nonce');
|
163 |
+
|
164 |
+
$this->form_data = get_post_meta($post->ID, 'metform_entries__form_data', true);
|
165 |
+
$this->form_data = (isset($this->form_data)) ? $this->form_data : "";
|
166 |
+
// format all form data into html table
|
167 |
+
if ($this->form_data != '') {
|
168 |
+
$form_html = \MetForm\Core\Entries\Form_Data::format_form_data($this->form_id, $this->form_data);
|
169 |
+
echo $form_html;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
function show_file_upload_cmb($post)
|
174 |
+
{
|
175 |
+
echo "<div class='mf-file-show'><p><i class='mf mf-file-2'></i> ";
|
176 |
+
foreach ($this->file_meta_data as $key => $value) {
|
177 |
+
if (empty($this->fields)) {
|
178 |
+
return;
|
179 |
+
}
|
180 |
+
$file_url = isset($value['url']) ? $value['url'] : '';
|
181 |
+
$file_type = isset($value['type']) ? $value['type'] : '';
|
182 |
+
if ($file_url != '') {
|
183 |
+
echo esc_html(((isset($this->fields[$key]->mf_input_label)) ? $this->fields[$key]->mf_input_label : $key) . " : ") . "<a target='_blank' class='mf-file-url' href=" . esc_url($file_url) . ">" . esc_html__('Download', 'elementskit') . "</a>";
|
184 |
+
echo((in_array($file_type, ['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'image/ico'])) ? ' | <a href="#" class="" data-toggle="modal" data-target="#mfFileUploadModal' . $key . '">' . esc_html__('View', 'metform') . '</a>' : '');
|
185 |
+
} else {
|
186 |
+
echo esc_html(((isset($this->fields[$key]->mf_input_label)) ? $this->fields[$key]->mf_input_label : $key) . " : ") . esc_html__('This file is not uploaded.', 'metform');
|
187 |
+
}
|
188 |
+
|
189 |
+
?>
|
190 |
<!-- Modal -->
|
191 |
+
<div class="attr-modal attr-fade mf-modal-container" id="mfFileUploadModal<?php echo $key ?>" tabindex="-1"
|
192 |
+
role="dialog" aria-labelledby="mfFileUploadodalMLabel" aria-hidden="true">
|
193 |
<div class="attr-modal-dialog" role="document">
|
194 |
<div class="attr-modal-content">
|
195 |
<div class="attr-modal-header">
|
203 |
</div>
|
204 |
</div>
|
205 |
</div>
|
206 |
+
<?php
|
207 |
}
|
208 |
echo "</p></div>";
|
209 |
}
|
215 |
|
216 |
}
|
217 |
|
218 |
+
function add_woo_payment_status_cmb()
|
219 |
+
{
|
220 |
+
add_meta_box(
|
221 |
+
'metform_entries__woo_checkout_status',
|
222 |
+
esc_html__('Woocommerce Checkout'),
|
223 |
+
[$this, 'show_woo_checkout_status_cmb'],
|
224 |
+
$this->cpt->get_name(),
|
225 |
+
'side',
|
226 |
+
'high'
|
227 |
+
);
|
228 |
+
}
|
229 |
+
|
230 |
+
function show_woo_checkout_status_cmb($post)
|
231 |
+
{
|
232 |
+
$order_id = get_post_meta($post->ID, 'mf_woo_order_id', true);
|
233 |
+
if($order_id == null) {
|
234 |
+
return;
|
235 |
+
}
|
236 |
+
$order = wc_get_order($order_id);
|
237 |
+
$order_url = get_admin_url() . 'post.php?post=' . $order_id . '&action=edit';
|
238 |
+
?>
|
239 |
+
|
240 |
+
<div class="metform-entry-data container">
|
241 |
+
<table class='mf-entry-data' cellpadding="5" cellspacing="0">
|
242 |
+
<tbody>
|
243 |
+
<tr class="mf-data-label">
|
244 |
+
<td colspan='2'><strong><?php esc_html_e('Order ID ', 'metform'); ?></strong></td>
|
245 |
+
</tr>
|
246 |
+
<tr class='mf-data-value'>
|
247 |
+
<td><?php echo esc_attr($order_id); ?></td>
|
248 |
+
</tr>
|
249 |
+
<tr class="mf-data-label">
|
250 |
+
<td colspan='2'><strong><?php esc_html_e('Order Status', 'metform'); ?></strong></td>
|
251 |
+
</tr>
|
252 |
+
<tr class='mf-data-value'>
|
253 |
+
<td><?php echo esc_attr($order->get_status()); ?></td>
|
254 |
+
</tr>
|
255 |
+
|
256 |
+
<tr class="mf-data-label">
|
257 |
+
<td colspan='2'><strong><?php esc_html_e('Total', 'metform'); ?></strong></td>
|
258 |
+
</tr>
|
259 |
+
<tr class='mf-data-value'>
|
260 |
+
<td><?php echo esc_attr($order->get_total() . ' ' . $order->get_currency()); ?></td>
|
261 |
+
</tr>
|
262 |
+
|
263 |
+
<tr class="mf-data-label">
|
264 |
+
|
265 |
+
</tr>
|
266 |
+
<tr class='mf-data-value'>
|
267 |
+
<td><a class="button" href="<?php echo $order_url; ?>" target="__blank">Order Details</a></td>
|
268 |
+
</tr>
|
269 |
+
|
270 |
+
</tbody>
|
271 |
+
</table>
|
272 |
+
</div>
|
273 |
+
|
274 |
+
|
275 |
+
<?php
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
function add_form_payment_status_cmb()
|
280 |
{
|
281 |
|
292 |
|
293 |
function show_form_payment_status_cmb($post)
|
294 |
{
|
295 |
+
echo "Status : " . get_post_meta($post->ID, 'metform_entries__payment_status', true) . "<br>";
|
296 |
|
297 |
+
if (get_post_meta($post->ID, 'metform_entries__payment_invoice', true)) {
|
298 |
echo "Invoice : ";
|
299 |
echo get_post_meta($post->ID, 'metform_entries__payment_invoice', true) . "<br>";
|
300 |
}
|
301 |
+
|
302 |
}
|
303 |
}
|
metform.php
CHANGED
@@ -5,7 +5,7 @@ defined( 'ABSPATH' ) || exit;
|
|
5 |
* Plugin Name: MetForm
|
6 |
* Plugin URI: http://products.wpmet.com/metform/
|
7 |
* Description: Most flexible and design friendly form builder for Elementor
|
8 |
-
* Version: 1.3.
|
9 |
* Author: Wpmet
|
10 |
* Author URI: https://wpmet.com
|
11 |
* Text Domain: metform
|
5 |
* Plugin Name: MetForm
|
6 |
* Plugin URI: http://products.wpmet.com/metform/
|
7 |
* Description: Most flexible and design friendly form builder for Elementor
|
8 |
+
* Version: 1.3.5
|
9 |
* Author: Wpmet
|
10 |
* Author URI: https://wpmet.com
|
11 |
* Text Domain: metform
|
plugin.php
CHANGED
@@ -16,7 +16,7 @@ final class Plugin{
|
|
16 |
}
|
17 |
|
18 |
public function version(){
|
19 |
-
return '1.3.
|
20 |
}
|
21 |
|
22 |
public function package_type(){
|
16 |
}
|
17 |
|
18 |
public function version(){
|
19 |
+
return '1.3.5';
|
20 |
}
|
21 |
|
22 |
public function package_type(){
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Metform Elementor Addon - Most flexible and design-friendly Contact Form builder ===
|
2 |
-
Contributors: ataurr, wpmet,
|
3 |
Tags: Form builder, Elementor form builder, contact form, custom form, forms, drag & drop form builder
|
4 |
Requires at least: 4.8
|
5 |
Tested up to: 5.5
|
6 |
-
Stable tag: 1.3.
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -221,7 +221,10 @@ Connect with Gmail, Slack, Mailchimp, and many more.
|
|
221 |
|
222 |
|
223 |
== Changelog ==
|
224 |
-
|
|
|
|
|
|
|
225 |
Version 1.3.4
|
226 |
Fix: Stripe issue
|
227 |
Added: Custom JS event for developer
|
1 |
=== Metform Elementor Addon - Most flexible and design-friendly Contact Form builder ===
|
2 |
+
Contributors: ataurr, wpmet, emrnco, prappo_p, atiqsu, easin55474
|
3 |
Tags: Form builder, Elementor form builder, contact form, custom form, forms, drag & drop form builder
|
4 |
Requires at least: 4.8
|
5 |
Tested up to: 5.5
|
6 |
+
Stable tag: 1.3.5
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
221 |
|
222 |
|
223 |
== Changelog ==
|
224 |
+
Version 1.3.5
|
225 |
+
Fix: Rating notice issues
|
226 |
+
Added: CSS optimization.
|
227 |
+
|
228 |
Version 1.3.4
|
229 |
Fix: Stripe issue
|
230 |
Added: Custom JS event for developer
|
utils/rating-notice.php
CHANGED
@@ -1,241 +1,431 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
|
7 |
-
/**
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
*/
|
14 |
-
class Notice
|
15 |
-
{
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
|
|
22 |
/**
|
23 |
-
*
|
24 |
*
|
25 |
-
* @
|
26 |
*/
|
27 |
-
|
28 |
-
{
|
29 |
-
add_action('admin_footer', [$this, 'enqueue_scripts'], 9999);
|
30 |
-
add_action('wp_ajax_metform-notices', [$this, 'dismiss']);
|
31 |
-
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
|
|
34 |
/**
|
35 |
-
*
|
36 |
*
|
37 |
-
* @
|
38 |
-
* @since 1.0.0
|
39 |
*/
|
40 |
-
|
41 |
-
{
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
wp_send_json_error();
|
60 |
-
}
|
61 |
|
62 |
/**
|
63 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
*
|
65 |
* @return void
|
66 |
-
* @since 1.0.0
|
67 |
*/
|
68 |
-
public function
|
69 |
-
|
70 |
-
echo "
|
71 |
-
<script>
|
72 |
-
jQuery(document).ready(function ($) {
|
73 |
-
$( '.metform-notice.is-dismissible' ).on( 'click', '.notice-dismiss', function() {
|
74 |
-
_this = $( this ).parents( '.metform-notice' );
|
75 |
-
var id = _this.attr( 'id' ) || '';
|
76 |
-
var time = _this.attr( 'dismissible-time' ) || '';
|
77 |
-
var meta = _this.attr( 'dismissible-meta' ) || '';
|
78 |
-
|
79 |
-
$.ajax({
|
80 |
-
url: ajaxurl,
|
81 |
-
type: 'POST',
|
82 |
-
data: {
|
83 |
-
action : 'metform-notices',
|
84 |
-
id : id,
|
85 |
-
meta : meta,
|
86 |
-
time : time,
|
87 |
-
},
|
88 |
-
});
|
89 |
-
|
90 |
-
});
|
91 |
-
|
92 |
-
});
|
93 |
-
</script>
|
94 |
-
";
|
95 |
}
|
96 |
|
|
|
|
|
|
|
97 |
/**
|
98 |
-
*
|
99 |
*
|
|
|
100 |
* @return void
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
{
|
105 |
-
|
106 |
-
$defaults = [
|
107 |
-
'id' => '',
|
108 |
-
'type' => 'info',
|
109 |
-
'show_if' => true,
|
110 |
-
'message' => '',
|
111 |
-
'class' => 'metform-notice',
|
112 |
-
'dismissible' => false,
|
113 |
-
'btn' => [],
|
114 |
-
'dismissible-meta' => 'user',
|
115 |
-
'dismissible-time' => WEEK_IN_SECONDS,
|
116 |
-
'data' => '',
|
117 |
-
];
|
118 |
|
119 |
-
$
|
120 |
|
121 |
-
$
|
122 |
|
123 |
-
$
|
124 |
-
if (isset($notice['type'])) {
|
125 |
-
$classes[] = 'notice-' . $notice['type'];
|
126 |
-
}
|
127 |
|
128 |
-
|
129 |
-
if (true === $notice['dismissible']) {
|
130 |
-
$classes[] = 'is-dismissible';
|
131 |
|
132 |
-
|
133 |
-
$notice['data'] = ' dismissible-time=' . esc_attr($notice['dismissible-time']) . ' ';
|
134 |
-
}
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
$
|
139 |
-
|
140 |
-
|
141 |
-
$notice['id'] = $notice_id;
|
142 |
-
} else {
|
143 |
-
$notice_id = $notice['id'];
|
144 |
-
}
|
145 |
|
146 |
-
$
|
147 |
|
148 |
-
|
149 |
-
$notice['data'] .= ' dismissible-meta=' . esc_attr($notice['dismissible-meta']) . ' ';
|
150 |
-
if ('user' === $notice['dismissible-meta']) {
|
151 |
-
$expired = get_user_meta(get_current_user_id(), $notice_id, true);
|
152 |
-
} elseif ('transient' === $notice['dismissible-meta']) {
|
153 |
-
$expired = get_transient($notice_id);
|
154 |
-
}
|
155 |
|
156 |
-
|
157 |
-
if (isset($notice['show_if'])) {
|
158 |
-
if (true === $notice['show_if']) {
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
}
|
168 |
-
}
|
169 |
|
|
|
170 |
|
171 |
-
|
172 |
-
{
|
173 |
-
if (count($array) == count($array, COUNT_RECURSIVE)) {
|
174 |
-
return false;
|
175 |
-
} else {
|
176 |
-
return true;
|
177 |
-
}
|
178 |
}
|
179 |
|
|
|
|
|
180 |
/**
|
181 |
-
*
|
182 |
*
|
183 |
-
* @param
|
184 |
* @return void
|
185 |
-
* @since 1.0.0
|
186 |
*/
|
187 |
-
public
|
188 |
-
|
189 |
-
?>
|
190 |
-
<div id="<?php echo esc_attr($notice['id']); ?>" class="<?php echo esc_attr($notice['classes']); ?>" <?php echo $notice['data']; ?>>
|
191 |
-
<p>
|
192 |
-
<?php echo $notice['message']; ?>
|
193 |
-
</p>
|
194 |
|
195 |
-
|
|
|
|
|
|
|
|
|
196 |
|
197 |
-
|
|
|
198 |
|
199 |
-
|
|
|
|
|
200 |
|
201 |
-
|
|
|
202 |
|
203 |
-
|
|
|
|
|
|
|
204 |
|
205 |
-
|
|
|
206 |
|
207 |
-
|
|
|
|
|
|
|
|
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
</p>
|
212 |
|
213 |
-
|
|
|
214 |
|
|
|
215 |
|
216 |
-
|
|
|
217 |
|
218 |
-
|
219 |
-
|
220 |
-
</p>
|
221 |
|
222 |
-
|
|
|
223 |
|
|
|
224 |
|
225 |
-
<?php endforeach; ?>
|
226 |
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
|
230 |
|
231 |
-
<?php else : ?>
|
232 |
-
<p>
|
233 |
-
<a href="<?php echo esc_url($notice['btn']['url']); ?>" class="<?php echo esc_html(isset($notice['btn']['style']['class']) ? $notice['btn']['style']['class'] : 'button-primary'); ?>"><?php echo esc_html($notice['btn']['label']); ?></a>
|
234 |
-
</p>
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
240 |
}
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
namespace Wpmet\Notice;
|
3 |
|
4 |
+
defined( 'ABSPATH' ) || exit;
|
5 |
|
6 |
+
class Notice{
|
7 |
|
8 |
+
/**
|
9 |
+
* Unique ID to identify each notice
|
10 |
+
*
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
+
protected $notice_id;
|
|
|
|
|
|
|
14 |
|
15 |
+
/**
|
16 |
+
* Plugin text-domain
|
17 |
+
*
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
protected $text_domain;
|
21 |
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Unique ID
|
25 |
+
*
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
protected $unique_id;
|
29 |
|
30 |
+
|
31 |
/**
|
32 |
+
* Notice div container's class
|
33 |
*
|
34 |
+
* @var string
|
35 |
*/
|
36 |
+
protected $class;
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Single button's data
|
41 |
+
*
|
42 |
+
* @var array
|
43 |
+
*/
|
44 |
+
protected $button;
|
45 |
|
46 |
+
|
47 |
/**
|
48 |
+
* Size class
|
49 |
*
|
50 |
+
* @var array
|
|
|
51 |
*/
|
52 |
+
protected $size;
|
|
|
53 |
|
54 |
+
|
55 |
+
/**
|
56 |
+
* List of all buttons with it's config data
|
57 |
+
*
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
protected $buttons;
|
61 |
|
62 |
+
/**
|
63 |
+
* Notice title
|
64 |
+
*
|
65 |
+
* @var string
|
66 |
+
*/
|
67 |
+
protected $title;
|
68 |
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Notice message
|
72 |
+
*
|
73 |
+
* @var string
|
74 |
+
*/
|
75 |
+
protected $message;
|
76 |
|
77 |
+
/**
|
78 |
+
* Left logo
|
79 |
+
*
|
80 |
+
* @var string
|
81 |
+
*/
|
82 |
+
protected $logo;
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Left logo style
|
86 |
+
*
|
87 |
+
* @var string
|
88 |
+
*/
|
89 |
+
protected $logo_style;
|
90 |
|
|
|
|
|
91 |
|
92 |
/**
|
93 |
+
* Left logo style
|
94 |
+
*
|
95 |
+
* @var string
|
96 |
+
*/
|
97 |
+
protected $dismissible;
|
98 |
+
|
99 |
+
protected $expired_time;
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* html markup for notice
|
105 |
+
*
|
106 |
+
* @var string
|
107 |
+
*/
|
108 |
+
protected $html;
|
109 |
+
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Constractor
|
113 |
*
|
114 |
* @return void
|
|
|
115 |
*/
|
116 |
+
public function __construct(){
|
117 |
+
add_action( 'admin_footer', [ $this, 'enqueue_scripts' ], 9999);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
|
120 |
+
|
121 |
+
// config
|
122 |
+
|
123 |
/**
|
124 |
+
* Configures all setter variables
|
125 |
*
|
126 |
+
* @param string $prefix
|
127 |
* @return void
|
128 |
+
*/
|
129 |
+
public function config(string $text_domain = '', string $unique_id = ''){
|
130 |
+
$this->text_domain = $text_domain;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
+
$this->unique_id = $unique_id;
|
133 |
|
134 |
+
$this->notice_id = $text_domain . '-' . $unique_id;
|
135 |
|
136 |
+
$this->dismissible = false; // false, user, global
|
|
|
|
|
|
|
137 |
|
138 |
+
$this->expired_time = 1;
|
|
|
|
|
139 |
|
140 |
+
$this->html = '';
|
|
|
|
|
141 |
|
142 |
+
$this->title = '';
|
143 |
+
|
144 |
+
$this->message = '';
|
145 |
+
|
146 |
+
$this->class = '';
|
|
|
|
|
|
|
|
|
147 |
|
148 |
+
$this->logo = '';
|
149 |
|
150 |
+
$this->logo_style = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
+
$this->size = [ ];
|
|
|
|
|
153 |
|
154 |
+
$this->button = [
|
155 |
+
'default_class' => 'button',
|
156 |
+
'class' => 'button-secondary', // button-primary button-secondary button-small button-large button-link
|
157 |
+
'text' => 'Button',
|
158 |
+
'url' => '#',
|
159 |
+
'icon' => ''
|
160 |
+
];
|
|
|
|
|
161 |
|
162 |
+
$this->buttons = [];
|
163 |
|
164 |
+
return $this;
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
+
// setters begin
|
168 |
+
|
169 |
/**
|
170 |
+
* Adds classes to the container
|
171 |
*
|
172 |
+
* @param string $classname
|
173 |
* @return void
|
|
|
174 |
*/
|
175 |
+
public function add_class(string $classname = ''){
|
176 |
+
$this->class .= $classname;
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
|
181 |
+
public function add_type(string $type = ''){
|
182 |
+
$this->class .= 'notice-' . $type;
|
183 |
|
184 |
+
return $this;
|
185 |
+
}
|
186 |
|
187 |
+
public function add_button(array $button = []){
|
188 |
+
$button = array_merge($this->button, $button);
|
189 |
+
$this->buttons[] = $button;
|
190 |
|
191 |
+
return $this;
|
192 |
+
}
|
193 |
|
194 |
+
public function add_id($id){
|
195 |
+
$this->notice_id = $id;
|
196 |
+
return $this;
|
197 |
+
}
|
198 |
|
199 |
+
public function add_title(string $title = ''){
|
200 |
+
$this->title .= $title;
|
201 |
|
202 |
+
return $this;
|
203 |
+
}
|
204 |
+
|
205 |
+
public function add_message(string $message = ''){
|
206 |
+
$this->message .= $message;
|
207 |
|
208 |
+
return $this;
|
209 |
+
}
|
|
|
210 |
|
211 |
+
public function add_logo(string $logo = '', string $logo_style = ""){
|
212 |
+
$this->logo = $logo;
|
213 |
|
214 |
+
$this->logo_style = $logo_style;
|
215 |
|
216 |
+
return $this;
|
217 |
+
}
|
218 |
|
219 |
+
public function add_html(string $html = ''){
|
220 |
+
$this->html .= $html;
|
|
|
221 |
|
222 |
+
return $this;
|
223 |
+
}
|
224 |
|
225 |
+
// setters ends
|
226 |
|
|
|
227 |
|
228 |
+
// group getter
|
229 |
+
public function get_data(){
|
230 |
+
return [
|
231 |
+
'message' => $this->message,
|
232 |
+
'title' => $this->title,
|
233 |
+
'buttons' => $this->buttons,
|
234 |
+
'class' => $this->class,
|
235 |
+
'html' => $this->html,
|
236 |
+
];
|
237 |
+
}
|
238 |
|
239 |
|
240 |
|
|
|
|
|
|
|
|
|
241 |
|
242 |
+
public function init(){
|
243 |
+
if(!is_admin()){
|
244 |
+
return;
|
245 |
+
}
|
246 |
+
add_action( 'admin_notices', [$this, 'get_notice'] );
|
247 |
+
add_action( 'wp_ajax_wp-advanced-notices', [ $this, 'dismiss_ajax_call' ] );
|
248 |
}
|
249 |
+
|
250 |
+
public function get_notice(){
|
251 |
+
|
252 |
+
// dismissible conditions
|
253 |
+
if ( 'user' === $this->dismissible) {
|
254 |
+
$expired = get_user_meta( get_current_user_id(), $this->notice_id, true );
|
255 |
+
} elseif ( 'global' === $this->dismissible ) {
|
256 |
+
$expired = get_transient( $this->notice_id );
|
257 |
+
}else{
|
258 |
+
$expired = '';
|
259 |
+
}
|
260 |
+
|
261 |
+
// echo $expired; exit;
|
262 |
+
|
263 |
+
// notice visible after transient expire.
|
264 |
+
if ( false === $this->notice_id ) {
|
265 |
+
$this->generate_html();
|
266 |
+
}else{
|
267 |
+
// is transient expired?
|
268 |
+
if ( false === $expired || empty( $expired ) ) {
|
269 |
+
$this->generate_html();
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
public function dismissible($scope, $time){
|
276 |
+
$this->dismissible = $scope;
|
277 |
+
$this->expired_time = $time;
|
278 |
+
|
279 |
+
return $this;
|
280 |
+
}
|
281 |
+
|
282 |
+
public function dismiss_ajax_call() {
|
283 |
+
$notice_id = ( isset( $_POST['notice_id'] ) ) ? $_POST['notice_id'] : '';
|
284 |
+
$dismissible = ( isset( $_POST['dismissible'] ) ) ? $_POST['dismissible'] : '';
|
285 |
+
$expired_time = ( isset( $_POST['expired_time'] ) ) ? $_POST['expired_time'] : '';
|
286 |
+
print_r([$notice_id, $dismissible, $expired_time]);
|
287 |
+
|
288 |
+
if ( ! empty( $notice_id ) ) {
|
289 |
+
if ( 'user' === $dismissible ) {
|
290 |
+
update_user_meta( get_current_user_id(), $notice_id, true );
|
291 |
+
} else {
|
292 |
+
set_transient( $notice_id, true, $expired_time );
|
293 |
+
}
|
294 |
+
|
295 |
+
wp_send_json_success();
|
296 |
+
}
|
297 |
+
|
298 |
+
wp_send_json_error();
|
299 |
+
}
|
300 |
+
|
301 |
+
public function generate_html() {
|
302 |
+
|
303 |
+
?>
|
304 |
+
<div
|
305 |
+
id="<?php echo esc_attr($this->notice_id); ?>"
|
306 |
+
class="notice wp-advanced-notice notice-<?php echo esc_attr($this->notice_id . ' ' .$this->class); ?> <?php echo (false === $this->dismissible ? '' : 'is-dismissible') ;?>"
|
307 |
+
|
308 |
+
expired_time="<?php echo ($this->expired_time); ?>"
|
309 |
+
dismissible="<?php echo ($this->dismissible); ?>"
|
310 |
+
>
|
311 |
+
<?php if(!empty($this->logo)):?>
|
312 |
+
<div class="notice-left-container alignleft">
|
313 |
+
<p><img style="margin-right:15px; <?php echo esc_attr($this->logo_style); ?>" src="<?php echo esc_url($this->logo);?>" /></p>
|
314 |
+
</div>
|
315 |
+
<?php endif; ?>
|
316 |
+
|
317 |
+
<div class="notice-right-container">
|
318 |
+
|
319 |
+
<?php if(empty($this->html)): ?>
|
320 |
+
<div class="extension-message">
|
321 |
+
<?php echo (empty($this->title) ? '' : sprintf('<h3>%s</h3>', $this->title)); ?>
|
322 |
+
<?php echo ( $this->message );?>
|
323 |
+
</div>
|
324 |
+
|
325 |
+
<?php if(!empty($this->buttons)): ?>
|
326 |
+
<div class="submit">
|
327 |
+
<?php foreach($this->buttons as $button): ?>
|
328 |
+
<a id="<?php echo $button['id']; ?>" href="<?php echo esc_url($button['url']); ?>" class="wpmet-notice-buttons <?php echo esc_attr($button['class']); ?>">
|
329 |
+
<?php if(!empty($button['icon'])) :?>
|
330 |
+
<i class="notice-icon <?php echo esc_attr($button['icon']); ?>"></i>
|
331 |
+
<?php endif; ?>
|
332 |
+
<?php echo esc_html($button['text']);?>
|
333 |
+
</a>
|
334 |
+
|
335 |
+
<?php endforeach; ?>
|
336 |
+
</div>
|
337 |
+
<?php endif;?>
|
338 |
+
|
339 |
+
<?php else:?>
|
340 |
+
<?php echo $this->html; ?>
|
341 |
+
<?php endif;?>
|
342 |
+
|
343 |
+
<?php if(false !== $this->dismissible): ?>
|
344 |
+
<button type="button" class="notice-dismiss">
|
345 |
+
<span class="screen-reader-text">x</span>
|
346 |
+
</button>
|
347 |
+
<?php endif;?>
|
348 |
+
|
349 |
+
</div>
|
350 |
+
<div style="clear:both"></div>
|
351 |
+
|
352 |
+
</div>
|
353 |
+
<?php
|
354 |
+
}
|
355 |
+
|
356 |
+
public function enqueue_scripts() {
|
357 |
+
echo "
|
358 |
+
<script>
|
359 |
+
jQuery(document).ready(function ($) {
|
360 |
+
$( '.wp-advanced-notice.is-dismissible' ).on( 'click', '.notice-dismiss', function() {
|
361 |
+
|
362 |
+
_this = $( this ).parents('.wp-advanced-notice').eq(0);
|
363 |
+
var notice_id = _this.attr( 'id' ) || '';
|
364 |
+
var expired_time = _this.attr( 'expired_time' ) || '';
|
365 |
+
var dismissible = _this.attr( 'dismissible' ) || '';
|
366 |
+
var x = $( this ).attr('class');
|
367 |
+
console.log({
|
368 |
+
_this, x, notice_id, expired_time, dismissible
|
369 |
+
});
|
370 |
+
// return;
|
371 |
+
$.ajax({
|
372 |
+
url: ajaxurl,
|
373 |
+
type: 'POST',
|
374 |
+
data: {
|
375 |
+
action : 'wp-advanced-notices',
|
376 |
+
notice_id : notice_id,
|
377 |
+
dismissible : dismissible,
|
378 |
+
expired_time : expired_time,
|
379 |
+
},
|
380 |
+
});
|
381 |
+
});
|
382 |
+
});
|
383 |
+
</script>
|
384 |
+
<style>
|
385 |
+
.notice .notice-icon{
|
386 |
+
display:inline-block;
|
387 |
+
}
|
388 |
+
.notice .notice-icon:before{
|
389 |
+
vertical-align: middle!important;
|
390 |
+
margin-top: -1px;
|
391 |
+
}
|
392 |
+
.wpmet-notice-buttons {
|
393 |
+
text-decoration:none;
|
394 |
+
}
|
395 |
+
.wpmet-notice-buttons > i{
|
396 |
+
margin-right: 3px;
|
397 |
+
|
398 |
+
}
|
399 |
+
|
400 |
+
.notice-right-container{
|
401 |
+
padding-top: 10px;
|
402 |
+
}
|
403 |
+
.notice-right-container .submit {
|
404 |
+
padding-top: 8px
|
405 |
+
|
406 |
+
}
|
407 |
+
|
408 |
+
</style>
|
409 |
+
";
|
410 |
+
}
|
411 |
+
|
412 |
+
|
413 |
+
private static $instance;
|
414 |
+
|
415 |
+
/**
|
416 |
+
* init
|
417 |
+
*
|
418 |
+
* @return void
|
419 |
+
*/
|
420 |
+
public static function instance($text_domain = null, $unique_id = null) {
|
421 |
+
if($text_domain == null){
|
422 |
+
return false;
|
423 |
+
}
|
424 |
+
|
425 |
+
if(!self::$instance) {
|
426 |
+
self::$instance = new self();
|
427 |
+
}
|
428 |
+
|
429 |
+
return self::$instance->config($text_domain, (is_null($unique_id) ? uniqid() : $unique_id));
|
430 |
+
}
|
431 |
+
}
|
utils/rating.php
CHANGED
@@ -52,6 +52,7 @@ class Rating
|
|
52 |
|
53 |
public function init()
|
54 |
{
|
|
|
55 |
if (current_user_can('update_plugins')) {
|
56 |
add_action('admin_footer', [$this, 'scripts'], 9999);
|
57 |
add_action("wp_ajax_never_show_message", [$this, "never_show_message"]);
|
@@ -80,7 +81,6 @@ class Rating
|
|
80 |
}
|
81 |
|
82 |
$this->is_used_in($this->days);
|
83 |
-
|
84 |
}
|
85 |
}
|
86 |
|
@@ -88,7 +88,6 @@ class Rating
|
|
88 |
return $this;
|
89 |
}
|
90 |
|
91 |
-
|
92 |
public function cron_activation()
|
93 |
{
|
94 |
if (!wp_next_scheduled($this->plugin_name . '_cronjob')) {
|
@@ -96,7 +95,6 @@ class Rating
|
|
96 |
}
|
97 |
}
|
98 |
|
99 |
-
|
100 |
private function action_on_fire()
|
101 |
{
|
102 |
return true;
|
@@ -156,46 +154,84 @@ class Rating
|
|
156 |
|
157 |
if ($diff_interval >= $days) {
|
158 |
|
159 |
-
$array['btn'] = [
|
160 |
-
[
|
161 |
-
'label' => 'Ok, you deserved it',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
'url' => $this->rating_url,
|
163 |
-
'
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
],
|
169 |
-
[
|
170 |
-
'label' => 'I already did',
|
171 |
'url' => '#',
|
172 |
-
'
|
173 |
-
|
174 |
-
|
175 |
-
'
|
176 |
-
]
|
177 |
-
[
|
178 |
-
'
|
179 |
-
'
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
182 |
'url' => '#',
|
183 |
-
'
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
'
|
193 |
-
'
|
194 |
-
'
|
195 |
-
'
|
196 |
-
'
|
197 |
-
|
198 |
-
|
|
|
199 |
}
|
200 |
}
|
201 |
|
@@ -230,48 +266,44 @@ class Rating
|
|
230 |
|
231 |
if ($diff_interval >= $days) {
|
232 |
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
'url' => $this->rating_url,
|
237 |
-
'
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
],
|
243 |
-
[
|
244 |
-
'label' => 'I already did',
|
245 |
'url' => '#',
|
246 |
-
'
|
247 |
-
|
248 |
-
|
249 |
-
'
|
250 |
-
]
|
251 |
-
[
|
252 |
-
'
|
253 |
-
'
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
256 |
'url' => '#',
|
257 |
-
'
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
Notice::push(
|
266 |
-
[
|
267 |
-
'id' => $this->plugin_name . '_plugin_rating_msg_used_in_day',
|
268 |
-
'type' => 'info',
|
269 |
-
'dismissible' => false,
|
270 |
-
'btn' => $btn,
|
271 |
-
'style' => $this->style,
|
272 |
-
'message' => "Awesome, you've been using {$plugin_name} for more {$diff_interval} days. May we ask you to give a 5-star rating on wordpress?",
|
273 |
-
]
|
274 |
-
);
|
275 |
}
|
276 |
}
|
277 |
|
52 |
|
53 |
public function init()
|
54 |
{
|
55 |
+
|
56 |
if (current_user_can('update_plugins')) {
|
57 |
add_action('admin_footer', [$this, 'scripts'], 9999);
|
58 |
add_action("wp_ajax_never_show_message", [$this, "never_show_message"]);
|
81 |
}
|
82 |
|
83 |
$this->is_used_in($this->days);
|
|
|
84 |
}
|
85 |
}
|
86 |
|
88 |
return $this;
|
89 |
}
|
90 |
|
|
|
91 |
public function cron_activation()
|
92 |
{
|
93 |
if (!wp_next_scheduled($this->plugin_name . '_cronjob')) {
|
95 |
}
|
96 |
}
|
97 |
|
|
|
98 |
private function action_on_fire()
|
99 |
{
|
100 |
return true;
|
154 |
|
155 |
if ($diff_interval >= $days) {
|
156 |
|
157 |
+
// $array['btn'] = [
|
158 |
+
// [
|
159 |
+
// 'label' => 'Ok, you deserved it',
|
160 |
+
// 'url' => $this->rating_url,
|
161 |
+
// 'style' => [
|
162 |
+
// 'class' => 'none'
|
163 |
+
// ],
|
164 |
+
// 'id' => 'btn_deserved'
|
165 |
+
//
|
166 |
+
// ],
|
167 |
+
// [
|
168 |
+
// 'label' => 'I already did',
|
169 |
+
// 'url' => '#',
|
170 |
+
// 'style' => [
|
171 |
+
// 'class' => 'none'
|
172 |
+
// ],
|
173 |
+
// 'id' => 'btn_already_did'
|
174 |
+
// ],
|
175 |
+
// [
|
176 |
+
// 'label' => 'No, not good enough',
|
177 |
+
// 'style' => [
|
178 |
+
// 'class' => 'none'
|
179 |
+
// ],
|
180 |
+
// 'url' => '#',
|
181 |
+
// 'id' => 'btn_not_good'
|
182 |
+
// ]
|
183 |
+
// ];
|
184 |
+
//
|
185 |
+
// $btn = $array['btn'];
|
186 |
+
|
187 |
+
$message = "Hello! Seems like you have used {$plugin_name} to build this website — Thanks a lot! <br>
|
188 |
+
Could you please do us a <b>big favor</b> and give it a <b>5-star</b> rating on WordPress? This would boost our motivation and help other users make a comfortable decision while choosing the {$plugin_name}";
|
189 |
+
|
190 |
+
\Wpmet\Notice\Notice::instance('metform', 'rating')
|
191 |
+
->dismissible('global', (60))
|
192 |
+
->add_id($this->plugin_name . '_plugin_rating_msg_used_in_day')
|
193 |
+
// ->add_title('Metform')
|
194 |
+
->add_message($message)
|
195 |
+
->add_logo('https://ps.w.org/metform/assets/icon-128x128.png?rev=2158538', "max-height: 100px")
|
196 |
+
->add_button([
|
197 |
'url' => $this->rating_url,
|
198 |
+
'text' => 'Ok, you deserved it',
|
199 |
+
'class' => 'button-primary',
|
200 |
+
'id' => 'btn_deserved',
|
201 |
+
])
|
202 |
+
->add_button([
|
|
|
|
|
|
|
203 |
'url' => '#',
|
204 |
+
'text' => 'I already did',
|
205 |
+
'class' => 'button-default',
|
206 |
+
'id' => 'btn_already_did',
|
207 |
+
'icon' => 'dashicons-before dashicons-smiley'
|
208 |
+
])
|
209 |
+
->add_button([
|
210 |
+
'url' => 'https://help.wpmet.com/',
|
211 |
+
'text' => 'I need support',
|
212 |
+
'class' => 'button-default',
|
213 |
+
'id' => '#',
|
214 |
+
'icon' => 'dashicons-before dashicons-sos',
|
215 |
+
])
|
216 |
+
->add_button([
|
217 |
'url' => '#',
|
218 |
+
'text' => 'No, not good enough',
|
219 |
+
'class' => 'button-default',
|
220 |
+
'id' => 'btn_not_good',
|
221 |
+
'icon' => 'dashicons-before dashicons-thumbs-down',
|
222 |
+
])
|
223 |
+
->init();
|
224 |
+
|
225 |
+
// Notice::push(
|
226 |
+
// [
|
227 |
+
// 'id' => $this->plugin_name . '_plugin_rating_msg_used_in_day',
|
228 |
+
// 'type' => 'info',
|
229 |
+
// 'dismissible' => false,
|
230 |
+
// 'btn' => $btn,
|
231 |
+
// 'style' => $this->style,
|
232 |
+
// 'message' => "Awesome, you've been using {$plugin_name} for more {$diff_interval} days. May we ask you to give a 5-star rating on wordpress?",
|
233 |
+
// ]
|
234 |
+
// );
|
235 |
}
|
236 |
}
|
237 |
|
266 |
|
267 |
if ($diff_interval >= $days) {
|
268 |
|
269 |
+
|
270 |
+
$message = "Hello! Seems like you have used {$plugin_name} to build this website — Thanks a lot! <br>
|
271 |
+
Could you please do us a <b>big favor</b> and give it a <b>5-star</b> rating on WordPress? This would boost our motivation and help other users make a comfortable decision while choosing the {$plugin_name}";
|
272 |
+
|
273 |
+
\Wpmet\Notice\Notice::instance('metform', 'rating')
|
274 |
+
->dismissible('global', (60))
|
275 |
+
->add_id($this->plugin_name . '_plugin_rating_msg_used_in_day')
|
276 |
+
->add_message($message)
|
277 |
+
->add_logo('https://ps.w.org/metform/assets/icon-128x128.png?rev=2158538', "max-height: 100px")
|
278 |
+
->add_button([
|
279 |
'url' => $this->rating_url,
|
280 |
+
'text' => 'Ok, you deserved it',
|
281 |
+
'class' => 'button-primary',
|
282 |
+
'id' => 'btn_deserved',
|
283 |
+
])
|
284 |
+
->add_button([
|
|
|
|
|
|
|
285 |
'url' => '#',
|
286 |
+
'text' => 'I already did',
|
287 |
+
'class' => 'button-default',
|
288 |
+
'id' => 'btn_already_did',
|
289 |
+
'icon' => 'dashicons-before dashicons-smiley'
|
290 |
+
])
|
291 |
+
->add_button([
|
292 |
+
'url' => 'https://help.wpmet.com/',
|
293 |
+
'text' => 'I need support',
|
294 |
+
'class' => 'button-default',
|
295 |
+
'id' => '#',
|
296 |
+
'icon' => 'dashicons-before dashicons-sos',
|
297 |
+
])
|
298 |
+
->add_button([
|
299 |
'url' => '#',
|
300 |
+
'text' => 'No, not good enough',
|
301 |
+
'class' => 'button-default',
|
302 |
+
'id' => 'btn_not_good',
|
303 |
+
'icon' => 'dashicons-before dashicons-thumbs-down',
|
304 |
+
])
|
305 |
+
->init();
|
306 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
}
|
308 |
}
|
309 |
|