PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.49
E2Pdf – Export Pdf Tool for WordPress v1.32.49
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
← All changes | classes/extension/e2pdf-wordpress.php +370 -197 1.32.311.32.49 View file →
@@ -14,12 +14,12 @@
14 14 // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledClassName
15 15 class Extension_E2pdf_Wordpress extends Model_E2pdf_Model {
16 16
17 17 private $options;
18 - private $info = array(
18 + private $info = [
19 19 'key' => 'wordpress',
20 20 'title' => 'WordPress',
21 - );
21 + ];
22 22
23 23 // info
24 24 public function info($key = false) {
25 25 if ($key && isset($this->info[$key])) {
@@ -24,11 +24,11 @@
24 24 public function info($key = false) {
25 25 if ($key && isset($this->info[$key])) {
26 26 return $this->info[$key];
27 27 } else {
28 - return array(
28 + return [
29 29 $this->info['key'] => $this->info['title'],
30 - );
30 + ];
31 31 }
32 32 }
33 33
34 34 // active
@@ -74,9 +74,9 @@
74 74 $value = $this->options->$key;
75 75 } else {
76 76 switch ($key) {
77 77 case 'args':
78 - $value = array();
78 + $value = [];
79 79 break;
80 80 default:
81 81 $value = false;
82 82 break;
@@ -86,10 +86,10 @@
86 86 }
87 87
88 88 // items
89 89 public function items() {
90 - $items = array();
91 - $forms = get_post_types(array(), 'names');
90 + $items = [];
91 + $forms = get_post_types([], 'names');
92 92 foreach ($forms as $form) {
93 93 if ($form != 'attachment') {
94 94 $items[] = $this->item($form);
95 95 }
@@ -99,17 +99,17 @@
99 99 }
100 100
101 101 // datasets
102 102 public function datasets($item_id = false, $name = false) {
103 - $datasets = array();
103 + $datasets = [];
104 104 if ($item_id) {
105 105 if ($item_id == '-3') {
106 106 $entries = get_users(
107 - array(
108 - 'fields' => array(
107 + [
108 + 'fields' => [
109 109 'ID', 'user_login',
110 - ),
111 - )
110 + ],
111 + ]
112 112 );
113 113
114 114 if ($entries) {
115 115 $this->set('item', $item_id);
@@ -118,12 +118,12 @@
118 118 $entry_title = $this->render($name);
119 119 if (!$entry_title) {
120 120 $entry_title = isset($entry->user_login) && $entry->user_login ? $entry->user_login : $entry->ID;
121 121 }
122 - $datasets[] = array(
122 + $datasets[] = [
123 123 'key' => $entry->ID,
124 124 'value' => $entry_title,
125 - );
125 + ];
126 126 }
127 127 }
128 128 } else {
129 129 $wpml = $this->helper->load('translator')->isWPML();
@@ -129,23 +129,23 @@
129 129 $wpml = $this->helper->load('translator')->isWPML();
130 130 if ($wpml) {
131 131 $lang = apply_filters('wpml_current_language', null);
132 132 $entries = get_posts(
133 - array(
133 + [
134 134 'post_type' => $item_id,
135 135 'numberposts' => -1,
136 136 'post_status' => 'any',
137 137 'lang' => $lang,
138 138 'suppress_filters' => false,
139 - )
139 + ]
140 140 );
141 141 } else {
142 142 $entries = get_posts(
143 - array(
143 + [
144 144 'post_type' => $item_id,
145 145 'numberposts' => -1,
146 146 'post_status' => 'any',
147 - )
147 + ]
148 148 );
149 149 }
150 150 if ($entries) {
151 151 $this->set('item', $item_id);
@@ -154,12 +154,12 @@
154 154 $entry_title = $this->render($name);
155 155 if (!$entry_title) {
156 156 $entry_title = isset($entry->post_title) && $entry->post_title ? $entry->post_title : $entry->ID;
157 157 }
158 - $datasets[] = array(
158 + $datasets[] = [
159 159 'key' => $entry->ID,
160 160 'value' => $entry_title,
161 - );
161 + ];
162 162 }
163 163 }
164 164 }
165 165 }
@@ -174,18 +174,18 @@
174 174 }
175 175 $actions = new stdClass();
176 176 if ($this->get('item') == '-3') {
177 177 $actions->view = $this->helper->get_url(
178 - array(
178 + [
179 179 'user_id' => $dataset_id,
180 - ), 'user-edit.php?'
180 + ], 'user-edit.php?'
181 181 );
182 182 } else {
183 183 $actions->view = $this->helper->get_url(
184 - array(
184 + [
185 185 'post' => $dataset_id,
186 186 'action' => 'edit',
187 - ), 'post.php?'
187 + ], 'post.php?'
188 188 );
189 189 }
190 190 $actions->delete = false;
191 191 return $actions;
@@ -210,15 +210,15 @@
210 210 $item = new stdClass();
211 211 if ($item_id == '-3') {
212 212 $item->id = $item_id;
213 213 $item->name = __('Users');
214 - $item->url = $this->helper->get_url(array(), 'users.php');
214 + $item->url = $this->helper->get_url([], 'users.php');
215 215 } else {
216 216 $form = get_post_type_object($item_id);
217 217 if ($form) {
218 218 $item->id = $item_id;
219 219 $item->name = $form->label ? $form->label : $item_id;
220 - $item->url = $this->helper->get_url(array('post_type' => $item_id), 'edit.php?');
220 + $item->url = $this->helper->get_url(['post_type' => $item_id], 'edit.php?');
221 221 } else {
222 222 $item->id = '';
223 223 $item->name = '';
224 224 $item->url = '';
@@ -228,99 +228,111 @@
228 228 }
229 229
230 230 // load filters
231 231 public function load_filters() {
232 - add_filter('the_content', array($this, 'filter_the_content'), 10, 2);
233 - add_filter('widget_text', array($this, 'filter_content_custom'));
234 - add_filter('widget_block_content', array($this, 'filter_content_custom'));
232 + add_filter('the_content', [$this, 'filter_the_content'], 10, 2);
233 + add_filter('widget_text', [$this, 'filter_content_custom']);
234 + add_filter('widget_block_content', [$this, 'filter_content_custom']);
235 235
236 236 /**
237 237 * Popup Maker – Popup for opt-ins, lead gen, & more
238 238 * https://wordpress.org/plugins/popup-maker/
239 239 */
240 - add_filter('pum_popup_content', array($this, 'filter_the_content'), 10, 2);
240 + add_filter('pum_popup_content', [$this, 'filter_the_content'], 10, 2);
241 241
242 242 /**
243 243 * Events Manager
244 244 * https://wordpress.org/plugins/events-manager/
245 245 */
246 - add_filter('em_event_output_placeholder', array($this, 'filter_content_custom'), 0);
247 - add_filter('em_event_output', array($this, 'filter_content_custom'));
248 - add_filter('em_booking_output_placeholder', array($this, 'filter_content_custom'), 0);
249 - add_filter('em_booking_output', array($this, 'filter_content_custom'));
250 - add_filter('em_location_output_placeholder', array($this, 'filter_content_custom'), 0);
251 - add_filter('em_location_output', array($this, 'filter_content_custom'));
252 - add_filter('em_category_output_placeholder', array($this, 'filter_content_custom'), 0);
246 + add_filter('em_event_output_placeholder', [$this, 'filter_content_custom'], 0);
247 + add_filter('em_event_output', [$this, 'filter_content_custom']);
248 + add_filter('em_booking_output_placeholder', [$this, 'filter_content_custom'], 0);
249 + add_filter('em_booking_output', [$this, 'filter_content_custom']);
250 + add_filter('em_location_output_placeholder', [$this, 'filter_content_custom'], 0);
251 + add_filter('em_location_output', [$this, 'filter_content_custom']);
252 + add_filter('em_category_output_placeholder', [$this, 'filter_content_custom'], 0);
253 253
254 254 /**
255 255 * Beaver Builder – WordPress Page Builder
256 256 * https://wordpress.org/plugins/beaver-builder-lite-version/
257 257 */
258 - add_filter('fl_builder_before_render_shortcodes', array($this, 'filter_content_loop'));
258 + add_filter('fl_builder_before_render_shortcodes', [$this, 'filter_content_loop']);
259 259
260 260 /**
261 261 * WPBakery Page Builder Image Object Link
262 262 */
263 - add_filter('vc_map_get_attributes', array($this, 'filter_vc_map_get_attributes'), 10, 2);
263 + add_filter('vc_map_get_attributes', [$this, 'filter_vc_map_get_attributes'], 10, 2);
264 264
265 265 /**
266 266 * Flatsome theme global tab content
267 267 */
268 - add_filter('theme_mod_tab_content', array($this, 'filter_content_custom'));
268 + add_filter('theme_mod_tab_content', [$this, 'filter_content_custom']);
269 269
270 270 /**
271 271 * MemberPress Mail attachments
272 272 * https://memberpress.com/
273 273 */
274 - add_filter('mepr_email_send_attachments', array($this, 'filter_mepr_email_send_attachments'), 10, 4);
275 - add_filter('the_content', array($this, 'filter_mepr_the_content'), 99);
276 - add_filter('mepr_custom_thankyou_message', array($this, 'filter_mepr_custom_thankyou_message'));
274 + add_filter('mepr_email_send_attachments', [$this, 'filter_mepr_email_send_attachments'], 10, 4);
275 + add_filter('the_content', [$this, 'filter_mepr_the_content'], 99);
276 + add_filter('mepr_custom_thankyou_message', [$this, 'filter_mepr_custom_thankyou_message']);
277 277
278 278 /**
279 279 * Thrive Theme Builder dynamic shortcode support
280 280 */
281 - add_filter('thrive_theme_template_content', array($this, 'filter_thrive_theme_template_content'));
281 + add_filter('thrive_theme_template_content', [$this, 'filter_thrive_theme_template_content']);
282 282
283 283 /**
284 284 * WPBakery Page Builder Grid Item
285 285 * [e2pdf-download id="1" dataset="{{ post_data:ID }}"]
286 286 */
287 - add_filter('vc_basic_grid_items_list', array($this, 'filter_vc_basic_grid_items_list'));
287 + add_filter('vc_basic_grid_items_list', [$this, 'filter_vc_basic_grid_items_list']);
288 288
289 289 /**
290 290 * Themify Builder dynamic shortcode support
291 291 * https://wordpress.org/plugins/themify-builder/
292 292 */
293 - add_filter('themify_builder_module_content', array($this, 'filter_themify_builder_module_content'));
293 + add_filter('themify_builder_module_content', [$this, 'filter_themify_builder_module_content']);
294 294
295 295 /**
296 296 * Impreza theme by Up Solutions
297 297 * https://themeforest.net/item/impreza-retina-responsive-wordpress-theme/6434280
298 298 */
299 - add_filter('us_content_template_the_content', array($this, 'filter_content_custom'));
299 + add_filter('us_content_template_the_content', [$this, 'filter_content_custom']);
300 300
301 301 /**
302 302 * Cornerstone Builder
303 303 * https://theme.co/cornerstone/
304 304 */
305 - add_filter('cs_element_pre_render', array($this, 'filter_cs_element_pre_render'));
305 + add_filter('cs_element_pre_render', [$this, 'filter_cs_element_pre_render']);
306 306
307 307 /**
308 308 * Divi Theme Builder
309 309 * https://www.elegantthemes.com/
310 310 */
311 - add_filter('et_pb_module_content', array($this, 'filter_et_pb_module_content'), 30, 6);
311 + add_filter('et_pb_module_content', [$this, 'filter_et_pb_module_content'], 30, 6);
312 312
313 313 /**
314 314 * User Registration & Membership – Custom Registration Form, Login Form, and User Profile
315 315 * https://wordpress.org/plugins/user-registration/
316 316 */
317 - add_filter('user_registration_smart_tag_values', array($this, 'filter_user_registration_smart_tag_values'), 0);
317 + add_filter('user_registration_smart_tag_values', [$this, 'filter_user_registration_smart_tag_values'], 0);
318 318
319 + /**
320 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
321 + * https://wordpress.org/plugins/ultimate-member/
322 + */
323 + add_filter('um_email_send_message_content', [$this, 'filter_um_email_send_message_content']);
324 +
325 + /**
326 + * Shortcodes do not render when the Toolset template is used
327 + * https://toolset.com/
328 + */
329 + add_filter('wpv_filter_content_template_output', [$this, 'filter_wpv_filter_content_template_output']);
330 +
319 331 /* Hooks */
320 - add_filter('post_row_actions', array($this, 'hook_wordpress_row_actions'), 10, 2);
321 - add_filter('page_row_actions', array($this, 'hook_wordpress_row_actions'), 10, 2);
322 - add_filter('user_row_actions', array($this, 'hook_wordpress_row_actions'), 10, 2);
332 + add_filter('post_row_actions', [$this, 'hook_wordpress_row_actions'], 10, 2);
333 + add_filter('page_row_actions', [$this, 'hook_wordpress_row_actions'], 10, 2);
334 + add_filter('user_row_actions', [$this, 'hook_wordpress_row_actions'], 10, 2);
323 335 }
324 336
325 337 // load actions
326 338 public function load_actions() {
@@ -327,43 +339,50 @@
327 339 /**
328 340 * Elementor Website Builder – More than Just a Page Builder
329 341 * https://wordpress.org/plugins/elementor/
330 342 */
331 - add_action('elementor/widget/before_render_content', array($this, 'action_elementor_widget_before_render_content'));
332 - add_action('elementor/frontend/widget/before_render', array($this, 'action_elementor_widget_before_render_content'), 5);
343 + add_action('elementor/widget/before_render_content', [$this, 'action_elementor_widget_before_render_content']);
344 + add_action('elementor/frontend/widget/before_render', [$this, 'action_elementor_widget_before_render_content'], 5);
333 345
334 346 /**
335 347 * JetEngine: WordPress Plugin for Elementor
336 348 * https://crocoblock.com
337 349 */
338 - add_action('jet-engine/listing/grid/before-render', array($this, 'action_jet_engine_listing_grid_before_render'));
339 - add_action('jet-engine/listing/grid/after-render', array($this, 'action_jet_engine_listing_grid_after_render'));
350 + add_action('jet-engine/listing/grid/before-render', [$this, 'action_jet_engine_listing_grid_before_render']);
351 + add_action('jet-engine/listing/grid/after-render', [$this, 'action_jet_engine_listing_grid_after_render']);
340 352
341 353 /**
342 354 * Happy Addons for Elementor
343 355 * https://wordpress.org/plugins/happy-elementor-addons/ compatibility fix
344 356 */
345 - add_action('elementor/frontend/before_render', array($this, 'action_elementor_widget_before_render_content'), 0);
357 + add_action('elementor/frontend/before_render', [$this, 'action_elementor_widget_before_render_content'], 0);
346 358
347 359 /**
348 360 * MemberPress Mail attachments remove
349 361 * https://memberpress.com/
350 362 */
351 - add_action('mepr_email_sent', array($this, 'action_mepr_email_sent'), 10, 3);
363 + add_action('mepr_email_sent', [$this, 'action_mepr_email_sent']);
352 364
353 365 /**
354 366 * User Registration & Membership – Custom Registration Form, Login Form, and User Profile
355 367 * https://wordpress.org/plugins/user-registration/
356 368 */
357 - add_action('user_registration_email_send_before', array($this, 'action_user_registration_email_send_before'));
358 - add_action('user_registration_email_send_after', array($this, 'action_user_registration_email_send_after'));
369 + add_action('user_registration_email_send_before', [$this, 'action_user_registration_email_send_before']);
370 + add_action('user_registration_email_send_after', [$this, 'action_user_registration_email_send_after']);
359 371
372 + /**
373 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
374 + * https://wordpress.org/plugins/ultimate-member/
375 + */
376 + add_action('um_before_email_notification_sending', [$this, 'action_um_before_email_notification_sending']);
377 + add_action('um_after_email_notification_sending', [$this, 'action_um_after_email_notification_sending']);
378 +
360 379 /* Hooks */
361 - add_action('add_meta_boxes', array($this, 'hook_wordpress_page_edit'));
380 + add_action('add_meta_boxes', [$this, 'hook_wordpress_page_edit']);
362 381 }
363 382
364 383 // render
365 - public function render($value, $field = array(), $convert_shortcodes = true, $raw = false) {
384 + public function render($value, $field = [], $convert_shortcodes = true, $raw = false) {
366 385 $value = $this->render_shortcodes($value, $field);
367 386 if (!$raw) {
368 387 $value = $this->strip_shortcodes($value);
369 388 $value = $this->convert_shortcodes($value, $convert_shortcodes, isset($field['type']) && $field['type'] == 'e2pdf-html' ? true : false);
@@ -372,9 +391,9 @@
372 391 return $value;
373 392 }
374 393
375 394 // render shortcodes
376 - public function render_shortcodes($value, $field = array()) {
395 + public function render_shortcodes($value, $field = []) {
377 396
378 397 $element_id = isset($field['element_id']) ? $field['element_id'] : false;
379 398
380 399 if ($this->verify()) {
@@ -383,9 +402,9 @@
383 402 * https://toolset.com/
384 403 */
385 404 do_action('wpv_action_wpv_set_top_current_post', $this->get('cached_post'));
386 405
387 - $wordpress_shortcodes = array(
406 + $wordpress_shortcodes = [
388 407 'id',
389 408 'post_author',
390 409 'post_date',
391 410 'post_date_gmt',
@@ -413,19 +432,19 @@
413 432 'get_the_post_thumbnail',
414 433 'get_the_post_thumbnail_url',
415 434 'get_permalink',
416 435 'get_post_permalink',
417 - );
436 + ];
418 437
419 438 if (false !== strpos($value, '[')) {
420 439 $value = $this->helper->load('field')->pre_shortcodes($value, $this, $field);
421 440 $value = $this->helper->load('field')->inner_shortcodes($value, $this, $field);
422 441 if ($this->get('item') == '-3') {
423 - $shortcode_tags = array(
442 + $shortcode_tags = [
424 443 'acf',
425 - );
444 + ];
426 445 } else {
427 - $shortcode_tags = array(
446 + $shortcode_tags = [
428 447 'meta',
429 448 'terms',
430 449 'e2pdf-wp',
431 450 'e2pdf-wp-term',
@@ -430,9 +449,9 @@
430 449 'e2pdf-wp',
431 450 'e2pdf-wp-term',
432 451 'e2pdf-content',
433 452 'acf',
434 - );
453 + ];
435 454 $shortcode_tags = array_merge($shortcode_tags, $wordpress_shortcodes);
436 455 }
437 456 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches);
438 457 $tagnames = array_intersect($shortcode_tags, $matches[1]);
@@ -457,9 +476,9 @@
457 476 $shortcode[3] .= ' terms=true';
458 477 }
459 478 if (substr($shortcode_value, -11) === '[/e2pdf-wp]' || substr($shortcode_value, -8) === '[/terms]' || substr($shortcode_value, -7) === '[/meta]') {
460 479 if ($shortcode[5]) {
461 - $shortcode[5] = $this->render($shortcode[5], array(), false);
480 + $shortcode[5] = $this->render($shortcode[5], [], false);
462 481 }
463 482 $value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wp]', $value);
464 483 } else {
465 484 $value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']', $value);
@@ -466,9 +485,9 @@
466 485 }
467 486 } elseif ($shortcode[2] === 'e2pdf-wp-term') {
468 487 if (substr($shortcode_value, -16) === '[/e2pdf-wp-term]') {
469 488 if ($shortcode[5]) {
470 - $shortcode[5] = $this->render($shortcode[5], array(), false);
489 + $shortcode[5] = $this->render($shortcode[5], [], false);
471 490 }
472 491 $value = str_replace($shortcode_value, '[e2pdf-wp-term' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wp-term]', $value);
473 492 }
474 493 } elseif (in_array($shortcode[2], $wordpress_shortcodes, false)) {
@@ -491,9 +510,9 @@
491 510 }
492 511 $value = $this->helper->load('field')->wrapper_shortcodes($value, $this, $field);
493 512 }
494 513
495 - add_filter('frm_filter_view', array($this, 'filter_frm_filter_view'));
514 + add_filter('frm_filter_view', [$this, 'filter_frm_filter_view']);
496 515 $value = $this->helper->load('field')->do_shortcodes($value, $this, $field);
497 516 $value = $this->helper->load('field')->render(
498 517 apply_filters('e2pdf_extension_render_shortcodes_pre_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false),
499 518 $this,
@@ -498,9 +517,9 @@
498 517 apply_filters('e2pdf_extension_render_shortcodes_pre_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false),
499 518 $this,
500 519 $field
501 520 );
502 - remove_filter('frm_filter_view', array($this, 'filter_frm_filter_view'));
521 + remove_filter('frm_filter_view', [$this, 'filter_frm_filter_view']);
503 522 }
504 523 return apply_filters(
505 524 'e2pdf_extension_render_shortcodes_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false
506 525 );
@@ -529,16 +548,16 @@
529 548
530 549 // auto
531 550 public function auto() {
532 551
533 - $response = array();
534 - $elements = array();
552 + $response = [];
553 + $elements = [];
535 554
536 555 if ($this->get('item') == '-3') {
537 - $elements[] = array(
556 + $elements[] = [
538 557 'type' => 'e2pdf-html',
539 558 'block' => true,
540 - 'properties' => array(
559 + 'properties' => [
541 560 'top' => '20',
542 561 'left' => '20',
543 562 'right' => '20',
544 563 'width' => '100%',
@@ -543,14 +562,14 @@
543 562 'right' => '20',
544 563 'width' => '100%',
545 564 'height' => 'auto',
546 565 'value' => '<h1>[e2pdf-user key="user_login"]</h1>',
547 - ),
548 - );
549 - $elements[] = array(
566 + ],
567 + ];
568 + $elements[] = [
550 569 'type' => 'e2pdf-image',
551 570 'block' => true,
552 - 'properties' => array(
571 + 'properties' => [
553 572 'top' => '20',
554 573 'left' => '20',
555 574 'right' => '20',
556 575 'width' => '100%',
@@ -556,14 +575,14 @@
556 575 'width' => '100%',
557 576 'height' => '100',
558 577 'vertical' => 'top',
559 578 'value' => '[e2pdf-user key="get_avatar_url"]',
560 - ),
561 - );
562 - $elements[] = array(
579 + ],
580 + ];
581 + $elements[] = [
563 582 'type' => 'e2pdf-html',
564 583 'block' => true,
565 - 'properties' => array(
584 + 'properties' => [
566 585 'top' => '20',
567 586 'left' => '20',
568 587 'right' => '20',
569 588 'width' => '100%',
@@ -568,14 +587,14 @@
568 587 'right' => '20',
569 588 'width' => '100%',
570 589 'height' => 'auto',
571 590 'value' => 'ID: [e2pdf-user key="ID"]',
572 - ),
573 - );
574 - $elements[] = array(
591 + ],
592 + ];
593 + $elements[] = [
575 594 'type' => 'e2pdf-html',
576 595 'block' => true,
577 - 'properties' => array(
596 + 'properties' => [
578 597 'top' => '20',
579 598 'left' => '20',
580 599 'right' => '20',
581 600 'width' => '100%',
@@ -580,14 +599,14 @@
580 599 'right' => '20',
581 600 'width' => '100%',
582 601 'height' => 'auto',
583 602 'value' => 'First Name: [e2pdf-user key="user_firstname"]',
584 - ),
585 - );
586 - $elements[] = array(
603 + ],
604 + ];
605 + $elements[] = [
587 606 'type' => 'e2pdf-html',
588 607 'block' => true,
589 - 'properties' => array(
608 + 'properties' => [
590 609 'top' => '20',
591 610 'left' => '20',
592 611 'right' => '20',
593 612 'width' => '100%',
@@ -592,14 +611,14 @@
592 611 'right' => '20',
593 612 'width' => '100%',
594 613 'height' => 'auto',
595 614 'value' => 'Last Name: [e2pdf-user key="user_lastname"]',
596 - ),
597 - );
598 - $elements[] = array(
615 + ],
616 + ];
617 + $elements[] = [
599 618 'type' => 'e2pdf-html',
600 619 'block' => true,
601 - 'properties' => array(
620 + 'properties' => [
602 621 'top' => '20',
603 622 'left' => '20',
604 623 'right' => '20',
605 624 'width' => '100%',
@@ -604,14 +623,14 @@
604 623 'right' => '20',
605 624 'width' => '100%',
606 625 'height' => 'auto',
607 626 'value' => 'Email: [e2pdf-user key="user_email"]',
608 - ),
609 - );
610 - $elements[] = array(
627 + ],
628 + ];
629 + $elements[] = [
611 630 'type' => 'e2pdf-html',
612 631 'block' => true,
613 - 'properties' => array(
632 + 'properties' => [
614 633 'top' => '20',
615 634 'left' => '20',
616 635 'right' => '20',
617 636 'width' => '100%',
@@ -616,15 +635,15 @@
616 635 'right' => '20',
617 636 'width' => '100%',
618 637 'height' => 'auto',
619 638 'value' => 'Registered: [e2pdf-user key="user_registered"]',
620 - ),
621 - );
639 + ],
640 + ];
622 641 } else {
623 - $elements[] = array(
642 + $elements[] = [
624 643 'type' => 'e2pdf-html',
625 644 'block' => true,
626 - 'properties' => array(
645 + 'properties' => [
627 646 'top' => '20',
628 647 'left' => '20',
629 648 'right' => '20',
630 649 'width' => '100%',
@@ -629,14 +648,14 @@
629 648 'right' => '20',
630 649 'width' => '100%',
631 650 'height' => 'auto',
632 651 'value' => '<h1>[e2pdf-wp key="post_title"]</h1>',
633 - ),
634 - );
635 - $elements[] = array(
652 + ],
653 + ];
654 + $elements[] = [
636 655 'type' => 'e2pdf-html',
637 656 'block' => true,
638 - 'properties' => array(
657 + 'properties' => [
639 658 'top' => '20',
640 659 'left' => '20',
641 660 'right' => '20',
642 661 'width' => '100%',
@@ -641,14 +660,14 @@
641 660 'right' => '20',
642 661 'width' => '100%',
643 662 'height' => 'auto',
644 663 'value' => 'Post name: [e2pdf-wp key="post_name"]',
645 - ),
646 - );
647 - $elements[] = array(
664 + ],
665 + ];
666 + $elements[] = [
648 667 'type' => 'e2pdf-html',
649 668 'block' => true,
650 - 'properties' => array(
669 + 'properties' => [
651 670 'top' => '20',
652 671 'left' => '20',
653 672 'right' => '20',
654 673 'width' => '100%',
@@ -653,14 +672,14 @@
653 672 'right' => '20',
654 673 'width' => '100%',
655 674 'height' => 'auto',
656 675 'value' => 'Post type: [e2pdf-wp key="post_type"]',
657 - ),
658 - );
659 - $elements[] = array(
676 + ],
677 + ];
678 + $elements[] = [
660 679 'type' => 'e2pdf-html',
661 680 'block' => true,
662 - 'properties' => array(
681 + 'properties' => [
663 682 'top' => '20',
664 683 'left' => '20',
665 684 'right' => '20',
666 685 'width' => '100%',
@@ -665,14 +684,14 @@
665 684 'right' => '20',
666 685 'width' => '100%',
667 686 'height' => 'auto',
668 687 'value' => 'ID: [e2pdf-wp key="id"]',
669 - ),
670 - );
671 - $elements[] = array(
688 + ],
689 + ];
690 + $elements[] = [
672 691 'type' => 'e2pdf-html',
673 692 'block' => true,
674 - 'properties' => array(
693 + 'properties' => [
675 694 'top' => '20',
676 695 'left' => '20',
677 696 'right' => '20',
678 697 'width' => '100%',
@@ -677,14 +696,14 @@
677 696 'right' => '20',
678 697 'width' => '100%',
679 698 'height' => 'auto',
680 699 'value' => 'Author: [e2pdf-wp key="post_author"]',
681 - ),
682 - );
683 - $elements[] = array(
700 + ],
701 + ];
702 + $elements[] = [
684 703 'type' => 'e2pdf-html',
685 704 'block' => true,
686 - 'properties' => array(
705 + 'properties' => [
687 706 'top' => '20',
688 707 'left' => '20',
689 708 'right' => '20',
690 709 'width' => '100%',
@@ -689,14 +708,14 @@
689 708 'right' => '20',
690 709 'width' => '100%',
691 710 'height' => '300',
692 711 'value' => '[e2pdf-wp key="post_content"]',
693 - ),
694 - );
695 - $elements[] = array(
712 + ],
713 + ];
714 + $elements[] = [
696 715 'type' => 'e2pdf-html',
697 716 'block' => true,
698 - 'properties' => array(
717 + 'properties' => [
699 718 'top' => '20',
700 719 'left' => '20',
701 720 'right' => '20',
702 721 'width' => '100%',
@@ -701,14 +720,14 @@
701 720 'right' => '20',
702 721 'width' => '100%',
703 722 'height' => 'auto',
704 723 'value' => 'Created: [e2pdf-wp key="post_date"]',
705 - ),
706 - );
707 - $elements[] = array(
724 + ],
725 + ];
726 + $elements[] = [
708 727 'type' => 'e2pdf-html',
709 728 'block' => true,
710 - 'properties' => array(
729 + 'properties' => [
711 730 'top' => '20',
712 731 'left' => '20',
713 732 'right' => '20',
714 733 'width' => '100%',
@@ -713,17 +732,17 @@
713 732 'right' => '20',
714 733 'width' => '100%',
715 734 'height' => 'auto',
716 735 'value' => 'Modified: [e2pdf-wp key="post_modified"]',
717 - ),
718 - );
736 + ],
737 + ];
719 738 }
720 - $response['page'] = array(
739 + $response['page'] = [
721 740 'bottom' => '20',
722 741 'top' => '20',
723 742 'left' => '20',
724 743 'right' => '20',
725 - );
744 + ];
726 745
727 746 $response['elements'] = $elements;
728 747 return $response;
729 748 }
@@ -762,9 +781,9 @@
762 781 /**
763 782 * Delete attachments that were sent by MemberPress email
764 783 * https://memberpress.com/
765 784 */
766 - public function action_mepr_email_sent($email, $values, $attachments) {
785 + public function action_mepr_email_sent() {
767 786 $files = $this->helper->get('wordpress_attachments_mepr');
768 787 if (is_array($files) && !empty($files)) {
769 788 foreach ($files as $key => $file) {
770 789 $this->helper->delete_dir(dirname($file) . '/');
@@ -774,14 +793,14 @@
774 793 }
775 794
776 795 // registration email send before action
777 796 public function action_user_registration_email_send_before() {
778 - add_filter('wp_mail', array($this, 'filter_wp_mail'), 11);
797 + add_filter('wp_mail', [$this, 'filter_wp_mail'], 11);
779 798 }
780 799
781 800 // registration email send after action
782 801 public function action_user_registration_email_send_after() {
783 - remove_filter('wp_mail', array($this, 'filter_wp_mail'), 11);
802 + remove_filter('wp_mail', [$this, 'filter_wp_mail'], 11);
784 803 $files = $this->helper->get('wordpress_attachments');
785 804 if (is_array($files) && !empty($files)) {
786 805 foreach ($files as $key => $file) {
787 806 $this->helper->delete_dir(dirname($file) . '/');
@@ -789,8 +808,76 @@
789 808 $this->helper->deset('wordpress_attachments');
790 809 }
791 810 }
792 811
812 + /**
813 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
814 + * https://wordpress.org/plugins/ultimate-member/
815 + */
816 + public function action_um_before_email_notification_sending() {
817 + add_filter('wp_mail', [$this, 'filter_wp_mail_um'], 11);
818 + }
819 +
820 + /**
821 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
822 + * https://wordpress.org/plugins/ultimate-member/
823 + */
824 + public function action_um_after_email_notification_sending() {
825 + remove_filter('wp_mail', [$this, 'filter_wp_mail_um'], 11);
826 + $files = $this->helper->get('wordpress_attachments_um_del');
827 + if (is_array($files) && !empty($files)) {
828 + foreach ($files as $key => $file) {
829 + $this->helper->delete_dir(dirname($file) . '/');
830 + }
831 + $this->helper->deset('wordpress_attachments_um');
832 + $this->helper->deset('wordpress_attachments_um_del');
833 + }
834 + }
835 +
836 + /**
837 + * Enable / Disable pre-rendering of E2Pdf shortcodes in the Toolset template.
838 + * https://toolset.com/
839 + */
840 + public function filter_wpv_filter_content_template_output($content) {
841 + add_filter('render_block', [$this, 'filter_render_block_toolset_disable'], 9, 2);
842 + add_filter('render_block', [$this, 'filter_render_block_toolset_enable'], 11, 2);
843 + return $content;
844 + }
845 +
846 + /**
847 + * Disable pre-rendering of E2Pdf shortcodes in the Toolset template.
848 + * https://toolset.com/
849 + */
850 + public function filter_render_block_toolset_disable($block_content, $block) {
851 + if (
852 + !empty($block['blockName']) && strpos($block['blockName'], 'toolset-blocks/') === 0 && false !== strpos($block_content, '[e2pdf-')
853 + ) {
854 + remove_shortcode('e2pdf-download');
855 + remove_shortcode('e2pdf-view');
856 + remove_shortcode('e2pdf-save');
857 + remove_shortcode('e2pdf-zapier');
858 + remove_shortcode('e2pdf-adobesign');
859 + }
860 + return $block_content;
861 + }
862 +
863 + /**
864 + * Enable rendering of E2Pdf shortcodes in the Toolset template.
865 + * https://toolset.com/
866 + */
867 + public function filter_render_block_toolset_enable($block_content, $block) {
868 + if (
869 + !empty($block['blockName']) && strpos($block['blockName'], 'toolset-blocks/') === 0 && false !== strpos($block_content, '[e2pdf-')
870 + ) {
871 + add_shortcode('e2pdf-download', [new Model_E2pdf_Shortcode(), 'e2pdf_download']);
872 + add_shortcode('e2pdf-view', [new Model_E2pdf_Shortcode(), 'e2pdf_view']);
873 + add_shortcode('e2pdf-save', [new Model_E2pdf_Shortcode(), 'e2pdf_save']);
874 + add_shortcode('e2pdf-zapier', [new Model_E2pdf_Shortcode(), 'e2pdf_zapier']);
875 + add_shortcode('e2pdf-adobesign', [new Model_E2pdf_Shortcode(), 'e2pdf_adobesign']);
876 + }
877 + return $block_content;
878 + }
879 +
793 880 // filter content
794 881 public function filter_content($content, $post_id = false, $wp_reset_postdata = true) {
795 882 global $post;
796 883 if (!is_string($content) || false === strpos($content, '[')) {
@@ -795,15 +882,15 @@
795 882 global $post;
796 883 if (!is_string($content) || false === strpos($content, '[')) {
797 884 return $content;
798 885 }
799 - $shortcode_tags = array(
886 + $shortcode_tags = [
800 887 'e2pdf-download',
801 888 'e2pdf-save',
802 889 'e2pdf-view',
803 890 'e2pdf-adobesign',
804 891 'e2pdf-zapier',
805 - );
892 + ];
806 893 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
807 894 $tagnames = array_intersect($shortcode_tags, $matches[1]);
808 895 if (!empty($tagnames)) {
809 896 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
@@ -938,12 +1025,12 @@
938 1025 public function filter_mepr_email_send_attachments($attachments, $mail, $body, $values) {
939 1026 $message = $body ? $body : $mail->body();
940 1027 if ($message && false !== strpos($message, '[')) {
941 1028 $message = $mail->replace_variables($message, $values);
942 - $shortcode_tags = array(
1029 + $shortcode_tags = [
943 1030 'e2pdf-attachment',
944 1031 'e2pdf-save',
945 - );
1032 + ];
946 1033 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $message, $matches);
947 1034 $tagnames = array_intersect($shortcode_tags, $matches[1]);
948 1035 if (!empty($tagnames)) {
949 1036 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $message, $shortcodes);
@@ -1005,13 +1092,13 @@
1005 1092 }
1006 1093
1007 1094 // mepr custom thank you message filter
1008 1095 public function filter_mepr_custom_thankyou_message($content) {
1009 - add_shortcode('e2pdf-download', array(new Model_E2pdf_Shortcode(), 'e2pdf_download'));
1010 - add_shortcode('e2pdf-view', array(new Model_E2pdf_Shortcode(), 'e2pdf_view'));
1011 - add_shortcode('e2pdf-save', array(new Model_E2pdf_Shortcode(), 'e2pdf_save'));
1012 - add_shortcode('e2pdf-zapier', array(new Model_E2pdf_Shortcode(), 'e2pdf_zapier'));
1013 - add_shortcode('e2pdf-adobesign', array(new Model_E2pdf_Shortcode(), 'e2pdf_adobesign'));
1096 + add_shortcode('e2pdf-download', [new Model_E2pdf_Shortcode(), 'e2pdf_download']);
1097 + add_shortcode('e2pdf-view', [new Model_E2pdf_Shortcode(), 'e2pdf_view']);
1098 + add_shortcode('e2pdf-save', [new Model_E2pdf_Shortcode(), 'e2pdf_save']);
1099 + add_shortcode('e2pdf-zapier', [new Model_E2pdf_Shortcode(), 'e2pdf_zapier']);
1100 + add_shortcode('e2pdf-adobesign', [new Model_E2pdf_Shortcode(), 'e2pdf_adobesign']);
1014 1101 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1015 1102 if (isset($_REQUEST['trans_num']) && class_exists('MeprTransaction') && method_exists('MeprTransaction', 'get_one_by_trans_num')) {
1016 1103 $txn = new MeprTransaction();
1017 1104 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
@@ -1018,15 +1105,15 @@
1018 1105 $data = MeprTransaction::get_one_by_trans_num($_REQUEST['trans_num']);
1019 1106 if (method_exists($txn, 'load_data')) {
1020 1107 $txn->load_data($data);
1021 1108 if (false !== strpos($content, '[')) {
1022 - $shortcode_tags = array(
1109 + $shortcode_tags = [
1023 1110 'e2pdf-download',
1024 1111 'e2pdf-view',
1025 1112 'e2pdf-save',
1026 1113 'e2pdf-zapier',
1027 1114 'e2pdf-adobesign',
1028 - );
1115 + ];
1029 1116 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1030 1117 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1031 1118 if (!empty($tagnames)) {
1032 1119 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
@@ -1075,19 +1162,106 @@
1075 1162 }
1076 1163 return $values;
1077 1164 }
1078 1165
1166 + /**
1167 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
1168 + * https://wordpress.org/plugins/ultimate-member/
1169 + */
1170 + public function filter_um_email_send_message_content($content) {
1171 + if (!is_string($content) || false === strpos($content, '[')) {
1172 + return $content;
1173 + }
1174 + $shortcode_tags = [
1175 + 'e2pdf-download',
1176 + 'e2pdf-save',
1177 + 'e2pdf-attachment',
1178 + 'e2pdf-view',
1179 + 'e2pdf-adobesign',
1180 + 'e2pdf-zapier',
1181 + ];
1182 + preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1183 + $tagnames = array_intersect($shortcode_tags, $matches[1]);
1184 + if (!empty($tagnames)) {
1185 + preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
1186 + foreach ($shortcodes[0] as $key => $shortcode_value) {
1187 + $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
1188 + $atts = shortcode_parse_atts($shortcode[3]);
1189 + if (!isset($atts['apply'])) {
1190 + $shortcode[3] .= ' apply="true"';
1191 + }
1192 + if (!isset($atts['filter'])) {
1193 + $shortcode[3] .= ' filter="true"';
1194 + }
1195 + if (isset($atts['id'])) {
1196 + $template = new Model_E2pdf_Template();
1197 + $template->load($atts['id']);
1198 + if ($template->get('extension') === 'wordpress') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1199 + if (!isset($atts['dataset'])) {
1200 + if ($template->get('item') == '-3' && function_exists('um_user')) {
1201 + $dataset = um_user('ID');
1202 + $atts['dataset'] = $dataset;
1203 + $shortcode[3] .= ' dataset="' . $dataset . '"';
1204 + }
1205 + }
1206 + }
1207 + }
1208 + if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) {
1209 + $file = do_shortcode_tag($shortcode);
1210 + if ($file) {
1211 + $tmp = false;
1212 + if (substr($file, 0, 4) === 'tmp:') {
1213 + $file = substr($file, 4);
1214 + $tmp = true;
1215 + }
1216 + if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) {
1217 + if ($tmp) {
1218 + $this->helper->add('wordpress_attachments_um_del', $file);
1219 + }
1220 + } else {
1221 + $this->helper->add('wordpress_attachments_um_del', $file);
1222 + }
1223 + $this->helper->add('wordpress_attachments_um', $file);
1224 + }
1225 + $content = str_replace($shortcode_value, '', $content);
1226 + } else {
1227 + $content = str_replace($shortcode_value, do_shortcode_tag($shortcode), $content);
1228 + }
1229 + }
1230 + }
1231 + return $content;
1232 + }
1233 +
1234 + /**
1235 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
1236 + * https://wordpress.org/plugins/ultimate-member/
1237 + */
1238 + public function filter_wp_mail_um($args) {
1239 + $files = $this->helper->get('wordpress_attachments_um');
1240 + if (is_array($files) && !empty($files)) {
1241 + if (empty($args['attachments'])) {
1242 + $args['attachments'] = [];
1243 + } elseif (!is_array($args['attachments'])) {
1244 + $args['attachments'] = [$args['attachments']];
1245 + }
1246 + foreach ($files as $key => $file) {
1247 + $args['attachments'][] = $file;
1248 + }
1249 + }
1250 + return $args;
1251 + }
1252 +
1079 1253 // wp mail filter
1080 1254 public function filter_wp_mail($args) {
1081 1255 if (isset($args['message'])) {
1082 1256 if (false !== strpos($args['message'], '[')) {
1083 - $shortcode_tags = array(
1257 + $shortcode_tags = [
1084 1258 'e2pdf-download',
1085 1259 'e2pdf-save',
1086 1260 'e2pdf-attachment',
1087 1261 'e2pdf-adobesign',
1088 1262 'e2pdf-zapier',
1089 - );
1263 + ];
1090 1264 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $args['message'], $matches);
1091 1265 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1092 1266 if (!empty($tagnames)) {
1093 1267 $args['attachments'] = $this->helper->load('convert')->is_string_array($args['attachments']);
@@ -1126,24 +1300,23 @@
1126 1300 }
1127 1301 }
1128 1302 }
1129 1303 }
1130 - $wp_mail = array(
1304 + return [
1131 1305 'to' => $args['to'],
1132 1306 'subject' => $args['subject'],
1133 1307 'message' => $args['message'],
1134 1308 'headers' => $args['headers'],
1135 1309 'attachments' => $args['attachments'],
1136 - );
1137 - return $wp_mail;
1310 + ];
1138 1311 }
1139 1312
1140 - // Thrive Theme Builder dynamic shortcode support
1313 + // Thrive Theme Builder dynamic shortcode support
1141 1314 public function filter_thrive_theme_template_content($html) {
1142 - add_filter('e2pdf_model_shortcode_e2pdf_download_atts', array($this, 'filter_global_post_id'));
1143 - add_filter('e2pdf_model_shortcode_e2pdf_view_atts', array($this, 'filter_global_post_id'));
1144 - add_filter('e2pdf_model_shortcode_e2pdf_save_atts', array($this, 'filter_global_post_id'));
1145 - add_filter('e2pdf_model_shortcode_e2pdf_zapier_atts', array($this, 'filter_global_post_id'));
1315 + add_filter('e2pdf_model_shortcode_e2pdf_download_atts', [$this, 'filter_global_post_id']);
1316 + add_filter('e2pdf_model_shortcode_e2pdf_view_atts', [$this, 'filter_global_post_id']);
1317 + add_filter('e2pdf_model_shortcode_e2pdf_save_atts', [$this, 'filter_global_post_id']);
1318 + add_filter('e2pdf_model_shortcode_e2pdf_zapier_atts', [$this, 'filter_global_post_id']);
1146 1319 return $html;
1147 1320 }
1148 1321
1149 1322 // dynamic post id support filter
@@ -1176,15 +1349,15 @@
1176 1349 function_exists('et_core_is_builder_used_on_current_request') &&
1177 1350 !et_core_is_builder_used_on_current_request()
1178 1351 ) {
1179 1352 global $post;
1180 - $shortcode_tags = array(
1353 + $shortcode_tags = [
1181 1354 'e2pdf-download',
1182 1355 'e2pdf-save',
1183 1356 'e2pdf-view',
1184 1357 'e2pdf-adobesign',
1185 1358 'e2pdf-zapier',
1186 - );
1359 + ];
1187 1360 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1188 1361 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1189 1362 if (!empty($tagnames)) {
1190 1363 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
@@ -1319,12 +1492,12 @@
1319 1492 }
1320 1493
1321 1494 if (class_exists('ACF') && function_exists('acf_get_field_groups')) {
1322 1495 $user_groups = acf_get_field_groups(
1323 - array(
1496 + [
1324 1497 'user_id' => 'new',
1325 1498 'user_form' => 'all',
1326 - )
1499 + ]
1327 1500 );
1328 1501 if (!empty($user_groups)) {
1329 1502 $user_groups = array_column($user_groups, 'key');
1330 1503 }
@@ -1329,15 +1502,15 @@
1329 1502 $user_groups = array_column($user_groups, 'key');
1330 1503 }
1331 1504 if ($this->get('item') == '-3') {
1332 1505 $groups = acf_get_field_groups(
1333 - array(
1506 + [
1334 1507 'user_id' => 'new',
1335 1508 'user_form' => 'all',
1336 - )
1509 + ]
1337 1510 );
1338 1511 } else {
1339 - $groups = acf_get_field_groups(array('post_type' => $this->get('item')));
1512 + $groups = acf_get_field_groups(['post_type' => $this->get('item')]);
1340 1513 }
1341 1514 if (!empty($groups)) {
1342 1515 $vc .= "<h3 class='e2pdf-plr5'>ACF</h3>";
1343 1516 foreach ($groups as $group_key => $group) {
@@ -1365,9 +1538,9 @@
1365 1538
1366 1539 // get acf field
1367 1540 public function get_acf_field($vc, $field, $post_id) {
1368 1541 if ($field['type'] == 'repeater' && !empty($field['sub_fields'])) {
1369 - $sub_fields = array();
1542 + $sub_fields = [];
1370 1543 foreach ($field['sub_fields'] as $sub_field_key => $sub_field) {
1371 1544 $sub_fields[] = '[acf field="' . $sub_field['name'] . '"' . $post_id . ']';
1372 1545 $sub_field['label'] = $field['label'] . ' ' . $sub_field['label'];
1373 1546 $sub_field['name'] = $field['name'] . '_0_' . $sub_field['name'];
@@ -1376,9 +1549,9 @@
1376 1549 if (!empty($sub_fields)) {
1377 1550 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($field['label'] . ' Iteration', 'e2pdf-acf-repeater field="' . $field['name'] . '"' . $post_id . ']' . implode(' ', $sub_fields) . "\r\n" . '[/e2pdf-acf-repeater') . '</div>';
1378 1551 }
1379 1552 } elseif ($field['type'] == 'group' && !empty($field['sub_fields'])) {
1380 - $sub_fields = array();
1553 + $sub_fields = [];
1381 1554 foreach ($field['sub_fields'] as $sub_field_key => $sub_field) {
1382 1555 $sub_field['label'] = $field['label'] . ' ' . $sub_field['label'];
1383 1556 $sub_field['name'] = $field['name'] . '_' . $sub_field['name'];
1384 1557 $vc = $this->get_acf_field($vc, $sub_field, $post_id);
@@ -1393,21 +1566,21 @@
1393 1566
1394 1567 // get post meta keys
1395 1568 public function get_post_meta_keys() {
1396 1569 global $wpdb;
1397 - $meta_keys = array();
1570 + $meta_keys = [];
1398 1571 if ($this->get('item')) {
1399 - $condition = array(
1400 - 'p.post_type' => array(
1572 + $condition = [
1573 + 'p.post_type' => [
1401 1574 'condition' => '=',
1402 1575 'value' => $this->get('item'),
1403 1576 'type' => '%s',
1404 - ),
1405 - );
1406 - $order_condition = array(
1577 + ],
1578 + ];
1579 + $order_condition = [
1407 1580 'orderby' => 'meta_key',
1408 1581 'order' => 'desc',
1409 - );
1582 + ];
1410 1583 $where = $this->helper->load('db')->prepare_where($condition);
1411 1584 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1412 1585 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1413 1586 $meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_key` FROM `' . $wpdb->postmeta . '` `pm` LEFT JOIN ' . $wpdb->posts . ' `p` ON (`p`.`ID` = `pm`.`post_ID`) ' . $where['sql'] . $orderby . '', $where['filter']));
@@ -1417,14 +1590,14 @@
1417 1590
1418 1591 // get user meta keys
1419 1592 public function get_user_meta_keys() {
1420 1593 global $wpdb;
1421 - $meta_keys = array();
1594 + $meta_keys = [];
1422 1595 if ($this->get('item')) {
1423 - $order_condition = array(
1596 + $order_condition = [
1424 1597 'orderby' => 'meta_key',
1425 1598 'order' => 'desc',
1426 - );
1599 + ];
1427 1600 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1428 1601 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1429 1602 $meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_key` FROM `' . $wpdb->usermeta . '` ' . $orderby . ''));
1430 1603 }
@@ -1433,14 +1606,14 @@
1433 1606
1434 1607 // get post taxonomy keys
1435 1608 public function get_post_taxonomy_keys() {
1436 1609 global $wpdb;
1437 - $meta_keys = array();
1610 + $meta_keys = [];
1438 1611 if ($this->get('item')) {
1439 - $order_condition = array(
1612 + $order_condition = [
1440 1613 'orderby' => 'taxonomy',
1441 1614 'order' => 'desc',
1442 - );
1615 + ];
1443 1616 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1444 1617 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1445 1618 $meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `taxonomy` FROM `' . $wpdb->term_taxonomy . '` `t` ' . $orderby . ''));
1446 1619 }
@@ -1463,9 +1636,9 @@
1463 1636 if (!empty($items)) {
1464 1637 add_meta_box(
1465 1638 'e2pdf',
1466 1639 apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_wordpress_page_edit'),
1467 - array($this, 'hook_wordpress_page_edit_callback'),
1640 + [$this, 'hook_wordpress_page_edit_callback'],
1468 1641 $items,
1469 1642 'side',
1470 1643 'default'
1471 1644 );
@@ -1488,20 +1661,20 @@
1488 1661 )
1489 1662 ) {
1490 1663 $action = apply_filters(
1491 1664 'e2pdf_hook_action_button',
1492 - array(
1665 + [
1493 1666 'html' => '<p><a class="e2pdf-download-hook" target="_blank" title="%2$s" href="%1$s"><span class="dashicons dashicons-pdf"></span> %2$s</a></p>',
1494 1667 'url' => $this->helper->get_url(
1495 - array(
1668 + [
1496 1669 'page' => 'e2pdf',
1497 1670 'action' => 'export',
1498 1671 'id' => $hook,
1499 1672 'dataset' => $post->ID,
1500 - ), 'admin.php?'
1673 + ], 'admin.php?'
1501 1674 ),
1502 1675 'title' => 'PDF #' . $hook,
1503 - ), 'hook_wordpress_page_edit', $hook, $post->ID
1676 + ], 'hook_wordpress_page_edit', $hook, $post->ID
1504 1677 );
1505 1678 if (!empty($action)) {
1506 1679 echo sprintf(
1507 1680 $action['html'], $action['url'], $action['title']
@@ -1529,20 +1702,20 @@
1529 1702 )
1530 1703 ) {
1531 1704 $action = apply_filters(
1532 1705 'e2pdf_hook_action_button',
1533 - array(
1706 + [
1534 1707 'html' => '<a class="e2pdf-download-hook" target="_blank" href="%s">%s</a>',
1535 1708 'url' => $this->helper->get_url(
1536 - array(
1709 + [
1537 1710 'page' => 'e2pdf',
1538 1711 'action' => 'export',
1539 1712 'id' => $hook,
1540 1713 'dataset' => $post->ID,
1541 - ), 'admin.php?'
1714 + ], 'admin.php?'
1542 1715 ),
1543 1716 'title' => 'PDF #' . $hook,
1544 - ), 'hook_wordpress_row_actions', $hook, $post->ID
1717 + ], 'hook_wordpress_row_actions', $hook, $post->ID
1545 1718 );
1546 1719 if (!empty($action)) {
1547 1720 $actions['e2pdf_' . $hook] = sprintf(
1548 1721 $action['html'], $action['url'], $action['title']
@@ -1565,20 +1738,20 @@
1565 1738 )
1566 1739 ) {
1567 1740 $action = apply_filters(
1568 1741 'e2pdf_hook_action_button',
1569 - array(
1742 + [
1570 1743 'html' => '<a class="e2pdf-download-hook" target="_blank" href="%s">%s</a>',
1571 1744 'url' => $this->helper->get_url(
1572 - array(
1745 + [
1573 1746 'page' => 'e2pdf',
1574 1747 'action' => 'export',
1575 1748 'id' => $hook,
1576 1749 'dataset' => $post->ID,
1577 - ), 'admin.php?'
1750 + ], 'admin.php?'
1578 1751 ),
1579 1752 'title' => 'PDF #' . $hook,
1580 - ), 'hook_wordpress_row_actions', $hook, $post->ID
1753 + ], 'hook_wordpress_row_actions', $hook, $post->ID
1581 1754 );
1582 1755 if (!empty($action)) {
1583 1756 $actions['e2pdf_' . $hook] = sprintf(
1584 1757 $action['html'], $action['url'], $action['title']