Completed
Push — master ( afc025...ba2dc4 )
by Bui Quang
9s
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/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.
wpdfi.php 2 patches
Indentation   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  
22 22
 You should have received a copy of the GNU General Public License
23 23
 along with WP Default Feature Image. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
24
-
25
-*/
24
+ */
26 25
 
27 26
 
28 27
 define('WPDFI_PLUGIN', __FILE__ );
@@ -133,7 +132,7 @@  discard block
 block discarded – undo
133 132
  * @return WPDFI  Singleton instance of plugin class.
134 133
  */
135 134
 function wpdfi() {
136
-    return WPDFI::instance();
135
+	return WPDFI::instance();
137 136
 }
138 137
 
139 138
 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
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 */
26 26
 
27 27
 
28
-define('WPDFI_PLUGIN', __FILE__ );
29
-define('WPDFI_PLUGIN_BASENAME', plugin_basename( WPDFI_PLUGIN ) );
30
-define('WPDFI_URL_BASE', plugin_dir_url( WPDFI_PLUGIN) );
31
-define('WPDFI_DIR_BASE', plugin_dir_path( WPDFI_PLUGIN ) );
32
-define('WPDFI_ASSETS', WPDFI_URL_BASE . '/assets/' );
33
-define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE.  '/templates/');
28
+define('WPDFI_PLUGIN', __FILE__);
29
+define('WPDFI_PLUGIN_BASENAME', plugin_basename(WPDFI_PLUGIN));
30
+define('WPDFI_URL_BASE', plugin_dir_url(WPDFI_PLUGIN));
31
+define('WPDFI_DIR_BASE', plugin_dir_path(WPDFI_PLUGIN));
32
+define('WPDFI_ASSETS', WPDFI_URL_BASE.'/assets/');
33
+define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE.'/templates/');
34 34
 
35
-require_once WPDFI_DIR_BASE . '/vendor/autoload.php';
35
+require_once WPDFI_DIR_BASE.'/vendor/autoload.php';
36 36
 
37 37
 use WPDFI\Traits\HasModule;
38 38
 use WPDFI\Traits\Singleton;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	public function hooks() 
70 70
 	{
71 71
 
72
-		add_action( 'init', [$this, 'init']);
72
+		add_action('init', [$this, 'init']);
73 73
 
74 74
 		/* Load all module hooks */
75 75
 		$this->moduleHooks();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	public function install() {
86 86
 
87 87
 		$options = get_option('wpdfi-settings');
88
-		if(!$options['options']['status_for_update']) {
88
+		if (!$options['options']['status_for_update']) {
89 89
 			$options['options']['status_for_update'] = 'publish';
90 90
 			update_option('wpdfi-settings', $options);
91 91
 		}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function init() 
102 102
 	{
103
-		load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE . '/lang/');
103
+		load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE.'/lang/');
104 104
 	}
105 105
 	
106 106
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			'admin'		=> Admin::instance()
119 119
 		];
120 120
 			
121
-		foreach($modules as $moduleName => $moduleHandle) {
121
+		foreach ($modules as $moduleName => $moduleHandle) {
122 122
 			$this->module($moduleName, $moduleHandle);
123 123
 		}
124 124
 		
Please login to merge, or discard this patch.