@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * Clean up the old values on instantiation. |
29 | 29 | */ |
30 | 30 | public function __construct() { |
31 | - delete_option( self::KEY ); |
|
31 | + delete_option(self::KEY); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return bool |
41 | 41 | */ |
42 | 42 | public function is_open() { |
43 | - if ( self::VALUE_LOCKED === get_transient( self::KEY ) ) { |
|
43 | + if (self::VALUE_LOCKED === get_transient(self::KEY)) { |
|
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | * Enables the push lock. |
52 | 52 | */ |
53 | 53 | public function lock() { |
54 | - set_transient( self::KEY, self::VALUE_LOCKED, MINUTE_IN_SECONDS ); |
|
54 | + set_transient(self::KEY, self::VALUE_LOCKED, MINUTE_IN_SECONDS); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Disables the push lock. |
59 | 59 | */ |
60 | 60 | public function unlock() { |
61 | - set_transient( self::KEY, self::VALUE_UNLOCKED, MINUTE_IN_SECONDS ); |
|
61 | + set_transient(self::KEY, self::VALUE_UNLOCKED, MINUTE_IN_SECONDS); |
|
62 | 62 | } |
63 | 63 | } |
@@ -44,28 +44,28 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @param array $args Command arguments. |
46 | 46 | */ |
47 | - public function export( $args ) { |
|
48 | - list( $post_id, $user_id ) = $args; |
|
47 | + public function export($args) { |
|
48 | + list($post_id, $user_id) = $args; |
|
49 | 49 | |
50 | - if ( ! is_numeric( $user_id ) ) { |
|
51 | - WP_CLI::error( __( 'Invalid user ID', 'writing-on-github' ) ); |
|
50 | + if ( ! is_numeric($user_id)) { |
|
51 | + WP_CLI::error(__('Invalid user ID', 'writing-on-github')); |
|
52 | 52 | } |
53 | 53 | |
54 | - $this->app->export()->set_user( $user_id ); |
|
54 | + $this->app->export()->set_user($user_id); |
|
55 | 55 | |
56 | - if ( 'all' === $post_id ) { |
|
57 | - WP_CLI::line( __( 'Starting full export to GitHub.', 'writing-on-github' ) ); |
|
56 | + if ('all' === $post_id) { |
|
57 | + WP_CLI::line(__('Starting full export to GitHub.', 'writing-on-github')); |
|
58 | 58 | $this->app->controller()->export_all(); |
59 | - } elseif ( is_numeric( $post_id ) ) { |
|
59 | + } elseif (is_numeric($post_id)) { |
|
60 | 60 | WP_CLI::line( |
61 | 61 | sprintf( |
62 | - __( 'Exporting post ID to GitHub: %d', 'writing-on-github' ), |
|
62 | + __('Exporting post ID to GitHub: %d', 'writing-on-github'), |
|
63 | 63 | $post_id |
64 | 64 | ) |
65 | 65 | ); |
66 | - $this->app->controller()->export_post( (int) $post_id ); |
|
66 | + $this->app->controller()->export_post((int) $post_id); |
|
67 | 67 | } else { |
68 | - WP_CLI::error( __( 'Invalid post ID', 'writing-on-github' ) ); |
|
68 | + WP_CLI::error(__('Invalid post ID', 'writing-on-github')); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param array $args Command arguments. |
88 | 88 | */ |
89 | - public function import( $args ) { |
|
90 | - list( $user_id ) = $args; |
|
89 | + public function import($args) { |
|
90 | + list($user_id) = $args; |
|
91 | 91 | |
92 | - if ( ! is_numeric( $user_id ) ) { |
|
93 | - WP_CLI::error( __( 'Invalid user ID', 'writing-on-github' ) ); |
|
92 | + if ( ! is_numeric($user_id)) { |
|
93 | + WP_CLI::error(__('Invalid user ID', 'writing-on-github')); |
|
94 | 94 | } |
95 | 95 | |
96 | - update_option( '_wogh_export_user_id', (int) $user_id ); |
|
96 | + update_option('_wogh_export_user_id', (int) $user_id); |
|
97 | 97 | |
98 | - WP_CLI::line( __( 'Starting import from GitHub.', 'writing-on-github' ) ); |
|
98 | + WP_CLI::line(__('Starting import from GitHub.', 'writing-on-github')); |
|
99 | 99 | |
100 | 100 | $this->app->controller()->import_master(); |
101 | 101 | } |
@@ -119,40 +119,40 @@ discard block |
||
119 | 119 | * @param array $args Command arguments. |
120 | 120 | * @param array $assoc_args Command associated arguments. |
121 | 121 | */ |
122 | - public function prime( $args, $assoc_args ) { |
|
123 | - if ( isset( $assoc_args['branch'] ) ) { |
|
124 | - WP_CLI::line( __( 'Starting branch import.', 'writing-on-github' ) ); |
|
122 | + public function prime($args, $assoc_args) { |
|
123 | + if (isset($assoc_args['branch'])) { |
|
124 | + WP_CLI::line(__('Starting branch import.', 'writing-on-github')); |
|
125 | 125 | |
126 | 126 | $commit = $this->app->api()->fetch()->master(); |
127 | 127 | |
128 | - if ( is_wp_error( $commit ) ) { |
|
128 | + if (is_wp_error($commit)) { |
|
129 | 129 | WP_CLI::error( |
130 | 130 | sprintf( |
131 | - __( 'Failed to import and cache branch with error: %s', 'writing-on-github' ), |
|
131 | + __('Failed to import and cache branch with error: %s', 'writing-on-github'), |
|
132 | 132 | $commit->get_error_message() |
133 | 133 | ) |
134 | 134 | ); |
135 | 135 | } else { |
136 | 136 | WP_CLI::success( |
137 | 137 | sprintf( |
138 | - __( 'Successfully imported and cached commit %s from branch.', 'writing-on-github' ), |
|
138 | + __('Successfully imported and cached commit %s from branch.', 'writing-on-github'), |
|
139 | 139 | $commit->sha() |
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | } |
143 | - } else if ( isset( $assoc_args['sha'] ) ) { |
|
144 | - WP_CLI::line( 'Starting sha import.' ); |
|
143 | + } else if (isset($assoc_args['sha'])) { |
|
144 | + WP_CLI::line('Starting sha import.'); |
|
145 | 145 | |
146 | - $commit = $this->app->api()->fetch()->commit( $assoc_args['sha'] ); |
|
146 | + $commit = $this->app->api()->fetch()->commit($assoc_args['sha']); |
|
147 | 147 | |
148 | 148 | WP_CLI::success( |
149 | 149 | sprintf( |
150 | - __( 'Successfully imported and cached commit %s.', 'writing-on-github' ), |
|
150 | + __('Successfully imported and cached commit %s.', 'writing-on-github'), |
|
151 | 151 | $commit->sha() |
152 | 152 | ) |
153 | 153 | ); |
154 | 154 | } else { |
155 | - WP_CLI::error( 'Invalid fetch.' ); |
|
155 | + WP_CLI::error('Invalid fetch.'); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
@@ -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 ) { |
@@ -60,26 +60,26 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @todo remove database operations from this method |
62 | 62 | */ |
63 | - public function __construct( $id_or_args, Writing_On_GitHub_Api $api ) { |
|
63 | + public function __construct($id_or_args, Writing_On_GitHub_Api $api) { |
|
64 | 64 | $this->api = $api; |
65 | 65 | |
66 | - if ( is_numeric( $id_or_args ) ) { |
|
66 | + if (is_numeric($id_or_args)) { |
|
67 | 67 | $this->id = (int) $id_or_args; |
68 | - $this->post = get_post( $this->id ); |
|
68 | + $this->post = get_post($this->id); |
|
69 | 69 | $this->new = false; |
70 | 70 | } |
71 | 71 | |
72 | - if ( is_array( $id_or_args ) ) { |
|
72 | + if (is_array($id_or_args)) { |
|
73 | 73 | $this->args = $id_or_args; |
74 | 74 | |
75 | - if ( isset( $this->args['ID'] ) ) { |
|
76 | - $this->post = get_post( $this->args['ID'] ); |
|
75 | + if (isset($this->args['ID'])) { |
|
76 | + $this->post = get_post($this->args['ID']); |
|
77 | 77 | |
78 | - if ( $this->post ) { |
|
78 | + if ($this->post) { |
|
79 | 79 | $this->id = $this->post->ID; |
80 | 80 | $this->new = false; |
81 | 81 | } else { |
82 | - unset( $this->args['ID'] ); |
|
82 | + unset($this->args['ID']); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return bool |
116 | 116 | */ |
117 | 117 | public function has_password() { |
118 | - return ! empty( $this->post->post_password ); |
|
118 | + return ! empty($this->post->post_password); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function github_content() { |
125 | 125 | $content = $this->front_matter() . $this->post_content(); |
126 | - $ending = apply_filters( 'wogh_line_endings', "\n" ); |
|
126 | + $ending = apply_filters('wogh_line_endings', "\n"); |
|
127 | 127 | |
128 | - return preg_replace( '~(*BSR_ANYCRLF)\R~', $ending, $content ); |
|
128 | + return preg_replace('~(*BSR_ANYCRLF)\R~', $ending, $content); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * Returns String the YAML frontmatter, ready to be written to the file |
135 | 135 | */ |
136 | 136 | public function front_matter() { |
137 | - return "---\n" . spyc_dump( $this->meta() ) . "---\n"; |
|
137 | + return "---\n" . spyc_dump($this->meta()) . "---\n"; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,24 +145,24 @@ discard block |
||
145 | 145 | public function post_content() { |
146 | 146 | $content = $this->post->post_content; |
147 | 147 | |
148 | - if ( function_exists( 'wpmarkdown_html_to_markdown' ) ) { |
|
149 | - $content = wpmarkdown_html_to_markdown( $content ); |
|
150 | - } else if ( class_exists( 'WPCom_Markdown' ) ) { |
|
151 | - if ( WPCom_Markdown::get_instance()->is_markdown( $this->post->ID ) ) { |
|
148 | + if (function_exists('wpmarkdown_html_to_markdown')) { |
|
149 | + $content = wpmarkdown_html_to_markdown($content); |
|
150 | + } else if (class_exists('WPCom_Markdown')) { |
|
151 | + if (WPCom_Markdown::get_instance()->is_markdown($this->post->ID)) { |
|
152 | 152 | $content = $this->post->post_content_filtered; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - return apply_filters( 'wogh_content_export', $content, $this ); |
|
156 | + return apply_filters('wogh_content_export', $content, $this); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | public function old_github_path() { |
160 | 160 | return $this->old_github_path; |
161 | 161 | } |
162 | 162 | |
163 | - public function set_old_github_path( $path ) { |
|
163 | + public function set_old_github_path($path) { |
|
164 | 164 | $this->old_github_path = $path; |
165 | - update_post_meta( $this->id, '_wogh_github_path', $path); |
|
165 | + update_post_meta($this->id, '_wogh_github_path', $path); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * @return string |
185 | 185 | */ |
186 | 186 | public function github_directory() { |
187 | - if ( 'publish' !== $this->status() ) { |
|
188 | - return apply_filters( 'wogh_directory_unpublished', '_drafts/', $this ); |
|
187 | + if ('publish' !== $this->status()) { |
|
188 | + return apply_filters('wogh_directory_unpublished', '_drafts/', $this); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $name = ''; |
192 | 192 | |
193 | - switch ( $this->type() ) { |
|
193 | + switch ($this->type()) { |
|
194 | 194 | case 'post': |
195 | 195 | $name = 'posts'; |
196 | 196 | break; |
@@ -198,35 +198,35 @@ discard block |
||
198 | 198 | $name = 'pages'; |
199 | 199 | break; |
200 | 200 | default: |
201 | - $obj = get_post_type_object( $this->type() ); |
|
201 | + $obj = get_post_type_object($this->type()); |
|
202 | 202 | |
203 | - if ( $obj ) { |
|
204 | - $name = strtolower( $obj->labels->name ); |
|
203 | + if ($obj) { |
|
204 | + $name = strtolower($obj->labels->name); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( ! $name ) { |
|
207 | + if ( ! $name) { |
|
208 | 208 | $name = ''; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if ( $name ) { |
|
212 | + if ($name) { |
|
213 | 213 | $name = '_' . $name . '/'; |
214 | 214 | } |
215 | 215 | |
216 | - return apply_filters( 'wogh_directory_published', $name, $this ); |
|
216 | + return apply_filters('wogh_directory_published', $name, $this); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
220 | 220 | * Build GitHub filename based on post |
221 | 221 | */ |
222 | 222 | public function github_filename() { |
223 | - if ( 'post' === $this->type() ) { |
|
224 | - $filename = get_the_time( 'Y-m-d-', $this->id ) . $this->get_name() . '.md'; |
|
223 | + if ('post' === $this->type()) { |
|
224 | + $filename = get_the_time('Y-m-d-', $this->id) . $this->get_name() . '.md'; |
|
225 | 225 | } else { |
226 | 226 | $filename = $this->get_name() . '.md'; |
227 | 227 | } |
228 | 228 | |
229 | - return apply_filters( 'wogh_filename', $filename, $this ); |
|
229 | + return apply_filters('wogh_filename', $filename, $this); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | * @return string |
236 | 236 | */ |
237 | 237 | protected function get_name() { |
238 | - if ( '' !== $this->name() ) { |
|
238 | + if ('' !== $this->name()) { |
|
239 | 239 | return $this->name(); |
240 | 240 | } |
241 | 241 | |
242 | - return sanitize_title( get_the_title( $this->post ) ); |
|
242 | + return sanitize_title(get_the_title($this->post)); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * @return boolean |
248 | 248 | */ |
249 | 249 | public function is_on_github() { |
250 | - $sha = get_post_meta( $this->id, '_wogh_sha', true ); |
|
251 | - $github_path = get_post_meta( $this->id, '_wogh_github_path', true ); |
|
252 | - if ( $sha && $github_path ) { |
|
250 | + $sha = get_post_meta($this->id, '_wogh_sha', true); |
|
251 | + $github_path = get_post_meta($this->id, '_wogh_github_path', true); |
|
252 | + if ($sha && $github_path) { |
|
253 | 253 | return true; |
254 | 254 | } |
255 | 255 | return false; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @return string |
262 | 262 | */ |
263 | 263 | public function github_view_url() { |
264 | - $github_path = get_post_meta( $this->id, '_wogh_github_path', true ); |
|
264 | + $github_path = get_post_meta($this->id, '_wogh_github_path', true); |
|
265 | 265 | $repository = $this->api->fetch()->repository(); |
266 | 266 | $branch = $this->api->fetch()->branch(); |
267 | 267 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @return string |
275 | 275 | */ |
276 | 276 | public function github_edit_url() { |
277 | - $github_path = get_post_meta( $this->id, '_wogh_github_path', true ); |
|
277 | + $github_path = get_post_meta($this->id, '_wogh_github_path', true); |
|
278 | 278 | $repository = $this->api->fetch()->repository(); |
279 | 279 | $branch = $this->api->fetch()->branch(); |
280 | 280 | |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return string |
290 | 290 | */ |
291 | - public function get_directory_from_path( $path ) { |
|
292 | - $directory = explode( '/', $path ); |
|
293 | - $directory = count( $directory ) > 0 ? $directory[0] : ''; |
|
291 | + public function get_directory_from_path($path) { |
|
292 | + $directory = explode('/', $path); |
|
293 | + $directory = count($directory) > 0 ? $directory[0] : ''; |
|
294 | 294 | |
295 | 295 | return $directory; |
296 | 296 | } |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | * Returns Array an array containing the author name and email |
302 | 302 | */ |
303 | 303 | public function last_modified_author() { |
304 | - if ( $last_id = get_post_meta( $this->id, '_edit_last', true ) ) { |
|
305 | - $user = get_userdata( $last_id ); |
|
304 | + if ($last_id = get_post_meta($this->id, '_edit_last', true)) { |
|
305 | + $user = get_userdata($last_id); |
|
306 | 306 | |
307 | - if ( $user ) { |
|
308 | - return array( 'name' => $user->display_name, 'email' => $user->user_email ); |
|
307 | + if ($user) { |
|
308 | + return array('name' => $user->display_name, 'email' => $user->user_email); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * Returns String the sha1 hash |
320 | 320 | */ |
321 | 321 | public function sha() { |
322 | - $sha = get_post_meta( $this->id, '_wogh_sha', true ); |
|
322 | + $sha = get_post_meta($this->id, '_wogh_sha', true); |
|
323 | 323 | |
324 | 324 | // If we've done a full export and we have no sha |
325 | 325 | // then we should try a live check to see if it exists. |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | // } |
336 | 336 | |
337 | 337 | // if the sha still doesn't exist, then it's empty |
338 | - if ( ! $sha || is_wp_error( $sha ) ) { |
|
338 | + if ( ! $sha || is_wp_error($sha)) { |
|
339 | 339 | $sha = ''; |
340 | 340 | } |
341 | 341 | |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @param string $sha |
349 | 349 | */ |
350 | - public function set_sha( $sha ) { |
|
351 | - update_post_meta( $this->id, '_wogh_sha', $sha ); |
|
350 | + public function set_sha($sha) { |
|
351 | + update_post_meta($this->id, '_wogh_sha', $sha); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -359,24 +359,24 @@ discard block |
||
359 | 359 | public function meta() { |
360 | 360 | $meta = array( |
361 | 361 | 'ID' => $this->id, |
362 | - 'post_title' => get_the_title( $this->post ), |
|
362 | + 'post_title' => get_the_title($this->post), |
|
363 | 363 | 'post_name' => $this->post->post_name, |
364 | - 'author' => ( $author = get_userdata( $this->post->post_author ) ) ? $author->display_name : '', |
|
364 | + 'author' => ($author = get_userdata($this->post->post_author)) ? $author->display_name : '', |
|
365 | 365 | 'post_date' => $this->post->post_date, |
366 | 366 | 'post_excerpt' => $this->post->post_excerpt, |
367 | - 'layout' => get_post_type( $this->post ), |
|
368 | - 'link' => get_permalink( $this->post ), |
|
367 | + 'layout' => get_post_type($this->post), |
|
368 | + 'link' => get_permalink($this->post), |
|
369 | 369 | 'published' => 'publish' === $this->status() ? true : false, |
370 | - 'tags' => wp_get_post_tags( $this->id, array( 'fields' => 'names' ) ), |
|
371 | - 'categories' => wp_get_post_categories( $this->id, array( 'fields' => 'names' ) ) |
|
370 | + 'tags' => wp_get_post_tags($this->id, array('fields' => 'names')), |
|
371 | + 'categories' => wp_get_post_categories($this->id, array('fields' => 'names')) |
|
372 | 372 | ); |
373 | - if ( empty($this->post->post_name) ) { |
|
373 | + if (empty($this->post->post_name)) { |
|
374 | 374 | unset($meta['post_name']); |
375 | 375 | } |
376 | - if ( empty($this->post->post_excerpt) ) { |
|
376 | + if (empty($this->post->post_excerpt)) { |
|
377 | 377 | unset($meta['post_excerpt']); |
378 | 378 | } |
379 | - if ( 'yes' == get_option('wogh_ignore_author') ) { |
|
379 | + if ('yes' == get_option('wogh_ignore_author')) { |
|
380 | 380 | unset($meta['author']); |
381 | 381 | } |
382 | 382 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // } |
393 | 393 | |
394 | - return apply_filters( 'wogh_post_meta', $meta, $this ); |
|
394 | + return apply_filters('wogh_post_meta', $meta, $this); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param array $meta |
410 | 410 | */ |
411 | - public function set_meta( $meta ) { |
|
411 | + public function set_meta($meta) { |
|
412 | 412 | $this->meta = $meta; |
413 | 413 | } |
414 | 414 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * |
438 | 438 | * @return $this |
439 | 439 | */ |
440 | - public function set_post( WP_Post $post ) { |
|
440 | + public function set_post(WP_Post $post) { |
|
441 | 441 | $this->post = $post; |
442 | 442 | $this->id = $post->ID; |
443 | 443 | |
@@ -456,6 +456,6 @@ discard block |
||
456 | 456 | $data->content = $this->github_content(); |
457 | 457 | $data->sha = $this->sha(); |
458 | 458 | |
459 | - return new Writing_On_GitHub_Blob( $data ); |
|
459 | + return new Writing_On_GitHub_Blob($data); |
|
460 | 460 | } |
461 | 461 | } |
@@ -5,8 +5,8 @@ |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | ?> |
8 | -<?php $value = get_option( $args['name'], $args['default'] ); ?> |
|
9 | -<textarea name="<?php echo esc_attr( $args['name'] ); ?>" id="<?php echo esc_attr( $args['name'] ); ?>" rows="10" cols="40"> |
|
10 | -<?php echo esc_attr( $value ); ?> |
|
8 | +<?php $value = get_option($args['name'], $args['default']); ?> |
|
9 | +<textarea name="<?php echo esc_attr($args['name']); ?>" id="<?php echo esc_attr($args['name']); ?>" rows="10" cols="40"> |
|
10 | +<?php echo esc_attr($value); ?> |
|
11 | 11 | </textarea> |
12 | 12 | <p class="description"><?php echo $args['help_text']; ?></p> |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | ?> |
8 | 8 | <div class="wrap"> |
9 | - <h2><?php esc_html_e( 'Writing On GitHub', 'writing-on-github' ); ?></h2> |
|
9 | + <h2><?php esc_html_e('Writing On GitHub', 'writing-on-github'); ?></h2> |
|
10 | 10 | |
11 | 11 | <form method="post" action="options.php"> |
12 | - <?php settings_fields( Writing_On_GitHub::$text_domain ); ?> |
|
13 | - <?php do_settings_sections( Writing_On_GitHub::$text_domain ); ?> |
|
12 | + <?php settings_fields(Writing_On_GitHub::$text_domain); ?> |
|
13 | + <?php do_settings_sections(Writing_On_GitHub::$text_domain); ?> |
|
14 | 14 | <table class="form-table"> |
15 | 15 | <tr> |
16 | - <th scope="row"><?php esc_html_e( 'Webhook callback', 'writing-on-github' ); ?></th> |
|
17 | - <td><code><?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>?action=wogh_push_request</code></td> |
|
16 | + <th scope="row"><?php esc_html_e('Webhook callback', 'writing-on-github'); ?></th> |
|
17 | + <td><code><?php echo esc_url(admin_url('admin-ajax.php')); ?>?action=wogh_push_request</code></td> |
|
18 | 18 | </tr> |
19 | 19 | <tr> |
20 | - <th scope="row"><?php esc_html_e( 'Bulk actions', 'writing-on-github' ); ?></th> |
|
20 | + <th scope="row"><?php esc_html_e('Bulk actions', 'writing-on-github'); ?></th> |
|
21 | 21 | <td> |
22 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'export' ) ) ); ?>"> |
|
23 | - <?php esc_html_e( 'Export to GitHub', 'writing-on-github' ); ?> |
|
22 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'export'))); ?>"> |
|
23 | + <?php esc_html_e('Export to GitHub', 'writing-on-github'); ?> |
|
24 | 24 | </a> | |
25 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'force_export' ) ) ); ?>"> |
|
26 | - <?php esc_html_e( 'Force export to GitHub', 'writing-on-github' ); ?> |
|
25 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'force_export'))); ?>"> |
|
26 | + <?php esc_html_e('Force export to GitHub', 'writing-on-github'); ?> |
|
27 | 27 | </a> | |
28 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'import' ) ) ); ?>"> |
|
29 | - <?php esc_html_e( 'Import from GitHub', 'writing-on-github' ); ?> |
|
28 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'import'))); ?>"> |
|
29 | + <?php esc_html_e('Import from GitHub', 'writing-on-github'); ?> |
|
30 | 30 | </a> |
31 | 31 | </td> |
32 | 32 | </table> |
@@ -1,8 +1,8 @@ |
||
1 | -<?php $value = get_option( $args['name'], $args['default'] ); ?> |
|
2 | -<select name="<?php echo esc_attr( $args['name'] ) ?>" id="<?php echo esc_attr( $args['name'] ) ?>"> |
|
3 | - <?php foreach ( get_users() as $user ) : ?> |
|
4 | - <option value="<?php echo esc_attr( $user->ID ); ?>"<?php echo (int) $value === $user->ID ? ' selected' : '';?>> |
|
5 | - <?php echo esc_html( $user->display_name ); ?> |
|
1 | +<?php $value = get_option($args['name'], $args['default']); ?> |
|
2 | +<select name="<?php echo esc_attr($args['name']) ?>" id="<?php echo esc_attr($args['name']) ?>"> |
|
3 | + <?php foreach (get_users() as $user) : ?> |
|
4 | + <option value="<?php echo esc_attr($user->ID); ?>"<?php echo (int) $value === $user->ID ? ' selected' : ''; ?>> |
|
5 | + <?php echo esc_html($user->display_name); ?> |
|
6 | 6 | </option> |
7 | 7 | <?php endforeach; ?> |
8 | 8 | </select> |
@@ -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> |
@@ -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(); |
@@ -12,12 +12,12 @@ 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 | -$path = dirname( __FILE__ ) . '/vendor/autoload.php'; |
|
16 | -if ( file_exists( $path ) ) { |
|
17 | - require_once( $path ); |
|
15 | +$path = dirname(__FILE__) . '/vendor/autoload.php'; |
|
16 | +if (file_exists($path)) { |
|
17 | + require_once($path); |
|
18 | 18 | } |
19 | 19 | |
20 | -add_action( 'plugins_loaded', array( new Writing_On_GitHub, 'boot' ) ); |
|
20 | +add_action('plugins_loaded', array(new Writing_On_GitHub, 'boot')); |
|
21 | 21 | |
22 | 22 | class Writing_On_GitHub { |
23 | 23 | |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | public function __construct() { |
108 | 108 | self::$instance = $this; |
109 | 109 | |
110 | - if ( is_admin() ) { |
|
110 | + if (is_admin()) { |
|
111 | 111 | $this->admin = new Writing_On_GitHub_Admin; |
112 | 112 | } |
113 | 113 | |
114 | - $this->controller = new Writing_On_GitHub_Controller( $this ); |
|
114 | + $this->controller = new Writing_On_GitHub_Controller($this); |
|
115 | 115 | |
116 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
117 | - WP_CLI::add_command( 'wogh', $this->cli() ); |
|
116 | + if (defined('WP_CLI') && WP_CLI) { |
|
117 | + WP_CLI::add_command('wogh', $this->cli()); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -122,30 +122,30 @@ discard block |
||
122 | 122 | * Attaches the plugin's hooks into WordPress. |
123 | 123 | */ |
124 | 124 | public function boot() { |
125 | - register_activation_hook( __FILE__, array( $this, 'activate' ) ); |
|
126 | - add_action( 'admin_notices', array( $this, 'activation_notice' ) ); |
|
125 | + register_activation_hook(__FILE__, array($this, 'activate')); |
|
126 | + add_action('admin_notices', array($this, 'activation_notice')); |
|
127 | 127 | |
128 | - add_action( 'init', array( $this, 'l10n' ) ); |
|
128 | + add_action('init', array($this, 'l10n')); |
|
129 | 129 | |
130 | 130 | // Controller actions. |
131 | - add_action( 'save_post', array( $this->controller, 'export_post' ) ); |
|
132 | - add_action( 'delete_post', array( $this->controller, 'delete_post' ) ); |
|
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 ); |
|
135 | - add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 ); |
|
136 | - add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 ); |
|
131 | + add_action('save_post', array($this->controller, 'export_post')); |
|
132 | + add_action('delete_post', array($this->controller, 'delete_post')); |
|
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); |
|
135 | + add_action('wogh_import', array($this->controller, 'import_master'), 10, 1); |
|
136 | + add_filter('get_edit_post_link', array($this, 'edit_post_link'), 10, 3); |
|
137 | 137 | |
138 | 138 | // add_filter( 'wogh_post_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
139 | 139 | // add_filter( 'wogh_pre_import_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
140 | - add_filter( 'the_content', array( $this, 'the_content' ) ); |
|
140 | + add_filter('the_content', array($this, 'the_content')); |
|
141 | 141 | |
142 | - do_action( 'wogh_boot', $this ); |
|
142 | + do_action('wogh_boot', $this); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | public function edit_post_link($link, $postID, $context) { |
146 | - if ( ! wp_is_post_revision( $postID ) ) { |
|
147 | - $post = new Writing_On_GitHub_Post( $postID, Writing_On_GitHub::$instance->api() ); |
|
148 | - if ( $post->is_on_github() ) { |
|
146 | + if ( ! wp_is_post_revision($postID)) { |
|
147 | + $post = new Writing_On_GitHub_Post($postID, Writing_On_GitHub::$instance->api()); |
|
148 | + if ($post->is_on_github()) { |
|
149 | 149 | return $post->github_edit_url(); |
150 | 150 | } |
151 | 151 | } |
@@ -204,29 +204,29 @@ discard block |
||
204 | 204 | * Init i18n files |
205 | 205 | */ |
206 | 206 | public function l10n() { |
207 | - load_plugin_textdomain( self::$text_domain ); |
|
207 | + load_plugin_textdomain(self::$text_domain); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
211 | 211 | * Sets and kicks off the export cronjob |
212 | 212 | */ |
213 | - public function start_export( $force = false ) { |
|
214 | - $this->start_cron( 'export', $force ); |
|
213 | + public function start_export($force = false) { |
|
214 | + $this->start_cron('export', $force); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Sets and kicks off the import cronjob |
219 | 219 | */ |
220 | 220 | public function start_import() { |
221 | - $this->start_cron( 'import' ); |
|
221 | + $this->start_cron('import'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
225 | 225 | * Enables the admin notice on initial activation |
226 | 226 | */ |
227 | 227 | public function activate() { |
228 | - if ( 'yes' !== get_option( '_wogh_fully_exported' ) ) { |
|
229 | - set_transient( '_wogh_activated', 'yes' ); |
|
228 | + if ('yes' !== get_option('_wogh_fully_exported')) { |
|
229 | + set_transient('_wogh_activated', 'yes'); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -234,18 +234,18 @@ discard block |
||
234 | 234 | * Displays the activation admin notice |
235 | 235 | */ |
236 | 236 | public function activation_notice() { |
237 | - if ( ! get_transient( '_wogh_activated' ) ) { |
|
237 | + if ( ! get_transient('_wogh_activated')) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - delete_transient( '_wogh_activated' ); |
|
241 | + delete_transient('_wogh_activated'); |
|
242 | 242 | |
243 | 243 | ?><div class="updated"> |
244 | 244 | <p> |
245 | 245 | <?php |
246 | 246 | printf( |
247 | - __( 'To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github' ), |
|
248 | - admin_url( 'options-general.php?page=' . static::$text_domain) |
|
247 | + __('To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github'), |
|
248 | + admin_url('options-general.php?page=' . static::$text_domain) |
|
249 | 249 | ); |
250 | 250 | ?> |
251 | 251 | </p> |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return Writing_On_GitHub_CLI |
268 | 268 | */ |
269 | 269 | public function cli() { |
270 | - if ( ! $this->cli ) { |
|
270 | + if ( ! $this->cli) { |
|
271 | 271 | $this->cli = new Writing_On_GitHub_CLI; |
272 | 272 | } |
273 | 273 | |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | * @return Writing_On_GitHub_Request |
281 | 281 | */ |
282 | 282 | public function request() { |
283 | - if ( ! $this->request ) { |
|
284 | - $this->request = new Writing_On_GitHub_Request( $this ); |
|
283 | + if ( ! $this->request) { |
|
284 | + $this->request = new Writing_On_GitHub_Request($this); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | return $this->request; |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | * @return Writing_On_GitHub_Response |
294 | 294 | */ |
295 | 295 | public function response() { |
296 | - if ( ! $this->response ) { |
|
297 | - $this->response = new Writing_On_GitHub_Response( $this ); |
|
296 | + if ( ! $this->response) { |
|
297 | + $this->response = new Writing_On_GitHub_Response($this); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | return $this->response; |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @return Writing_On_GitHub_Api |
307 | 307 | */ |
308 | 308 | public function api() { |
309 | - if ( ! $this->api ) { |
|
310 | - $this->api = new Writing_On_GitHub_Api( $this ); |
|
309 | + if ( ! $this->api) { |
|
310 | + $this->api = new Writing_On_GitHub_Api($this); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return $this->api; |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @return Writing_On_GitHub_Import |
320 | 320 | */ |
321 | 321 | public function import() { |
322 | - if ( ! $this->import ) { |
|
323 | - $this->import = new Writing_On_GitHub_Import( $this ); |
|
322 | + if ( ! $this->import) { |
|
323 | + $this->import = new Writing_On_GitHub_Import($this); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $this->import; |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | * @return Writing_On_GitHub_Export |
333 | 333 | */ |
334 | 334 | public function export() { |
335 | - if ( ! $this->export ) { |
|
336 | - $this->export = new Writing_On_GitHub_Export( $this ); |
|
335 | + if ( ! $this->export) { |
|
336 | + $this->export = new Writing_On_GitHub_Export($this); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | return $this->export; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @return Writing_On_GitHub_Semaphore |
346 | 346 | */ |
347 | 347 | public function semaphore() { |
348 | - if ( ! $this->semaphore ) { |
|
348 | + if ( ! $this->semaphore) { |
|
349 | 349 | $this->semaphore = new Writing_On_GitHub_Semaphore; |
350 | 350 | } |
351 | 351 | |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * @return Writing_On_GitHub_Database |
359 | 359 | */ |
360 | 360 | public function database() { |
361 | - if ( ! $this->database ) { |
|
362 | - $this->database = new Writing_On_GitHub_Database( $this ); |
|
361 | + if ( ! $this->database) { |
|
362 | + $this->database = new Writing_On_GitHub_Database($this); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | return $this->database; |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | * @param mixed $msg |
374 | 374 | * @param string $write |
375 | 375 | */ |
376 | - public static function write_log( $msg, $write = 'line' ) { |
|
377 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
378 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
379 | - WP_CLI::print_value( $msg ); |
|
376 | + public static function write_log($msg, $write = 'line') { |
|
377 | + if (defined('WP_CLI') && WP_CLI) { |
|
378 | + if (is_array($msg) || is_object($msg)) { |
|
379 | + WP_CLI::print_value($msg); |
|
380 | 380 | } else { |
381 | - WP_CLI::$write( $msg ); |
|
381 | + WP_CLI::$write($msg); |
|
382 | 382 | } |
383 | - } elseif ( true === WP_DEBUG ) { |
|
384 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
385 | - error_log( print_r( $msg, true ) ); |
|
383 | + } elseif (true === WP_DEBUG) { |
|
384 | + if (is_array($msg) || is_object($msg)) { |
|
385 | + error_log(print_r($msg, true)); |
|
386 | 386 | } else { |
387 | - error_log( $msg ); |
|
387 | + error_log($msg); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | * @param bool $force |
396 | 396 | * @param string $type |
397 | 397 | */ |
398 | - protected function start_cron( $type, $force = false ) { |
|
399 | - update_option( '_wogh_' . $type . '_started', 'yes' ); |
|
398 | + protected function start_cron($type, $force = false) { |
|
399 | + update_option('_wogh_' . $type . '_started', 'yes'); |
|
400 | 400 | $user_id = get_current_user_id(); |
401 | - wp_schedule_single_event( time(), 'wogh_' . $type . '', array( $user_id, $force ) ); |
|
401 | + wp_schedule_single_event(time(), 'wogh_' . $type . '', array($user_id, $force)); |
|
402 | 402 | spawn_cron(); |
403 | 403 | } |
404 | 404 | } |