PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 1.3.4
Nested Pages v1.3.4
3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / app / Entities / Post / PostDataFactory.php
wp-nested-pages / app / Entities / Post Last commit date
PostDataFactory.php 11 years ago PostFactory.php 11 years ago PostRepository.php 11 years ago PostTrashActions.php 11 years ago PostUpdateRepository.php 11 years ago
PostDataFactory.php
98 lines
1 <?php namespace NestedPages\Entities\Post;
2 /**
3 * Build Post Data Object
4 */
5 class PostDataFactory {
6
7 /**
8 * Post Data
9 * @var object
10 */
11 private $post_data;
12
13 /**
14 * Build the Object
15 */
16 public function build($post)
17 {
18 $this->post_data = new \stdClass();
19 $this->addPostVars($post);
20 $this->addPostMeta($post);
21 $this->addMenuOptions($post);
22 $this->addDate($post);
23 $this->author($post);
24
25 return $this->post_data;
26 }
27
28 /**
29 * Post Items
30 */
31 public function addPostVars($post)
32 {
33 $this->post_data->id = $post->ID;
34 $this->post_data->parent_id = $post->post_parent;
35 $this->post_data->title = $post->post_title;
36 $this->post_data->template = get_post_meta($post->ID, '_wp_page_template', true);
37 $this->post_data->password = $post->post_password;
38 $this->post_data->status = $post->post_status;
39 $this->post_data->type = $post->post_type;
40 $this->post_data->comment_status = $post->comment_status;
41 $this->post_data->content = $post->post_content;
42 $this->post_data->hierarchical = is_post_type_hierarchical($post->post_type);
43 $this->post_data->link = get_the_permalink($post->ID);
44 }
45
46 /**
47 * Post Meta
48 */
49 public function addPostMeta($post)
50 {
51 // Hidden in Nested Pages?
52 $np_status = get_post_meta( $post->ID, 'nested_pages_status', true );
53 $this->post_data->np_status = ( $np_status == 'hide' ) ? 'hide' : 'show';
54
55 // Yoast Score
56 if ( function_exists('wpseo_translate_score') ) {
57 $yoast_score = get_post_meta($post->ID, '_yoast_wpseo_linkdex', true);
58 $this->post_data->score = wpseo_translate_score($yoast_score);
59 };
60 }
61
62 /**
63 * Menu Options
64 */
65 private function addMenuOptions($post)
66 {
67 $this->post_data->nav_title = get_post_meta($post->ID, 'np_nav_title', true);
68 $this->post_data->link_target = get_post_meta($post->ID, 'np_link_target', true);
69 $this->post_data->nav_title_attr = get_post_meta($post->ID, 'np_title_attribute', true);
70 $this->post_data->nav_css = get_post_meta($post->ID, 'np_nav_css_classes', true);
71 $nav_status = get_post_meta( $post->ID, 'np_nav_status', true);
72 $this->post_data->nav_status = ( $nav_status == 'hide' ) ? 'hide' : 'show';
73 }
74
75 /**
76 * Date Vars
77 */
78 private function addDate($post)
79 {
80 $this->post_data->date = new \stdClass();
81 $this->post_data->date->d = get_the_time('d', $post->ID);
82 $this->post_data->date->month = get_the_time('m', $post->ID);
83 $this->post_data->date->y = get_the_time('Y', $post->ID);
84 $this->post_data->date->h = get_the_time('H', $post->ID);
85 $this->post_data->date->m = get_the_time('i', $post->ID);
86 $this->post_data->date->datepicker = get_the_time('U', $post->ID);
87 }
88
89 /**
90 * Add Author Info
91 */
92 private function author($post)
93 {
94 $this->post_data->author = get_the_author_meta('display_name', $post->post_author);
95 $this->post_data->author_link = admin_url('edit.php?post_type=' . $post->post_type . '&author=' . $post->post_author);
96 }
97
98 }