@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param Writing_On_GitHub $app Application container. |
| 37 | 37 | */ |
| 38 | - public function __construct( Writing_On_GitHub $app ) { |
|
| 38 | + public function __construct(Writing_On_GitHub $app) { |
|
| 39 | 39 | $this->app = $app; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * @return Writing_On_GitHub_Fetch_Client |
| 46 | 46 | */ |
| 47 | 47 | public function fetch() { |
| 48 | - if ( ! $this->fetch ) { |
|
| 49 | - $this->fetch = new Writing_On_GitHub_Fetch_Client( $this->app ); |
|
| 48 | + if ( ! $this->fetch) { |
|
| 49 | + $this->fetch = new Writing_On_GitHub_Fetch_Client($this->app); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | return $this->fetch; |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | * @return Writing_On_GitHub_Persist_Client |
| 59 | 59 | */ |
| 60 | 60 | public function persist() { |
| 61 | - if ( ! $this->persist ) { |
|
| 62 | - $this->persist = new Writing_On_GitHub_Persist_Client( $this->app ); |
|
| 61 | + if ( ! $this->persist) { |
|
| 62 | + $this->persist = new Writing_On_GitHub_Persist_Client($this->app); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return $this->persist; |
@@ -6,13 +6,13 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class Writing_On_GitHub_File_Info { |
| 8 | 8 | |
| 9 | - public function __construct( stdClass $data ) { |
|
| 9 | + public function __construct(stdClass $data) { |
|
| 10 | 10 | $this->sha = $data->sha; |
| 11 | 11 | $this->path = $data->path; |
| 12 | - $this->status = $data->status; |
|
| 12 | + $this->status = $data->status; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public $sha; |
| 16 | 16 | public $path; |
| 17 | - public $status; // added removed modified |
|
| 17 | + public $status; // added removed modified |
|
| 18 | 18 | } |
@@ -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> |