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

818 lines 30.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Wordpress Extension
5 *
6 * @copyright Copyright 2017 https://e2pdf.com
7 * @license GPL v2
8 * @version 1
9 * @link https://e2pdf.com
10 * @since 0.00.01
11 */
12 if (!defined('ABSPATH')) {
13 die('Access denied.');
14 }
15
16 class Extension_E2pdf_Wordpress extends Model_E2pdf_Model {
17
18 private $options;
19 private $info = array(
20 'key' => 'wordpress',
21 'title' => 'WordPress'
22 );
23
24 function __construct() {
25 parent::__construct();
26 }
27
28 /**
29 * Get info about extension
30 *
31 * @param string $key - Key to get assigned extension info value
32 *
33 * @return array|string - Extension Key and Title or Assigned extension info value
34 */
35 public function info($key = false) {
36 if ($key && isset($this->info[$key])) {
37 return $this->info[$key];
38 } else {
39 return array(
40 $this->info['key'] => $this->info['title']
41 );
42 }
43 }
44
45 /**
46 * Check if needed plugin active
47 *
48 * @return bool - Activated/Not Activated plugin
49 */
50 public function active() {
51 return true;
52 }
53
54 /**
55 * Set option
56 *
57 * @param string $key - Key of option
58 * @param string $value - Value of option
59 *
60 * @return bool - Status of setting option
61 */
62 public function set($key, $value) {
63 if (!isset($this->options)) {
64 $this->options = new stdClass();
65 }
66
67 $this->options->$key = $value;
68 }
69
70 /**
71 * Get option by key
72 *
73 * @param string $key - Key to get assigned option value
74 *
75 * @return mixed
76 */
77 public function get($key) {
78 if (isset($this->options->$key)) {
79 $value = $this->options->$key;
80 return $value;
81 } elseif ($key == 'args') {
82 return array();
83 } else {
84 return false;
85 }
86 }
87
88 /**
89 * Get items to work with
90 *
91 * @return array() - List of available items
92 */
93 public function items() {
94 $content = array();
95
96 $items = get_post_types(array(), 'names');
97
98 foreach ($items as $item) {
99 if ($item != 'attachment') {
100 $content[] = $this->item($item);
101 }
102 }
103
104 return $content;
105 }
106
107 /**
108 * Get entries for export
109 *
110 * @param string $item - Item
111 * @param string $name - Entries names
112 *
113 * @return array() - Entries list
114 */
115 public function datasets($item = false, $name = false) {
116
117 $datasets = array();
118
119 if ($item) {
120 $datasets_tmp = get_posts(
121 array(
122 'post_type' => $item,
123 'numberposts' => -1,
124 'post_status' => 'any'
125 ));
126
127 if ($datasets_tmp) {
128 foreach ($datasets_tmp as $key => $dataset) {
129 $this->set('item', $item);
130 $this->set('dataset', $dataset->ID);
131
132 $dataset_title = $this->render($name);
133 if (!$dataset_title) {
134 $dataset_title = isset($dataset->post_title) && $dataset->post_title ? $dataset->post_title : $dataset->ID;
135 }
136 $datasets[] = array(
137 'key' => $dataset->ID,
138 'value' => $dataset_title
139 );
140 }
141 }
142 }
143
144 return $datasets;
145 }
146
147 /**
148 * Get dataset
149 *
150 * @param int $dataset - Dataset ID
151 *
152 * @return object - Dataset
153 */
154 public function dataset($dataset = false) {
155
156 $dataset = (int) $dataset;
157
158 if (!$dataset) {
159 return;
160 }
161
162 $data = new stdClass();
163 $data->url = $this->helper->get_url(array('post' => $dataset, 'action' => 'edit'), 'post.php?');
164
165 return $data;
166 }
167
168 /**
169 * Get item
170 *
171 * @param string $item - Item
172 *
173 * @return object - Item
174 */
175 public function item($item = false) {
176
177 if (!$item && $this->get('item')) {
178 $item = $this->get('item');
179 }
180
181 $form = new stdClass();
182 $post = get_post_type_object($item);
183 if ($post) {
184 $form->id = $item;
185 $form->name = $post->label ? $post->label : $item;
186 $form->url = $this->helper->get_url(array('post_type' => $item), 'edit.php?');
187 } else {
188 $form->id = '';
189 $form->name = '';
190 $form->url = 'javascript:void(0);';
191 }
192
193 return $form;
194 }
195
196 public function load_filters() {
197 add_filter('the_content', array($this, 'filter_content'), 10, 2);
198 add_filter('widget_text', array($this, 'filter_content_custom'), 10, 1);
199
200 /**
201 * https://wordpress.org/plugins/popup-maker/
202 */
203 add_filter('pum_popup_content', array($this, 'filter_content'), 10, 2);
204
205 /**
206 * https://wordpress.org/plugins/events-manager/
207 */
208 add_filter('em_event_output_placeholder', array($this, 'filter_content_custom'), 0, 1);
209 add_filter('em_event_output', array($this, 'filter_content_custom'), 10, 1);
210 add_filter('em_booking_output_placeholder', array($this, 'filter_content_custom'), 0, 1);
211 add_filter('em_booking_output', array($this, 'filter_content_custom'), 10, 1);
212 add_filter('em_location_output_placeholder', array($this, 'filter_content_custom'), 0, 1);
213 add_filter('em_location_output', array($this, 'filter_content_custom'), 10, 1);
214 add_filter('em_category_output_placeholder', array($this, 'filter_content_custom'), 0, 1);
215 }
216
217 /**
218 * Render value according to content
219 *
220 * @param string $value - Content
221 * @param string $type - Type of rendering value
222 * @param array $field - Field details
223 *
224 * @return string - Fully rendered value
225 */
226 public function render($value, $type = false, $field = array()) {
227
228 $value = $this->render_shortcodes($value, $type, $field);
229 $value = $this->strip_shortcodes($value);
230
231 if ($type === 'value' && isset($field['type']) && $field['type'] === 'e2pdf-checkbox' && isset($field['properties']['option'])) {
232 $option = $this->render($field['properties']['option']);
233 $options = explode(', ', $value);
234 $option_options = explode(', ', $option);
235 if (is_array($options) && is_array($option_options) && !array_diff($option_options, $options)) {
236 return $option;
237 } else {
238 return "";
239 }
240 }
241
242 if ($type === 'value') {
243 $value = $this->convert_shortcodes($value, true);
244 }
245
246 return $value;
247 }
248
249 /**
250 * Render shortcodes which available in this extension
251 *
252 * @param string $value - Content
253 * @param string $type - Type of rendering value
254 * @param array $field - Field details
255 *
256 * @return string - Value with rendered shortcodes
257 */
258 public function render_shortcodes($value, $type = false, $field = array()) {
259
260 $dataset = $this->get('dataset');
261 $item = $this->get('item');
262 $args = $this->get('args');
263 $user_id = $this->get('user_id');
264 $template_id = $this->get('template_id') ? $this->get('template_id') : '0';
265 $element_id = isset($field['element_id']) ? $field['element_id'] : '0';
266
267 if ($this->verify()) {
268
269 $args = apply_filters('e2pdf_extension_render_shortcodes_args', $args, $element_id, $template_id, $item, $dataset);
270
271 $post = get_post($dataset);
272
273 $wordpress_shortcodes = array(
274 'id',
275 'post_author',
276 'post_date',
277 'post_date_gmt',
278 'post_content',
279 'post_title',
280 'post_excerpt',
281 'post_status',
282 'comment_status',
283 'ping_status',
284 'post_password',
285 'post_name',
286 'to_ping',
287 'pinged',
288 'post_modified',
289 'post_modified_gmt',
290 'post_content_filtered',
291 'post_parent',
292 'guid',
293 'menu_order',
294 'post_type',
295 'post_mime_type',
296 'comment_count',
297 'filter',
298 'post_thumbnail'
299 );
300
301 if (false !== strpos($value, '[')) {
302
303 $shortcode_tags = array(
304 'meta',
305 'terms',
306 'e2pdf-wp',
307 'e2pdf-content',
308 'e2pdf-user',
309 'e2pdf-arg'
310 );
311
312 $shortcode_tags = array_merge($shortcode_tags, $wordpress_shortcodes);
313
314 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches);
315 $tagnames = array_intersect($shortcode_tags, $matches[1]);
316
317 if (!empty($tagnames)) {
318
319 $pattern = $this->helper->load('shortcode')->get_shortcode_regex($tagnames);
320
321 preg_match_all("/$pattern/", $value, $shortcodes);
322
323 foreach ($shortcodes[0] as $key => $shortcode_value) {
324 $shortcode = array();
325 $shortcode[1] = $shortcodes[1][$key];
326 $shortcode[2] = $shortcodes[2][$key];
327 $shortcode[3] = $shortcodes[3][$key];
328 $shortcode[4] = $shortcodes[4][$key];
329 $shortcode[5] = $shortcodes[5][$key];
330 $shortcode[6] = $shortcodes[6][$key];
331
332 $atts = shortcode_parse_atts($shortcode[3]);
333
334 if ($shortcode[2] === 'e2pdf-content') {
335 if (!isset($atts['id']) && isset($post->ID) && $post->ID) {
336 $shortcode[3] .= " id=\"" . $post->ID . "\"";
337 $value = str_replace($shortcode_value, "[" . $shortcode['2'] . $shortcode['3'] . "]", $value);
338 }
339 } else if ($shortcode[2] === 'e2pdf-user') {
340 if (!isset($atts['id']) && $user_id) {
341 $shortcode[3] .= " id=\"" . $user_id . "\"";
342 $value = str_replace($shortcode_value, "[" . $shortcode['2'] . $shortcode['3'] . "]", $value);
343 }
344 } else if ($shortcode['2'] === 'meta' || $shortcode['2'] === 'terms' || $shortcode['2'] == 'e2pdf-wp') {
345 if (!isset($atts['id']) && isset($post->ID) && $post->ID) {
346 $shortcode[3] .= " id=\"" . $post->ID . "\"";
347 }
348 if ($shortcode['2'] === 'meta') {
349 $shortcode[3] .= " meta=\"true\"";
350 }
351 if ($shortcode['2'] === 'terms') {
352 $shortcode[3] .= " terms=\"true\"";
353 }
354
355 $value = str_replace($shortcode_value, "[e2pdf-wp" . $shortcode['3'] . "]", $value);
356 } elseif (in_array($shortcode[2], $wordpress_shortcodes)) {
357 if (!isset($atts['id']) && isset($post->ID) && $post->ID) {
358 $shortcode[3] .= " id=\"" . $post->ID . "\"";
359 }
360 $shortcode[3] .= " key=\"" . $shortcode[2] . "\"";
361 $value = str_replace($shortcode_value, "[e2pdf-wp" . $shortcode['3'] . "]", $value);
362 } elseif ($shortcode['2'] == 'e2pdf-arg') {
363 if (isset($atts['key']) && isset($args[$atts['key']])) {
364 $sub_value = $this->strip_shortcodes($args[$atts['key']]);
365 $value = str_replace($shortcode_value, $sub_value, $value);
366 } else {
367 $value = str_replace($shortcode_value, '', $value);
368 }
369 }
370 }
371 }
372
373 $shortcode_tags = array(
374 'e2pdf-format-number',
375 'e2pdf-format-date',
376 'e2pdf-format-output',
377 );
378 $shortcode_tags = apply_filters('e2pdf_extension_render_shortcodes_tags', $shortcode_tags);
379 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches);
380 $tagnames = array_intersect($shortcode_tags, $matches[1]);
381
382 if (!empty($tagnames)) {
383
384 $pattern = $this->helper->load('shortcode')->get_shortcode_regex($tagnames);
385
386 preg_match_all("/$pattern/", $value, $shortcodes);
387 foreach ($shortcodes[0] as $key => $shortcode_value) {
388 $shortcode = array();
389 $shortcode[1] = $shortcodes[1][$key];
390 $shortcode[2] = $shortcodes[2][$key];
391 $shortcode[3] = $shortcodes[3][$key];
392 $shortcode[4] = $shortcodes[4][$key];
393 $shortcode[5] = $shortcodes[5][$key];
394 $shortcode[6] = $shortcodes[6][$key];
395
396 if (!$shortcode['5']) {
397 $sub_value = '';
398 } elseif (isset($field['type']) && ($field['type'] === 'e2pdf-image' || $field['type'] === 'e2pdf-signature')) {
399 $sub_value = $this->render($shortcode['5'], $type);
400 } else {
401 $sub_value = $this->render($shortcode['5'], $type, $field);
402 }
403 $value = str_replace($shortcode_value, "[" . $shortcode['2'] . $shortcode['3'] . "]" . $sub_value . "[/" . $shortcode['2'] . "]", $value);
404 }
405 }
406 }
407
408 $value = do_shortcode($value);
409
410 if (isset($field['type']) && ($field['type'] === 'e2pdf-image' || $field['type'] === 'e2pdf-signature')) {
411 $esig = isset($field['properties']['esig']) && $field['properties']['esig'] ? true : false;
412 if ($esig) {
413 //process e-signature
414 $value = "";
415 } else {
416
417 if (isset($field['properties']['preg_pattern']) && $field['properties']['preg_pattern'] && isset($field['properties']['preg_replacement']) && $value) {
418 $value = $this->helper->load('convert')->preg_replace($field['properties']['preg_pattern'], $field['properties']['preg_replacement'], $value);
419 }
420
421 if (!$this->helper->load('image')->get_image($value)) {
422 $value = $this->strip_shortcodes($value);
423 if (
424 $value &&
425 trim($value) != "" &&
426 extension_loaded('gd') &&
427 function_exists('imagettftext')
428 ) {
429 if (isset($field['properties']['text_color']) && $field['properties']['text_color']) {
430 $penColour = $this->helper->load('convert')->to_hex_color($field['properties']['text_color']);
431 } else {
432 $penColour = array(0x14, 0x53, 0x94);
433 }
434
435 $default_options = array(
436 'imageSize' => array(isset($field['width']) ? $field['width'] : '400', isset($field['height']) ? $field['height'] : '150'),
437 'bgColour' => 'transparent',
438 'penColour' => $penColour
439 );
440
441 $options = array();
442 $options = apply_filters('e2pdf_image_sig_output_options', $options, $element_id, $template_id);
443 $options = array_merge($default_options, $options);
444
445 $model_e2pdf_font = new Model_E2pdf_Font();
446
447 $font = false;
448 if (isset($field['properties']['text_font']) && $field['properties']['text_font']) {
449 $font = $model_e2pdf_font->get_font_path($field['properties']['text_font']);
450 }
451 if (!$font) {
452 $font = $model_e2pdf_font->get_font_path('Noto Sans');
453 }
454
455 $size = 150;
456 if (isset($field['properties']['text_font_size']) && $field['properties']['text_font_size']) {
457 $size = $field['properties']['text_font_size'];
458 }
459
460 $model_e2pdf_signature = new Model_E2pdf_Signature();
461 $value = $model_e2pdf_signature->ttf_signature($value, $size, $font, $options);
462 } else {
463 $value = "";
464 }
465 }
466 }
467 } else {
468
469 $value = $this->convert_shortcodes($value);
470
471 if (isset($field['properties']['preg_pattern']) && $field['properties']['preg_pattern'] && isset($field['properties']['preg_replacement']) && $value) {
472 $value = $this->helper->load('convert')->preg_replace($field['properties']['preg_pattern'], $field['properties']['preg_replacement'], $value);
473 }
474 }
475 }
476
477 $value = apply_filters('e2pdf_extension_render_shortcodes_value', $value, $element_id, $template_id, $item, $dataset);
478
479 return $value;
480 }
481
482 /**
483 * Strip unused shortcodes
484 *
485 * @param string $value - Content
486 *
487 * @return string - Value with removed unused shortcodes
488 */
489 public function strip_shortcodes($value) {
490 $value = preg_replace('~(?:\[/?)[^/\]]+/?\]~s', "", $value);
491 return $value;
492 }
493
494 /**
495 * Convert "shortcodes" inside value string
496 *
497 * @param string $value - Value string
498 * @param bool $to - Convert From/To
499 *
500 * @return string - Converted value
501 */
502 public function convert_shortcodes($value, $to = false) {
503 if ($value) {
504 if ($to) {
505 $value = str_replace("&#91;", "[", $value);
506 } else {
507 $value = str_replace("[", "&#91;", $value);
508 }
509 }
510 return $value;
511 }
512
513 public function auto() {
514 $response = array();
515 $elements = array();
516
517 $post = $this->get('item');
518
519 $elements[] = array(
520 'type' => 'e2pdf-html',
521 'block' => true,
522 'properties' => array(
523 'top' => '20',
524 'left' => '20',
525 'right' => '20',
526 'width' => '100%',
527 'height' => 'auto',
528 'value' => "<h1>[post_title]</h1>",
529 )
530 );
531
532 $elements[] = array(
533 'type' => 'e2pdf-html',
534 'block' => true,
535 'properties' => array(
536 'top' => '20',
537 'left' => '20',
538 'right' => '20',
539 'width' => '100%',
540 'height' => 'auto',
541 'value' => __("Post name", 'e2pdf') . ": [post_name]",
542 )
543 );
544
545 $elements[] = array(
546 'type' => 'e2pdf-html',
547 'block' => true,
548 'properties' => array(
549 'top' => '20',
550 'left' => '20',
551 'right' => '20',
552 'width' => '100%',
553 'height' => 'auto',
554 'value' => __("Post type", 'e2pdf') . ": [post_type]",
555 )
556 );
557
558 $elements[] = array(
559 'type' => 'e2pdf-html',
560 'block' => true,
561 'properties' => array(
562 'top' => '20',
563 'left' => '20',
564 'right' => '20',
565 'width' => '100%',
566 'height' => 'auto',
567 'value' => __("ID", 'e2pdf') . ": [id]",
568 )
569 );
570
571 $elements[] = array(
572 'type' => 'e2pdf-html',
573 'block' => true,
574 'properties' => array(
575 'top' => '20',
576 'left' => '20',
577 'right' => '20',
578 'width' => '100%',
579 'height' => 'auto',
580 'value' => __("Author", 'e2pdf') . ": [post_author]",
581 )
582 );
583
584 $elements[] = array(
585 'type' => 'e2pdf-html',
586 'block' => true,
587 'properties' => array(
588 'top' => '20',
589 'left' => '20',
590 'right' => '20',
591 'width' => '100%',
592 'height' => '300',
593 'value' => "[post_content]",
594 'dynamic_height' => '1',
595 )
596 );
597
598 $elements[] = array(
599 'type' => 'e2pdf-html',
600 'block' => true,
601 'properties' => array(
602 'top' => '20',
603 'left' => '20',
604 'right' => '20',
605 'width' => '100%',
606 'height' => 'auto',
607 'value' => __("Created", 'e2pdf') . ": [post_date]",
608 )
609 );
610
611 $elements[] = array(
612 'type' => 'e2pdf-html',
613 'block' => true,
614 'properties' => array(
615 'top' => '20',
616 'left' => '20',
617 'right' => '20',
618 'width' => '100%',
619 'height' => 'auto',
620 'value' => __("Modified", 'e2pdf') . ": [post_modified]",
621 )
622 );
623
624 $response['page'] = array(
625 'bottom' => '20',
626 'top' => '20',
627 'left' => '20',
628 'right' => '20'
629 );
630
631 $response['elements'] = $elements;
632 return $response;
633 }
634
635 /**
636 * Search and update shortcodes for this extension inside content
637 * Auto set of dataset id
638 *
639 * @param string $content - Content
640 * @param string $post_id - Custom Post ID
641 *
642 * @return string - Content with updated shortcodes
643 */
644 public function filter_content($content, $post_id = false) {
645 global $post;
646
647 if (false === strpos($content, '[')) {
648 return $content;
649 }
650
651 $shortcode_tags = array(
652 'e2pdf-download',
653 'e2pdf-save',
654 'e2pdf-view',
655 'e2pdf-adobesign'
656 );
657
658 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
659 $tagnames = array_intersect($shortcode_tags, $matches[1]);
660
661 if (!empty($tagnames)) {
662
663 $pattern = $this->helper->load('shortcode')->get_shortcode_regex($tagnames);
664
665 preg_match_all("/$pattern/", $content, $shortcodes);
666
667 foreach ($shortcodes[0] as $key => $shortcode_value) {
668
669 wp_reset_postdata();
670
671 $shortcode = array();
672 $shortcode[1] = $shortcodes[1][$key];
673 $shortcode[2] = $shortcodes[2][$key];
674 $shortcode[3] = $shortcodes[3][$key];
675 $shortcode[4] = $shortcodes[4][$key];
676 $shortcode[5] = $shortcodes[5][$key];
677 $shortcode[6] = $shortcodes[6][$key];
678
679 $atts = shortcode_parse_atts($shortcode[3]);
680
681 if (($shortcode[2] === 'e2pdf-save' && isset($atts['attachment']) && $atts['attachment'] == 'true') || $shortcode[2] === 'e2pdf-attachment') {
682
683 } else {
684 if (!isset($atts['dataset']) && isset($atts['id'])) {
685 $template = new Model_E2pdf_Template();
686 $template->load($atts['id']);
687 if ($template->get('extension') === 'wordpress') {
688 if ($post_id || isset($post->ID)) {
689 $dataset = $post_id ? $post_id : $post->ID;
690 $atts['dataset'] = $dataset;
691 $shortcode[3] .= " dataset=\"{$dataset}\"";
692 }
693 }
694 }
695
696 if (!isset($atts['apply'])) {
697 $shortcode[3] .= " apply=\"true\"";
698 }
699
700 if (!isset($atts['filter'])) {
701 $shortcode[3] .= " filter=\"true\"";
702 }
703
704 $content = str_replace($shortcode_value, do_shortcode_tag($shortcode), $content);
705 }
706 }
707 }
708
709 return $content;
710 }
711
712 public function filter_content_custom($content) {
713 $content = $this->filter_content($content);
714 return $content;
715 }
716
717 /**
718 * Verify if item and dataset exists
719 *
720 * @return bool - item and dataset exists
721 */
722 public function verify() {
723 $item = $this->get('item');
724 $dataset = $this->get('dataset');
725
726 if ($item && $dataset && get_post($dataset) && $item == get_post_type($dataset)) {
727 return true;
728 }
729
730 return false;
731 }
732
733 /**
734 * Init Visual Mapper data
735 *
736 * @return bool|string - HTML data source for Visual Mapper
737 */
738 public function visual_mapper() {
739
740 $meta_keys = $this->get_post_meta_keys();
741 if (!empty($meta_keys)) {
742 $vc .= "<h3>" . __('Meta Keys', 'e2pdf') . "</h3>";
743 $vc .= "<div class='e2pdf-grid'>";
744 foreach ($meta_keys as $meta_key) {
745 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element($meta_key, "meta key=\"{$meta_key}\"")}</div>";
746 }
747 $vc .= "</div>";
748 }
749
750 $vc .= "<h3>" . __('Common', 'e2pdf') . "</h3>";
751 $vc .= "<div class='e2pdf-grid'>";
752 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("ID", "e2pdf"), 'id')}</div>";
753 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Author", "e2pdf"), 'post_author')}</div>";
754 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Date", "e2pdf"), 'post_date')}</div>";
755 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Date (GMT)", "e2pdf"), 'post_date_gmt')}</div>";
756 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Content", "e2pdf"), 'post_content')}</div>";
757 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Title", "e2pdf"), 'post_title')}</div>";
758 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Excerpt", "e2pdf"), 'post_excerpt')}</div>";
759 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Status", "e2pdf"), 'post_status')}</div>";
760 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Comment Status", "e2pdf"), 'comment_status')}</div>";
761 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Ping Status", "e2pdf"), 'ping_status')}</div>";
762 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Post Password", "e2pdf"), 'post_password')}</div>";
763 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Post Name", "e2pdf"), 'post_name')}</div>";
764 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("To Ping", "e2pdf"), 'to_ping')}</div>";
765 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Ping", "e2pdf"), 'pinged')}</div>";
766 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Modified Date", "e2pdf"), 'post_modified')}</div>";
767 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Modified Date (GMT)", "e2pdf"), 'post_modified_gmt')}</div>";
768 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Filtered Content", "e2pdf"), 'post_content_filtered')}</div>";
769 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Parent ID", "e2pdf"), 'post_parent')}</div>";
770 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("GUID", "e2pdf"), 'guid')}</div>";
771 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Menu Order", "e2pdf"), 'menu_order')}</div>";
772 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Type", "e2pdf"), 'post_type')}</div>";
773 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Mime Type", "e2pdf"), 'post_mime_type')}</div>";
774 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Comments Count", "e2pdf"), 'comment_count')}</div>";
775 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pl10'>{$this->get_vm_element(__("Filter", "e2pdf"), 'filter')}</div>";
776 $vc .= "<div class='e2pdf-ib e2pdf-w50 e2pdf-pr10'>{$this->get_vm_element(__("Post Thumbnail", "e2pdf"), 'post_thumbnail')}</div>";
777 $vc .= "</div>";
778
779 return $vc;
780 }
781
782 private function get_post_meta_keys() {
783 global $wpdb;
784
785 $meta_keys = array();
786 if ($this->get('item')) {
787 $condition = array(
788 'p.post_type' => array(
789 'condition' => '=',
790 'value' => $this->get('item'),
791 'type' => '%s'
792 ),
793 );
794
795 $order_condition = array(
796 'orderby' => 'meta_key',
797 'order' => 'desc',
798 );
799
800 $where = $this->helper->load('db')->prepare_where($condition);
801 $orderby = $this->helper->load('db')->prepare_orderby($order_condition);
802
803 $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']));
804 }
805
806 return $meta_keys;
807 }
808
809 private function get_vm_element($name, $id) {
810 $element = "<div>";
811 $element .= "<label>{$name}:</label>";
812 $element .= "<input type='text' name='[{$id}]' value='[{$id}]' class='e2pdf-w100'>";
813 $element .= "</div>";
814 return $element;
815 }
816
817 }
818