Passed
Push — ci ( b7da7f...c140ce )
by litefeel
02:10
created
lib/controller.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,10 +126,10 @@
 block discarded – undo
126 126
 	/**
127 127
 	 * Export all the posts in the database to GitHub.
128 128
 	 *
129
-     * @param  int        $user_id
130
-     * @param  boolean    $force
131
-     * @return boolean
132
-     */
129
+	 * @param  int        $user_id
130
+	 * @param  boolean    $force
131
+	 * @return boolean
132
+	 */
133 133
 	public function export_all( $user_id, $force = false ) {
134 134
 		if ( ! $this->app->semaphore()->is_open() ) {
135 135
 			return $this->app->response()->error( new WP_Error(
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param Writing_On_GitHub $app Applicatio container.
23 23
 	 */
24
-	public function __construct( Writing_On_GitHub $app ) {
24
+	public function __construct(Writing_On_GitHub $app) {
25 25
 		$this->app = $app;
26 26
 	}
27 27
 
@@ -34,57 +34,57 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public function pull_posts() {
36 36
 		$this->set_ajax();
37
-		if ( ! $this->app->semaphore()->is_open() ) {
38
-			return $this->app->response()->error( new WP_Error(
37
+		if ( ! $this->app->semaphore()->is_open()) {
38
+			return $this->app->response()->error(new WP_Error(
39 39
 				'semaphore_locked',
40
-				sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::pull_posts()' )
41
-			) );
40
+				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::pull_posts()')
41
+			));
42 42
 		}
43 43
 
44
-		if ( ! $this->app->request()->is_secret_valid() ) {
45
-			return $this->app->response()->error( new WP_Error(
44
+		if ( ! $this->app->request()->is_secret_valid()) {
45
+			return $this->app->response()->error(new WP_Error(
46 46
 				'invalid_headers',
47
-				__( 'Failed to validate secret.', 'writing-on-github' )
48
-			) );
47
+				__('Failed to validate secret.', 'writing-on-github')
48
+			));
49 49
 		}
50 50
 
51 51
 		// ping
52
-		if ( $this->app->request()->is_ping() ) {
53
-			return $this->app->response()->success( __( 'Wordpress is ready.', 'writing-on-github' ) );
52
+		if ($this->app->request()->is_ping()) {
53
+			return $this->app->response()->success(__('Wordpress is ready.', 'writing-on-github'));
54 54
 		}
55 55
 
56 56
 		// push
57
-		if ( ! $this->app->request()->is_push() ) {
58
-			return $this->app->response()->error( new WP_Error(
57
+		if ( ! $this->app->request()->is_push()) {
58
+			return $this->app->response()->error(new WP_Error(
59 59
 				'invalid_headers',
60
-				__( 'Failed to validate webhook event.', 'writing-on-github' )
61
-			) );
60
+				__('Failed to validate webhook event.', 'writing-on-github')
61
+			));
62 62
 		}
63 63
 		$payload = $this->app->request()->payload();
64 64
 
65
-		if ( ! $payload->should_import() ) {
66
-			return $this->app->response()->error( new WP_Error(
65
+		if ( ! $payload->should_import()) {
66
+			return $this->app->response()->error(new WP_Error(
67 67
 				'invalid_payload',
68 68
 				sprintf(
69
-					__( "%s won't be imported.", 'writing-on-github' ),
70
-					strtolower( $payload->get_commit_id() ) ? : '[Missing Commit ID]'
69
+					__("%s won't be imported.", 'writing-on-github'),
70
+					strtolower($payload->get_commit_id()) ?: '[Missing Commit ID]'
71 71
 				)
72
-			) );
72
+			));
73 73
 		}
74 74
 
75 75
 		$this->app->semaphore()->lock();
76
-		remove_action( 'save_post', array( $this, 'export_post' ) );
77
-		remove_action( 'delete_post', array( $this, 'delete_post' ) );
76
+		remove_action('save_post', array($this, 'export_post'));
77
+		remove_action('delete_post', array($this, 'delete_post'));
78 78
 
79
-		$result = $this->app->import()->payload( $payload );
79
+		$result = $this->app->import()->payload($payload);
80 80
 
81 81
 		$this->app->semaphore()->unlock();
82 82
 
83
-		if ( is_wp_error( $result ) ) {
84
-			return $this->app->response()->error( $result );
83
+		if (is_wp_error($result)) {
84
+			return $this->app->response()->error($result);
85 85
 		}
86 86
 
87
-		return $this->app->response()->success( $result );
87
+		return $this->app->response()->success($result);
88 88
 	}
89 89
 
90 90
 	/**
@@ -92,35 +92,35 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return boolean
94 94
 	 */
95
-	public function import_master( $user_id ) {
96
-		if ( ! $this->app->semaphore()->is_open() ) {
97
-			return $this->app->response()->error( new WP_Error(
95
+	public function import_master($user_id) {
96
+		if ( ! $this->app->semaphore()->is_open()) {
97
+			return $this->app->response()->error(new WP_Error(
98 98
 				'semaphore_locked',
99
-				sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::import_master()' )
100
-			) );
99
+				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::import_master()')
100
+			));
101 101
 		}
102 102
 
103 103
 		$this->app->semaphore()->lock();
104
-		remove_action( 'save_post', array( $this, 'export_post' ) );
105
-		remove_action( 'save_post', array( $this, 'delete_post' ) );
104
+		remove_action('save_post', array($this, 'export_post'));
105
+		remove_action('save_post', array($this, 'delete_post'));
106 106
 
107
-		if ( $user_id ) {
108
-			wp_set_current_user( $user_id );
107
+		if ($user_id) {
108
+			wp_set_current_user($user_id);
109 109
 		}
110 110
 
111 111
 		$result = $this->app->import()->master();
112 112
 
113 113
 		$this->app->semaphore()->unlock();
114 114
 
115
-		if ( is_wp_error( $result ) ) {
116
-			update_option( '_wogh_import_error', $result->get_error_message() );
115
+		if (is_wp_error($result)) {
116
+			update_option('_wogh_import_error', $result->get_error_message());
117 117
 
118
-			return $this->app->response()->error( $result );
118
+			return $this->app->response()->error($result);
119 119
 		}
120 120
 
121
-		update_option( '_wogh_import_complete', 'yes' );
121
+		update_option('_wogh_import_complete', 'yes');
122 122
 
123
-		return $this->app->response()->success( $result );
123
+		return $this->app->response()->success($result);
124 124
 	}
125 125
 
126 126
 	/**
@@ -130,33 +130,33 @@  discard block
 block discarded – undo
130 130
      * @param  boolean    $force
131 131
      * @return boolean
132 132
      */
133
-	public function export_all( $user_id, $force = false ) {
134
-		if ( ! $this->app->semaphore()->is_open() ) {
135
-			return $this->app->response()->error( new WP_Error(
133
+	public function export_all($user_id, $force = false) {
134
+		if ( ! $this->app->semaphore()->is_open()) {
135
+			return $this->app->response()->error(new WP_Error(
136 136
 				'semaphore_locked',
137
-				sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::export_all()' )
138
-			) );
137
+				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::export_all()')
138
+			));
139 139
 		}
140 140
 
141 141
 		$this->app->semaphore()->lock();
142 142
 
143
-		if ( $user_id ) {
144
-			wp_set_current_user( $user_id );
143
+		if ($user_id) {
144
+			wp_set_current_user($user_id);
145 145
 		}
146 146
 
147 147
 		$result = $this->app->export()->full($force);
148 148
 		$this->app->semaphore()->unlock();
149 149
 
150 150
 		// Maybe move option updating out of this class/upgrade message display?
151
-		if ( is_wp_error( $result ) ) {
152
-			update_option( '_wogh_export_error', $result->get_error_message() );
151
+		if (is_wp_error($result)) {
152
+			update_option('_wogh_export_error', $result->get_error_message());
153 153
 
154
-			return $this->app->response()->error( $result );
154
+			return $this->app->response()->error($result);
155 155
 		} else {
156
-			update_option( '_wogh_export_complete', 'yes' );
157
-			update_option( '_wogh_fully_exported', 'yes' );
156
+			update_option('_wogh_export_complete', 'yes');
157
+			update_option('_wogh_fully_exported', 'yes');
158 158
 
159
-			return $this->app->response()->success( $result );
159
+			return $this->app->response()->success($result);
160 160
 		}
161 161
 	}
162 162
 
@@ -169,27 +169,27 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return boolean
171 171
 	 */
172
-	public function export_post( $post_id ) {
173
-		if ( wp_is_post_revision( $post_id ) ) {
172
+	public function export_post($post_id) {
173
+		if (wp_is_post_revision($post_id)) {
174 174
 			return;
175 175
 		}
176 176
 
177
-		if ( ! $this->app->semaphore()->is_open() ) {
178
-			return $this->app->response()->error( new WP_Error(
177
+		if ( ! $this->app->semaphore()->is_open()) {
178
+			return $this->app->response()->error(new WP_Error(
179 179
 				'semaphore_locked',
180
-				sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::export_post()' )
181
-			) );
180
+				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::export_post()')
181
+			));
182 182
 		}
183 183
 
184 184
 		$this->app->semaphore()->lock();
185
-		$result = $this->app->export()->update( $post_id );
185
+		$result = $this->app->export()->update($post_id);
186 186
 		$this->app->semaphore()->unlock();
187 187
 
188
-		if ( is_wp_error( $result ) ) {
189
-			return $this->app->response()->error( $result );
188
+		if (is_wp_error($result)) {
189
+			return $this->app->response()->error($result);
190 190
 		}
191 191
 
192
-		return $this->app->response()->success( $result );
192
+		return $this->app->response()->success($result);
193 193
 	}
194 194
 
195 195
 	/**
@@ -201,27 +201,27 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return boolean
203 203
 	 */
204
-	public function delete_post( $post_id ) {
205
-		if ( wp_is_post_revision( $post_id ) ) {
204
+	public function delete_post($post_id) {
205
+		if (wp_is_post_revision($post_id)) {
206 206
 			return;
207 207
 		}
208 208
 
209
-		if ( ! $this->app->semaphore()->is_open() ) {
210
-			return $this->app->response()->error( new WP_Error(
209
+		if ( ! $this->app->semaphore()->is_open()) {
210
+			return $this->app->response()->error(new WP_Error(
211 211
 				'semaphore_locked',
212
-				sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::delete_post()' )
213
-			) );
212
+				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::delete_post()')
213
+			));
214 214
 		}
215 215
 
216 216
 		$this->app->semaphore()->lock();
217
-		$result = $this->app->export()->delete( $post_id );
217
+		$result = $this->app->export()->delete($post_id);
218 218
 		$this->app->semaphore()->unlock();
219 219
 
220
-		if ( is_wp_error( $result ) ) {
221
-			return $this->app->response()->error( $result );
220
+		if (is_wp_error($result)) {
221
+			return $this->app->response()->error($result);
222 222
 		}
223 223
 
224
-		return $this->app->response()->success( $result );
224
+		return $this->app->response()->success($result);
225 225
 	}
226 226
 
227 227
 	/**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * than just returning data.
231 231
 	 */
232 232
 	protected function set_ajax() {
233
-		if ( ! defined( 'WOGH_AJAX' ) ) {
234
-			define( 'WOGH_AJAX', true );
233
+		if ( ! defined('WOGH_AJAX')) {
234
+			define('WOGH_AJAX', true);
235 235
 		}
236 236
 	}
237 237
 }
Please login to merge, or discard this patch.