Passed
Branch master (5ed1e2)
by litefeel
03:16
created
lib/controller.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$this->app->semaphore()->unlock();
82 82
 
83 83
 		if ( is_wp_error( $result ) ) {
84
-            /* @var WP_Error $result */
84
+			/* @var WP_Error $result */
85 85
 			return $this->app->response()->error( $result );
86 86
 		}
87 87
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->app->semaphore()->unlock();
115 115
 
116
-        if ( is_wp_error( $result ) ) {
117
-            /* @var WP_Error $result */
118
-            update_option( '_wogh_import_error', $result->get_error_message() );
116
+		if ( is_wp_error( $result ) ) {
117
+			/* @var WP_Error $result */
118
+			update_option( '_wogh_import_error', $result->get_error_message() );
119 119
 
120 120
 			return $this->app->response()->error( $result );
121 121
 		}
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	/**
129 129
 	 * Export all the posts in the database to GitHub.
130 130
 	 *
131
-     * @param  int        $user_id
132
-     * @param  boolean    $force
133
-     * @return boolean
134
-     */
131
+	 * @param  int        $user_id
132
+	 * @param  boolean    $force
133
+	 * @return boolean
134
+	 */
135 135
 	public function export_all( $user_id = 0, $force = false ) {
136 136
 		if ( ! $this->app->semaphore()->is_open() ) {
137 137
 			return $this->app->response()->error( new WP_Error(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 		// Maybe move option updating out of this class/upgrade message display?
153 153
 		if ( is_wp_error( $result ) ) {
154
-            /* @var WP_Error $result */
154
+			/* @var WP_Error $result */
155 155
 			update_option( '_wogh_export_error', $result->get_error_message() );
156 156
 
157 157
 			return $this->app->response()->error( $result );
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		$this->app->semaphore()->unlock();
190 190
 
191 191
 		if ( is_wp_error( $result ) ) {
192
-            /* @var WP_Error $result */
192
+			/* @var WP_Error $result */
193 193
 			return $this->app->response()->error( $result );
194 194
 		}
195 195
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$this->app->semaphore()->unlock();
223 223
 
224 224
 		if ( is_wp_error( $result ) ) {
225
-            /* @var WP_Error $result */
225
+			/* @var WP_Error $result */
226 226
 			return $this->app->response()->error( $result );
227 227
 		}
228 228
 
Please login to merge, or discard this patch.
lib/client/base.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 	 */
42 42
 	protected function call( $method, $endpoint, $body = array() ) {
43 43
 		if ( is_wp_error( $error = $this->can_call() ) ) {
44
-            /* @var WP_Error $error */
44
+			/* @var WP_Error $error */
45 45
 			return $error;
46 46
 		}
47 47
 
Please login to merge, or discard this patch.
lib/import.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
 		$this->app = $app;
27 27
 	}
28 28
 
29
-    /**
30
-     * Imports a payload.
31
-     * @param  Writing_On_GitHub_Payload $payload
32
-     *
33
-     * @return string|WP_Error
34
-     */
29
+	/**
30
+	 * Imports a payload.
31
+	 * @param  Writing_On_GitHub_Payload $payload
32
+	 *
33
+	 * @return string|WP_Error
34
+	 */
35 35
 	public function payload( Writing_On_GitHub_Payload $payload ) {
36 36
 
37 37
 		$result = $this->app->api()->fetch()->compare( $payload->get_before_commit_id() );
38 38
 
39 39
 		if ( is_wp_error( $result ) ) {
40
-            /* @var WP_Error $result */
40
+			/* @var WP_Error $result */
41 41
 			return $result;
42 42
 		}
43 43
 
44
-        if ( is_array( $result ) ) {
45
-            $result = $this->import_files( $result );
46
-        }
44
+		if ( is_array( $result ) ) {
45
+			$result = $this->import_files( $result );
46
+		}
47 47
 
48 48
 		if ( is_wp_error( $result ) ) {
49 49
 			return $files;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * import blob by files
57 57
 	 * @param  Writing_On_GitHub_File_Info[] $files
58
-     *
58
+	 *
59 59
 	 * @return string|WP_Error
60 60
 	 */
61 61
 	protected function import_files( $files ) {
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 			foreach ($delete_ids as $id) {
74 74
 				$result = $this->app->database()->delete_post( $id );
75 75
 				if ( is_wp_error( $result ) ) {
76
-                    /* @var WP_Error $result */
77
-                    $error = wogh_append_error( $error, $result );
76
+					/* @var WP_Error $result */
77
+					$error = wogh_append_error( $error, $result );
78 78
 				}
79 79
 			}
80 80
 		}
@@ -91,32 +91,32 @@  discard block
 block discarded – undo
91 91
 		$result = $this->app->api()->fetch()->tree_recursive();
92 92
 
93 93
 		if ( is_wp_error( $result ) ) {
94
-            /* @var WP_Error $result */
94
+			/* @var WP_Error $result */
95 95
 			return $result;
96 96
 		}
97 97
 
98
-        if ( is_array( $result ) ) {
99
-            $result = $this->import_files( $result );
100
-        }
98
+		if ( is_array( $result ) ) {
99
+			$result = $this->import_files( $result );
100
+		}
101 101
 
102 102
 		if ( is_wp_error( $result ) ) {
103
-            /* @var WP_Error $result */
103
+			/* @var WP_Error $result */
104 104
 			return $result;
105 105
 		}
106 106
 
107 107
 		return __( 'Payload processed', 'writing-on-github' );
108 108
 	}
109 109
 
110
-    /**
111
-     * Do compare
112
-     * @param  Writing_On_GitHub_File_Info[]|WP_Error $files
113
-     * @param  int[] &$delete_ids
114
-     *
115
-     * @return string|WP_Error
116
-     */
110
+	/**
111
+	 * Do compare
112
+	 * @param  Writing_On_GitHub_File_Info[]|WP_Error $files
113
+	 * @param  int[] &$delete_ids
114
+	 *
115
+	 * @return string|WP_Error
116
+	 */
117 117
 	protected function compare( $files, &$delete_ids ) {
118 118
 		if ( is_wp_error( $files ) ) {
119
-            /* @var WP_Error $files */
119
+			/* @var WP_Error $files */
120 120
 			return $files;
121 121
 		}
122 122
 
Please login to merge, or discard this patch.
lib/export.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,34 +29,34 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * Updates all of the current posts in the database on master.
31 31
 	 *
32
-     * @param  bool    $force
33
-     *
34
-     * @return string|WP_Error
35
-     */
32
+	 * @param  bool    $force
33
+	 *
34
+	 * @return string|WP_Error
35
+	 */
36 36
 	public function full( $force = false ) {
37 37
 		$posts = $this->app->database()->fetch_all_supported( $force );
38 38
 
39 39
 		if ( is_wp_error( $posts ) ) {
40
-            /* @var WP_Error $posts */
40
+			/* @var WP_Error $posts */
41 41
 			return $posts;
42 42
 		}
43 43
 
44
-        $error = '';
44
+		$error = '';
45 45
 
46
-        foreach ( $posts as $post ) {
47
-            $result = $this->update( $post->id() );
48
-            if ( is_wp_error( $result ) ) {
49
-                /* @var WP_Error $result */
50
-                $error = wogh_append_error( $error, $result );
51
-            }
52
-        }
46
+		foreach ( $posts as $post ) {
47
+			$result = $this->update( $post->id() );
48
+			if ( is_wp_error( $result ) ) {
49
+				/* @var WP_Error $result */
50
+				$error = wogh_append_error( $error, $result );
51
+			}
52
+		}
53 53
 
54
-        if ( is_wp_error( $error ) ) {
55
-            /* @var WP_Error $error */
56
-            return $error;
57
-        }
54
+		if ( is_wp_error( $error ) ) {
55
+			/* @var WP_Error $error */
56
+			return $error;
57
+		}
58 58
 
59
-        return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
59
+		return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
60 60
 	}
61 61
 
62 62
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		$post = $this->app->database()->fetch_by_id( $post_id );
87 87
 
88 88
 		if ( is_wp_error( $post ) ) {
89
-            /* @var WP_Error $post */
89
+			/* @var WP_Error $post */
90 90
 			return $post;
91 91
 		}
92 92
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		$result = $this->new_posts( array( $post ) );
103 103
 
104 104
 		if ( is_wp_error( $result ) ) {
105
-            /* @var WP_Error $result */
105
+			/* @var WP_Error $result */
106 106
 			return $result;
107 107
 		}
108 108
 
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
 	 * @return string|WP_Error
118 118
 	 */
119 119
 	public function new_posts( array $posts ) {
120
-        $persist = $this->app->api()->persist();
120
+		$persist = $this->app->api()->persist();
121 121
 
122 122
 		$error = '';
123 123
 		foreach ( $posts as $post ) {
124 124
 			$result = $this->new_post( $post, $persist );
125 125
 			if ( is_wp_error( $result ) ) {
126
-                /* @var WP_Error $result */
127
-                $error = wogh_append_error( $error, $result );
126
+				/* @var WP_Error $result */
127
+				$error = wogh_append_error( $error, $result );
128 128
 			}
129 129
 		}
130 130
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			return $error;
133 133
 		}
134 134
 
135
-        return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
135
+		return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
136 136
 	}
137 137
 
138 138
 	protected function new_post( $post, $persist ) {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		$post = $this->app->database()->fetch_by_id( $post_id );
213 213
 
214 214
 		if ( is_wp_error( $post ) ) {
215
-            /* @var WP_Error $post */
215
+			/* @var WP_Error $post */
216 216
 			return $post;
217 217
 		}
218 218
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		$result = $this->app->api()->persist()->delete_file( $github_path, $post->sha(), $message );
233 233
 
234 234
 		if ( is_wp_error( $result ) ) {
235
-            /* @var WP_Error $result */
235
+			/* @var WP_Error $result */
236 236
 			return $result;
237 237
 		}
238 238
 
Please login to merge, or discard this patch.
lib/database.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 * Queries the database for all of the supported posts.
44 44
 	 *
45
-     * @param  bool $force
46
-     *
47
-     * @return Writing_On_GitHub_Post[]|WP_Error
48
-     */
45
+	 * @param  bool $force
46
+	 *
47
+	 * @return Writing_On_GitHub_Post[]|WP_Error
48
+	 */
49 49
 	public function fetch_all_supported( $force = false ) {
50 50
 		$args  = array(
51 51
 			'post_type'   => $this->get_whitelisted_post_types(),
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			);
66 66
 		}
67 67
 
68
-        /* @var Writing_On_GitHub_Post[] $results */
68
+		/* @var Writing_On_GitHub_Post[] $results */
69 69
 		$results = array();
70 70
 		foreach ( $post_ids as $post_id ) {
71 71
 			// Do not export posts that have already been exported
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 			add_filter( 'content_save_pre', 'wp_filter_post_kses' );
133 133
 
134 134
 			if ( is_wp_error( $post_id ) ) {
135
-                /* @var WP_Error $post_id */
136
-                $error = wogh_append_error( $error, $post_id );
135
+				/* @var WP_Error $post_id */
136
+				$error = wogh_append_error( $error, $post_id );
137 137
 
138 138
 				// Abort saving if updating the post fails.
139 139
 				continue;
@@ -183,65 +183,65 @@  discard block
 block discarded – undo
183 183
 
184 184
 		// update tags
185 185
 		if ( ! empty( $meta['tags'] ) ) {
186
-		    $args['tags_input'] = $meta['tags'];
186
+			$args['tags_input'] = $meta['tags'];
187 187
 		}
188 188
 
189 189
 		// update categories
190 190
 		if ( ! empty( $meta['categories'] ) ) {
191
-		    $categories = $meta['categories'];
192
-		    if ( ! is_array( $categories ) ) {
193
-		        $categories = array( $categories );
194
-		    }
195
-		    $terms = get_terms( array(
196
-		        'taxonomy' => 'category',
197
-		        'fields' => 'id=>name',
198
-		        'hide_empty' => 0,
199
-		        'name' => $categories
200
-		        )
201
-		    );
202
-		    $map = array();
203
-		    foreach ( $categories as $name ) {
204
-		        $map[$name] = 1;
205
-		    }
206
-
207
-		    $ids = array();
208
-		    if ( ! empty( $terms ) ) {
209
-		        foreach ( $terms as $id => $name ) {
210
-		            $ids[] = $id;
211
-		            unset( $map[$name] );
212
-		        }
213
-		    }
214
-
215
-		    // create new terms
216
-		    if ( ! empty( $map ) ) {
217
-		        foreach ( $map as $name => $value ) {
218
-		            $term = wp_insert_term( $name, 'category', array( 'parent' => 0 ) );
219
-		            // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
220
-		            $ids[] = $term['term_id'];
221
-		        }
222
-		    }
223
-
224
-		    $args['post_category'] = $ids;
191
+			$categories = $meta['categories'];
192
+			if ( ! is_array( $categories ) ) {
193
+				$categories = array( $categories );
194
+			}
195
+			$terms = get_terms( array(
196
+				'taxonomy' => 'category',
197
+				'fields' => 'id=>name',
198
+				'hide_empty' => 0,
199
+				'name' => $categories
200
+				)
201
+			);
202
+			$map = array();
203
+			foreach ( $categories as $name ) {
204
+				$map[$name] = 1;
205
+			}
206
+
207
+			$ids = array();
208
+			if ( ! empty( $terms ) ) {
209
+				foreach ( $terms as $id => $name ) {
210
+					$ids[] = $id;
211
+					unset( $map[$name] );
212
+				}
213
+			}
214
+
215
+			// create new terms
216
+			if ( ! empty( $map ) ) {
217
+				foreach ( $map as $name => $value ) {
218
+					$term = wp_insert_term( $name, 'category', array( 'parent' => 0 ) );
219
+					// array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
220
+					$ids[] = $term['term_id'];
221
+				}
222
+			}
223
+
224
+			$args['post_category'] = $ids;
225 225
 		}
226 226
 
227 227
 		return $args;
228 228
 	}
229 229
 
230
-    private function get_post_id_by_filename( $filename, $pattern  ) {
231
-        preg_match( $pattern , $filename, $matches );
232
-        $title = $matches[4];
230
+	private function get_post_id_by_filename( $filename, $pattern  ) {
231
+		preg_match( $pattern , $filename, $matches );
232
+		$title = $matches[4];
233 233
 
234
-        $query = new WP_Query( array(
235
-            'name'     => $title,
236
-            'posts_per_page' => 1,
237
-            'post_type' => $this->get_whitelisted_post_types(),
238
-            'fields'         => 'ids',
239
-        ) );
234
+		$query = new WP_Query( array(
235
+			'name'     => $title,
236
+			'posts_per_page' => 1,
237
+			'post_type' => $this->get_whitelisted_post_types(),
238
+			'fields'         => 'ids',
239
+		) );
240 240
 
241
-        $post_id = $query->get_posts();
242
-        $post_id = array_pop( $post_id );
243
-        return $post_id;
244
-    }
241
+		$post_id = $query->get_posts();
242
+		$post_id = array_pop( $post_id );
243
+		return $post_id;
244
+	}
245 245
 
246 246
 	/**
247 247
 	 * Deletes a post from the database based on its GitHub path.
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 			$directory = $parts ? array_shift( $parts ) : '';
269 269
 
270 270
 			if ( false !== strpos( $directory, 'post' ) ) {
271
-                $post_id = get_post_id_by_filename( $filename, '/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md/' );
271
+				$post_id = get_post_id_by_filename( $filename, '/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md/' );
272 272
 			}
273 273
 
274 274
 			if ( ! $post_id ) {
275
-                $post_id = get_post_id_by_filename( $filename, '/(.*)\.md/' );
275
+				$post_id = get_post_id_by_filename( $filename, '/(.*)\.md/' );
276 276
 			}
277 277
 		}
278 278
 
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 		if ( ! empty( $display_name ) ) {
418 418
 			$search_string = esc_attr( $display_name );
419 419
 			$query = new WP_User_Query( array(
420
-			    'search'         => "{$search_string}",
421
-			    'search_columns' => array(
422
-			        'display_name',
423
-			        'user_nicename',
424
-			        'user_login',
425
-			    )
420
+				'search'         => "{$search_string}",
421
+				'search_columns' => array(
422
+					'display_name',
423
+					'user_nicename',
424
+					'user_login',
425
+				)
426 426
 			) );
427 427
 			$users = $query->get_results();
428 428
 			$user = empty($users) ? false : $users[0];
Please login to merge, or discard this patch.
lib/function.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
  * @return WP_Error
9 9
  */
10 10
 function wogh_append_error( $error, $error2 ) {
11
-    if ( is_wp_error( $error ) ) {
12
-        $error->add( $error2->get_error_code(), $error2->get_error_message() );
13
-    }
14
-    return $error2;
11
+	if ( is_wp_error( $error ) ) {
12
+		$error->add( $error2->get_error_code(), $error2->get_error_message() );
13
+	}
14
+	return $error2;
15 15
 }
Please login to merge, or discard this patch.