Completed
Pull Request — master (#52)
by Bui Quang
03:48
created
src/PostType.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -241,16 +241,16 @@
 block discarded – undo
241 241
 	protected function _get_args_posts_no_fimage($post_type) {
242 242
 		return [
243 243
 			'post_type' => $post_type,
244
-		    'meta_query' => [
245
-		        [
246
-		            'key' => '_thumbnail_id',
247
-		            'compare' => 'NOT EXISTS'
248
-		        ]
249
-		    ],
250
-		    'post_status' => ['publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'],
251
-		    'orderby' => 'ID',
252
-		    'order' => 'ASC',
253
-		    'posts_per_page' => -1
244
+			'meta_query' => [
245
+				[
246
+					'key' => '_thumbnail_id',
247
+					'compare' => 'NOT EXISTS'
248
+				]
249
+			],
250
+			'post_status' => ['publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'],
251
+			'orderby' => 'ID',
252
+			'order' => 'ASC',
253
+			'posts_per_page' => -1
254 254
 	 	];
255 255
 	}
256 256
 
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
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
 		$sections_values = \wpdfi()->admin->get_option('sections');
223
-		if($sections_values) {
224
-			foreach($sections_values as $section_values) {
223
+		if ($sections_values) {
224
+			foreach ($sections_values as $section_values) {
225 225
 				/* Only insert new value if there current value is not exist yet. */
226
-				if(!in_array($section_values['post_type'], $pt_fl_settings)) {
226
+				if (!in_array($section_values['post_type'], $pt_fl_settings)) {
227 227
 					$pt_fl_settings[] = $section_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);
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
 
278 278
 	public function get_posts_no_fimage_id() {
279 279
 		$post_types = $this->_get_pt_fl_settings();
280
-		$qr_posts_no_fimage = get_posts( $this->_get_args_posts_no_fimage($post_types) );
280
+		$qr_posts_no_fimage = get_posts($this->_get_args_posts_no_fimage($post_types));
281 281
 		$ids = [];
282
-		foreach($qr_posts_no_fimage as $post) {
282
+		foreach ($qr_posts_no_fimage as $post) {
283 283
 			$ids[] = $post->ID;
284 284
 		}  
285 285
 		return $ids;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,9 @@
 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) {
75
+			return false;
76
+		}
75 77
 		$post_type = \get_post_type($post_id);
76 78
 		/* Get post's data about Terms */
77 79
 		$terms = $this->get_all_terms_post($post_id, $post_type);
Please login to merge, or discard this patch.
src/Admin/Notice.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -10,88 +10,88 @@
 block discarded – undo
10 10
 
11 11
 final class Notice 
12 12
 {
13
-    use Singleton;
13
+	use Singleton;
14 14
 
15
-    /**
16
-     * @traitDoc
17
-     */
18
-    public function initializes() 
19
-    {   
20
-        //
21
-    }
15
+	/**
16
+	 * @traitDoc
17
+	 */
18
+	public function initializes() 
19
+	{   
20
+		//
21
+	}
22 22
 
23
-    /**
24
-     * Type of notice, it can be 'success', 'error', 'warning', 'info'.
25
-     */
26
-    private $type;
23
+	/**
24
+	 * Type of notice, it can be 'success', 'error', 'warning', 'info'.
25
+	 */
26
+	private $type;
27 27
         
28
-    /**
29
-     * Message of the notice
30
-     */
31
-    private $message;
28
+	/**
29
+	 * Message of the notice
30
+	 */
31
+	private $message;
32 32
     
33
-    /**
34
-     * Add new notice to the admin dashboard.
35
-     *
36
-     * @param string $noticeMessage
37
-     * @param string $noticeType
38
-     * @since 1.0.0
39
-     * @return void
40
-     */
41
-    public function add($noticeMessage, $noticeType = 'info') 
42
-    {
43
-        $this->message = $noticeMessage;
44
-        $this->type = $noticeType;
33
+	/**
34
+	 * Add new notice to the admin dashboard.
35
+	 *
36
+	 * @param string $noticeMessage
37
+	 * @param string $noticeType
38
+	 * @since 1.0.0
39
+	 * @return void
40
+	 */
41
+	public function add($noticeMessage, $noticeType = 'info') 
42
+	{
43
+		$this->message = $noticeMessage;
44
+		$this->type = $noticeType;
45 45
         
46
-        \add_action( 'admin_notices', [$this, 'display']);
47
-    }
46
+		\add_action( 'admin_notices', [$this, 'display']);
47
+	}
48 48
     
49
-    /**
50
-     * Display notice template to the admin dashboard.
51
-     * 
52
-     * @since 1.0.0
53
-     * @return \VA\Templater
54
-     */
55
-    public function display() 
56
-    {
57
-        if(!$this->message) return;
49
+	/**
50
+	 * Display notice template to the admin dashboard.
51
+	 * 
52
+	 * @since 1.0.0
53
+	 * @return \VA\Templater
54
+	 */
55
+	public function display() 
56
+	{
57
+		if(!$this->message) return;
58 58
         
59
-        echo \wpdfi()->templater->render('admin/notice', [
60
-            'classes'   => $this->get_classes(),
61
-            'message'   => __($this->message, 'wpdfi')
62
-        ]);
63
-    }
59
+		echo \wpdfi()->templater->render('admin/notice', [
60
+			'classes'   => $this->get_classes(),
61
+			'message'   => __($this->message, 'wpdfi')
62
+		]);
63
+	}
64 64
     
65
-    /**
66
-     * Get all the classes of the notice
67
-     * 
68
-     * @since 1.0.0
69
-     * @return string
70
-     */
71
-    private function get_classes() 
72
-    {
73
-        return "notice notice-{$this->get_type()} is-dismissible";
74
-    }
65
+	/**
66
+	 * Get all the classes of the notice
67
+	 * 
68
+	 * @since 1.0.0
69
+	 * @return string
70
+	 */
71
+	private function get_classes() 
72
+	{
73
+		return "notice notice-{$this->get_type()} is-dismissible";
74
+	}
75 75
     
76
-    /**
77
-     * Get the type of the notice
78
-     *
79
-     * @since 1.0.0
80
-     * @return string
81
-     */ 
82
-    private function get_type()
83
-    {
84
-        return $this->type ? $this->type : $this->get_default_type();
85
-    }
76
+	/**
77
+	 * Get the type of the notice
78
+	 *
79
+	 * @since 1.0.0
80
+	 * @return string
81
+	 */ 
82
+	private function get_type()
83
+	{
84
+		return $this->type ? $this->type : $this->get_default_type();
85
+	}
86 86
     
87
-    /**
88
-     * Get default type of the notice
89
-     *
90
-     * @since 1.0.0
91
-     * @return string
92
-     */
93
-    private function get_default_type()
94
-    {
95
-        return 'info';
96
-    }
87
+	/**
88
+	 * Get default type of the notice
89
+	 *
90
+	 * @since 1.0.0
91
+	 * @return string
92
+	 */
93
+	private function get_default_type()
94
+	{
95
+		return 'info';
96
+	}
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
src/Ajax.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 		$actions = ['get_post_types', 'get_terms', 'get_image_size_names_and_dimensions', 
34 34
 					'get_default_layout', 'get_related_layout', 'generate_feature_image'];
35 35
 
36
-		foreach($actions as $action) {
37
-			\add_action('wp_ajax_wpdfi_'. $action, [$this, $action]);
38
-			\add_action('wp_ajax_nopriv_wpdfi'. $action, [$this, $action]);
36
+		foreach ($actions as $action) {
37
+			\add_action('wp_ajax_wpdfi_'.$action, [$this, $action]);
38
+			\add_action('wp_ajax_nopriv_wpdfi'.$action, [$this, $action]);
39 39
 		}
40 40
 	}
41 41
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 	public function generate_feature_image() {
88 88
 		/* security check. */
89
-		\check_ajax_referer( 'wpdfi-ajax-nonce', 'security' );
89
+		\check_ajax_referer('wpdfi-ajax-nonce', 'security');
90 90
 		$update_fimage = \wpdfi()->post_type->update_fimage($_POST['post_id']);
91 91
 		$post_type = \get_post_type($_POST['post_id']);
92 92
 		$post_type_name = \wpdfi()->post_type->get_singular_name($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($section_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
 			'section_index' => $section_index
82 82
 		]);
83
-		$layout.= \wpdfi()->templater->render('admin.blocks.imageupload.default', [
83
+		$layout .= \wpdfi()->templater->render('admin.blocks.imageupload.default', [
84 84
 			'section_index' => $section_index
85 85
 		]);
86 86
 		// $layout.= \wpdfi()->templater->render('admin.blocks.imagesize.default', [
Please login to merge, or discard this patch.