@@ 173-194 (lines=22) @@ | ||
170 | * |
|
171 | * @return boolean |
|
172 | */ |
|
173 | public function export_post( $post_id ) { |
|
174 | if ( wp_is_post_revision( $post_id ) ) { |
|
175 | return; |
|
176 | } |
|
177 | ||
178 | if ( ! $this->app->semaphore()->is_open() ) { |
|
179 | return $this->app->response()->error( new WP_Error( |
|
180 | 'semaphore_locked', |
|
181 | sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::export_post()' ) |
|
182 | ) ); |
|
183 | } |
|
184 | ||
185 | $this->app->semaphore()->lock(); |
|
186 | $result = $this->app->export()->update( $post_id ); |
|
187 | $this->app->semaphore()->unlock(); |
|
188 | ||
189 | if ( is_wp_error( $result ) ) { |
|
190 | /* @var WP_Error $result */ |
|
191 | return $this->app->response()->error( $result ); |
|
192 | } |
|
193 | ||
194 | return $this->app->response()->success( $result ); |
|
195 | } |
|
196 | ||
197 | /** |
|
@@ 206-227 (lines=22) @@ | ||
203 | * |
|
204 | * @return boolean |
|
205 | */ |
|
206 | public function delete_post( $post_id ) { |
|
207 | if ( wp_is_post_revision( $post_id ) ) { |
|
208 | return; |
|
209 | } |
|
210 | ||
211 | if ( ! $this->app->semaphore()->is_open() ) { |
|
212 | return $this->app->response()->error( new WP_Error( |
|
213 | 'semaphore_locked', |
|
214 | sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::delete_post()' ) |
|
215 | ) ); |
|
216 | } |
|
217 | ||
218 | $this->app->semaphore()->lock(); |
|
219 | $result = $this->app->export()->delete( $post_id ); |
|
220 | $this->app->semaphore()->unlock(); |
|
221 | ||
222 | if ( is_wp_error( $result ) ) { |
|
223 | /* @var WP_Error $result */ |
|
224 | return $this->app->response()->error( $result ); |
|
225 | } |
|
226 | ||
227 | return $this->app->response()->success( $result ); |
|
228 | } |
|
229 | ||
230 | /** |