@@ 160-177 (lines=18) @@ | ||
157 | * |
|
158 | * @return boolean |
|
159 | */ |
|
160 | public function export_post( $post_id ) { |
|
161 | if ( ! $this->app->semaphore()->is_open() ) { |
|
162 | return $this->app->response()->error( new WP_Error( |
|
163 | 'semaphore_locked', |
|
164 | sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'wp-github-sync' ), 'Controller::export_post()' ) |
|
165 | ) ); |
|
166 | } |
|
167 | ||
168 | $this->app->semaphore()->lock(); |
|
169 | $result = $this->app->export()->update( $post_id ); |
|
170 | $this->app->semaphore()->unlock(); |
|
171 | ||
172 | if ( is_wp_error( $result ) ) { |
|
173 | return $this->app->response()->error( $result ); |
|
174 | } |
|
175 | ||
176 | return $this->app->response()->success( $result ); |
|
177 | } |
|
178 | ||
179 | /** |
|
180 | * Removes the post from the tree. |
|
@@ 188-205 (lines=18) @@ | ||
185 | * |
|
186 | * @return boolean |
|
187 | */ |
|
188 | public function delete_post( $post_id ) { |
|
189 | if ( ! $this->app->semaphore()->is_open() ) { |
|
190 | return $this->app->response()->error( new WP_Error( |
|
191 | 'semaphore_locked', |
|
192 | sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'wp-github-sync' ), 'Controller::delete_post()' ) |
|
193 | ) ); |
|
194 | } |
|
195 | ||
196 | $this->app->semaphore()->lock(); |
|
197 | $result = $this->app->export()->delete( $post_id ); |
|
198 | $this->app->semaphore()->unlock(); |
|
199 | ||
200 | if ( is_wp_error( $result ) ) { |
|
201 | return $this->app->response()->error( $result ); |
|
202 | } |
|
203 | ||
204 | return $this->app->response()->success( $result ); |
|
205 | } |
|
206 | ||
207 | /** |
|
208 | * Indicates we're running our own AJAX hook |