Passed
Push — ci ( 38d7bc...9f72b5 )
by litefeel
03:33
created
lib/admin.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 			)
85 85
 		);
86 86
 
87
-        register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_author' );
88
-        add_settings_field( 'wogh_ignore_author', __( 'Ignore author', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(
89
-                'default'   => '',
90
-                'name'      => 'wogh_ignore_author',
91
-                'help_text' => __( 'Do not export author and do not use author info from GitHub.', 'writing-on-github' ),
92
-            )
93
-        );
87
+		register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_author' );
88
+		add_settings_field( 'wogh_ignore_author', __( 'Ignore author', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(
89
+				'default'   => '',
90
+				'name'      => 'wogh_ignore_author',
91
+				'help_text' => __( 'Do not export author and do not use author info from GitHub.', 'writing-on-github' ),
92
+			)
93
+		);
94 94
 
95 95
 		// register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_metas' );
96 96
 		// add_settings_field( 'wogh_ignore_metas', __( 'Ignore post metas', 'writing-on-github' ), array( &$this, 'textarea_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 		include dirname( dirname( __FILE__ ) ) . '/views/textarea-setting-field.php';
129 129
 	}
130 130
 
131
-    /**
132
-     * Callback to render the checkbox field.
133
-     *
134
-     * @param array $args Field arguments.
135
-     */
136
-    public function checkbox_field_callback( $args ) {
137
-        include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';
138
-    }
131
+	/**
132
+	 * Callback to render the checkbox field.
133
+	 *
134
+	 * @param array $args Field arguments.
135
+	 */
136
+	public function checkbox_field_callback( $args ) {
137
+		include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';
138
+	}
139 139
 
140 140
 	/**
141 141
 	 * Displays settings messages from background processes
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 			Writing_On_GitHub::$instance->start_export();
222 222
 		}
223 223
 
224
-        if ( 'force_export' === $_GET['action'] ) {
225
-            Writing_On_GitHub::$instance->start_export(true);
226
-        }
224
+		if ( 'force_export' === $_GET['action'] ) {
225
+			Writing_On_GitHub::$instance->start_export(true);
226
+		}
227 227
 
228 228
 		if ( 'import' === $_GET['action'] ) {
229 229
 			Writing_On_GitHub::$instance->start_import();
Please login to merge, or discard this patch.
lib/blob.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -152,9 +152,9 @@
 block discarded – undo
152 152
 			array_pop( $matches );
153 153
 
154 154
 			$meta = spyc_load( $matches[2] );
155
-            if ( 'yes' == get_option('wogh_ignore_author') ) {
156
-                unset($meta['author']);
157
-            }
155
+			if ( 'yes' == get_option('wogh_ignore_author') ) {
156
+				unset($meta['author']);
157
+			}
158 158
 			// if ( isset( $meta['link'] ) ) {
159 159
 			// 	$meta['link'] = str_replace( home_url(), '', $meta['link'] );
160 160
 			// }
Please login to merge, or discard this patch.
lib/post.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -376,9 +376,9 @@
 block discarded – undo
376 376
 		if ( empty($this->post->post_excerpt) ) {
377 377
 			unset($meta['post_excerpt']);
378 378
 		}
379
-        if ( 'yes' == get_option('wogh_ignore_author') ) {
380
-            unset($meta['author']);
381
-        }
379
+		if ( 'yes' == get_option('wogh_ignore_author') ) {
380
+			unset($meta['author']);
381
+		}
382 382
 
383 383
 		//convert traditional post_meta values, hide hidden values, skip already populated values
384 384
 		// foreach ( get_post_custom( $this->id ) as $key => $value ) {
Please login to merge, or discard this patch.
writing-on-github.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 // This fixes function duplication during unit testing.
15 15
 $path = dirname( __FILE__ ) . '/vendor/autoload.php';
16 16
 if ( file_exists( $path ) ) {
17
-    require_once( $path );
17
+	require_once( $path );
18 18
 }
19 19
 
20 20
 add_action( 'plugins_loaded', array( new Writing_On_GitHub, 'boot' ) );
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		add_action( 'save_post', array( $this->controller, 'export_post' ) );
132 132
 		add_action( 'delete_post', array( $this->controller, 'delete_post' ) );
133 133
 		add_action( 'wp_ajax_nopriv_wogh_push_request', array( $this->controller, 'pull_posts' ) );
134
-        add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 );
134
+		add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 );
135 135
 		add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 );
136 136
 		add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 );
137 137
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			}
151 151
 		}
152 152
 
153
-	    return $link;
153
+		return $link;
154 154
 	}
155 155
 
156 156
 	public function ignore_post_meta($meta) {
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
 	/**
393 393
 	 * Kicks of an import or export cronjob.
394 394
 	 *
395
-     * @param bool   $force
396
-     * @param string $type
397
-     */
395
+	 * @param bool   $force
396
+	 * @param string $type
397
+	 */
398 398
 	protected function start_cron( $type, $force = false ) {
399 399
 		update_option( '_wogh_' . $type . '_started', 'yes' );
400 400
 		$user_id = get_current_user_id();
Please login to merge, or discard this patch.
lib/database.php 1 patch
Indentation   +45 added lines, -45 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(),
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
 
188 188
 		// update tags
189 189
 		if ( isset( $meta['tags'] ) && $meta['tags'] ) {
190
-		    $args['tags_input'] = $meta['tags'];
190
+			$args['tags_input'] = $meta['tags'];
191 191
 		}
192 192
 
193 193
 		// update categories
194 194
 		if ( isset( $meta['categories'] ) && $meta['categories'] ) {
195
-		    $categories = $meta['categories'];
196
-		    if (!is_array($categories)) {
197
-		        $categories = array($categories);
198
-		    }
199
-		    $terms = get_terms(array(
200
-		        'taxonomy' => 'category',
201
-		        'fields' => 'id=>name',
202
-		        'hide_empty' => 0,
203
-		        'name' => $categories
204
-		        )
205
-		    );
206
-		    $map = array();
207
-		    foreach ($categories as $name) {
208
-		        $map[$name] = 1;
209
-		    }
210
-
211
-		    $ids = array();
212
-		    if (!empty($terms)) {
213
-		        foreach ($terms as $id => $name) {
214
-		            $ids[] = $id;
215
-		            unset($map[$name]);
216
-		        }
217
-		    }
218
-
219
-		    // create new terms
220
-		    if (!empty($map)) {
221
-		        foreach ($map as $name => $value) {
222
-		            $term = wp_insert_term($name, 'category', array('parent' => 0));
223
-		            // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
224
-		            $ids[] = $term['term_id'];
225
-		        }
226
-		    }
227
-
228
-		    $args['post_category'] = $ids;
195
+			$categories = $meta['categories'];
196
+			if (!is_array($categories)) {
197
+				$categories = array($categories);
198
+			}
199
+			$terms = get_terms(array(
200
+				'taxonomy' => 'category',
201
+				'fields' => 'id=>name',
202
+				'hide_empty' => 0,
203
+				'name' => $categories
204
+				)
205
+			);
206
+			$map = array();
207
+			foreach ($categories as $name) {
208
+				$map[$name] = 1;
209
+			}
210
+
211
+			$ids = array();
212
+			if (!empty($terms)) {
213
+				foreach ($terms as $id => $name) {
214
+					$ids[] = $id;
215
+					unset($map[$name]);
216
+				}
217
+			}
218
+
219
+			// create new terms
220
+			if (!empty($map)) {
221
+				foreach ($map as $name => $value) {
222
+					$term = wp_insert_term($name, 'category', array('parent' => 0));
223
+					// array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
224
+					$ids[] = $term['term_id'];
225
+				}
226
+			}
227
+
228
+			$args['post_category'] = $ids;
229 229
 		}
230 230
 
231 231
 		return $args;
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
 		if ( ! empty( $display_name ) ) {
428 428
 			$search_string = esc_attr( $display_name );
429 429
 			$query = new WP_User_Query( array(
430
-			    'search'         => "{$search_string}",
431
-			    'search_columns' => array(
432
-			        'display_name',
433
-			        'user_nicename',
434
-			        'user_login',
435
-			    )
430
+				'search'         => "{$search_string}",
431
+				'search_columns' => array(
432
+					'display_name',
433
+					'user_nicename',
434
+					'user_login',
435
+				)
436 436
 			) );
437 437
 			$users = $query->get_results();
438 438
 			$user = empty($users) ? false : $users[0];
Please login to merge, or discard this patch.
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   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  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
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * import blob by files
55 55
 	 * @param  Writing_On_GitHub_File_Info[] $files
56
-     *
56
+	 *
57 57
 	 * @return string|WP_Error
58 58
 	 */
59 59
 	protected function import_files( $files ) {
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		$result = $this->app->api()->fetch()->tree_recursive();
93 93
 
94 94
 		if ( is_wp_error( $result ) ) {
95
-            /* @var WP_Error $result */
95
+			/* @var WP_Error $result */
96 96
 			return $result;
97 97
 		}
98 98
 
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 		return __( 'Payload processed', 'writing-on-github' );
106 106
 	}
107 107
 
108
-    /**
109
-     * Do compare
110
-     * @param  Writing_On_GitHub_File_Info[]|WP_Error $files
111
-     * @param  int[] &$delete_ids
112
-     *
113
-     * @return string|WP_Error
114
-     */
108
+	/**
109
+	 * Do compare
110
+	 * @param  Writing_On_GitHub_File_Info[]|WP_Error $files
111
+	 * @param  int[] &$delete_ids
112
+	 *
113
+	 * @return string|WP_Error
114
+	 */
115 115
 	protected function compare( $files, &$delete_ids ) {
116 116
 		if ( is_wp_error( $files ) ) {
117
-            /* @var WP_Error $files */
117
+			/* @var WP_Error $files */
118 118
 			return $files;
119 119
 		}
120 120
 
Please login to merge, or discard this patch.
lib/export.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,36 +29,36 @@  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 = false;
44
+		$error = false;
45 45
 
46
-        foreach ( $posts as $post ) {
47
-            $result = $this->update( $post->id() );
48
-            if ( is_wp_error( $result ) ) {
49
-                if ( $error ) {
50
-                    $error->add( $result->get_error_code(), $result->get_error_message() );
51
-                } else {
52
-                    $error = $result;
53
-                }
54
-            }
55
-        }
46
+		foreach ( $posts as $post ) {
47
+			$result = $this->update( $post->id() );
48
+			if ( is_wp_error( $result ) ) {
49
+				if ( $error ) {
50
+					$error->add( $result->get_error_code(), $result->get_error_message() );
51
+				} else {
52
+					$error = $result;
53
+				}
54
+			}
55
+		}
56 56
 
57
-        if ( is_wp_error( $error ) ) {
58
-            return $error;
59
-        }
57
+		if ( is_wp_error( $error ) ) {
58
+			return $error;
59
+		}
60 60
 
61
-        return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
61
+		return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
62 62
 	}
63 63
 
64 64
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		$post = $this->app->database()->fetch_by_id( $post_id );
89 89
 
90 90
 		if ( is_wp_error( $post ) ) {
91
-            /* @var WP_Error $post */
91
+			/* @var WP_Error $post */
92 92
 			return $post;
93 93
 		}
94 94
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		$result = $this->new_posts( array( $post ) );
105 105
 
106 106
 		if ( is_wp_error( $result ) ) {
107
-            /* @var WP_Error $result */
107
+			/* @var WP_Error $result */
108 108
 			return $result;
109 109
 		}
110 110
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 			return $error;
139 139
 		}
140 140
 
141
-        return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
141
+		return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
142 142
 	}
143 143
 
144 144
 	protected function new_post( $post, $persist ) {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		$post = $this->app->database()->fetch_by_id( $post_id );
219 219
 
220 220
 		if ( is_wp_error( $post ) ) {
221
-            /* @var WP_Error $post */
221
+			/* @var WP_Error $post */
222 222
 			return $post;
223 223
 		}
224 224
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		$result = $this->app->api()->persist()->delete_file( $github_path, $post->sha(), $message );
239 239
 
240 240
 		if ( is_wp_error( $result ) ) {
241
-            /* @var WP_Error $result */
241
+			/* @var WP_Error $result */
242 242
 			return $result;
243 243
 		}
244 244
 
Please login to merge, or discard this patch.