Completed
Pull Request — master (#52)
by Bui Quang
02:42
created
wpdfi.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
  * @return WPDFI  Singleton instance of plugin class.
117 117
  */
118 118
 function wpdfi() {
119
-    return WPDFI::instance();
119
+	return WPDFI::instance();
120 120
 }
121 121
 
122 122
 add_action('plugins_loaded', [wpdfi(), 'hooks']);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@  discard block
 block discarded – undo
8 8
  * License: GNUv3
9 9
  * Text Domain: wpdfi
10 10
  */
11
-define('WPDFI_PLUGIN', __FILE__ );
12
-define('WPDFI_PLUGIN_BASENAME', plugin_basename( WPDFI_PLUGIN ) );
13
-define('WPDFI_URL_BASE', plugin_dir_url( WPDFI_PLUGIN) );
14
-define('WPDFI_DIR_BASE', plugin_dir_path( WPDFI_PLUGIN ) );
15
-define('WPDFI_ASSETS', WPDFI_URL_BASE . '/assets/' );
16
-define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE.  '/templates/');
11
+define('WPDFI_PLUGIN', __FILE__);
12
+define('WPDFI_PLUGIN_BASENAME', plugin_basename(WPDFI_PLUGIN));
13
+define('WPDFI_URL_BASE', plugin_dir_url(WPDFI_PLUGIN));
14
+define('WPDFI_DIR_BASE', plugin_dir_path(WPDFI_PLUGIN));
15
+define('WPDFI_ASSETS', WPDFI_URL_BASE.'/assets/');
16
+define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE.'/templates/');
17 17
 
18
-require_once WPDFI_DIR_BASE . '/vendor/autoload.php';
18
+require_once WPDFI_DIR_BASE.'/vendor/autoload.php';
19 19
 
20 20
 use WPDFI\Traits\HasModule;
21 21
 use WPDFI\Traits\Singleton;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	public function hooks() 
53 53
 	{
54 54
 
55
-		add_action( 'init', [$this, 'init']);
55
+		add_action('init', [$this, 'init']);
56 56
 
57 57
 		/* Load all module hooks */
58 58
 		$this->moduleHooks();
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	public function install() {
69 69
 
70 70
 		$options = get_option('wpdfi-settings');
71
-		if(!$options['options']['status_for_update']) {
71
+		if (!$options['options']['status_for_update']) {
72 72
 			$options['options']['status_for_update'] = 'publish';
73 73
 			update_option('wpdfi-settings', $options);
74 74
 		}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function init() 
85 85
 	{
86
-		load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE . '/lang/');
86
+		load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE.'/lang/');
87 87
 	}
88 88
 	
89 89
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			'admin'		=> Admin::instance()
102 102
 		];
103 103
 			
104
-		foreach($modules as $moduleName => $moduleHandle) {
104
+		foreach ($modules as $moduleName => $moduleHandle) {
105 105
 			$this->module($moduleName, $moduleHandle);
106 106
 		}
107 107
 		
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 /* All uninstall actions of this plugin come here */
3 3
 
4 4
 
5
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
5
+if (!defined('WP_UNINSTALL_PLUGIN')) {
6 6
 	exit();
7 7
 }
8 8
 
Please login to merge, or discard this patch.
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/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.