@@ -84,13 +84,13 @@ discard block |
||
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 |
||
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 |
||
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(); |
@@ -152,9 +152,9 @@ |
||
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 | // } |
@@ -376,9 +376,9 @@ |
||
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 ) { |
@@ -14,7 +14,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -81,7 +81,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -41,7 +41,7 @@ |
||
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 |
@@ -26,24 +26,24 @@ discard block |
||
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 | |
44 | - if ( is_array( $result ) ) { |
|
45 | - $result = $this->import_files( $result ); |
|
46 | - } |
|
44 | + if ( is_array( $result ) ) { |
|
45 | + $result = $this->import_files( $result ); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | if ( is_wp_error( $result ) ) { |
49 | 49 | return $files; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * import blob by files |
57 | 57 | * @param Writing_On_GitHub_File_Info[] $files |
58 | - * |
|
58 | + * |
|
59 | 59 | * @return string|WP_Error |
60 | 60 | */ |
61 | 61 | protected function import_files( $files ) { |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | foreach ($delete_ids as $id) { |
74 | 74 | $result = $this->app->database()->delete_post( $id ); |
75 | 75 | if ( is_wp_error( $result ) ) { |
76 | - /* @var WP_Error $result */ |
|
77 | - $error = wogh_append_error( $error, $result ); |
|
76 | + /* @var WP_Error $result */ |
|
77 | + $error = wogh_append_error( $error, $result ); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | } |
@@ -91,32 +91,32 @@ discard block |
||
91 | 91 | $result = $this->app->api()->fetch()->tree_recursive(); |
92 | 92 | |
93 | 93 | if ( is_wp_error( $result ) ) { |
94 | - /* @var WP_Error $result */ |
|
94 | + /* @var WP_Error $result */ |
|
95 | 95 | return $result; |
96 | 96 | } |
97 | 97 | |
98 | - if ( is_array( $result ) ) { |
|
99 | - $result = $this->import_files( $result ); |
|
100 | - } |
|
98 | + if ( is_array( $result ) ) { |
|
99 | + $result = $this->import_files( $result ); |
|
100 | + } |
|
101 | 101 | |
102 | 102 | if ( is_wp_error( $result ) ) { |
103 | - /* @var WP_Error $result */ |
|
103 | + /* @var WP_Error $result */ |
|
104 | 104 | return $result; |
105 | 105 | } |
106 | 106 | |
107 | 107 | return __( 'Payload processed', 'writing-on-github' ); |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Do compare |
|
112 | - * @param Writing_On_GitHub_File_Info[]|WP_Error $files |
|
113 | - * @param int[] &$delete_ids |
|
114 | - * |
|
115 | - * @return string|WP_Error |
|
116 | - */ |
|
110 | + /** |
|
111 | + * Do compare |
|
112 | + * @param Writing_On_GitHub_File_Info[]|WP_Error $files |
|
113 | + * @param int[] &$delete_ids |
|
114 | + * |
|
115 | + * @return string|WP_Error |
|
116 | + */ |
|
117 | 117 | protected function compare( $files, &$delete_ids ) { |
118 | 118 | if ( is_wp_error( $files ) ) { |
119 | - /* @var WP_Error $files */ |
|
119 | + /* @var WP_Error $files */ |
|
120 | 120 | return $files; |
121 | 121 | } |
122 | 122 |
@@ -29,34 +29,34 @@ discard block |
||
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 = ''; |
|
44 | + $error = ''; |
|
45 | 45 | |
46 | - foreach ( $posts as $post ) { |
|
47 | - $result = $this->update( $post->id() ); |
|
48 | - if ( is_wp_error( $result ) ) { |
|
49 | - /* @var WP_Error $result */ |
|
50 | - $error = wogh_append_error( $error, $result ); |
|
51 | - } |
|
52 | - } |
|
46 | + foreach ( $posts as $post ) { |
|
47 | + $result = $this->update( $post->id() ); |
|
48 | + if ( is_wp_error( $result ) ) { |
|
49 | + /* @var WP_Error $result */ |
|
50 | + $error = wogh_append_error( $error, $result ); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - if ( is_wp_error( $error ) ) { |
|
55 | - /* @var WP_Error $error */ |
|
56 | - return $error; |
|
57 | - } |
|
54 | + if ( is_wp_error( $error ) ) { |
|
55 | + /* @var WP_Error $error */ |
|
56 | + return $error; |
|
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 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $post = $this->app->database()->fetch_by_id( $post_id ); |
87 | 87 | |
88 | 88 | if ( is_wp_error( $post ) ) { |
89 | - /* @var WP_Error $post */ |
|
89 | + /* @var WP_Error $post */ |
|
90 | 90 | return $post; |
91 | 91 | } |
92 | 92 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $result = $this->new_posts( array( $post ) ); |
103 | 103 | |
104 | 104 | if ( is_wp_error( $result ) ) { |
105 | - /* @var WP_Error $result */ |
|
105 | + /* @var WP_Error $result */ |
|
106 | 106 | return $result; |
107 | 107 | } |
108 | 108 | |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | * @return string|WP_Error |
118 | 118 | */ |
119 | 119 | public function new_posts( array $posts ) { |
120 | - $persist = $this->app->api()->persist(); |
|
120 | + $persist = $this->app->api()->persist(); |
|
121 | 121 | |
122 | 122 | $error = ''; |
123 | 123 | foreach ( $posts as $post ) { |
124 | 124 | $result = $this->new_post( $post, $persist ); |
125 | 125 | if ( is_wp_error( $result ) ) { |
126 | - /* @var WP_Error $result */ |
|
127 | - $error = wogh_append_error( $error, $result ); |
|
126 | + /* @var WP_Error $result */ |
|
127 | + $error = wogh_append_error( $error, $result ); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | return $error; |
133 | 133 | } |
134 | 134 | |
135 | - return __( 'Export to GitHub completed successfully.', 'writing-on-github' ); |
|
135 | + return __( 'Export to GitHub completed successfully.', 'writing-on-github' ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | protected function new_post( $post, $persist ) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $post = $this->app->database()->fetch_by_id( $post_id ); |
213 | 213 | |
214 | 214 | if ( is_wp_error( $post ) ) { |
215 | - /* @var WP_Error $post */ |
|
215 | + /* @var WP_Error $post */ |
|
216 | 216 | return $post; |
217 | 217 | } |
218 | 218 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $result = $this->app->api()->persist()->delete_file( $github_path, $post->sha(), $message ); |
233 | 233 | |
234 | 234 | if ( is_wp_error( $result ) ) { |
235 | - /* @var WP_Error $result */ |
|
235 | + /* @var WP_Error $result */ |
|
236 | 236 | return $result; |
237 | 237 | } |
238 | 238 |
@@ -8,8 +8,8 @@ |
||
8 | 8 | * @return WP_Error |
9 | 9 | */ |
10 | 10 | function wogh_append_error( $error, $error2 ) { |
11 | - if ( is_wp_error( $error ) ) { |
|
12 | - $error->add( $error2->get_error_code(), $error2->get_error_message() ); |
|
13 | - } |
|
14 | - return $error2; |
|
11 | + if ( is_wp_error( $error ) ) { |
|
12 | + $error->add( $error2->get_error_code(), $error2->get_error_message() ); |
|
13 | + } |
|
14 | + return $error2; |
|
15 | 15 | } |