Completed
Pull Request — master (#61)
by Bui Quang
02:37
created
templates/admin/partials/content.blade.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1
-<form method="POST" action="<?php \admin_url( 'options-general.php?page=wpdfi-settings.php' ); ?>" id="wpdfi-form">
1
+<form method="POST" action="<?php \admin_url('options-general.php?page=wpdfi-settings.php'); ?>" id="wpdfi-form">
2 2
 	<div class="error-wrapper" id="error_wrapper"></div>
3
-	<?php wp_nonce_field( "wpdfi-settings-page" ); ?>
3
+	<?php wp_nonce_field("wpdfi-settings-page"); ?>
4 4
 	<div class="wpdfi-content">
5 5
 		<div class="wpdfi-content-inner clearfix">
6 6
 			@if($current_tab == 'dfis')
Please login to merge, or discard this patch.
src/PostType.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
 	public function add_default_feature_image($post_id, $post_after, $post_before) {
49 49
 		/* Get the Admin Setting for option 'status_for_update', this option will has a value like publish, pending,... */
50 50
 		$status_for_update = \wpdfi()->admin->get_option('options', 'status_for_update');
51
-		if($status_for_update) $status_for_update = 'publish';
51
+		if ($status_for_update) $status_for_update = 'publish';
52 52
 		/**
53 53
 		 * Check the post-after-updated (pau).
54 54
 		 * If the pau does not have a feature image.
55 55
 		 */
56
-		if(!\has_post_thumbnail($post_after)) {
56
+		if (!\has_post_thumbnail($post_after)) {
57 57
 
58 58
 			/* Check if the pau status match the Admin Setting option 'status_for_update'. */
59
-			if($status_for_update == $post_after->post_status) {
59
+			if ($status_for_update == $post_after->post_status) {
60 60
 
61 61
 				$this->update_fimage($post_id);
62 62
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @return boolean
72 72
 	 */
73 73
 	public function update_fimage($post_id) {
74
-		if(!$post_id) return false;
74
+		if (!$post_id) return false;
75 75
 		$post_type = \get_post_type($post_id);
76 76
 		/* Get post's data about Terms */
77 77
 		$terms = $this->get_all_terms_post($post_id, $post_type);
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 
82 82
 		/* Loop through main Admin Setting to compare with post's data. */
83 83
 		$conditional_status = false; 
84
-		foreach($options as $option) {
84
+		foreach ($options as $option) {
85 85
 
86
-			if($option['post_type'] == $post_type) {
86
+			if ($option['post_type'] == $post_type) {
87 87
 				$option_taxonomy_not_exist = (!$option['taxonomy']);
88 88
 				$term_is_uncategorized = ($terms == ['category' => [1]]);
89 89
 				$posttype_is_post = ($post_type == 'post');
90 90
 				/* If two terms array match. */
91
-				if($terms == $option['taxonomy']) {
91
+				if ($terms == $option['taxonomy']) {
92 92
 
93 93
 					$conditional_status = true;
94 94
 
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 
105 105
 			}
106 106
 			/* If match conditional, set the default feature image for the post. */
107
-			if($conditional_status == true) {
107
+			if ($conditional_status == true) {
108 108
 
109
-				\set_post_thumbnail( $post_id, $option['image_id'] );
109
+				\set_post_thumbnail($post_id, $option['image_id']);
110 110
 				return true;
111 111
 			
112 112
 			}
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 	public function get_name() {
124 124
 		$names = \get_post_types();
125 125
 
126
-		if(is_array($names)) {
126
+		if (is_array($names)) {
127 127
 
128
-			foreach($names as $name) {
128
+			foreach ($names as $name) {
129 129
 
130
-				if(!\post_type_supports( $name, 'thumbnail' )) {
130
+				if (!\post_type_supports($name, 'thumbnail')) {
131 131
 
132 132
 					unset($names[$name]);
133 133
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @return string
149 149
 	 */
150 150
 	public function get_singular_name($post_type) {
151
-		return \get_post_type_object( $post_type )->labels->singular_name;
151
+		return \get_post_type_object($post_type)->labels->singular_name;
152 152
 	}
153 153
 
154 154
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		$data = [];
162 162
 
163 163
 		$index = 0;
164
-		foreach($this->get_name() as $name => $value) {
164
+		foreach ($this->get_name() as $name => $value) {
165 165
 
166 166
 			$data[$index]['id'] = $name; 
167 167
 			$data[$index]['text'] = $this->get_singular_name($name);
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 		/* Get all taxonomies of a post type. */
188 188
 		$taxonomies = \wpdfi()->taxonomy->get($post_type);
189 189
 		/* Loop through all taxonomies of a post type. */
190
-		foreach($taxonomies as $taxonomy_id => $taxonomy_value) {
190
+		foreach ($taxonomies as $taxonomy_id => $taxonomy_value) {
191 191
 			/* Push all the terms of the post (detected via post_id) to terms variable. */
192
-			foreach(\wp_get_post_terms($post_id, $taxonomy_id) as $term) {
192
+			foreach (\wp_get_post_terms($post_id, $taxonomy_id) as $term) {
193 193
 
194 194
 				$terms[] = $term;
195 195
 
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 
221 221
 		$pt_fl_settings = [];
222 222
 		$dfis_values = \wpdfi()->admin->get_option('dfis');
223
-		if($dfis_values) {
224
-			foreach($dfis_values as $dfi_values) {
223
+		if ($dfis_values) {
224
+			foreach ($dfis_values as $dfi_values) {
225 225
 				/* Only insert new value if there current value is not exist yet. */
226
-				if(!in_array($dfi_values['post_type'], $pt_fl_settings)) {
226
+				if (!in_array($dfi_values['post_type'], $pt_fl_settings)) {
227 227
 					$pt_fl_settings[] = $dfi_values['post_type'];
228 228
 				} 
229 229
 			}
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
 	public function get_pt_details_fl_settings() {
265 265
 		$post_types = $this->_get_pt_fl_settings();
266 266
 		$pt_details_fl_settings = [];
267
-		foreach($post_types as $pt) {
267
+		foreach ($post_types as $pt) {
268 268
 			/* Only insert new value if there current value is not exist yet. */
269
-			if(!array_key_exists($pt, $pt_details_fl_settings)) {
269
+			if (!array_key_exists($pt, $pt_details_fl_settings)) {
270 270
 				$args = $this->_get_args_posts_no_fimage($pt);
271 271
 				$posts_no_fimage = get_posts($args);
272 272
 				$pt_details_fl_settings[$pt] = count($posts_no_fimage);
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	public function get_posts_no_fimage_id() {
285 285
 		$post_types = $this->_get_pt_fl_settings();
286
-		$qr_posts_no_fimage = get_posts( $this->_get_args_posts_no_fimage($post_types) );
286
+		$qr_posts_no_fimage = get_posts($this->_get_args_posts_no_fimage($post_types));
287 287
 		$ids = [];
288
-		foreach($qr_posts_no_fimage as $post) {
288
+		foreach ($qr_posts_no_fimage as $post) {
289 289
 			$ids[] = $post->ID;
290 290
 		}  
291 291
 		return $ids;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,9 @@  discard block
 block discarded – undo
48 48
 	public function add_default_feature_image($post_id, $post_after, $post_before) {
49 49
 		/* Get the Admin Setting for option 'status_for_update', this option will has a value like publish, pending,... */
50 50
 		$status_for_update = \wpdfi()->admin->get_option('options', 'status_for_update');
51
-		if($status_for_update) $status_for_update = 'publish';
51
+		if($status_for_update) {
52
+			$status_for_update = 'publish';
53
+		}
52 54
 		/**
53 55
 		 * Check the post-after-updated (pau).
54 56
 		 * If the pau does not have a feature image.
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	 * @return boolean
72 74
 	 */
73 75
 	public function update_fimage($post_id) {
74
-		if(!$post_id) return false;
76
+		if(!$post_id) {
77
+			return false;
78
+		}
75 79
 		$post_type = \get_post_type($post_id);
76 80
 		/* Get post's data about Terms */
77 81
 		$terms = $this->get_all_terms_post($post_id, $post_type);
Please login to merge, or discard this patch.
src/Layout.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return \VA\Templater
35 35
 	 */
36 36
 	public function get_admin_layout($tabs, $current_tab, $options, $layout_name) {
37
-		return \wpdfi()->templater->render('admin.layout',[
37
+		return \wpdfi()->templater->render('admin.layout', [
38 38
 			'tabs' => $tabs, 'current_tab' => $current_tab,
39 39
 			'options' => $options, 'layout_name' => $layout_name,
40 40
 		]); 
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	public function get_related_layout($dfi_index, $post_type) {
77 77
 		$layout = '';
78 78
 		/* Get taxonomy layout */
79
-		$layout.= \wpdfi()->templater->render('admin.blocks.taxonomy.default', [
79
+		$layout .= \wpdfi()->templater->render('admin.blocks.taxonomy.default', [
80 80
 			'taxonomies' => \wpdfi()->taxonomy->get($post_type),
81 81
 			'dfi_index' => $dfi_index
82 82
 		]);
83
-		$layout.= \wpdfi()->templater->render('admin.blocks.imageupload.default', [
83
+		$layout .= \wpdfi()->templater->render('admin.blocks.imageupload.default', [
84 84
 			'dfi_index' => $dfi_index
85 85
 		]);
86 86
 		// $layout.= \wpdfi()->templater->render('admin.blocks.imagesize.default', [
Please login to merge, or discard this patch.