@@ -5,6 +5,6 @@ |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | ?> |
8 | -<?php $value = get_option( $args['name'], $args['default'] ); ?> |
|
9 | -<input type="checkbox" name="<?php echo esc_attr( $args['name'] ); ?>" id="<?php echo esc_attr( $args['name'] ); ?>" value="yes" <?php echo 'yes' === $value ? 'checked' : ''; ?> /> |
|
8 | +<?php $value = get_option($args['name'], $args['default']); ?> |
|
9 | +<input type="checkbox" name="<?php echo esc_attr($args['name']); ?>" id="<?php echo esc_attr($args['name']); ?>" value="yes" <?php echo 'yes' === $value ? 'checked' : ''; ?> /> |
|
10 | 10 | <p class="description"><?php echo $args['help_text']; ?></p> |
@@ -5,6 +5,6 @@ |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | ?> |
8 | -<?php $value = get_option( $args['name'], $args['default'] ); ?> |
|
9 | -<input name="<?php echo esc_attr( $args['name'] ); ?>" id="<?php echo esc_attr( $args['name'] ); ?>" type="<?php echo 'wogh_secret' === $args['name'] ? 'password' : 'text'; ?>" value="<?php echo esc_attr( $value ); ?>" /> |
|
8 | +<?php $value = get_option($args['name'], $args['default']); ?> |
|
9 | +<input name="<?php echo esc_attr($args['name']); ?>" id="<?php echo esc_attr($args['name']); ?>" type="<?php echo 'wogh_secret' === $args['name'] ? 'password' : 'text'; ?>" value="<?php echo esc_attr($value); ?>" /> |
|
10 | 10 | <p class="description"><?php echo $args['help_text']; ?></p> |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | |
13 | 13 | // If the functions have already been autoloaded, don't reload. |
14 | 14 | // This fixes function duplication during unit testing. |
15 | -if ( defined( 'WRITING_ON_GITHUB_TEST' ) && WRITING_ON_GITHUB_TEST ) { |
|
16 | - $path = dirname( __FILE__ ) . '/vendor/autoload.php'; |
|
15 | +if (defined('WRITING_ON_GITHUB_TEST') && WRITING_ON_GITHUB_TEST) { |
|
16 | + $path = dirname(__FILE__) . '/vendor/autoload.php'; |
|
17 | 17 | include_once $path; |
18 | 18 | } |
19 | 19 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | // require_once(dirname(__FILE__) . '/views/options.php'); |
42 | 42 | // require_once(dirname(__FILE__) . '/views/user-setting-field.php'); |
43 | 43 | |
44 | -add_action( 'plugins_loaded', array( new Writing_On_GitHub, 'boot' ) ); |
|
44 | +add_action('plugins_loaded', array(new Writing_On_GitHub, 'boot')); |
|
45 | 45 | |
46 | 46 | class Writing_On_GitHub { |
47 | 47 | |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | public function __construct() { |
139 | 139 | self::$instance = $this; |
140 | 140 | |
141 | - if ( is_admin() ) { |
|
141 | + if (is_admin()) { |
|
142 | 142 | $this->admin = new Writing_On_GitHub_Admin; |
143 | 143 | } |
144 | 144 | |
145 | - $this->controller = new Writing_On_GitHub_Controller( $this ); |
|
145 | + $this->controller = new Writing_On_GitHub_Controller($this); |
|
146 | 146 | |
147 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
148 | - WP_CLI::add_command( 'wogh', $this->cli() ); |
|
147 | + if (defined('WP_CLI') && WP_CLI) { |
|
148 | + WP_CLI::add_command('wogh', $this->cli()); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -153,30 +153,30 @@ discard block |
||
153 | 153 | * Attaches the plugin's hooks into WordPress. |
154 | 154 | */ |
155 | 155 | public function boot() { |
156 | - register_activation_hook( __FILE__, array( $this, 'activate' ) ); |
|
157 | - add_action( 'admin_notices', array( $this, 'activation_notice' ) ); |
|
156 | + register_activation_hook(__FILE__, array($this, 'activate')); |
|
157 | + add_action('admin_notices', array($this, 'activation_notice')); |
|
158 | 158 | |
159 | - add_action( 'init', array( $this, 'l10n' ) ); |
|
159 | + add_action('init', array($this, 'l10n')); |
|
160 | 160 | |
161 | 161 | // Controller actions. |
162 | - add_action( 'save_post', array( $this->controller, 'export_post' ) ); |
|
163 | - add_action( 'delete_post', array( $this->controller, 'delete_post' ) ); |
|
164 | - add_action( 'wp_ajax_nopriv_wogh_push_request', array( $this->controller, 'pull_posts' ) ); |
|
165 | - add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 ); |
|
166 | - add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 ); |
|
167 | - add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 ); |
|
162 | + add_action('save_post', array($this->controller, 'export_post')); |
|
163 | + add_action('delete_post', array($this->controller, 'delete_post')); |
|
164 | + add_action('wp_ajax_nopriv_wogh_push_request', array($this->controller, 'pull_posts')); |
|
165 | + add_action('wogh_export', array($this->controller, 'export_all'), 10, 2); |
|
166 | + add_action('wogh_import', array($this->controller, 'import_master'), 10, 1); |
|
167 | + add_filter('get_edit_post_link', array($this, 'edit_post_link'), 10, 3); |
|
168 | 168 | |
169 | 169 | // add_filter( 'wogh_post_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
170 | 170 | // add_filter( 'wogh_pre_import_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
171 | - add_filter( 'the_content', array( $this, 'the_content' ) ); |
|
171 | + add_filter('the_content', array($this, 'the_content')); |
|
172 | 172 | |
173 | - do_action( 'wogh_boot', $this ); |
|
173 | + do_action('wogh_boot', $this); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | public function edit_post_link($link, $postID, $context) { |
177 | - if ( ! wp_is_post_revision( $postID ) ) { |
|
178 | - $post = new Writing_On_GitHub_Post( $postID, Writing_On_GitHub::$instance->api() ); |
|
179 | - if ( $post->is_on_github() ) { |
|
177 | + if ( ! wp_is_post_revision($postID)) { |
|
178 | + $post = new Writing_On_GitHub_Post($postID, Writing_On_GitHub::$instance->api()); |
|
179 | + if ($post->is_on_github()) { |
|
180 | 180 | return $post->github_edit_url(); |
181 | 181 | } |
182 | 182 | } |
@@ -235,29 +235,29 @@ discard block |
||
235 | 235 | * Init i18n files |
236 | 236 | */ |
237 | 237 | public function l10n() { |
238 | - load_plugin_textdomain( self::$text_domain ); |
|
238 | + load_plugin_textdomain(self::$text_domain); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | 242 | * Sets and kicks off the export cronjob |
243 | 243 | */ |
244 | - public function start_export( $force = false ) { |
|
245 | - $this->start_cron( 'export', $force ); |
|
244 | + public function start_export($force = false) { |
|
245 | + $this->start_cron('export', $force); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Sets and kicks off the import cronjob |
250 | 250 | */ |
251 | 251 | public function start_import() { |
252 | - $this->start_cron( 'import' ); |
|
252 | + $this->start_cron('import'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | 256 | * Enables the admin notice on initial activation |
257 | 257 | */ |
258 | 258 | public function activate() { |
259 | - if ( 'yes' !== get_option( '_wogh_fully_exported' ) ) { |
|
260 | - set_transient( '_wogh_activated', 'yes' ); |
|
259 | + if ('yes' !== get_option('_wogh_fully_exported')) { |
|
260 | + set_transient('_wogh_activated', 'yes'); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -265,18 +265,18 @@ discard block |
||
265 | 265 | * Displays the activation admin notice |
266 | 266 | */ |
267 | 267 | public function activation_notice() { |
268 | - if ( ! get_transient( '_wogh_activated' ) ) { |
|
268 | + if ( ! get_transient('_wogh_activated')) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | - delete_transient( '_wogh_activated' ); |
|
272 | + delete_transient('_wogh_activated'); |
|
273 | 273 | |
274 | 274 | ?><div class="updated"> |
275 | 275 | <p> |
276 | 276 | <?php |
277 | 277 | printf( |
278 | - __( 'To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github' ), |
|
279 | - admin_url( 'options-general.php?page=' . static::$text_domain) |
|
278 | + __('To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github'), |
|
279 | + admin_url('options-general.php?page=' . static::$text_domain) |
|
280 | 280 | ); |
281 | 281 | ?> |
282 | 282 | </p> |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return Writing_On_GitHub_CLI |
299 | 299 | */ |
300 | 300 | public function cli() { |
301 | - if ( ! $this->cli ) { |
|
301 | + if ( ! $this->cli) { |
|
302 | 302 | $this->cli = new Writing_On_GitHub_CLI; |
303 | 303 | } |
304 | 304 | |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @return Writing_On_GitHub_Request |
312 | 312 | */ |
313 | 313 | public function request() { |
314 | - if ( ! $this->request ) { |
|
315 | - $this->request = new Writing_On_GitHub_Request( $this ); |
|
314 | + if ( ! $this->request) { |
|
315 | + $this->request = new Writing_On_GitHub_Request($this); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | return $this->request; |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | * @return Writing_On_GitHub_Response |
325 | 325 | */ |
326 | 326 | public function response() { |
327 | - if ( ! $this->response ) { |
|
328 | - $this->response = new Writing_On_GitHub_Response( $this ); |
|
327 | + if ( ! $this->response) { |
|
328 | + $this->response = new Writing_On_GitHub_Response($this); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $this->response; |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | * @return Writing_On_GitHub_Api |
338 | 338 | */ |
339 | 339 | public function api() { |
340 | - if ( ! $this->api ) { |
|
341 | - $this->api = new Writing_On_GitHub_Api( $this ); |
|
340 | + if ( ! $this->api) { |
|
341 | + $this->api = new Writing_On_GitHub_Api($this); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return $this->api; |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | * @return Writing_On_GitHub_Import |
351 | 351 | */ |
352 | 352 | public function import() { |
353 | - if ( ! $this->import ) { |
|
354 | - $this->import = new Writing_On_GitHub_Import( $this ); |
|
353 | + if ( ! $this->import) { |
|
354 | + $this->import = new Writing_On_GitHub_Import($this); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | return $this->import; |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | * @return Writing_On_GitHub_Export |
364 | 364 | */ |
365 | 365 | public function export() { |
366 | - if ( ! $this->export ) { |
|
367 | - $this->export = new Writing_On_GitHub_Export( $this ); |
|
366 | + if ( ! $this->export) { |
|
367 | + $this->export = new Writing_On_GitHub_Export($this); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | return $this->export; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * @return Writing_On_GitHub_Semaphore |
377 | 377 | */ |
378 | 378 | public function semaphore() { |
379 | - if ( ! $this->semaphore ) { |
|
379 | + if ( ! $this->semaphore) { |
|
380 | 380 | $this->semaphore = new Writing_On_GitHub_Semaphore; |
381 | 381 | } |
382 | 382 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * @return Writing_On_GitHub_Database |
390 | 390 | */ |
391 | 391 | public function database() { |
392 | - if ( ! $this->database ) { |
|
393 | - $this->database = new Writing_On_GitHub_Database( $this ); |
|
392 | + if ( ! $this->database) { |
|
393 | + $this->database = new Writing_On_GitHub_Database($this); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | return $this->database; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @return Writing_On_GitHub_Cache |
403 | 403 | */ |
404 | 404 | public function cache() { |
405 | - if ( ! $this->cache ) { |
|
405 | + if ( ! $this->cache) { |
|
406 | 406 | $this->cache = new Writing_On_GitHub_Cache; |
407 | 407 | } |
408 | 408 | |
@@ -417,18 +417,18 @@ discard block |
||
417 | 417 | * @param mixed $msg |
418 | 418 | * @param string $write |
419 | 419 | */ |
420 | - public static function write_log( $msg, $write = 'line' ) { |
|
421 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
422 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
423 | - WP_CLI::print_value( $msg ); |
|
420 | + public static function write_log($msg, $write = 'line') { |
|
421 | + if (defined('WP_CLI') && WP_CLI) { |
|
422 | + if (is_array($msg) || is_object($msg)) { |
|
423 | + WP_CLI::print_value($msg); |
|
424 | 424 | } else { |
425 | - WP_CLI::$write( $msg ); |
|
425 | + WP_CLI::$write($msg); |
|
426 | 426 | } |
427 | - } elseif ( true === WP_DEBUG ) { |
|
428 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
429 | - error_log( print_r( $msg, true ) ); |
|
427 | + } elseif (true === WP_DEBUG) { |
|
428 | + if (is_array($msg) || is_object($msg)) { |
|
429 | + error_log(print_r($msg, true)); |
|
430 | 430 | } else { |
431 | - error_log( $msg ); |
|
431 | + error_log($msg); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | * @param bool $force |
440 | 440 | * @param string $type |
441 | 441 | */ |
442 | - protected function start_cron( $type, $force = false ) { |
|
443 | - update_option( '_wogh_' . $type . '_started', 'yes' ); |
|
442 | + protected function start_cron($type, $force = false) { |
|
443 | + update_option('_wogh_' . $type . '_started', 'yes'); |
|
444 | 444 | $user_id = get_current_user_id(); |
445 | - wp_schedule_single_event( time(), 'wogh_' . $type . '', array( $user_id, $force ) ); |
|
445 | + wp_schedule_single_event(time(), 'wogh_' . $type . '', array($user_id, $force)); |
|
446 | 446 | spawn_cron(); |
447 | 447 | } |
448 | 448 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param Writing_On_GitHub $app Application container. |
24 | 24 | */ |
25 | - public function __construct( Writing_On_GitHub $app ) { |
|
25 | + public function __construct(Writing_On_GitHub $app) { |
|
26 | 26 | $this->app = $app; |
27 | 27 | } |
28 | 28 | |
@@ -32,31 +32,31 @@ discard block |
||
32 | 32 | * @param bool $force_all |
33 | 33 | * @return string|WP_Error |
34 | 34 | */ |
35 | - public function full( bool $force_all = false ) { |
|
35 | + public function full(bool $force_all = false) { |
|
36 | 36 | $posts = $this->app->database()->fetch_all_supported($force_all); |
37 | 37 | |
38 | - if ( is_wp_error( $posts ) ) { |
|
38 | + if (is_wp_error($posts)) { |
|
39 | 39 | return $posts; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $error = false; |
43 | 43 | |
44 | - foreach ( $posts as $post ) { |
|
45 | - $result = $this->update( $post->id() ); |
|
46 | - if ( is_wp_error( $result ) ) { |
|
47 | - if ( $error ) { |
|
48 | - $error->add( $result->get_error_code(), $result->get_error_message() ); |
|
44 | + foreach ($posts as $post) { |
|
45 | + $result = $this->update($post->id()); |
|
46 | + if (is_wp_error($result)) { |
|
47 | + if ($error) { |
|
48 | + $error->add($result->get_error_code(), $result->get_error_message()); |
|
49 | 49 | } else { |
50 | 50 | $error = $result; |
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - if ( is_wp_error( $error ) ) { |
|
55 | + if (is_wp_error($error)) { |
|
56 | 56 | return $error; |
57 | 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 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | * @param int $post_id |
66 | 66 | * @return boolean |
67 | 67 | */ |
68 | - protected function github_path( $post_id ) { |
|
69 | - $github_path = get_post_meta( $post_id, '_wogh_github_path', true ); |
|
68 | + protected function github_path($post_id) { |
|
69 | + $github_path = get_post_meta($post_id, '_wogh_github_path', true); |
|
70 | 70 | |
71 | - if ( $github_path && $this->app->api()->fetch()->exists( $github_path ) ) { |
|
71 | + if ($github_path && $this->app->api()->fetch()->exists($github_path)) { |
|
72 | 72 | return $github_path; |
73 | 73 | } |
74 | 74 | |
@@ -82,29 +82,29 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return string|WP_Error |
84 | 84 | */ |
85 | - public function update( $post_id ) { |
|
86 | - $post = $this->app->database()->fetch_by_id( $post_id ); |
|
85 | + public function update($post_id) { |
|
86 | + $post = $this->app->database()->fetch_by_id($post_id); |
|
87 | 87 | |
88 | - if ( is_wp_error( $post ) ) { |
|
88 | + if (is_wp_error($post)) { |
|
89 | 89 | return $post; |
90 | 90 | } |
91 | 91 | |
92 | - if ( 'trash' === $post->status() ) { |
|
93 | - return $this->delete( $post_id ); |
|
92 | + if ('trash' === $post->status()) { |
|
93 | + return $this->delete($post_id); |
|
94 | 94 | } |
95 | 95 | |
96 | - if ( $old_github_path = $this->github_path( $post->id() ) ) { |
|
96 | + if ($old_github_path = $this->github_path($post->id())) { |
|
97 | 97 | error_log("old_github_path: $old_github_path"); |
98 | 98 | $post->set_old_github_path($old_github_path); |
99 | 99 | } |
100 | 100 | |
101 | - $result = $this->new_posts( array( $post ) ); |
|
101 | + $result = $this->new_posts(array($post)); |
|
102 | 102 | |
103 | - if ( is_wp_error( $result ) ) { |
|
103 | + if (is_wp_error($result)) { |
|
104 | 104 | return $result; |
105 | 105 | } |
106 | 106 | |
107 | - return __( 'Export to GitHub completed successfully.', 'writing-on-github' ); |
|
107 | + return __('Export to GitHub completed successfully.', 'writing-on-github'); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string|WP_Error |
116 | 116 | */ |
117 | - public function new_posts( array $posts ) { |
|
117 | + public function new_posts(array $posts) { |
|
118 | 118 | $error = false; |
119 | 119 | |
120 | 120 | $persist = $this->app->api()->persist(); |
121 | 121 | |
122 | - foreach ( $posts as $post ) { |
|
123 | - $result = $this->new_post( $post, $persist ); |
|
124 | - if ( is_wp_error( $result ) ) { |
|
125 | - if ( $error ) { |
|
126 | - $error->add( $result->get_error_code(), $result->get_error_message() ); |
|
122 | + foreach ($posts as $post) { |
|
123 | + $result = $this->new_post($post, $persist); |
|
124 | + if (is_wp_error($result)) { |
|
125 | + if ($error) { |
|
126 | + $error->add($result->get_error_code(), $result->get_error_message()); |
|
127 | 127 | } else { |
128 | 128 | $error = $result; |
129 | 129 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | // $result = $this->app->api()->persist()->commit( $master ); |
136 | 136 | |
137 | - if ( is_wp_error( $error ) ) { |
|
137 | + if (is_wp_error($error)) { |
|
138 | 138 | return $error; |
139 | 139 | } |
140 | 140 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | |
145 | - protected function new_post( $post, $persist ) { |
|
145 | + protected function new_post($post, $persist) { |
|
146 | 146 | $github_path = $post->github_path(); |
147 | 147 | $old_github_path = $post->old_github_path(); |
148 | 148 | $blob = $post->to_blob(); |
149 | 149 | $result = false; |
150 | 150 | |
151 | - if ( $old_github_path && $old_github_path != $github_path ) { |
|
151 | + if ($old_github_path && $old_github_path != $github_path) { |
|
152 | 152 | // rename |
153 | 153 | $message = apply_filters( |
154 | 154 | 'wogh_commit_msg_move_post', |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | 'Move %s to %s via WordPress at %s (%s)', |
157 | 157 | $old_github_path, $github_path, |
158 | 158 | site_url(), |
159 | - get_bloginfo( 'name' ) |
|
159 | + get_bloginfo('name') |
|
160 | 160 | ) |
161 | 161 | ) . $this->get_commit_msg_tag(); |
162 | 162 | |
163 | - $result = $persist->delete_file( $post->old_github_path(), $blob->sha(), $message ); |
|
164 | - if ( is_wp_error( $result ) ) { |
|
163 | + $result = $persist->delete_file($post->old_github_path(), $blob->sha(), $message); |
|
164 | + if (is_wp_error($result)) { |
|
165 | 165 | return $result; |
166 | 166 | } |
167 | 167 | |
168 | - $result = $persist->create_file( $blob, $message ); |
|
169 | - if ( is_wp_error( $result ) ) { |
|
168 | + $result = $persist->create_file($blob, $message); |
|
169 | + if (is_wp_error($result)) { |
|
170 | 170 | return $result; |
171 | 171 | } |
172 | - } elseif ( ! $old_github_path ) { |
|
172 | + } elseif ( ! $old_github_path) { |
|
173 | 173 | // create new |
174 | 174 | $message = apply_filters( |
175 | 175 | 'wogh_commit_msg_new_post', |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | 'Create new post %s from WordPress at %s (%s)', |
178 | 178 | $github_path, |
179 | 179 | site_url(), |
180 | - get_bloginfo( 'name' ) |
|
180 | + get_bloginfo('name') |
|
181 | 181 | ) |
182 | 182 | ) . $this->get_commit_msg_tag(); |
183 | - $result = $persist->create_file( $blob, $message ); |
|
184 | - if ( is_wp_error( $result ) ) { |
|
183 | + $result = $persist->create_file($blob, $message); |
|
184 | + if (is_wp_error($result)) { |
|
185 | 185 | return $result; |
186 | 186 | } |
187 | - } elseif ( $old_github_path && $old_github_path == $github_path ) { |
|
187 | + } elseif ($old_github_path && $old_github_path == $github_path) { |
|
188 | 188 | // update |
189 | 189 | $message = apply_filters( |
190 | 190 | 'wogh_commit_msg_update_post', |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | 'Update post %s from WordPress at %s (%s)', |
193 | 193 | $github_path, |
194 | 194 | site_url(), |
195 | - get_bloginfo( 'name' ) |
|
195 | + get_bloginfo('name') |
|
196 | 196 | ) |
197 | 197 | ) . $this->get_commit_msg_tag(); |
198 | - $result = $persist->update_file( $blob, $message ); |
|
199 | - if ( is_wp_error( $result ) ) { |
|
198 | + $result = $persist->update_file($blob, $message); |
|
199 | + if (is_wp_error($result)) { |
|
200 | 200 | return $result; |
201 | 201 | } |
202 | 202 | } |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return string|WP_Error |
217 | 217 | */ |
218 | - public function delete( $post_id ) { |
|
219 | - $post = $this->app->database()->fetch_by_id( $post_id ); |
|
218 | + public function delete($post_id) { |
|
219 | + $post = $this->app->database()->fetch_by_id($post_id); |
|
220 | 220 | |
221 | - if ( is_wp_error( $post ) ) { |
|
221 | + if (is_wp_error($post)) { |
|
222 | 222 | return $post; |
223 | 223 | } |
224 | 224 | |
225 | - $github_path = get_post_meta( $post_id, '_wogh_github_path', true ); |
|
225 | + $github_path = get_post_meta($post_id, '_wogh_github_path', true); |
|
226 | 226 | |
227 | 227 | $message = apply_filters( |
228 | 228 | 'wogh_commit_msg_delete', |
@@ -230,18 +230,18 @@ discard block |
||
230 | 230 | 'Deleting %s via WordPress at %s (%s)', |
231 | 231 | $github_path, |
232 | 232 | site_url(), |
233 | - get_bloginfo( 'name' ) |
|
233 | + get_bloginfo('name') |
|
234 | 234 | ), |
235 | 235 | $post |
236 | 236 | ) . $this->get_commit_msg_tag(); |
237 | 237 | |
238 | - $result = $this->app->api()->persist()->delete_file( $github_path, $post->sha(), $message ); |
|
238 | + $result = $this->app->api()->persist()->delete_file($github_path, $post->sha(), $message); |
|
239 | 239 | |
240 | - if ( is_wp_error( $result ) ) { |
|
240 | + if (is_wp_error($result)) { |
|
241 | 241 | return $result; |
242 | 242 | } |
243 | 243 | |
244 | - return __( 'Export to GitHub completed successfully.', 'writing-on-github' ); |
|
244 | + return __('Export to GitHub completed successfully.', 'writing-on-github'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return bool |
254 | 254 | */ |
255 | - public function set_user( $user_id ) { |
|
256 | - return update_option( self::EXPORT_USER_OPTION, (int) $user_id ); |
|
255 | + public function set_user($user_id) { |
|
256 | + return update_option(self::EXPORT_USER_OPTION, (int) $user_id); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | * @return string |
263 | 263 | */ |
264 | 264 | protected function get_commit_msg_tag() { |
265 | - $tag = apply_filters( 'wogh_commit_msg_tag', 'wogh' ); |
|
265 | + $tag = apply_filters('wogh_commit_msg_tag', 'wogh'); |
|
266 | 266 | |
267 | - if ( ! $tag ) { |
|
268 | - throw new Exception( __( 'Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github' ) ); |
|
267 | + if ( ! $tag) { |
|
268 | + throw new Exception(__('Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github')); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | return ' - ' . $tag; |