PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.43
E2Pdf – Export Pdf Tool for WordPress v1.32.43
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
e2pdf / classes / extension / e2pdf-wordpress.php

e2pdf-wordpress.php in E2Pdf – Export Pdf Tool for WordPress 1.32.43, at classes/extension/e2pdf-wordpress.php

1,717 lines 78.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * File: /extension/e2pdf-wordpress.php
5 *
6 * @package E2Pdf
7 * @license GPLv3
8 * @link https://e2pdf.com
9 */
10 if (!defined('ABSPATH')) {
11 die('Access denied.');
12 }
13
14 // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledClassName
15 class Extension_E2pdf_Wordpress extends Model_E2pdf_Model {
16
17 private $options;
18 private $info = [
19 'key' => 'wordpress',
20 'title' => 'WordPress',
21 ];
22
23 // info
24 public function info($key = false) {
25 if ($key && isset($this->info[$key])) {
26 return $this->info[$key];
27 } else {
28 return [
29 $this->info['key'] => $this->info['title'],
30 ];
31 }
32 }
33
34 // active
35 public function active() {
36 return true;
37 }
38
39 // set
40 public function set($key, $value) {
41 if (!isset($this->options)) {
42 $this->options = new stdClass();
43 }
44 $this->options->$key = $value;
45 switch ($key) {
46 case 'dataset':
47 $this->set('cached_post', false);
48 if ($this->get('dataset')) {
49 if ($this->get('item') == '-3') {
50 $this->set('cached_post', get_user_by('id', $this->get('dataset')));
51 } else {
52 $pll = $this->helper->load('translator')->isPolylang();
53 if ($pll) {
54 $lang = pll_get_post_language($this->get('dataset'));
55 if ($lang) {
56 PLL()->curlang = PLL()->model->get_language($lang);
57 }
58 }
59 $this->set('cached_post', get_post($this->get('dataset')));
60 }
61 }
62 break;
63 default:
64 break;
65 }
66 }
67
68 // get
69 public function get($key) {
70 if ($key == 'user_id' && $this->get('item') == '-3') {
71 $key = 'dataset';
72 }
73 if (isset($this->options->$key)) {
74 $value = $this->options->$key;
75 } else {
76 switch ($key) {
77 case 'args':
78 $value = [];
79 break;
80 default:
81 $value = false;
82 break;
83 }
84 }
85 return $value;
86 }
87
88 // items
89 public function items() {
90 $items = [];
91 $forms = get_post_types([], 'names');
92 foreach ($forms as $form) {
93 if ($form != 'attachment') {
94 $items[] = $this->item($form);
95 }
96 }
97 $items[] = $this->item('-3');
98 return $items;
99 }
100
101 // datasets
102 public function datasets($item_id = false, $name = false) {
103 $datasets = [];
104 if ($item_id) {
105 if ($item_id == '-3') {
106 $entries = get_users(
107 [
108 'fields' => [
109 'ID', 'user_login',
110 ],
111 ]
112 );
113
114 if ($entries) {
115 $this->set('item', $item_id);
116 foreach ($entries as $key => $entry) {
117 $this->set('dataset', $entry->ID);
118 $entry_title = $this->render($name);
119 if (!$entry_title) {
120 $entry_title = isset($entry->user_login) && $entry->user_login ? $entry->user_login : $entry->ID;
121 }
122 $datasets[] = [
123 'key' => $entry->ID,
124 'value' => $entry_title,
125 ];
126 }
127 }
128 } else {
129 $wpml = $this->helper->load('translator')->isWPML();
130 if ($wpml) {
131 $lang = apply_filters('wpml_current_language', null);
132 $entries = get_posts(
133 [
134 'post_type' => $item_id,
135 'numberposts' => -1,
136 'post_status' => 'any',
137 'lang' => $lang,
138 'suppress_filters' => false,
139 ]
140 );
141 } else {
142 $entries = get_posts(
143 [
144 'post_type' => $item_id,
145 'numberposts' => -1,
146 'post_status' => 'any',
147 ]
148 );
149 }
150 if ($entries) {
151 $this->set('item', $item_id);
152 foreach ($entries as $key => $entry) {
153 $this->set('dataset', $entry->ID);
154 $entry_title = $this->render($name);
155 if (!$entry_title) {
156 $entry_title = isset($entry->post_title) && $entry->post_title ? $entry->post_title : $entry->ID;
157 }
158 $datasets[] = [
159 'key' => $entry->ID,
160 'value' => $entry_title,
161 ];
162 }
163 }
164 }
165 }
166 return $datasets;
167 }
168
169 // get dataset actions
170 public function get_dataset_actions($dataset_id = false) {
171 $dataset_id = (int) $dataset_id;
172 if (!$dataset_id) {
173 return false;
174 }
175 $actions = new stdClass();
176 if ($this->get('item') == '-3') {
177 $actions->view = $this->helper->get_url(
178 [
179 'user_id' => $dataset_id,
180 ], 'user-edit.php?'
181 );
182 } else {
183 $actions->view = $this->helper->get_url(
184 [
185 'post' => $dataset_id,
186 'action' => 'edit',
187 ], 'post.php?'
188 );
189 }
190 $actions->delete = false;
191 return $actions;
192 }
193
194 // get template actions
195 public function get_template_actions($template = false) {
196 $template = (int) $template;
197 if (!$template) {
198 return;
199 }
200 $actions = new stdClass();
201 $actions->delete = false;
202 return $actions;
203 }
204
205 // item
206 public function item($item_id = false) {
207 if (!$item_id && $this->get('item')) {
208 $item_id = $this->get('item');
209 }
210 $item = new stdClass();
211 if ($item_id == '-3') {
212 $item->id = $item_id;
213 $item->name = __('Users');
214 $item->url = $this->helper->get_url([], 'users.php');
215 } else {
216 $form = get_post_type_object($item_id);
217 if ($form) {
218 $item->id = $item_id;
219 $item->name = $form->label ? $form->label : $item_id;
220 $item->url = $this->helper->get_url(['post_type' => $item_id], 'edit.php?');
221 } else {
222 $item->id = '';
223 $item->name = '';
224 $item->url = '';
225 }
226 }
227 return $item;
228 }
229
230 // load filters
231 public function load_filters() {
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
236 /**
237 * Popup Maker – Popup for opt-ins, lead gen, & more
238 * https://wordpress.org/plugins/popup-maker/
239 */
240 add_filter('pum_popup_content', [$this, 'filter_the_content'], 10, 2);
241
242 /**
243 * Events Manager
244 * https://wordpress.org/plugins/events-manager/
245 */
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
254 /**
255 * Beaver Builder – WordPress Page Builder
256 * https://wordpress.org/plugins/beaver-builder-lite-version/
257 */
258 add_filter('fl_builder_before_render_shortcodes', [$this, 'filter_content_loop']);
259
260 /**
261 * WPBakery Page Builder Image Object Link
262 */
263 add_filter('vc_map_get_attributes', [$this, 'filter_vc_map_get_attributes'], 10, 2);
264
265 /**
266 * Flatsome theme global tab content
267 */
268 add_filter('theme_mod_tab_content', [$this, 'filter_content_custom']);
269
270 /**
271 * MemberPress Mail attachments
272 * https://memberpress.com/
273 */
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
278 /**
279 * Thrive Theme Builder dynamic shortcode support
280 */
281 add_filter('thrive_theme_template_content', [$this, 'filter_thrive_theme_template_content']);
282
283 /**
284 * WPBakery Page Builder Grid Item
285 * [e2pdf-download id="1" dataset="{{ post_data:ID }}"]
286 */
287 add_filter('vc_basic_grid_items_list', [$this, 'filter_vc_basic_grid_items_list']);
288
289 /**
290 * Themify Builder dynamic shortcode support
291 * https://wordpress.org/plugins/themify-builder/
292 */
293 add_filter('themify_builder_module_content', [$this, 'filter_themify_builder_module_content']);
294
295 /**
296 * Impreza theme by Up Solutions
297 * https://themeforest.net/item/impreza-retina-responsive-wordpress-theme/6434280
298 */
299 add_filter('us_content_template_the_content', [$this, 'filter_content_custom']);
300
301 /**
302 * Cornerstone Builder
303 * https://theme.co/cornerstone/
304 */
305 add_filter('cs_element_pre_render', [$this, 'filter_cs_element_pre_render']);
306
307 /**
308 * Divi Theme Builder
309 * https://www.elegantthemes.com/
310 */
311 add_filter('et_pb_module_content', [$this, 'filter_et_pb_module_content'], 30, 6);
312
313 /**
314 * User Registration & Membership – Custom Registration Form, Login Form, and User Profile
315 * https://wordpress.org/plugins/user-registration/
316 */
317 add_filter('user_registration_smart_tag_values', [$this, 'filter_user_registration_smart_tag_values'], 0);
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 /* Hooks */
326 add_filter('post_row_actions', [$this, 'hook_wordpress_row_actions'], 10, 2);
327 add_filter('page_row_actions', [$this, 'hook_wordpress_row_actions'], 10, 2);
328 add_filter('user_row_actions', [$this, 'hook_wordpress_row_actions'], 10, 2);
329 }
330
331 // load actions
332 public function load_actions() {
333 /**
334 * Elementor Website Builder – More than Just a Page Builder
335 * https://wordpress.org/plugins/elementor/
336 */
337 add_action('elementor/widget/before_render_content', [$this, 'action_elementor_widget_before_render_content']);
338 add_action('elementor/frontend/widget/before_render', [$this, 'action_elementor_widget_before_render_content'], 5);
339
340 /**
341 * JetEngine: WordPress Plugin for Elementor
342 * https://crocoblock.com
343 */
344 add_action('jet-engine/listing/grid/before-render', [$this, 'action_jet_engine_listing_grid_before_render']);
345 add_action('jet-engine/listing/grid/after-render', [$this, 'action_jet_engine_listing_grid_after_render']);
346
347 /**
348 * Happy Addons for Elementor
349 * https://wordpress.org/plugins/happy-elementor-addons/ compatibility fix
350 */
351 add_action('elementor/frontend/before_render', [$this, 'action_elementor_widget_before_render_content'], 0);
352
353 /**
354 * MemberPress Mail attachments remove
355 * https://memberpress.com/
356 */
357 add_action('mepr_email_sent', [$this, 'action_mepr_email_sent']);
358
359 /**
360 * User Registration & Membership – Custom Registration Form, Login Form, and User Profile
361 * https://wordpress.org/plugins/user-registration/
362 */
363 add_action('user_registration_email_send_before', [$this, 'action_user_registration_email_send_before']);
364 add_action('user_registration_email_send_after', [$this, 'action_user_registration_email_send_after']);
365
366 /**
367 * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
368 * https://wordpress.org/plugins/ultimate-member/
369 */
370 add_action('um_before_email_notification_sending', [$this, 'action_um_before_email_notification_sending']);
371 add_action('um_after_email_notification_sending', [$this, 'action_um_after_email_notification_sending']);
372
373 /* Hooks */
374 add_action('add_meta_boxes', [$this, 'hook_wordpress_page_edit']);
375 }
376
377 // render
378 public function render($value, $field = [], $convert_shortcodes = true, $raw = false) {
379 $value = $this->render_shortcodes($value, $field);
380 if (!$raw) {
381 $value = $this->strip_shortcodes($value);
382 $value = $this->convert_shortcodes($value, $convert_shortcodes, isset($field['type']) && $field['type'] == 'e2pdf-html' ? true : false);
383 $value = $this->helper->load('field')->render_checkbox($value, $this, $field);
384 }
385 return $value;
386 }
387
388 // render shortcodes
389 public function render_shortcodes($value, $field = []) {
390
391 $element_id = isset($field['element_id']) ? $field['element_id'] : false;
392
393 if ($this->verify()) {
394 /**
395 * Set current Post for Toolset Views
396 * https://toolset.com/
397 */
398 do_action('wpv_action_wpv_set_top_current_post', $this->get('cached_post'));
399
400 $wordpress_shortcodes = [
401 'id',
402 'post_author',
403 'post_date',
404 'post_date_gmt',
405 'post_content',
406 'post_title',
407 'post_excerpt',
408 'post_status',
409 'comment_status',
410 'ping_status',
411 'post_password',
412 'post_name',
413 'to_ping',
414 'pinged',
415 'post_modified',
416 'post_modified_gmt',
417 'post_content_filtered',
418 'post_parent',
419 'guid',
420 'menu_order',
421 'post_type',
422 'post_mime_type',
423 'comment_count',
424 'filter',
425 'post_thumbnail',
426 'get_the_post_thumbnail',
427 'get_the_post_thumbnail_url',
428 'get_permalink',
429 'get_post_permalink',
430 ];
431
432 if (false !== strpos($value, '[')) {
433 $value = $this->helper->load('field')->pre_shortcodes($value, $this, $field);
434 $value = $this->helper->load('field')->inner_shortcodes($value, $this, $field);
435 if ($this->get('item') == '-3') {
436 $shortcode_tags = [
437 'acf',
438 ];
439 } else {
440 $shortcode_tags = [
441 'meta',
442 'terms',
443 'e2pdf-wp',
444 'e2pdf-wp-term',
445 'e2pdf-content',
446 'acf',
447 ];
448 $shortcode_tags = array_merge($shortcode_tags, $wordpress_shortcodes);
449 }
450 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches);
451 $tagnames = array_intersect($shortcode_tags, $matches[1]);
452 if (!empty($tagnames)) {
453 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $value, $shortcodes);
454 foreach ($shortcodes[0] as $key => $shortcode_value) {
455 $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
456 $atts = shortcode_parse_atts($shortcode[3]);
457 if ($shortcode[2] === 'e2pdf-content') {
458 if (!isset($atts['id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) {
459 $shortcode[3] .= ' id=' . $this->get('cached_post')->ID . '';
460 $value = str_replace($shortcode_value, '[' . $shortcode[2] . $shortcode[3] . ']', $value);
461 }
462 } elseif ($shortcode[2] === 'meta' || $shortcode[2] === 'terms' || $shortcode[2] == 'e2pdf-wp') {
463 if (!isset($atts['id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) {
464 $shortcode[3] .= ' id=' . $this->get('cached_post')->ID . '';
465 }
466 if ($shortcode[2] === 'meta') {
467 $shortcode[3] .= ' meta=true';
468 }
469 if ($shortcode[2] === 'terms') {
470 $shortcode[3] .= ' terms=true';
471 }
472 if (substr($shortcode_value, -11) === '[/e2pdf-wp]' || substr($shortcode_value, -8) === '[/terms]' || substr($shortcode_value, -7) === '[/meta]') {
473 if ($shortcode[5]) {
474 $shortcode[5] = $this->render($shortcode[5], [], false);
475 }
476 $value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wp]', $value);
477 } else {
478 $value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']', $value);
479 }
480 } elseif ($shortcode[2] === 'e2pdf-wp-term') {
481 if (substr($shortcode_value, -16) === '[/e2pdf-wp-term]') {
482 if ($shortcode[5]) {
483 $shortcode[5] = $this->render($shortcode[5], [], false);
484 }
485 $value = str_replace($shortcode_value, '[e2pdf-wp-term' . $shortcode[3] . ']' . $shortcode[5] . '[/e2pdf-wp-term]', $value);
486 }
487 } elseif (in_array($shortcode[2], $wordpress_shortcodes, false)) {
488 if (!isset($atts['id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) {
489 $shortcode[3] .= ' id=' . $this->get('cached_post')->ID . '';
490 }
491 $shortcode[3] .= ' key=' . $shortcode[2] . '';
492 $value = str_replace($shortcode_value, '[e2pdf-wp' . $shortcode[3] . ']', $value);
493 } elseif ($shortcode[2] === 'acf') {
494 if (!isset($atts['post_id']) && isset($this->get('cached_post')->ID) && $this->get('cached_post')->ID) {
495 if ($this->get('item') == '-3') {
496 $shortcode[3] .= ' post_id=user_' . $this->get('cached_post')->ID . '';
497 } else {
498 $shortcode[3] .= ' post_id=' . $this->get('cached_post')->ID . '';
499 }
500 $value = str_replace($shortcode_value, '[' . $shortcode[2] . $shortcode[3] . ']', $value);
501 }
502 }
503 }
504 }
505 $value = $this->helper->load('field')->wrapper_shortcodes($value, $this, $field);
506 }
507
508 add_filter('frm_filter_view', [$this, 'filter_frm_filter_view']);
509 $value = $this->helper->load('field')->do_shortcodes($value, $this, $field);
510 $value = $this->helper->load('field')->render(
511 apply_filters('e2pdf_extension_render_shortcodes_pre_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false),
512 $this,
513 $field
514 );
515 remove_filter('frm_filter_view', [$this, 'filter_frm_filter_view']);
516 }
517 return apply_filters(
518 'e2pdf_extension_render_shortcodes_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), false, false
519 );
520 }
521
522 // strip shortcodes
523 public function strip_shortcodes($value) {
524 $value = preg_replace('~(?:\[/?)[^/\]]+/?\]~s', '', $value);
525 return $value;
526 }
527
528 // convert shortcodes
529 public function convert_shortcodes($value, $to = false, $html = false) {
530 if ($value) {
531 if ($to) {
532 $value = str_replace('&#91;', '[', $value);
533 if (!$html) {
534 $value = wp_specialchars_decode($value, ENT_QUOTES);
535 }
536 } else {
537 $value = str_replace('[', '&#91;', $value);
538 }
539 }
540 return $value;
541 }
542
543 // auto
544 public function auto() {
545
546 $response = [];
547 $elements = [];
548
549 if ($this->get('item') == '-3') {
550 $elements[] = [
551 'type' => 'e2pdf-html',
552 'block' => true,
553 'properties' => [
554 'top' => '20',
555 'left' => '20',
556 'right' => '20',
557 'width' => '100%',
558 'height' => 'auto',
559 'value' => '<h1>[e2pdf-user key="user_login"]</h1>',
560 ],
561 ];
562 $elements[] = [
563 'type' => 'e2pdf-image',
564 'block' => true,
565 'properties' => [
566 'top' => '20',
567 'left' => '20',
568 'right' => '20',
569 'width' => '100%',
570 'height' => '100',
571 'vertical' => 'top',
572 'value' => '[e2pdf-user key="get_avatar_url"]',
573 ],
574 ];
575 $elements[] = [
576 'type' => 'e2pdf-html',
577 'block' => true,
578 'properties' => [
579 'top' => '20',
580 'left' => '20',
581 'right' => '20',
582 'width' => '100%',
583 'height' => 'auto',
584 'value' => 'ID: [e2pdf-user key="ID"]',
585 ],
586 ];
587 $elements[] = [
588 'type' => 'e2pdf-html',
589 'block' => true,
590 'properties' => [
591 'top' => '20',
592 'left' => '20',
593 'right' => '20',
594 'width' => '100%',
595 'height' => 'auto',
596 'value' => 'First Name: [e2pdf-user key="user_firstname"]',
597 ],
598 ];
599 $elements[] = [
600 'type' => 'e2pdf-html',
601 'block' => true,
602 'properties' => [
603 'top' => '20',
604 'left' => '20',
605 'right' => '20',
606 'width' => '100%',
607 'height' => 'auto',
608 'value' => 'Last Name: [e2pdf-user key="user_lastname"]',
609 ],
610 ];
611 $elements[] = [
612 'type' => 'e2pdf-html',
613 'block' => true,
614 'properties' => [
615 'top' => '20',
616 'left' => '20',
617 'right' => '20',
618 'width' => '100%',
619 'height' => 'auto',
620 'value' => 'Email: [e2pdf-user key="user_email"]',
621 ],
622 ];
623 $elements[] = [
624 'type' => 'e2pdf-html',
625 'block' => true,
626 'properties' => [
627 'top' => '20',
628 'left' => '20',
629 'right' => '20',
630 'width' => '100%',
631 'height' => 'auto',
632 'value' => 'Registered: [e2pdf-user key="user_registered"]',
633 ],
634 ];
635 } else {
636 $elements[] = [
637 'type' => 'e2pdf-html',
638 'block' => true,
639 'properties' => [
640 'top' => '20',
641 'left' => '20',
642 'right' => '20',
643 'width' => '100%',
644 'height' => 'auto',
645 'value' => '<h1>[e2pdf-wp key="post_title"]</h1>',
646 ],
647 ];
648 $elements[] = [
649 'type' => 'e2pdf-html',
650 'block' => true,
651 'properties' => [
652 'top' => '20',
653 'left' => '20',
654 'right' => '20',
655 'width' => '100%',
656 'height' => 'auto',
657 'value' => 'Post name: [e2pdf-wp key="post_name"]',
658 ],
659 ];
660 $elements[] = [
661 'type' => 'e2pdf-html',
662 'block' => true,
663 'properties' => [
664 'top' => '20',
665 'left' => '20',
666 'right' => '20',
667 'width' => '100%',
668 'height' => 'auto',
669 'value' => 'Post type: [e2pdf-wp key="post_type"]',
670 ],
671 ];
672 $elements[] = [
673 'type' => 'e2pdf-html',
674 'block' => true,
675 'properties' => [
676 'top' => '20',
677 'left' => '20',
678 'right' => '20',
679 'width' => '100%',
680 'height' => 'auto',
681 'value' => 'ID: [e2pdf-wp key="id"]',
682 ],
683 ];
684 $elements[] = [
685 'type' => 'e2pdf-html',
686 'block' => true,
687 'properties' => [
688 'top' => '20',
689 'left' => '20',
690 'right' => '20',
691 'width' => '100%',
692 'height' => 'auto',
693 'value' => 'Author: [e2pdf-wp key="post_author"]',
694 ],
695 ];
696 $elements[] = [
697 'type' => 'e2pdf-html',
698 'block' => true,
699 'properties' => [
700 'top' => '20',
701 'left' => '20',
702 'right' => '20',
703 'width' => '100%',
704 'height' => '300',
705 'value' => '[e2pdf-wp key="post_content"]',
706 ],
707 ];
708 $elements[] = [
709 'type' => 'e2pdf-html',
710 'block' => true,
711 'properties' => [
712 'top' => '20',
713 'left' => '20',
714 'right' => '20',
715 'width' => '100%',
716 'height' => 'auto',
717 'value' => 'Created: [e2pdf-wp key="post_date"]',
718 ],
719 ];
720 $elements[] = [
721 'type' => 'e2pdf-html',
722 'block' => true,
723 'properties' => [
724 'top' => '20',
725 'left' => '20',
726 'right' => '20',
727 'width' => '100%',
728 'height' => 'auto',
729 'value' => 'Modified: [e2pdf-wp key="post_modified"]',
730 ],
731 ];
732 }
733 $response['page'] = [
734 'bottom' => '20',
735 'top' => '20',
736 'left' => '20',
737 'right' => '20',
738 ];
739
740 $response['elements'] = $elements;
741 return $response;
742 }
743
744 // before render content widget action
745 public function action_elementor_widget_before_render_content($widget) {
746 if ($widget && ($widget->get_name() == 'shortcode' || $widget->get_name() == 'text-editor')) {
747 $content = $widget->get_name() == 'shortcode' ? $widget->get_settings('shortcode') : $widget->get_settings('editor');
748 if ($content && false !== strpos($content, '[e2pdf-')) {
749 $wp_reset_postdata = true;
750 if (class_exists('\ElementorPro\Plugin') && class_exists('\ElementorPro\Modules\LoopBuilder\Documents\Loop')) {
751 $document = \ElementorPro\Plugin::elementor()->documents->get_current();
752 if ($document && $document instanceof \ElementorPro\Modules\LoopBuilder\Documents\Loop) {
753 $wp_reset_postdata = false;
754 }
755 }
756 if ($widget->get_name() == 'shortcode') {
757 $widget->set_settings('shortcode', $this->filter_content($content, false, $wp_reset_postdata));
758 } elseif ($widget->get_name() == 'text-editor' && !$wp_reset_postdata) {
759 $widget->set_settings('editor', $this->filter_content($content, false, $wp_reset_postdata));
760 }
761 }
762 }
763 }
764
765 // jet engine listing grid before render action
766 public function action_jet_engine_listing_grid_before_render($listing_grid) {
767 $this->set('queried_object', true);
768 }
769
770 // jet engine listing grid after render action
771 public function action_jet_engine_listing_grid_after_render($listing_grid) {
772 $this->set('queried_object', false);
773 }
774
775 /**
776 * Delete attachments that were sent by MemberPress email
777 * https://memberpress.com/
778 */
779 public function action_mepr_email_sent() {
780 $files = $this->helper->get('wordpress_attachments_mepr');
781 if (is_array($files) && !empty($files)) {
782 foreach ($files as $key => $file) {
783 $this->helper->delete_dir(dirname($file) . '/');
784 }
785 $this->helper->deset('wordpress_attachments_mepr');
786 }
787 }
788
789 // registration email send before action
790 public function action_user_registration_email_send_before() {
791 add_filter('wp_mail', [$this, 'filter_wp_mail'], 11);
792 }
793
794 // registration email send after action
795 public function action_user_registration_email_send_after() {
796 remove_filter('wp_mail', [$this, 'filter_wp_mail'], 11);
797 $files = $this->helper->get('wordpress_attachments');
798 if (is_array($files) && !empty($files)) {
799 foreach ($files as $key => $file) {
800 $this->helper->delete_dir(dirname($file) . '/');
801 }
802 $this->helper->deset('wordpress_attachments');
803 }
804 }
805
806 /**
807 * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
808 * https://wordpress.org/plugins/ultimate-member/
809 */
810 public function action_um_before_email_notification_sending() {
811 add_filter('wp_mail', [$this, 'filter_wp_mail_um'], 11);
812 }
813
814 /**
815 * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
816 * https://wordpress.org/plugins/ultimate-member/
817 */
818 public function action_um_after_email_notification_sending() {
819 remove_filter('wp_mail', [$this, 'filter_wp_mail_um'], 11);
820 $files = $this->helper->get('wordpress_attachments_um_del');
821 if (is_array($files) && !empty($files)) {
822 foreach ($files as $key => $file) {
823 $this->helper->delete_dir(dirname($file) . '/');
824 }
825 $this->helper->deset('wordpress_attachments_um');
826 $this->helper->deset('wordpress_attachments_um_del');
827 }
828 }
829
830 // filter content
831 public function filter_content($content, $post_id = false, $wp_reset_postdata = true) {
832 global $post;
833 if (!is_string($content) || false === strpos($content, '[')) {
834 return $content;
835 }
836 $shortcode_tags = [
837 'e2pdf-download',
838 'e2pdf-save',
839 'e2pdf-view',
840 'e2pdf-adobesign',
841 'e2pdf-zapier',
842 ];
843 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
844 $tagnames = array_intersect($shortcode_tags, $matches[1]);
845 if (!empty($tagnames)) {
846 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
847 foreach ($shortcodes[0] as $key => $shortcode_value) {
848 $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
849 $atts = shortcode_parse_atts($shortcode[3]);
850 if (isset($atts['wp_reset_postdata'])) {
851 if ($atts['wp_reset_postdata'] == 'true') {
852 $wp_reset_postdata = true;
853 } else {
854 $wp_reset_postdata = false;
855 }
856 }
857 if ($wp_reset_postdata) {
858 wp_reset_postdata();
859 }
860 if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
861 } else {
862 if (isset($atts['id'])) {
863 $template = new Model_E2pdf_Template();
864 $template->load($atts['id']);
865 if ($template->get('extension') === 'woocommerce' || $template->get('extension') === 'jetformbuilder') {
866 continue;
867 } elseif ($template->get('extension') === 'wordpress') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
868 if (!isset($atts['dataset'])) {
869 if ($template->get('item') == '-3') {
870 $dataset = get_current_user_id();
871 $atts['dataset'] = $dataset;
872 $shortcode[3] .= ' dataset="' . $dataset . '"';
873 } else {
874 if ($this->get('queried_object') && !$post_id) {
875 $queried_object = get_queried_object();
876 $post_id = $queried_object && isset($queried_object->ID) ? $queried_object->ID : false;
877 }
878 if ($post_id || isset($post->ID)) {
879 $dataset = $post_id ? $post_id : $post->ID;
880 $atts['dataset'] = $dataset;
881 $shortcode[3] .= ' dataset="' . $dataset . '"';
882 }
883 }
884 }
885 }
886 }
887 if (!isset($atts['apply'])) {
888 $shortcode[3] .= ' apply="true"';
889 }
890 if (!isset($atts['filter'])) {
891 $shortcode[3] .= ' filter="true"';
892 }
893 $content = str_replace($shortcode_value, do_shortcode_tag($shortcode), $content);
894 }
895 }
896 }
897 return $content;
898 }
899
900 // [e2pdf-exclude] support inside Formidable Forms View beforeContent and afterContent
901 public function filter_frm_filter_view($view) {
902 if (isset($view->frm_before_content) && $view->frm_before_content) {
903 $view->frm_before_content = str_replace('[e2pdf-exclude]', '[e2pdf-exclude apply="true"]', $view->frm_before_content);
904 }
905 if (isset($view->post_content) && $view->post_content) {
906 $view->post_content = str_replace('[e2pdf-exclude]', '[e2pdf-exclude apply="true"]', $view->post_content);
907 }
908 if (isset($view->frm_after_content) && $view->frm_after_content) {
909 $view->frm_after_content = str_replace('[e2pdf-exclude]', '[e2pdf-exclude apply="true"]', $view->frm_after_content);
910 }
911 return $view;
912 }
913
914 // vc map get attributes filter
915 public function filter_vc_map_get_attributes($atts, $tag) {
916 if ($tag == 'vc_single_image' && ((isset($atts['onclick']) && $atts['onclick'] == 'custom_link') || (empty($atts['onclick']) && (!isset($atts['img_link_large']) || 'yes' !== $atts['img_link_large']))) && (!empty($atts['link']) || !empty($atts['img_link']))) {
917
918 if (!empty($atts['link'])) {
919 $atts['link'] = $this->filter_content($atts['link']);
920 }
921
922 if (!empty($atts['img_link'])) {
923 $atts['img_link'] = $this->filter_content($atts['img_link']);
924 }
925 }
926 return $atts;
927 }
928
929 // filter cs element pre prender
930 public function filter_cs_element_pre_render($data) {
931 if (!empty($data['_type']) && $data['_type'] == 'raw-content' && !empty($data['raw_content']) && !empty($data['_p'])) {
932 $data['raw_content'] = $this->filter_content($data['raw_content'], $data['_p']);
933 }
934 return $data;
935 }
936
937 // filter themify builder module content
938 public function filter_themify_builder_module_content($content) {
939 if ($content) {
940 $content = $this->filter_content($content);
941 }
942 return $content;
943 }
944
945 // filter vs basic grid items list
946 public function filter_vc_basic_grid_items_list($items) {
947 if ($items) {
948 $items = $this->filter_content($items);
949 }
950 return $items;
951 }
952
953 // filter the content
954 public function filter_the_content($content, $post_id = false) {
955 $content = $this->filter_content($content, $post_id);
956 return $content;
957 }
958
959 // filter content custom
960 public function filter_content_custom($content) {
961 $content = $this->filter_content($content);
962 return $content;
963 }
964
965 // filter content loop
966 public function filter_content_loop($content) {
967 $content = $this->filter_content($content, false, false);
968 return $content;
969 }
970
971 /**
972 * Memberpress Mail attachments filter
973 * https://memberpress.com/
974 */
975 public function filter_mepr_email_send_attachments($attachments, $mail, $body, $values) {
976 $message = $body ? $body : $mail->body();
977 if ($message && false !== strpos($message, '[')) {
978 $message = $mail->replace_variables($message, $values);
979 $shortcode_tags = [
980 'e2pdf-attachment',
981 'e2pdf-save',
982 ];
983 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $message, $matches);
984 $tagnames = array_intersect($shortcode_tags, $matches[1]);
985 if (!empty($tagnames)) {
986 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $message, $shortcodes);
987 foreach ($shortcodes[0] as $key => $shortcode_value) {
988 $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
989 $atts = shortcode_parse_atts($shortcode[3]);
990 $file = false;
991 if (isset($atts['id']) && isset($atts['dataset'])) {
992 if (!isset($atts['apply'])) {
993 $shortcode[3] .= ' apply="true"';
994 }
995 if (!isset($atts['filter'])) {
996 $shortcode[3] .= ' filter="true"';
997 }
998 if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) {
999 $file = do_shortcode_tag($shortcode);
1000 if ($file) {
1001 $tmp = false;
1002 if (substr($file, 0, 4) === 'tmp:') {
1003 $file = substr($file, 4);
1004 $tmp = true;
1005 }
1006 if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) {
1007 if ($tmp) {
1008 $this->helper->add('wordpress_attachments_mepr', $file);
1009 }
1010 } else {
1011 $this->helper->add('wordpress_attachments_mepr', $file);
1012 }
1013 $attachments[] = $file;
1014 }
1015 }
1016 }
1017 }
1018 }
1019 }
1020 return $attachments;
1021 }
1022
1023 // mepr the content filter
1024 public function filter_mepr_the_content($content) {
1025 if (
1026 class_exists('MeprUtils') && method_exists('MeprUtils', 'get_current_post') &&
1027 class_exists('MeprOptions') && method_exists('MeprOptions', 'fetch')
1028 ) {
1029 $current_post = MeprUtils::get_current_post();
1030 if ($current_post !== false) {
1031 $mepr_options = MeprOptions::fetch();
1032 if ($current_post->ID == $mepr_options->thankyou_page_id) {
1033 remove_shortcode('e2pdf-download');
1034 remove_shortcode('e2pdf-view');
1035 remove_shortcode('e2pdf-save');
1036 remove_shortcode('e2pdf-zapier');
1037 remove_shortcode('e2pdf-adobesign');
1038 }
1039 }
1040 }
1041 return $content;
1042 }
1043
1044 // mepr custom thank you message filter
1045 public function filter_mepr_custom_thankyou_message($content) {
1046 add_shortcode('e2pdf-download', [new Model_E2pdf_Shortcode(), 'e2pdf_download']);
1047 add_shortcode('e2pdf-view', [new Model_E2pdf_Shortcode(), 'e2pdf_view']);
1048 add_shortcode('e2pdf-save', [new Model_E2pdf_Shortcode(), 'e2pdf_save']);
1049 add_shortcode('e2pdf-zapier', [new Model_E2pdf_Shortcode(), 'e2pdf_zapier']);
1050 add_shortcode('e2pdf-adobesign', [new Model_E2pdf_Shortcode(), 'e2pdf_adobesign']);
1051 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1052 if (isset($_REQUEST['trans_num']) && class_exists('MeprTransaction') && method_exists('MeprTransaction', 'get_one_by_trans_num')) {
1053 $txn = new MeprTransaction();
1054 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1055 $data = MeprTransaction::get_one_by_trans_num($_REQUEST['trans_num']);
1056 if (method_exists($txn, 'load_data')) {
1057 $txn->load_data($data);
1058 if (false !== strpos($content, '[')) {
1059 $shortcode_tags = [
1060 'e2pdf-download',
1061 'e2pdf-view',
1062 'e2pdf-save',
1063 'e2pdf-zapier',
1064 'e2pdf-adobesign',
1065 ];
1066 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1067 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1068 if (!empty($tagnames)) {
1069 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
1070 foreach ($shortcodes[0] as $key => $shortcode_value) {
1071 wp_reset_postdata();
1072 $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
1073 $atts = shortcode_parse_atts($shortcode[3]);
1074 if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
1075 } elseif (isset($atts['id'])) {
1076 $user_id = !empty($txn->user_id) ? $txn->user_id : get_current_user_id();
1077 $template = new Model_E2pdf_Template();
1078 $template->load($atts['id']);
1079 if ($template->get('extension') === 'wordpress' && $template->get('item') == '-3') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1080 if (!isset($atts['dataset'])) {
1081 $atts['dataset'] = $user_id;
1082 $shortcode[3] .= ' dataset="' . $user_id . '"';
1083 }
1084 } else {
1085 if (!isset($atts['user_id'])) {
1086 $atts['user_id'] = $user_id;
1087 $shortcode[3] .= ' user_id="' . $user_id . '"';
1088 }
1089 }
1090 }
1091 if (!isset($atts['apply'])) {
1092 $shortcode[3] .= ' apply="true"';
1093 }
1094 if (!isset($atts['filter'])) {
1095 $shortcode[3] .= ' filter="true"';
1096 }
1097 $content = str_replace($shortcode_value, do_shortcode_tag($shortcode), $content);
1098 }
1099 }
1100 }
1101 }
1102 }
1103 return $content;
1104 }
1105
1106 // user registration smart tag values filter
1107 public function filter_user_registration_smart_tag_values($values) {
1108 foreach ($values as $key => $value) {
1109 if (is_string($value) && false !== strpos($value, '[e2pdf-')) {
1110 $values[$key] = str_replace('[e2pdf-', '&#91;e2pdf-', $value);
1111 }
1112 }
1113 return $values;
1114 }
1115
1116 /**
1117 * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
1118 * https://wordpress.org/plugins/ultimate-member/
1119 */
1120 public function filter_um_email_send_message_content($content) {
1121 if (!is_string($content) || false === strpos($content, '[')) {
1122 return $content;
1123 }
1124 $shortcode_tags = [
1125 'e2pdf-download',
1126 'e2pdf-save',
1127 'e2pdf-attachment',
1128 'e2pdf-view',
1129 'e2pdf-adobesign',
1130 'e2pdf-zapier',
1131 ];
1132 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1133 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1134 if (!empty($tagnames)) {
1135 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
1136 foreach ($shortcodes[0] as $key => $shortcode_value) {
1137 $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
1138 $atts = shortcode_parse_atts($shortcode[3]);
1139 if (!isset($atts['apply'])) {
1140 $shortcode[3] .= ' apply="true"';
1141 }
1142 if (!isset($atts['filter'])) {
1143 $shortcode[3] .= ' filter="true"';
1144 }
1145 if (isset($atts['id'])) {
1146 $template = new Model_E2pdf_Template();
1147 $template->load($atts['id']);
1148 if ($template->get('extension') === 'wordpress') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1149 if (!isset($atts['dataset'])) {
1150 if ($template->get('item') == '-3' && function_exists('um_user')) {
1151 $dataset = um_user('ID');
1152 $atts['dataset'] = $dataset;
1153 $shortcode[3] .= ' dataset="' . $dataset . '"';
1154 }
1155 }
1156 }
1157 }
1158 if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) {
1159 $file = do_shortcode_tag($shortcode);
1160 if ($file) {
1161 $tmp = false;
1162 if (substr($file, 0, 4) === 'tmp:') {
1163 $file = substr($file, 4);
1164 $tmp = true;
1165 }
1166 if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) {
1167 if ($tmp) {
1168 $this->helper->add('wordpress_attachments_um_del', $file);
1169 }
1170 } else {
1171 $this->helper->add('wordpress_attachments_um_del', $file);
1172 }
1173 $this->helper->add('wordpress_attachments_um', $file);
1174 }
1175 $content = str_replace($shortcode_value, '', $content);
1176 } else {
1177 $content = str_replace($shortcode_value, do_shortcode_tag($shortcode), $content);
1178 }
1179 }
1180 }
1181 return $content;
1182 }
1183
1184 /**
1185 * Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin
1186 * https://wordpress.org/plugins/ultimate-member/
1187 */
1188 public function filter_wp_mail_um($args) {
1189 $files = $this->helper->get('wordpress_attachments_um');
1190 if (is_array($files) && !empty($files)) {
1191 if (empty($args['attachments'])) {
1192 $args['attachments'] = [];
1193 } elseif (!is_array($args['attachments'])) {
1194 $args['attachments'] = [$args['attachments']];
1195 }
1196 foreach ($files as $key => $file) {
1197 $args['attachments'][] = $file;
1198 }
1199 }
1200 return $args;
1201 }
1202
1203 // wp mail filter
1204 public function filter_wp_mail($args) {
1205 if (isset($args['message'])) {
1206 if (false !== strpos($args['message'], '[')) {
1207 $shortcode_tags = [
1208 'e2pdf-download',
1209 'e2pdf-save',
1210 'e2pdf-attachment',
1211 'e2pdf-adobesign',
1212 'e2pdf-zapier',
1213 ];
1214 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $args['message'], $matches);
1215 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1216 if (!empty($tagnames)) {
1217 $args['attachments'] = $this->helper->load('convert')->is_string_array($args['attachments']);
1218 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $args['message'], $shortcodes);
1219 foreach ($shortcodes[0] as $key => $shortcode_value) {
1220 $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
1221 $atts = shortcode_parse_atts($shortcode[3]);
1222 if (!isset($atts['apply'])) {
1223 $shortcode[3] .= ' apply="true"';
1224 }
1225 if (!isset($atts['filter'])) {
1226 $shortcode[3] .= ' filter="true"';
1227 }
1228 $file = false;
1229 if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) {
1230 $file = do_shortcode_tag($shortcode);
1231 if ($file) {
1232 $tmp = false;
1233 if (substr($file, 0, 4) === 'tmp:') {
1234 $file = substr($file, 4);
1235 $tmp = true;
1236 }
1237 if ($shortcode[2] === 'e2pdf-save' || isset($atts['pdf'])) {
1238 if ($tmp) {
1239 $this->helper->add('wordpress_attachments', $file);
1240 }
1241 } else {
1242 $this->helper->add('wordpress_attachments', $file);
1243 }
1244 $args['attachments'][] = $file;
1245 }
1246 $args['message'] = str_replace($shortcode_value, '', $args['message']);
1247 } else {
1248 $args['message'] = str_replace($shortcode_value, do_shortcode_tag($shortcode), $args['message']);
1249 }
1250 }
1251 }
1252 }
1253 }
1254 return [
1255 'to' => $args['to'],
1256 'subject' => $args['subject'],
1257 'message' => $args['message'],
1258 'headers' => $args['headers'],
1259 'attachments' => $args['attachments'],
1260 ];
1261 }
1262
1263 // Thrive Theme Builder dynamic shortcode support
1264 public function filter_thrive_theme_template_content($html) {
1265 add_filter('e2pdf_model_shortcode_e2pdf_download_atts', [$this, 'filter_global_post_id']);
1266 add_filter('e2pdf_model_shortcode_e2pdf_view_atts', [$this, 'filter_global_post_id']);
1267 add_filter('e2pdf_model_shortcode_e2pdf_save_atts', [$this, 'filter_global_post_id']);
1268 add_filter('e2pdf_model_shortcode_e2pdf_zapier_atts', [$this, 'filter_global_post_id']);
1269 return $html;
1270 }
1271
1272 // dynamic post id support filter
1273 public function filter_global_post_id($atts) {
1274 if (!isset($atts['dataset']) && isset($atts['id'])) {
1275 $template_id = isset($atts['id']) ? (int) $atts['id'] : 0;
1276 $template = new Model_E2pdf_Template();
1277 if ($template->load($template_id, false)) {
1278 if ($template->get('extension') === 'wordpress') { // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1279 global $post;
1280 if (isset($post->ID)) {
1281 $atts['dataset'] = (string) $post->ID;
1282 if (!isset($atts['apply'])) {
1283 $atts['apply'] = 'true';
1284 }
1285 if (!isset($atts['filter'])) {
1286 $atts['filter'] = 'true';
1287 }
1288 }
1289 }
1290 }
1291 }
1292 return $atts;
1293 }
1294
1295 // et pb module content filter
1296 public function filter_et_pb_module_content($content, $props, $attrs, $render_slug, $_address, $global_content) {
1297 if (($render_slug == 'et_pb_code' || $render_slug == 'et_pb_text') &&
1298 false !== strpos($content, '[') &&
1299 function_exists('et_core_is_builder_used_on_current_request') &&
1300 !et_core_is_builder_used_on_current_request()
1301 ) {
1302 global $post;
1303 $shortcode_tags = [
1304 'e2pdf-download',
1305 'e2pdf-save',
1306 'e2pdf-view',
1307 'e2pdf-adobesign',
1308 'e2pdf-zapier',
1309 ];
1310 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
1311 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1312 if (!empty($tagnames)) {
1313 preg_match_all('/' . $this->helper->load('shortcode')->get_shortcode_regex($tagnames) . '/', $content, $shortcodes);
1314 foreach ($shortcodes[0] as $key => $shortcode_value) {
1315 wp_reset_postdata();
1316 $shortcode = $this->helper->load('shortcode')->get_shortcode($shortcodes, $key);
1317 $atts = shortcode_parse_atts($shortcode[3]);
1318 if ($this->helper->load('shortcode')->is_attachment($shortcode, $atts)) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
1319 } else {
1320 if (!isset($atts['dataset']) && isset($atts['id']) && (isset($post->ID))) {
1321 $dataset = $post->ID;
1322 $atts['dataset'] = $dataset;
1323 $shortcode[3] .= ' dataset="' . $dataset . '"';
1324 }
1325 }
1326 if (!isset($atts['apply'])) {
1327 $shortcode[3] .= ' apply="true"';
1328 }
1329
1330 if (!isset($atts['filter'])) {
1331 $shortcode[3] .= ' filter="true"';
1332 }
1333 $new_shortcode = '[' . $shortcode[2] . $shortcode[3] . ']';
1334 $content = str_replace($shortcode_value, $new_shortcode, $content);
1335 }
1336 }
1337 }
1338 return $content;
1339 }
1340
1341 // verify
1342 public function verify() {
1343 if ($this->get('item') && $this->get('cached_post') && (($this->get('item') == get_post_type($this->get('cached_post'))) || ($this->get('item') == '-3' && $this->get('cached_post')))) {
1344 return true;
1345 }
1346 return false;
1347 }
1348
1349 // visual mapper
1350 public function visual_mapper() {
1351
1352 $vc = '';
1353
1354 if ($this->get('item') != '-3') {
1355 $vc .= '<h3 class="e2pdf-plr5">Common</h3>';
1356 $vc .= '<div class="e2pdf-grid">';
1357 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('ID', 'e2pdf-wp key="id"') . '</div>';
1358 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author', 'e2pdf-wp key="post_author"') . '</div>';
1359 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Author ID', 'e2pdf-wp key="post_author_id"') . '</div>';
1360 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date', 'e2pdf-wp key="post_date"') . '</div>';
1361 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Date (GMT)', 'e2pdf-wp key="post_date_gmt"') . '</div>';
1362 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Content', 'e2pdf-wp key="post_content"') . '</div>';
1363 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Title', 'e2pdf-wp key="post_title"') . '</div>';
1364 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Excerpt', 'e2pdf-wp key="post_excerpt"') . '</div>';
1365 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Status', 'e2pdf-wp key="post_status"') . '</div>';
1366 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comment Status', 'e2pdf-wp key="comment_status"') . '</div>';
1367 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping Status', 'e2pdf-wp key="ping_status"') . '</div>';
1368 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Password', 'e2pdf-wp key="post_password"') . '</div>';
1369 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Name', 'e2pdf-wp key="post_name"') . '</div>';
1370 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('To Ping', 'e2pdf-wp key="to_ping"') . '</div>';
1371 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Ping', 'e2pdf-wp key="pinged"') . '</div>';
1372 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date', 'e2pdf-wp key="post_modified"') . '</div>';
1373 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Modified Date (GMT)', 'e2pdf-wp key="post_modified_gmt"') . '</div>';
1374 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filtered Content', 'e2pdf-wp key="post_content_filtered"') . '</div>';
1375 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Parent ID', 'e2pdf-wp key="post_parent"') . '</div>';
1376 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('GUID', 'e2pdf-wp key="guid"') . '</div>';
1377 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Menu Order', 'e2pdf-wp key="menu_order"') . '</div>';
1378 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Type', 'e2pdf-wp key="post_type"') . '</div>';
1379 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Mime Type', 'e2pdf-wp key="post_mime_type"') . '</div>';
1380 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Comments Count', 'e2pdf-wp key="comment_count"') . '</div>';
1381 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Filter', 'e2pdf-wp key="filter"') . '</div>';
1382 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail', 'e2pdf-wp key="get_the_post_thumbnail"') . '</div>';
1383 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Thumbnail URL', 'e2pdf-wp key="get_the_post_thumbnail_url"') . '</div>';
1384 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Permalink', 'e2pdf-wp key="get_permalink"') . '</div>';
1385 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Post Permalink', 'e2pdf-wp key="get_post_permalink"') . '</div>';
1386 $vc .= '</div>';
1387
1388 $meta_keys = $this->get_post_meta_keys();
1389 if (!empty($meta_keys)) {
1390 $vc .= '<h3 class="e2pdf-plr5">Meta Keys</h3>';
1391 $vc .= "<div class='e2pdf-grid'>";
1392 foreach ($meta_keys as $meta_key) {
1393 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wp key="' . $meta_key . '" meta="true"') . '</div>';
1394 }
1395 $vc .= '</div>';
1396 }
1397
1398 $meta_keys = $this->get_post_taxonomy_keys();
1399 if (!empty($meta_keys)) {
1400 $vc .= '<h3 class="e2pdf-plr5">Taxonomy</h3>';
1401 $vc .= "<div class='e2pdf-grid'>";
1402 foreach ($meta_keys as $meta_key) {
1403 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-wp key="' . $meta_key . '" terms="true" names="true"') . '</div>';
1404 }
1405 $vc .= '</div>';
1406 }
1407 }
1408
1409 $vc .= '<h3 class="e2pdf-plr5">User</h3>';
1410 $vc .= "<div class='e2pdf-grid'>";
1411 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('ID', 'e2pdf-user key="ID"') . '</div>';
1412 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Description', 'e2pdf-user key="user_description"') . '</div>';
1413 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('First Name', 'e2pdf-user key="user_firstname"') . '</div>';
1414 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Last Name', 'e2pdf-user key="user_lastname"') . '</div>';
1415 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Login', 'e2pdf-user key="user_login"') . '</div>';
1416 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Nicename', 'e2pdf-user key="user_nicename"') . '</div>';
1417 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('E-mail', 'e2pdf-user key="user_email"') . '</div>';
1418 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Url', 'e2pdf-user key="user_url"') . '</div>';
1419 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Registered', 'e2pdf-user key="user_registered"') . '</div>';
1420 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('User Status', 'e2pdf-user key="user_status"') . '</div>';
1421 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('User Level', 'e2pdf-user key="user_level"') . '</div>';
1422 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Display Name', 'e2pdf-user key="display_name"') . '</div>';
1423 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Spam', 'e2pdf-user key="spam"') . '</div>';
1424 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Deleted', 'e2pdf-user key="deleted"') . '</div>';
1425 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Locale', 'e2pdf-user key="locale"') . '</div>';
1426 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Rich Editing', 'e2pdf-user key="rich_editing"') . '</div>';
1427 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Syntax Highlighting', 'e2pdf-user key="syntax_highlighting"') . '</div>';
1428 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Use SSL', 'e2pdf-user key="use_ssl"') . '</div>';
1429 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Roles', 'e2pdf-user key="roles"') . '</div>';
1430 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Avatar', 'e2pdf-user key="get_avatar"') . '</div>';
1431 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element('Avatar Url', 'e2pdf-user key="get_avatar_url"') . '</div>';
1432 $vc .= '</div>';
1433
1434 $meta_keys = $this->get_user_meta_keys();
1435 if (!empty($meta_keys)) {
1436 $vc .= '<h3 class="e2pdf-plr5">User Meta Keys</h3>';
1437 $vc .= "<div class='e2pdf-grid'>";
1438 foreach ($meta_keys as $meta_key) {
1439 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($meta_key, 'e2pdf-user key="' . $meta_key . '" meta="true"') . '</div>';
1440 }
1441 $vc .= '</div>';
1442 }
1443
1444 if (class_exists('ACF') && function_exists('acf_get_field_groups')) {
1445 $user_groups = acf_get_field_groups(
1446 [
1447 'user_id' => 'new',
1448 'user_form' => 'all',
1449 ]
1450 );
1451 if (!empty($user_groups)) {
1452 $user_groups = array_column($user_groups, 'key');
1453 }
1454 if ($this->get('item') == '-3') {
1455 $groups = acf_get_field_groups(
1456 [
1457 'user_id' => 'new',
1458 'user_form' => 'all',
1459 ]
1460 );
1461 } else {
1462 $groups = acf_get_field_groups(['post_type' => $this->get('item')]);
1463 }
1464 if (!empty($groups)) {
1465 $vc .= "<h3 class='e2pdf-plr5'>ACF</h3>";
1466 foreach ($groups as $group_key => $group) {
1467 $post_id = '';
1468 if (!empty($user_groups)) {
1469 if (in_array($group['key'], $user_groups, false)) {
1470 if ($this->get('item') == '-3') {
1471 $post_id = ' post_id="user_[e2pdf-dataset]"';
1472 } else {
1473 $post_id = ' post_id="user_[e2pdf-userid]"';
1474 }
1475 }
1476 }
1477 $vc .= '<h3 class="e2pdf-plr5">' . $group['title'] . '</h3>';
1478 $vc .= "<div class='e2pdf-grid'>";
1479 foreach (acf_get_fields($group['key']) as $field_key => $field) {
1480 $vc = $this->get_acf_field($vc, $field, $post_id);
1481 }
1482 $vc .= '</div>';
1483 }
1484 }
1485 }
1486 return $vc;
1487 }
1488
1489 // get acf field
1490 public function get_acf_field($vc, $field, $post_id) {
1491 if ($field['type'] == 'repeater' && !empty($field['sub_fields'])) {
1492 $sub_fields = [];
1493 foreach ($field['sub_fields'] as $sub_field_key => $sub_field) {
1494 $sub_fields[] = '[acf field="' . $sub_field['name'] . '"' . $post_id . ']';
1495 $sub_field['label'] = $field['label'] . ' ' . $sub_field['label'];
1496 $sub_field['name'] = $field['name'] . '_0_' . $sub_field['name'];
1497 $vc = $this->get_acf_field($vc, $sub_field, $post_id);
1498 }
1499 if (!empty($sub_fields)) {
1500 $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>';
1501 }
1502 } elseif ($field['type'] == 'group' && !empty($field['sub_fields'])) {
1503 $sub_fields = [];
1504 foreach ($field['sub_fields'] as $sub_field_key => $sub_field) {
1505 $sub_field['label'] = $field['label'] . ' ' . $sub_field['label'];
1506 $sub_field['name'] = $field['name'] . '_' . $sub_field['name'];
1507 $vc = $this->get_acf_field($vc, $sub_field, $post_id);
1508 }
1509 } else {
1510 if ($field['name']) {
1511 $vc .= '<div class="e2pdf-ib e2pdf-w50 e2pdf-vm-item">' . $this->get_vm_element($field['label'], 'acf field="' . $field['name'] . '"' . $post_id) . '</div>';
1512 }
1513 }
1514 return $vc;
1515 }
1516
1517 // get post meta keys
1518 public function get_post_meta_keys() {
1519 global $wpdb;
1520 $meta_keys = [];
1521 if ($this->get('item')) {
1522 $condition = [
1523 'p.post_type' => [
1524 'condition' => '=',
1525 'value' => $this->get('item'),
1526 'type' => '%s',
1527 ],
1528 ];
1529 $order_condition = [
1530 'orderby' => 'meta_key',
1531 'order' => 'desc',
1532 ];
1533 $where = $this->helper->load('db')->prepare_where($condition);
1534 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1535 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1536 $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']));
1537 }
1538 return $meta_keys;
1539 }
1540
1541 // get user meta keys
1542 public function get_user_meta_keys() {
1543 global $wpdb;
1544 $meta_keys = [];
1545 if ($this->get('item')) {
1546 $order_condition = [
1547 'orderby' => 'meta_key',
1548 'order' => 'desc',
1549 ];
1550 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1551 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1552 $meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `meta_key` FROM `' . $wpdb->usermeta . '` ' . $orderby . ''));
1553 }
1554 return $meta_keys;
1555 }
1556
1557 // get post taxonomy keys
1558 public function get_post_taxonomy_keys() {
1559 global $wpdb;
1560 $meta_keys = [];
1561 if ($this->get('item')) {
1562 $order_condition = [
1563 'orderby' => 'taxonomy',
1564 'order' => 'desc',
1565 ];
1566 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
1567 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1568 $meta_keys = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT `taxonomy` FROM `' . $wpdb->term_taxonomy . '` `t` ' . $orderby . ''));
1569 }
1570 return $meta_keys;
1571 }
1572
1573 // get wm element
1574 public function get_vm_element($name, $id) {
1575 $element = '<div>';
1576 $element .= '<label>' . $name . ':</label>';
1577 $element .= '<input type="text" name=\'[' . $id . ']\' value=\'[' . $id . ']\' class="e2pdf-w100">';
1578 $element .= '</div>';
1579 return $element;
1580 }
1581
1582 // page edit hook
1583 public function hook_wordpress_page_edit() {
1584 // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1585 $items = $this->helper->load('hooks')->get_items('wordpress', 'hook_wordpress_page_edit');
1586 if (!empty($items)) {
1587 add_meta_box(
1588 'e2pdf',
1589 apply_filters('e2pdf_hook_section_title', __('E2Pdf Actions', 'e2pdf'), 'hook_wordpress_page_edit'),
1590 [$this, 'hook_wordpress_page_edit_callback'],
1591 $items,
1592 'side',
1593 'default'
1594 );
1595 }
1596 }
1597
1598 // page edit callback hook
1599 public function hook_wordpress_page_edit_callback($post) {
1600 if (!empty($post->post_type)) {
1601 // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1602 $hooks = $this->helper->load('hooks')->get('wordpress', 'hook_wordpress_page_edit', $post->post_type);
1603 if (!empty($hooks)) {
1604 foreach ($hooks as $hook) {
1605 if ($this->helper->load('hooks')->process_hook(
1606 $hook,
1607 [
1608 'dataset' => $post->ID,
1609 ],
1610 'hook_wordpress_page_edit'
1611 )
1612 ) {
1613 $action = apply_filters(
1614 'e2pdf_hook_action_button',
1615 [
1616 '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>',
1617 'url' => $this->helper->get_url(
1618 [
1619 'page' => 'e2pdf',
1620 'action' => 'export',
1621 'id' => $hook,
1622 'dataset' => $post->ID,
1623 ], 'admin.php?'
1624 ),
1625 'title' => 'PDF #' . $hook,
1626 ], 'hook_wordpress_page_edit', $hook, $post->ID
1627 );
1628 if (!empty($action)) {
1629 echo sprintf(
1630 $action['html'], $action['url'], $action['title']
1631 );
1632 }
1633 }
1634 }
1635 }
1636 }
1637 }
1638
1639 // row actions hook
1640 public function hook_wordpress_row_actions($actions, $post) {
1641 if ($post && is_a($post, 'WP_User')) {
1642 if (!empty($post->ID)) {
1643 // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1644 $hooks = $this->helper->load('hooks')->get('wordpress', 'hook_wordpress_row_actions', '-3');
1645 foreach ($hooks as $hook) {
1646 if ($this->helper->load('hooks')->process_hook(
1647 $hook,
1648 [
1649 'dataset' => $post->ID,
1650 ],
1651 'hook_wordpress_row_actions'
1652 )
1653 ) {
1654 $action = apply_filters(
1655 'e2pdf_hook_action_button',
1656 [
1657 'html' => '<a class="e2pdf-download-hook" target="_blank" href="%s">%s</a>',
1658 'url' => $this->helper->get_url(
1659 [
1660 'page' => 'e2pdf',
1661 'action' => 'export',
1662 'id' => $hook,
1663 'dataset' => $post->ID,
1664 ], 'admin.php?'
1665 ),
1666 'title' => 'PDF #' . $hook,
1667 ], 'hook_wordpress_row_actions', $hook, $post->ID
1668 );
1669 if (!empty($action)) {
1670 $actions['e2pdf_' . $hook] = sprintf(
1671 $action['html'], $action['url'], $action['title']
1672 );
1673 }
1674 }
1675 }
1676 }
1677 } else {
1678 if (!empty($post->post_type) && !empty($post->ID)) {
1679 // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
1680 $hooks = $this->helper->load('hooks')->get('wordpress', 'hook_wordpress_row_actions', $post->post_type);
1681 foreach ($hooks as $hook) {
1682 if ($this->helper->load('hooks')->process_hook(
1683 $hook,
1684 [
1685 'dataset' => $post->ID,
1686 ],
1687 'hook_wordpress_row_actions'
1688 )
1689 ) {
1690 $action = apply_filters(
1691 'e2pdf_hook_action_button',
1692 [
1693 'html' => '<a class="e2pdf-download-hook" target="_blank" href="%s">%s</a>',
1694 'url' => $this->helper->get_url(
1695 [
1696 'page' => 'e2pdf',
1697 'action' => 'export',
1698 'id' => $hook,
1699 'dataset' => $post->ID,
1700 ], 'admin.php?'
1701 ),
1702 'title' => 'PDF #' . $hook,
1703 ], 'hook_wordpress_row_actions', $hook, $post->ID
1704 );
1705 if (!empty($action)) {
1706 $actions['e2pdf_' . $hook] = sprintf(
1707 $action['html'], $action['url'], $action['title']
1708 );
1709 }
1710 }
1711 }
1712 }
1713 }
1714 return $actions;
1715 }
1716 }
1717