PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.55
E2Pdf – Export Pdf Tool for WordPress v1.32.55
1.32.55 1.32.56 1.32.53 1.32.51 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 All 76 releases
← All changes | classes/extension/e2pdf-wordpress.php +382 -197 1.32.31 → 1.32.55 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,123 @@
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);
335 +
336 + // extension hooks
337 + add_filter('e2pdf_extension_hooks', function ($hooks) {
338 + $hooks[$this->info['key'] . '_-3'] = [
339 + 'hook_wordpress_row_actions' => __('WP Admin User Row Actions', 'e2pdf')
340 + ];
341 + $hooks[$this->info['key']] = [
342 + 'hook_wordpress_page_edit' => __('WP Admin Page Edit', 'e2pdf'),
343 + 'hook_wordpress_row_actions' => __('WP Admin Page Row Actions', 'e2pdf')
344 + ];
345 + return $hooks;
346 + });
323 347 }
324 348
325 349 // load actions
326 350 public function load_actions() {
@@ -327,43 +351,50 @@
327 351 /**
328 352 * Elementor Website Builder – More than Just a Page Builder
329 353 * https://wordpress.org/plugins/elementor/
330 354 */
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);
355 + add_action('elementor/widget/before_render_content', [$this, 'action_elementor_widget_before_render_content']);
356 + add_action('elementor/frontend/widget/before_render', [$this, 'action_elementor_widget_before_render_content'], 5);
333 357
334 358 /**
335 359 * JetEngine: WordPress Plugin for Elementor
336 360 * https://crocoblock.com
337 361 */
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'));
362 + add_action('jet-engine/listing/grid/before-render', [$this, 'action_jet_engine_listing_grid_before_render']);
363 + add_action('jet-engine/listing/grid/after-render', [$this, 'action_jet_engine_listing_grid_after_render']);
340 364
341 365 /**
342 366 * Happy Addons for Elementor
343 367 * https://wordpress.org/plugins/happy-elementor-addons/ compatibility fix
344 368 */
345 - add_action('elementor/frontend/before_render', array($this, 'action_elementor_widget_before_render_content'), 0);
369 + add_action('elementor/frontend/before_render', [$this, 'action_elementor_widget_before_render_content'], 0);
346 370
347 371 /**
348 372 * MemberPress Mail attachments remove
349 373 * https://memberpress.com/
350 374 */
351 - add_action('mepr_email_sent', array($this, 'action_mepr_email_sent'), 10, 3);
375 + add_action('mepr_email_sent', [$this, 'action_mepr_email_sent']);
352 376
353 377 /**
354 378 * User Registration & Membership – Custom Registration Form, Login Form, and User Profile
355 379 * https://wordpress.org/plugins/user-registration/
356 380 */
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'));
381 + add_action('user_registration_email_send_before', [$this, 'action_user_registration_email_send_before']);
382 + add_action('user_registration_email_send_after', [$this, 'action_user_registration_email_send_after']);
359 383
384 + /**
385 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
386 + * https://wordpress.org/plugins/ultimate-member/
387 + */
388 + add_action('um_before_email_notification_sending', [$this, 'action_um_before_email_notification_sending']);
389 + add_action('um_after_email_notification_sending', [$this, 'action_um_after_email_notification_sending']);
390 +
360 391 /* Hooks */
361 - add_action('add_meta_boxes', array($this, 'hook_wordpress_page_edit'));
392 + add_action('add_meta_boxes', [$this, 'hook_wordpress_page_edit']);
362 393 }
363 394
364 395 // render
365 - public function render($value, $field = array(), $convert_shortcodes = true, $raw = false) {
396 + public function render($value, $field = [], $convert_shortcodes = true, $raw = false) {
366 397 $value = $this->render_shortcodes($value, $field);
367 398 if (!$raw) {
368 399 $value = $this->strip_shortcodes($value);
369 400 $value = $this->convert_shortcodes($value, $convert_shortcodes, isset($field['type']) && $field['type'] == 'e2pdf-html' ? true : false);
@@ -372,9 +403,9 @@
372 403 return $value;
373 404 }
374 405
375 406 // render shortcodes
376 - public function render_shortcodes($value, $field = array()) {
407 + public function render_shortcodes($value, $field = []) {
377 408
378 409 $element_id = isset($field['element_id']) ? $field['element_id'] : false;
379 410
380 411 if ($this->verify()) {
@@ -383,9 +414,9 @@
383 414 * https://toolset.com/
384 415 */
385 416 do_action('wpv_action_wpv_set_top_current_post', $this->get('cached_post'));
386 417
387 - $wordpress_shortcodes = array(
418 + $wordpress_shortcodes = [
388 419 'id',
389 420 'post_author',
390 421 'post_date',
391 422 'post_date_gmt',
@@ -413,19 +444,19 @@
413 444 'get_the_post_thumbnail',
414 445 'get_the_post_thumbnail_url',
415 446 'get_permalink',
416 447 'get_post_permalink',
417 - );
448 + ];
418 449
419 450 if (false !== strpos($value, '[')) {
420 451 $value = $this->helper->load('field')->pre_shortcodes($value, $this, $field);
421 452 $value = $this->helper->load('field')->inner_shortcodes($value, $this, $field);
422 453 if ($this->get('item') == '-3') {
423 - $shortcode_tags = array(
454 + $shortcode_tags = [
424 455 'acf',
425 - );
456 + ];
426 457 } else {
427 - $shortcode_tags = array(
458 + $shortcode_tags = [
428 459 'meta',
429 460 'terms',
430 461 'e2pdf-wp',
431 462 'e2pdf-wp-term',
@@ -430,9 +461,9 @@
430 461 'e2pdf-wp',
431 462 'e2pdf-wp-term',
432 463 'e2pdf-content',
433 464 'acf',
434 - );
465 + ];
435 466 $shortcode_tags = array_merge($shortcode_tags, $wordpress_shortcodes);
436 467 }
437 468 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches);
438 469 $tagnames = array_intersect($shortcode_tags, $matches[1]);
@@ -457,9 +488,9 @@
457 488 $shortcode[3] .= ' terms=true';
458 489 }
459 490 if (substr($shortcode_value, -11) === '[/e2pdf-wp]' || substr($shortcode_value, -8) === '[/terms]' || substr($shortcode_value, -7) === '[/meta]') {
460 491 if ($shortcode[5]) {
461 - $shortcode[5] = $this->render($shortcode[5], array(), false);
492 + $shortcode[5] = $this->render($shortcode[5], [], false);
462 493 }
463 494 $value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wp]', $value);
464 495 } else {
465 496 $value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']', $value);
@@ -466,9 +497,9 @@
466 497 }
467 498 } elseif ($shortcode[2] === 'e2pdf-wp-term') {
468 499 if (substr($shortcode_value, -16) === '[/e2pdf-wp-term]') {
469 500 if ($shortcode[5]) {
470 - $shortcode[5] = $this->render($shortcode[5], array(), false);
501 + $shortcode[5] = $this->render($shortcode[5], [], false);
471 502 }
472 503 $value = str_replace($shortcode_value, '[e2pdf-wp-term' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wp-term]', $value);
473 504 }
474 505 } elseif (in_array($shortcode[2], $wordpress_shortcodes, false)) {
@@ -491,9 +522,9 @@
491 522 }
492 523 $value = $this->helper->load('field')->wrapper_shortcodes($value, $this, $field);
493 524 }
494 525
495 - add_filter('frm_filter_view', array($this, 'filter_frm_filter_view'));
526 + add_filter('frm_filter_view', [$this, 'filter_frm_filter_view']);
496 527 $value = $this->helper->load('field')->do_shortcodes($value, $this, $field);
497 528 $value = $this->helper->load('field')->render(
498 529 apply_filters('e2pdf_extension_render_shortcodes_pre_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false),
499 530 $this,
@@ -498,9 +529,9 @@
498 529 apply_filters('e2pdf_extension_render_shortcodes_pre_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false),
499 530 $this,
500 531 $field
501 532 );
502 - remove_filter('frm_filter_view', array($this, 'filter_frm_filter_view'));
533 + remove_filter('frm_filter_view', [$this, 'filter_frm_filter_view']);
503 534 }
504 535 return apply_filters(
505 536 'e2pdf_extension_render_shortcodes_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false
506 537 );
@@ -529,16 +560,16 @@
529 560
530 561 // auto
531 562 public function auto() {
532 563
533 - $response = array();
534 - $elements = array();
564 + $response = [];
565 + $elements = [];
535 566
536 567 if ($this->get('item') == '-3') {
537 - $elements[] = array(
568 + $elements[] = [
538 569 'type' => 'e2pdf-html',
539 570 'block' => true,
540 - 'properties' => array(
571 + 'properties' => [
541 572 'top' => '20',
542 573 'left' => '20',
543 574 'right' => '20',
544 575 'width' => '100%',
@@ -543,14 +574,14 @@
543 574 'right' => '20',
544 575 'width' => '100%',
545 576 'height' => 'auto',
546 577 'value' => '<h1>[e2pdf-user key="user_login"]</h1>',
547 - ),
548 - );
549 - $elements[] = array(
578 + ],
579 + ];
580 + $elements[] = [
550 581 'type' => 'e2pdf-image',
551 582 'block' => true,
552 - 'properties' => array(
583 + 'properties' => [
553 584 'top' => '20',
554 585 'left' => '20',
555 586 'right' => '20',
556 587 'width' => '100%',
@@ -556,14 +587,14 @@
556 587 'width' => '100%',
557 588 'height' => '100',
558 589 'vertical' => 'top',
559 590 'value' => '[e2pdf-user key="get_avatar_url"]',
560 - ),
561 - );
562 - $elements[] = array(
591 + ],
592 + ];
593 + $elements[] = [
563 594 'type' => 'e2pdf-html',
564 595 'block' => true,
565 - 'properties' => array(
596 + 'properties' => [
566 597 'top' => '20',
567 598 'left' => '20',
568 599 'right' => '20',
569 600 'width' => '100%',
@@ -568,14 +599,14 @@
568 599 'right' => '20',
569 600 'width' => '100%',
570 601 'height' => 'auto',
571 602 'value' => 'ID: [e2pdf-user key="ID"]',
572 - ),
573 - );
574 - $elements[] = array(
603 + ],
604 + ];
605 + $elements[] = [
575 606 'type' => 'e2pdf-html',
576 607 'block' => true,
577 - 'properties' => array(
608 + 'properties' => [
578 609 'top' => '20',
579 610 'left' => '20',
580 611 'right' => '20',
581 612 'width' => '100%',
@@ -580,14 +611,14 @@
580 611 'right' => '20',
581 612 'width' => '100%',
582 613 'height' => 'auto',
583 614 'value' => 'First Name: [e2pdf-user key="user_firstname"]',
584 - ),
585 - );
586 - $elements[] = array(
615 + ],
616 + ];
617 + $elements[] = [
587 618 'type' => 'e2pdf-html',
588 619 'block' => true,
589 - 'properties' => array(
620 + 'properties' => [
590 621 'top' => '20',
591 622 'left' => '20',
592 623 'right' => '20',
593 624 'width' => '100%',
@@ -592,14 +623,14 @@
592 623 'right' => '20',
593 624 'width' => '100%',
594 625 'height' => 'auto',
595 626 'value' => 'Last Name: [e2pdf-user key="user_lastname"]',
596 - ),
597 - );
598 - $elements[] = array(
627 + ],
628 + ];
629 + $elements[] = [
599 630 'type' => 'e2pdf-html',
600 631 'block' => true,
601 - 'properties' => array(
632 + 'properties' => [
602 633 'top' => '20',
603 634 'left' => '20',
604 635 'right' => '20',
605 636 'width' => '100%',
@@ -604,14 +635,14 @@
604 635 'right' => '20',
605 636 'width' => '100%',
606 637 'height' => 'auto',
607 638 'value' => 'Email: [e2pdf-user key="user_email"]',
608 - ),
609 - );
610 - $elements[] = array(
639 + ],
640 + ];
641 + $elements[] = [
611 642 'type' => 'e2pdf-html',
612 643 'block' => true,
613 - 'properties' => array(
644 + 'properties' => [
614 645 'top' => '20',
615 646 'left' => '20',
616 647 'right' => '20',
617 648 'width' => '100%',
@@ -616,15 +647,15 @@
616 647 'right' => '20',
617 648 'width' => '100%',
618 649 'height' => 'auto',
619 650 'value' => 'Registered: [e2pdf-user key="user_registered"]',
620 - ),
621 - );
651 + ],
652 + ];
622 653 } else {
623 - $elements[] = array(
654 + $elements[] = [
624 655 'type' => 'e2pdf-html',
625 656 'block' => true,
626 - 'properties' => array(
657 + 'properties' => [
627 658 'top' => '20',
628 659 'left' => '20',
629 660 'right' => '20',
630 661 'width' => '100%',
@@ -629,14 +660,14 @@
629 660 'right' => '20',
630 661 'width' => '100%',
631 662 'height' => 'auto',
632 663 'value' => '<h1>[e2pdf-wp key="post_title"]</h1>',
633 - ),
634 - );
635 - $elements[] = array(
664 + ],
665 + ];
666 + $elements[] = [
636 667 'type' => 'e2pdf-html',
637 668 'block' => true,
638 - 'properties' => array(
669 + 'properties' => [
639 670 'top' => '20',
640 671 'left' => '20',
641 672 'right' => '20',
642 673 'width' => '100%',
@@ -641,14 +672,14 @@
641 672 'right' => '20',
642 673 'width' => '100%',
643 674 'height' => 'auto',
644 675 'value' => 'Post name: [e2pdf-wp key="post_name"]',
645 - ),
646 - );
647 - $elements[] = array(
676 + ],
677 + ];
678 + $elements[] = [
648 679 'type' => 'e2pdf-html',
649 680 'block' => true,
650 - 'properties' => array(
681 + 'properties' => [
651 682 'top' => '20',
652 683 'left' => '20',
653 684 'right' => '20',
654 685 'width' => '100%',
@@ -653,14 +684,14 @@
653 684 'right' => '20',
654 685 'width' => '100%',
655 686 'height' => 'auto',
656 687 'value' => 'Post type: [e2pdf-wp key="post_type"]',
657 - ),
658 - );
659 - $elements[] = array(
688 + ],
689 + ];
690 + $elements[] = [
660 691 'type' => 'e2pdf-html',
661 692 'block' => true,
662 - 'properties' => array(
693 + 'properties' => [
663 694 'top' => '20',
664 695 'left' => '20',
665 696 'right' => '20',
666 697 'width' => '100%',
@@ -665,14 +696,14 @@
665 696 'right' => '20',
666 697 'width' => '100%',
667 698 'height' => 'auto',
668 699 'value' => 'ID: [e2pdf-wp key="id"]',
669 - ),
670 - );
671 - $elements[] = array(
700 + ],
701 + ];
702 + $elements[] = [
672 703 'type' => 'e2pdf-html',
673 704 'block' => true,
674 - 'properties' => array(
705 + 'properties' => [
675 706 'top' => '20',
676 707 'left' => '20',
677 708 'right' => '20',
678 709 'width' => '100%',
@@ -677,14 +708,14 @@
677 708 'right' => '20',
678 709 'width' => '100%',
679 710 'height' => 'auto',
680 711 'value' => 'Author: [e2pdf-wp key="post_author"]',
681 - ),
682 - );
683 - $elements[] = array(
712 + ],
713 + ];
714 + $elements[] = [
684 715 'type' => 'e2pdf-html',
685 716 'block' => true,
686 - 'properties' => array(
717 + 'properties' => [
687 718 'top' => '20',
688 719 'left' => '20',
689 720 'right' => '20',
690 721 'width' => '100%',
@@ -689,14 +720,14 @@
689 720 'right' => '20',
690 721 'width' => '100%',
691 722 'height' => '300',
692 723 'value' => '[e2pdf-wp key="post_content"]',
693 - ),
694 - );
695 - $elements[] = array(
724 + ],
725 + ];
726 + $elements[] = [
696 727 'type' => 'e2pdf-html',
697 728 'block' => true,
698 - 'properties' => array(
729 + 'properties' => [
699 730 'top' => '20',
700 731 'left' => '20',
701 732 'right' => '20',
702 733 'width' => '100%',
@@ -701,14 +732,14 @@
701 732 'right' => '20',
702 733 'width' => '100%',
703 734 'height' => 'auto',
704 735 'value' => 'Created: [e2pdf-wp key="post_date"]',
705 - ),
706 - );
707 - $elements[] = array(
736 + ],
737 + ];
738 + $elements[] = [
708 739 'type' => 'e2pdf-html',
709 740 'block' => true,
710 - 'properties' => array(
741 + 'properties' => [
711 742 'top' => '20',
712 743 'left' => '20',
713 744 'right' => '20',
714 745 'width' => '100%',
@@ -713,17 +744,17 @@
713 744 'right' => '20',
714 745 'width' => '100%',
715 746 'height' => 'auto',
716 747 'value' => 'Modified: [e2pdf-wp key="post_modified"]',
717 - ),
718 - );
748 + ],
749 + ];
719 750 }
720 - $response['page'] = array(
751 + $response['page'] = [
721 752 'bottom' => '20',
722 753 'top' => '20',
723 754 'left' => '20',
724 755 'right' => '20',
725 - );
756 + ];
726 757
727 758 $response['elements'] = $elements;
728 759 return $response;
729 760 }
@@ -762,9 +793,9 @@
762 793 /**
763 794 * Delete attachments that were sent by MemberPress email
764 795 * https://memberpress.com/
765 796 */
766 - public function action_mepr_email_sent($email, $values, $attachments) {
797 + public function action_mepr_email_sent() {
767 798 $files = $this->helper->get('wordpress_attachments_mepr');
768 799 if (is_array($files) && !empty($files)) {
769 800 foreach ($files as $key => $file) {
770 801 $this->helper->delete_dir(dirname($file) . '/');
@@ -774,14 +805,14 @@
774 805 }
775 806
776 807 // registration email send before action
777 808 public function action_user_registration_email_send_before() {
778 - add_filter('wp_mail', array($this, 'filter_wp_mail'), 11);
809 + add_filter('wp_mail', [$this, 'filter_wp_mail'], 11);
779 810 }
780 811
781 812 // registration email send after action
782 813 public function action_user_registration_email_send_after() {
783 - remove_filter('wp_mail', array($this, 'filter_wp_mail'), 11);
814 + remove_filter('wp_mail', [$this, 'filter_wp_mail'], 11);
784 815 $files = $this->helper->get('wordpress_attachments');
785 816 if (is_array($files) && !empty($files)) {
786 817 foreach ($files as $key => $file) {
787 818 $this->helper->delete_dir(dirname($file) . '/');
@@ -789,8 +820,76 @@
789 820 $this->helper->deset('wordpress_attachments');
790 821 }
791 822 }
792 823
824 + /**
825 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
826 + * https://wordpress.org/plugins/ultimate-member/
827 + */
828 + public function action_um_before_email_notification_sending() {
829 + add_filter('wp_mail', [$this, 'filter_wp_mail_um'], 11);
830 + }
831 +
832 + /**
833 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
834 + * https://wordpress.org/plugins/ultimate-member/
835 + */
836 + public function action_um_after_email_notification_sending() {
837 + remove_filter('wp_mail', [$this, 'filter_wp_mail_um'], 11);
838 + $files = $this->helper->get('wordpress_attachments_um_del');
839 + if (is_array($files) && !empty($files)) {
840 + foreach ($files as $key => $file) {
841 + $this->helper->delete_dir(dirname($file) . '/');
842 + }
843 + $this->helper->deset('wordpress_attachments_um');
844 + $this->helper->deset('wordpress_attachments_um_del');
845 + }
846 + }
847 +
848 + /**
849 + * Enable / Disable pre-rendering of E2Pdf shortcodes in the Toolset template.
850 + * https://toolset.com/
851 + */
852 + public function filter_wpv_filter_content_template_output($content) {
853 + add_filter('render_block', [$this, 'filter_render_block_toolset_disable'], 9, 2);
854 + add_filter('render_block', [$this, 'filter_render_block_toolset_enable'], 11, 2);
855 + return $content;
856 + }
857 +
858 + /**
859 + * Disable pre-rendering of E2Pdf shortcodes in the Toolset template.
860 + * https://toolset.com/
861 + */
862 + public function filter_render_block_toolset_disable($block_content, $block) {
863 + if (
864 + !empty($block['blockName']) && strpos($block['blockName'], 'toolset-blocks/') === 0 && false !== strpos($block_content, '[e2pdf-')
865 + ) {
866 + remove_shortcode('e2pdf-download');
867 + remove_shortcode('e2pdf-view');
868 + remove_shortcode('e2pdf-save');
869 + remove_shortcode('e2pdf-zapier');
870 + remove_shortcode('e2pdf-adobesign');
871 + }
872 + return $block_content;
873 + }
874 +
875 + /**
876 + * Enable rendering of E2Pdf shortcodes in the Toolset template.
877 + * https://toolset.com/
878 + */
879 + public function filter_render_block_toolset_enable($block_content, $block) {
880 + if (
881 + !empty($block['blockName']) && strpos($block['blockName'], 'toolset-blocks/') === 0 && false !== strpos($block_content, '[e2pdf-')
882 + ) {
883 + add_shortcode('e2pdf-download', [new Model_E2pdf_Shortcode(), 'e2pdf_download']);
884 + add_shortcode('e2pdf-view', [new Model_E2pdf_Shortcode(), 'e2pdf_view']);
885 + add_shortcode('e2pdf-save', [new Model_E2pdf_Shortcode(), 'e2pdf_save']);
886 + add_shortcode('e2pdf-zapier', [new Model_E2pdf_Shortcode(), 'e2pdf_zapier']);
887 + add_shortcode('e2pdf-adobesign', [new Model_E2pdf_Shortcode(), 'e2pdf_adobesign']);
888 + }
889 + return $block_content;
890 + }
891 +
793 892 // filter content
794 893 public function filter_content($content, $post_id = false, $wp_reset_postdata = true) {
795 894 global $post;
796 895 if (!is_string($content) || false === strpos($content, '[')) {
@@ -795,15 +894,15 @@
795 894 global $post;
796 895 if (!is_string($content) || false === strpos($content, '[')) {
797 896 return $content;
798 897 }
799 - $shortcode_tags = array(
898 + $shortcode_tags = [
800 899 'e2pdf-download',
801 900 'e2pdf-save',
802 901 'e2pdf-view',
803 902 'e2pdf-adobesign',
804 903 'e2pdf-zapier',
805 - );
904 + ];
806 905 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
807 906 $tagnames = array_intersect($shortcode_tags, $matches[1]);
808 907 if (!empty($tagnames)) {
809 908 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
@@ -938,12 +1037,12 @@
938 1037 public function filter_mepr_email_send_attachments($attachments, $mail, $body, $values) {
939 1038 $message = $body ? $body : $mail->body();
940 1039 if ($message && false !== strpos($message, '[')) {
941 1040 $message = $mail->replace_variables($message, $values);
942 - $shortcode_tags = array(
1041 + $shortcode_tags = [
943 1042 'e2pdf-attachment',
944 1043 'e2pdf-save',
945 - );
1044 + ];
946 1045 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $message, $matches);
947 1046 $tagnames = array_intersect($shortcode_tags, $matches[1]);
948 1047 if (!empty($tagnames)) {
949 1048 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $message, $shortcodes);
@@ -1005,13 +1104,13 @@
1005 1104 }
1006 1105
1007 1106 // mepr custom thank you message filter
1008 1107 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'));
1108 + add_shortcode('e2pdf-download', [new Model_E2pdf_Shortcode(), 'e2pdf_download']);
1109 + add_shortcode('e2pdf-view', [new Model_E2pdf_Shortcode(), 'e2pdf_view']);
1110 + add_shortcode('e2pdf-save', [new Model_E2pdf_Shortcode(), 'e2pdf_save']);
1111 + add_shortcode('e2pdf-zapier', [new Model_E2pdf_Shortcode(), 'e2pdf_zapier']);
1112 + add_shortcode('e2pdf-adobesign', [new Model_E2pdf_Shortcode(), 'e2pdf_adobesign']);
1014 1113 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1015 1114 if (isset($_REQUEST['trans_num']) && class_exists('MeprTransaction') && method_exists('MeprTransaction', 'get_one_by_trans_num')) {
1016 1115 $txn = new MeprTransaction();
1017 1116 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
@@ -1018,15 +1117,15 @@
1018 1117 $data = MeprTransaction::get_one_by_trans_num($_REQUEST['trans_num']);
1019 1118 if (method_exists($txn, 'load_data')) {
1020 1119 $txn->load_data($data);
1021 1120 if (false !== strpos($content, '[')) {
1022 - $shortcode_tags = array(
1121 + $shortcode_tags = [
1023 1122 'e2pdf-download',
1024 1123 'e2pdf-view',
1025 1124 'e2pdf-save',
1026 1125 'e2pdf-zapier',
1027 1126 'e2pdf-adobesign',
1028 - );
1127 + ];
1029 1128 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1030 1129 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1031 1130 if (!empty($tagnames)) {
1032 1131 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
@@ -1075,19 +1174,106 @@
1075 1174 }
1076 1175 return $values;
1077 1176 }
1078 1177
1178 + /**
1179 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
1180 + * https://wordpress.org/plugins/ultimate-member/
1181 + */
1182 + public function filter_um_email_send_message_content($content) {
1183 + if (!is_string($content) || false === strpos($content, '[')) {
1184 + return $content;
1185 + }
1186 + $shortcode_tags = [
1187 + 'e2pdf-download',
1188 + 'e2pdf-save',
1189 + 'e2pdf-attachment',
1190 + 'e2pdf-view',
1191 + 'e2pdf-adobesign',
1192 + 'e2pdf-zapier',
1193 + ];
1194 + preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1195 + $tagnames = array_intersect($shortcode_tags, $matches[1]);
1196 + if (!empty($tagnames)) {
1197 + preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
1198 + foreach ($shortcodes[0] as $key => $shortcode_value) {
1199 + $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
1200 + $atts = shortcode_parse_atts($shortcode[3]);
1201 + if (!isset($atts['apply'])) {
1202 + $shortcode[3] .= ' apply="true"';
1203 + }
1204 + if (!isset($atts['filter'])) {
1205 + $shortcode[3] .= ' filter="true"';
1206 + }
1207 + if (isset($atts['id'])) {
1208 + $template = new Model_E2pdf_Template();
1209 + $template->load($atts['id']);
1210 + if ($template->get('extension') === 'wordpress') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1211 + if (!isset($atts['dataset'])) {
1212 + if ($template->get('item') == '-3' && function_exists('um_user')) {
1213 + $dataset = um_user('ID');
1214 + $atts['dataset'] = $dataset;
1215 + $shortcode[3] .= ' dataset="' . $dataset . '"';
1216 + }
1217 + }
1218 + }
1219 + }
1220 + if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) {
1221 + $file = do_shortcode_tag($shortcode);
1222 + if ($file) {
1223 + $tmp = false;
1224 + if (substr($file, 0, 4) === 'tmp:') {
1225 + $file = substr($file, 4);
1226 + $tmp = true;
1227 + }
1228 + if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) {
1229 + if ($tmp) {
1230 + $this->helper->add('wordpress_attachments_um_del', $file);
1231 + }
1232 + } else {
1233 + $this->helper->add('wordpress_attachments_um_del', $file);
1234 + }
1235 + $this->helper->add('wordpress_attachments_um', $file);
1236 + }
1237 + $content = str_replace($shortcode_value, '', $content);
1238 + } else {
1239 + $content = str_replace($shortcode_value, do_shortcode_tag($shortcode), $content);
1240 + }
1241 + }
1242 + }
1243 + return $content;
1244 + }
1245 +
1246 + /**
1247 + * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
1248 + * https://wordpress.org/plugins/ultimate-member/
1249 + */
1250 + public function filter_wp_mail_um($args) {
1251 + $files = $this->helper->get('wordpress_attachments_um');
1252 + if (is_array($files) && !empty($files)) {
1253 + if (empty($args['attachments'])) {
1254 + $args['attachments'] = [];
1255 + } elseif (!is_array($args['attachments'])) {
1256 + $args['attachments'] = [$args['attachments']];
1257 + }
1258 + foreach ($files as $key => $file) {
1259 + $args['attachments'][] = $file;
1260 + }
1261 + }
1262 + return $args;
1263 + }
1264 +
1079 1265 // wp mail filter
1080 1266 public function filter_wp_mail($args) {
1081 1267 if (isset($args['message'])) {
1082 1268 if (false !== strpos($args['message'], '[')) {
1083 - $shortcode_tags = array(
1269 + $shortcode_tags = [
1084 1270 'e2pdf-download',
1085 1271 'e2pdf-save',
1086 1272 'e2pdf-attachment',
1087 1273 'e2pdf-adobesign',
1088 1274 'e2pdf-zapier',
1089 - );
1275 + ];
1090 1276 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $args['message'], $matches);
1091 1277 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1092 1278 if (!empty($tagnames)) {
1093 1279 $args['attachments'] = $this->helper->load('convert')->is_string_array($args['attachments']);
@@ -1126,24 +1312,23 @@
1126 1312 }
1127 1313 }
1128 1314 }
1129 1315 }
1130 - $wp_mail = array(
1316 + return [
1131 1317 'to' => $args['to'],
1132 1318 'subject' => $args['subject'],
1133 1319 'message' => $args['message'],
1134 1320 'headers' => $args['headers'],
1135 1321 'attachments' => $args['attachments'],
1136 - );
1137 - return $wp_mail;
1322 + ];
1138 1323 }
1139 1324
1140 - // Thrive Theme Builder dynamic shortcode support
1325 + // Thrive Theme Builder dynamic shortcode support
1141 1326 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'));
1327 + add_filter('e2pdf_model_shortcode_e2pdf_download_atts', [$this, 'filter_global_post_id']);
1328 + add_filter('e2pdf_model_shortcode_e2pdf_view_atts', [$this, 'filter_global_post_id']);
1329 + add_filter('e2pdf_model_shortcode_e2pdf_save_atts', [$this, 'filter_global_post_id']);
1330 + add_filter('e2pdf_model_shortcode_e2pdf_zapier_atts', [$this, 'filter_global_post_id']);
1146 1331 return $html;
1147 1332 }
1148 1333
1149 1334 // dynamic post id support filter
@@ -1176,15 +1361,15 @@
1176 1361 function_exists('et_core_is_builder_used_on_current_request') &&
1177 1362 !et_core_is_builder_used_on_current_request()
1178 1363 ) {
1179 1364 global $post;
1180 - $shortcode_tags = array(
1365 + $shortcode_tags = [
1181 1366 'e2pdf-download',
1182 1367 'e2pdf-save',
1183 1368 'e2pdf-view',
1184 1369 'e2pdf-adobesign',
1185 1370 'e2pdf-zapier',
1186 - );
1371 + ];
1187 1372 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1188 1373 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1189 1374 if (!empty($tagnames)) {
1190 1375 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
@@ -1319,12 +1504,12 @@
1319 1504 }
1320 1505
1321 1506 if (class_exists('ACF') && function_exists('acf_get_field_groups')) {
1322 1507 $user_groups = acf_get_field_groups(
1323 - array(
1508 + [
1324 1509 'user_id' => 'new',
1325 1510 'user_form' => 'all',
1326 - )
1511 + ]
1327 1512 );
1328 1513 if (!empty($user_groups)) {
1329 1514 $user_groups = array_column($user_groups, 'key');
1330 1515 }
@@ -1329,15 +1514,15 @@
1329 1514 $user_groups = array_column($user_groups, 'key');
1330 1515 }
1331 1516 if ($this->get('item') == '-3') {
1332 1517 $groups = acf_get_field_groups(
1333 - array(
1518 + [
1334 1519 'user_id' => 'new',
1335 1520 'user_form' => 'all',
1336 - )
1521 + ]
1337 1522 );
1338 1523 } else {
1339 - $groups = acf_get_field_groups(array('post_type' => $this->get('item')));
1524 + $groups = acf_get_field_groups(['post_type' => $this->get('item')]);
1340 1525 }
1341 1526 if (!empty($groups)) {
1342 1527 $vc .= "<h3 class='e2pdf-plr5'>ACF</h3>";
1343 1528 foreach ($groups as $group_key => $group) {
@@ -1365,9 +1550,9 @@
1365 1550
1366 1551 // get acf field
1367 1552 public function get_acf_field($vc, $field, $post_id) {
1368 1553 if ($field['type'] == 'repeater' && !empty($field['sub_fields'])) {
1369 - $sub_fields = array();
1554 + $sub_fields = [];
1370 1555 foreach ($field['sub_fields'] as $sub_field_key => $sub_field) {
1371 1556 $sub_fields[] = '[acf field="' . $sub_field['name'] . '"' . $post_id . ']';
1372 1557 $sub_field['label'] = $field['label'] . ' ' . $sub_field['label'];
1373 1558 $sub_field['name'] = $field['name'] . '_0_' . $sub_field['name'];
@@ -1376,9 +1561,9 @@
1376 1561 if (!empty($sub_fields)) {
1377 1562 $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 1563 }
1379 1564 } elseif ($field['type'] == 'group' && !empty($field['sub_fields'])) {
1380 - $sub_fields = array();
1565 + $sub_fields = [];
1381 1566 foreach ($field['sub_fields'] as $sub_field_key => $sub_field) {
1382 1567 $sub_field['label'] = $field['label'] . ' ' . $sub_field['label'];
1383 1568 $sub_field['name'] = $field['name'] . '_' . $sub_field['name'];
1384 1569 $vc = $this->get_acf_field($vc, $sub_field, $post_id);
@@ -1393,21 +1578,21 @@
1393 1578
1394 1579 // get post meta keys
1395 1580 public function get_post_meta_keys() {
1396 1581 global $wpdb;
1397 - $meta_keys = array();
1582 + $meta_keys = [];
1398 1583 if ($this->get('item')) {
1399 - $condition = array(
1400 - 'p.post_type' => array(
1584 + $condition = [
1585 + 'p.post_type' => [
1401 1586 'condition' => '=',
1402 1587 'value' => $this->get('item'),
1403 1588 'type' => '%s',
1404 - ),
1405 - );
1406 - $order_condition = array(
1589 + ],
1590 + ];
1591 + $order_condition = [
1407 1592 'orderby' => 'meta_key',
1408 1593 'order' => 'desc',
1409 - );
1594 + ];
1410 1595 $where = $this->helper->load('db')->prepare_where($condition);
1411 1596 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1412 1597 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1413 1598 $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 +1602,14 @@
1417 1602
1418 1603 // get user meta keys
1419 1604 public function get_user_meta_keys() {
1420 1605 global $wpdb;
1421 - $meta_keys = array();
1606 + $meta_keys = [];
1422 1607 if ($this->get('item')) {
1423 - $order_condition = array(
1608 + $order_condition = [
1424 1609 'orderby' => 'meta_key',
1425 1610 'order' => 'desc',
1426 - );
1611 + ];
1427 1612 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1428 1613 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1429 1614 $meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_key` FROM `' . $wpdb->usermeta . '` ' . $orderby . ''));
1430 1615 }
@@ -1433,14 +1618,14 @@
1433 1618
1434 1619 // get post taxonomy keys
1435 1620 public function get_post_taxonomy_keys() {
1436 1621 global $wpdb;
1437 - $meta_keys = array();
1622 + $meta_keys = [];
1438 1623 if ($this->get('item')) {
1439 - $order_condition = array(
1624 + $order_condition = [
1440 1625 'orderby' => 'taxonomy',
1441 1626 'order' => 'desc',
1442 - );
1627 + ];
1443 1628 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1444 1629 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1445 1630 $meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `taxonomy` FROM `' . $wpdb->term_taxonomy . '` `t` ' . $orderby . ''));
1446 1631 }
@@ -1463,9 +1648,9 @@
1463 1648 if (!empty($items)) {
1464 1649 add_meta_box(
1465 1650 'e2pdf',
1466 1651 apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_wordpress_page_edit'),
1467 - array($this, 'hook_wordpress_page_edit_callback'),
1652 + [$this, 'hook_wordpress_page_edit_callback'],
1468 1653 $items,
1469 1654 'side',
1470 1655 'default'
1471 1656 );
@@ -1488,20 +1673,20 @@
1488 1673 )
1489 1674 ) {
1490 1675 $action = apply_filters(
1491 1676 'e2pdf_hook_action_button',
1492 - array(
1677 + [
1493 1678 '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 1679 'url' => $this->helper->get_url(
1495 - array(
1680 + [
1496 1681 'page' => 'e2pdf',
1497 1682 'action' => 'export',
1498 1683 'id' => $hook,
1499 1684 'dataset' => $post->ID,
1500 - ), 'admin.php?'
1685 + ], 'admin.php?'
1501 1686 ),
1502 1687 'title' => 'PDF #' . $hook,
1503 - ), 'hook_wordpress_page_edit', $hook, $post->ID
1688 + ], 'hook_wordpress_page_edit', $hook, $post->ID
1504 1689 );
1505 1690 if (!empty($action)) {
1506 1691 echo sprintf(
1507 1692 $action['html'], $action['url'], $action['title']
@@ -1529,20 +1714,20 @@
1529 1714 )
1530 1715 ) {
1531 1716 $action = apply_filters(
1532 1717 'e2pdf_hook_action_button',
1533 - array(
1718 + [
1534 1719 'html' => '<a class="e2pdf-download-hook" target="_blank" href="%s">%s</a>',
1535 1720 'url' => $this->helper->get_url(
1536 - array(
1721 + [
1537 1722 'page' => 'e2pdf',
1538 1723 'action' => 'export',
1539 1724 'id' => $hook,
1540 1725 'dataset' => $post->ID,
1541 - ), 'admin.php?'
1726 + ], 'admin.php?'
1542 1727 ),
1543 1728 'title' => 'PDF #' . $hook,
1544 - ), 'hook_wordpress_row_actions', $hook, $post->ID
1729 + ], 'hook_wordpress_row_actions', $hook, $post->ID
1545 1730 );
1546 1731 if (!empty($action)) {
1547 1732 $actions['e2pdf_' . $hook] = sprintf(
1548 1733 $action['html'], $action['url'], $action['title']
@@ -1565,20 +1750,20 @@
1565 1750 )
1566 1751 ) {
1567 1752 $action = apply_filters(
1568 1753 'e2pdf_hook_action_button',
1569 - array(
1754 + [
1570 1755 'html' => '<a class="e2pdf-download-hook" target="_blank" href="%s">%s</a>',
1571 1756 'url' => $this->helper->get_url(
1572 - array(
1757 + [
1573 1758 'page' => 'e2pdf',
1574 1759 'action' => 'export',
1575 1760 'id' => $hook,
1576 1761 'dataset' => $post->ID,
1577 - ), 'admin.php?'
1762 + ], 'admin.php?'
1578 1763 ),
1579 1764 'title' => 'PDF #' . $hook,
1580 - ), 'hook_wordpress_row_actions', $hook, $post->ID
1765 + ], 'hook_wordpress_row_actions', $hook, $post->ID
1581 1766 );
1582 1767 if (!empty($action)) {
1583 1768 $actions['e2pdf_' . $hook] = sprintf(
1584 1769 $action['html'], $action['url'], $action['title']