@@ -85,69 +85,69 @@ |
||
| 85 | 85 | public function setUp() { |
| 86 | 86 | parent::setUp(); |
| 87 | 87 | |
| 88 | - $this->data_dir = dirname( __DIR__ ) . '/data/'; |
|
| 89 | - |
|
| 90 | - $this->app = Mockery::mock( 'Writing_On_GitHub' ); |
|
| 91 | - $this->controller = Mockery::mock( 'Writing_On_GitHub_Controller' ); |
|
| 92 | - $this->request = Mockery::mock( 'Writing_On_GitHub_Request' ); |
|
| 93 | - $this->import = Mockery::mock( 'Writing_On_GitHub_Import' ); |
|
| 94 | - $this->export = Mockery::mock( 'Writing_On_GitHub_Export' ); |
|
| 95 | - $this->response = Mockery::mock( 'Writing_On_GitHub_Response' ); |
|
| 96 | - $this->payload = Mockery::mock( 'Writing_On_GitHub_Payload' ); |
|
| 97 | - $this->api = Mockery::mock( 'Writing_On_GitHub_Api' ); |
|
| 98 | - $this->semaphore = Mockery::mock( 'Writing_On_GitHub_Semaphore' ); |
|
| 99 | - $this->database = Mockery::mock( 'Writing_On_GitHub_Database' ); |
|
| 100 | - $this->post = Mockery::mock( 'Writing_On_GitHub_Post' ); |
|
| 101 | - $this->blob = Mockery::mock( 'Writing_On_GitHub_Blob' ); |
|
| 102 | - $this->api_cache = Mockery::mock( 'Writing_On_GitHub_Cache' ); |
|
| 103 | - $this->fetch = Mockery::mock( 'Writing_On_GitHub_Fetch_Client' ); |
|
| 104 | - $this->persist = Mockery::mock( 'Writing_On_GitHub_Persist_Client' ); |
|
| 88 | + $this->data_dir = dirname(__DIR__) . '/data/'; |
|
| 89 | + |
|
| 90 | + $this->app = Mockery::mock('Writing_On_GitHub'); |
|
| 91 | + $this->controller = Mockery::mock('Writing_On_GitHub_Controller'); |
|
| 92 | + $this->request = Mockery::mock('Writing_On_GitHub_Request'); |
|
| 93 | + $this->import = Mockery::mock('Writing_On_GitHub_Import'); |
|
| 94 | + $this->export = Mockery::mock('Writing_On_GitHub_Export'); |
|
| 95 | + $this->response = Mockery::mock('Writing_On_GitHub_Response'); |
|
| 96 | + $this->payload = Mockery::mock('Writing_On_GitHub_Payload'); |
|
| 97 | + $this->api = Mockery::mock('Writing_On_GitHub_Api'); |
|
| 98 | + $this->semaphore = Mockery::mock('Writing_On_GitHub_Semaphore'); |
|
| 99 | + $this->database = Mockery::mock('Writing_On_GitHub_Database'); |
|
| 100 | + $this->post = Mockery::mock('Writing_On_GitHub_Post'); |
|
| 101 | + $this->blob = Mockery::mock('Writing_On_GitHub_Blob'); |
|
| 102 | + $this->api_cache = Mockery::mock('Writing_On_GitHub_Cache'); |
|
| 103 | + $this->fetch = Mockery::mock('Writing_On_GitHub_Fetch_Client'); |
|
| 104 | + $this->persist = Mockery::mock('Writing_On_GitHub_Persist_Client'); |
|
| 105 | 105 | |
| 106 | 106 | Writing_On_GitHub::$instance = $this->app; |
| 107 | 107 | |
| 108 | 108 | $this->app |
| 109 | - ->shouldReceive( 'request' ) |
|
| 110 | - ->andReturn( $this->request ) |
|
| 109 | + ->shouldReceive('request') |
|
| 110 | + ->andReturn($this->request) |
|
| 111 | 111 | ->byDefault(); |
| 112 | 112 | $this->app |
| 113 | - ->shouldReceive( 'import' ) |
|
| 114 | - ->andReturn( $this->import ) |
|
| 113 | + ->shouldReceive('import') |
|
| 114 | + ->andReturn($this->import) |
|
| 115 | 115 | ->byDefault(); |
| 116 | 116 | $this->app |
| 117 | - ->shouldReceive( 'export' ) |
|
| 118 | - ->andReturn( $this->export ) |
|
| 117 | + ->shouldReceive('export') |
|
| 118 | + ->andReturn($this->export) |
|
| 119 | 119 | ->byDefault(); |
| 120 | 120 | $this->app |
| 121 | - ->shouldReceive( 'response' ) |
|
| 122 | - ->andReturn( $this->response ) |
|
| 121 | + ->shouldReceive('response') |
|
| 122 | + ->andReturn($this->response) |
|
| 123 | 123 | ->byDefault(); |
| 124 | 124 | $this->app |
| 125 | - ->shouldReceive( 'api' ) |
|
| 126 | - ->andReturn( $this->api ) |
|
| 125 | + ->shouldReceive('api') |
|
| 126 | + ->andReturn($this->api) |
|
| 127 | 127 | ->byDefault(); |
| 128 | 128 | $this->app |
| 129 | - ->shouldReceive( 'semaphore' ) |
|
| 130 | - ->andReturn( $this->semaphore ) |
|
| 129 | + ->shouldReceive('semaphore') |
|
| 130 | + ->andReturn($this->semaphore) |
|
| 131 | 131 | ->byDefault(); |
| 132 | 132 | $this->app |
| 133 | - ->shouldReceive( 'database' ) |
|
| 134 | - ->andReturn( $this->database ) |
|
| 133 | + ->shouldReceive('database') |
|
| 134 | + ->andReturn($this->database) |
|
| 135 | 135 | ->byDefault(); |
| 136 | 136 | $this->app |
| 137 | - ->shouldReceive( 'blob' ) |
|
| 138 | - ->andReturn( $this->blob ) |
|
| 137 | + ->shouldReceive('blob') |
|
| 138 | + ->andReturn($this->blob) |
|
| 139 | 139 | ->byDefault(); |
| 140 | 140 | $this->app |
| 141 | - ->shouldReceive( 'cache' ) |
|
| 142 | - ->andReturn( $this->api_cache ) |
|
| 141 | + ->shouldReceive('cache') |
|
| 142 | + ->andReturn($this->api_cache) |
|
| 143 | 143 | ->byDefault(); |
| 144 | 144 | $this->api |
| 145 | - ->shouldReceive( 'fetch' ) |
|
| 146 | - ->andReturn( $this->fetch ) |
|
| 145 | + ->shouldReceive('fetch') |
|
| 146 | + ->andReturn($this->fetch) |
|
| 147 | 147 | ->byDefault(); |
| 148 | 148 | $this->api |
| 149 | - ->shouldReceive( 'persist' ) |
|
| 150 | - ->andReturn( $this->persist ) |
|
| 149 | + ->shouldReceive('persist') |
|
| 150 | + ->andReturn($this->persist) |
|
| 151 | 151 | ->byDefault(); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | parent::setUp(); |
| 32 | 32 | |
| 33 | 33 | WP_HTTP_TestCase::init(); |
| 34 | - update_option( 'wogh_repository', self::REPO_OPTION_VALUE ); |
|
| 35 | - update_option( 'wogh_oauth_token', self::TOKEN_OPTION_VALUE ); |
|
| 36 | - update_option( 'wogh_host', self::HOST_OPTION_VALUE ); |
|
| 37 | - $this->http_responder = array( $this, 'mock_github_api' ); |
|
| 34 | + update_option('wogh_repository', self::REPO_OPTION_VALUE); |
|
| 35 | + update_option('wogh_oauth_token', self::TOKEN_OPTION_VALUE); |
|
| 36 | + update_option('wogh_host', self::HOST_OPTION_VALUE); |
|
| 37 | + $this->http_responder = array($this, 'mock_github_api'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,45 +43,45 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return void|string |
| 45 | 45 | */ |
| 46 | - public function mock_github_api( $request, $url ) { |
|
| 47 | - $host_length = strlen( self::HOST_OPTION_VALUE ); |
|
| 46 | + public function mock_github_api($request, $url) { |
|
| 47 | + $host_length = strlen(self::HOST_OPTION_VALUE); |
|
| 48 | 48 | |
| 49 | - if ( self::HOST_OPTION_VALUE !== substr( $url, 0, $host_length ) ) { |
|
| 50 | - $this->assertTrue( false, 'Called wrong host.' ); |
|
| 49 | + if (self::HOST_OPTION_VALUE !== substr($url, 0, $host_length)) { |
|
| 50 | + $this->assertTrue(false, 'Called wrong host.'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if ( |
| 54 | - ! isset( $request['headers']['Authorization'] ) || |
|
| 54 | + ! isset($request['headers']['Authorization']) || |
|
| 55 | 55 | 'token ' . self::TOKEN_OPTION_VALUE !== $request['headers']['Authorization'] |
| 56 | 56 | ) { |
| 57 | - $this->assertTrue( false, 'Missing authorization key.' ); |
|
| 57 | + $this->assertTrue(false, 'Missing authorization key.'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $url = explode( '/', substr( $url, $host_length + 1 ) ); |
|
| 60 | + $url = explode('/', substr($url, $host_length + 1)); |
|
| 61 | 61 | |
| 62 | - if ( 'repos' !== $url[0] ) { |
|
| 63 | - $this->assertTrue( false, 'Called wrong endpoint.' ); |
|
| 62 | + if ('repos' !== $url[0]) { |
|
| 63 | + $this->assertTrue(false, 'Called wrong endpoint.'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $repo = $url[1] . '/' . $url[2]; |
| 67 | 67 | |
| 68 | - if ( self::REPO_OPTION_VALUE !== $repo ) { |
|
| 69 | - $this->assertTrue( false, 'Called wrong repo.' ); |
|
| 68 | + if (self::REPO_OPTION_VALUE !== $repo) { |
|
| 69 | + $this->assertTrue(false, 'Called wrong repo.'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $parts = array_slice( $url, 4 ); |
|
| 73 | - array_unshift( $parts, strtolower( $request['method'] ) ); |
|
| 74 | - $endpoint = implode( '_', $parts ); |
|
| 75 | - $endpoint = str_replace( '?recursive=1', '', $endpoint ); |
|
| 76 | - $this->assertTrue( call_user_func( static::$validations[ $endpoint ], $request ), 'Request did not validate.' ); |
|
| 72 | + $parts = array_slice($url, 4); |
|
| 73 | + array_unshift($parts, strtolower($request['method'])); |
|
| 74 | + $endpoint = implode('_', $parts); |
|
| 75 | + $endpoint = str_replace('?recursive=1', '', $endpoint); |
|
| 76 | + $this->assertTrue(call_user_func(static::$validations[$endpoint], $request), 'Request did not validate.'); |
|
| 77 | 77 | |
| 78 | - return static::$responses[ $endpoint ]; |
|
| 78 | + return static::$responses[$endpoint]; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - protected function set_get_refs_heads_master( $succeed ) { |
|
| 81 | + protected function set_get_refs_heads_master($succeed) { |
|
| 82 | 82 | $this->set_endpoint( |
| 83 | - function ( $request ) { |
|
| 84 | - if ( '[]' === $request['body'] ) { |
|
| 83 | + function($request) { |
|
| 84 | + if ('[]' === $request['body']) { |
|
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | ); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - protected function set_get_commits( $succeed ) { |
|
| 93 | + protected function set_get_commits($succeed) { |
|
| 94 | 94 | $this->set_endpoint( |
| 95 | - function ( $request ) { |
|
| 96 | - if ( '[]' === $request['body'] ) { |
|
| 95 | + function($request) { |
|
| 96 | + if ('[]' === $request['body']) { |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - protected function set_get_trees( $succeed, $sha = '' ) { |
|
| 105 | + protected function set_get_trees($succeed, $sha = '') { |
|
| 106 | 106 | $this->set_endpoint( |
| 107 | - function ( $request ) { |
|
| 108 | - if ( '[]' === $request['body'] ) { |
|
| 107 | + function($request) { |
|
| 108 | + if ('[]' === $request['body']) { |
|
| 109 | 109 | return false; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -115,17 +115,17 @@ discard block |
||
| 115 | 115 | ); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - protected function set_get_blobs( $succeed ) { |
|
| 118 | + protected function set_get_blobs($succeed) { |
|
| 119 | 119 | $shas = array( |
| 120 | 120 | '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25', |
| 121 | 121 | '8d9b2e6fd93761211dc03abd71f4a9189d680fd0', |
| 122 | 122 | '2d73165945b0ccbe4932f1363457986b0ed49f19', |
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | - foreach ( $shas as $sha ) { |
|
| 125 | + foreach ($shas as $sha) { |
|
| 126 | 126 | $this->set_endpoint( |
| 127 | - function ( $request ) { |
|
| 128 | - if ( '[]' === $request['body'] ) { |
|
| 127 | + function($request) { |
|
| 128 | + if ('[]' === $request['body']) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -135,26 +135,26 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - protected function set_post_trees( $succeed ) { |
|
| 138 | + protected function set_post_trees($succeed) { |
|
| 139 | 139 | $this->set_endpoint( |
| 140 | - function ( $request ) { |
|
| 141 | - $body = json_decode( $request['body'], true ); |
|
| 140 | + function($request) { |
|
| 141 | + $body = json_decode($request['body'], true); |
|
| 142 | 142 | |
| 143 | - if ( ! isset( $body['tree'] ) ) { |
|
| 143 | + if ( ! isset($body['tree'])) { |
|
| 144 | 144 | return false; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if ( 1 !== count( $body['tree'] ) ) { |
|
| 147 | + if (1 !== count($body['tree'])) { |
|
| 148 | 148 | return false; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $blob = reset( $body['tree'] ); |
|
| 151 | + $blob = reset($body['tree']); |
|
| 152 | 152 | |
| 153 | 153 | if ( |
| 154 | - ! isset( $blob['path'] ) || |
|
| 155 | - ! isset( $blob['type'] ) || |
|
| 156 | - ! isset( $blob['content'] ) || |
|
| 157 | - ! isset( $blob['mode'] ) |
|
| 154 | + ! isset($blob['path']) || |
|
| 155 | + ! isset($blob['type']) || |
|
| 156 | + ! isset($blob['content']) || |
|
| 157 | + ! isset($blob['mode']) |
|
| 158 | 158 | ) { |
| 159 | 159 | return false; |
| 160 | 160 | } |
@@ -166,25 +166,25 @@ discard block |
||
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - protected function set_post_commits( $succeed, $anonymous = true ) { |
|
| 169 | + protected function set_post_commits($succeed, $anonymous = true) { |
|
| 170 | 170 | $this->set_endpoint( |
| 171 | - function ( $request ) use ( $anonymous ) { |
|
| 172 | - $body = json_decode( $request['body'], true ); |
|
| 171 | + function($request) use ($anonymous) { |
|
| 172 | + $body = json_decode($request['body'], true); |
|
| 173 | 173 | |
| 174 | 174 | if ( |
| 175 | - ! isset( $body['tree'] ) || |
|
| 176 | - ! isset( $body['message'] ) || |
|
| 177 | - ! isset( $body['parents'] ) || |
|
| 178 | - ! isset( $body['author'] ) |
|
| 175 | + ! isset($body['tree']) || |
|
| 176 | + ! isset($body['message']) || |
|
| 177 | + ! isset($body['parents']) || |
|
| 178 | + ! isset($body['author']) |
|
| 179 | 179 | ) { |
| 180 | 180 | return false; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( 1 !== count( $body['parents'] ) ) { |
|
| 183 | + if (1 !== count($body['parents'])) { |
|
| 184 | 184 | return false; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( ! $anonymous ) { |
|
| 187 | + if ( ! $anonymous) { |
|
| 188 | 188 | if ( |
| 189 | 189 | 'James DiGioia' !== $body['author']['name'] || |
| 190 | 190 | '[email protected]' !== $body['author']['email'] |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | ); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - protected function set_patch_refs_heads_master( $succeed ) { |
|
| 210 | + protected function set_patch_refs_heads_master($succeed) { |
|
| 211 | 211 | $this->set_endpoint( |
| 212 | - function ( $request ) { |
|
| 213 | - $body = json_decode( $request['body'], true ); |
|
| 212 | + function($request) { |
|
| 213 | + $body = json_decode($request['body'], true); |
|
| 214 | 214 | |
| 215 | - if ( ! isset( $body['sha'] ) ) { |
|
| 215 | + if ( ! isset($body['sha'])) { |
|
| 216 | 216 | return false; |
| 217 | 217 | } |
| 218 | 218 | |
@@ -223,18 +223,18 @@ discard block |
||
| 223 | 223 | ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - private function set_endpoint( $validation, $status, $succeed, $sha = '' ) { |
|
| 227 | - list( , $caller ) = debug_backtrace( false ); |
|
| 228 | - $endpoint = substr( $caller['function'], 4 ) . ( $sha ? "_$sha" : '' ); |
|
| 226 | + private function set_endpoint($validation, $status, $succeed, $sha = '') { |
|
| 227 | + list(, $caller) = debug_backtrace(false); |
|
| 228 | + $endpoint = substr($caller['function'], 4) . ($sha ? "_$sha" : ''); |
|
| 229 | 229 | |
| 230 | - static::$validations[ $endpoint ] = $validation; |
|
| 230 | + static::$validations[$endpoint] = $validation; |
|
| 231 | 231 | |
| 232 | - static::$responses[ $endpoint ] = array( |
|
| 232 | + static::$responses[$endpoint] = array( |
|
| 233 | 233 | 'headers' => array( |
| 234 | 234 | 'status' => $status, |
| 235 | 235 | ), |
| 236 | 236 | 'body' => file_get_contents( |
| 237 | - $this->data_dir . $endpoint . '_' . ( $succeed ? 'succeed' : 'fail' ) . '.json' |
|
| 237 | + $this->data_dir . $endpoint . '_' . ($succeed ? 'succeed' : 'fail') . '.json' |
|
| 238 | 238 | ), |
| 239 | 239 | ); |
| 240 | 240 | } |
@@ -6,24 +6,24 @@ |
||
| 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' => 'import' ) ) ); ?>"> |
|
| 26 | - <?php esc_html_e( 'Import from GitHub', 'writing-on-github' ); ?> |
|
| 25 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'import'))); ?>"> |
|
| 26 | + <?php esc_html_e('Import from GitHub', 'writing-on-github'); ?> |
|
| 27 | 27 | </a> |
| 28 | 28 | </td> |
| 29 | 29 | </table> |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param stdClass $data Raw blob data. |
| 51 | 51 | */ |
| 52 | - public function __construct( stdClass $data ) { |
|
| 53 | - $this->interpret_data( $data ); |
|
| 52 | + public function __construct(stdClass $data) { |
|
| 53 | + $this->interpret_data($data); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function id() { |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return $this |
| 80 | 80 | */ |
| 81 | - public function set_content( $content, $base64 = false ) { |
|
| 82 | - if ( $base64 ) { |
|
| 83 | - $content = base64_decode( $content ); |
|
| 81 | + public function set_content($content, $base64 = false) { |
|
| 82 | + if ($base64) { |
|
| 83 | + $content = base64_decode($content); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $this->frontmatter = '---' === substr( $this->content = $content, 0, 3 ) ? true : false; |
|
| 86 | + $this->frontmatter = '---' === substr($this->content = $content, 0, 3) ? true : false; |
|
| 87 | 87 | |
| 88 | 88 | return $this; |
| 89 | 89 | } |
@@ -122,20 +122,20 @@ discard block |
||
| 122 | 122 | public function content_import() { |
| 123 | 123 | $content = $this->content(); |
| 124 | 124 | |
| 125 | - if ( $this->has_frontmatter() ) { |
|
| 125 | + if ($this->has_frontmatter()) { |
|
| 126 | 126 | // Break out content. |
| 127 | - preg_match( '/(^---(.*?)---$)?(.*)/ms', $content, $matches ); |
|
| 128 | - $content = array_pop( $matches ); |
|
| 127 | + preg_match('/(^---(.*?)---$)?(.*)/ms', $content, $matches); |
|
| 128 | + $content = array_pop($matches); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( function_exists( 'wpmarkdown_markdown_to_html' ) ) { |
|
| 132 | - $content = wpmarkdown_markdown_to_html( $content ); |
|
| 131 | + if (function_exists('wpmarkdown_markdown_to_html')) { |
|
| 132 | + $content = wpmarkdown_markdown_to_html($content); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * Filters the content for import. |
| 137 | 137 | */ |
| 138 | - return apply_filters( 'wogh_content_import', trim( $content ) ); |
|
| 138 | + return apply_filters('wogh_content_import', trim($content)); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -146,14 +146,14 @@ discard block |
||
| 146 | 146 | public function meta() { |
| 147 | 147 | $meta = array(); |
| 148 | 148 | |
| 149 | - if ( $this->has_frontmatter() ) { |
|
| 149 | + if ($this->has_frontmatter()) { |
|
| 150 | 150 | // Break out meta, if present. |
| 151 | - preg_match( '/(^---(.*?)---$)?(.*)/ms', $this->content(), $matches ); |
|
| 152 | - array_pop( $matches ); |
|
| 151 | + preg_match('/(^---(.*?)---$)?(.*)/ms', $this->content(), $matches); |
|
| 152 | + array_pop($matches); |
|
| 153 | 153 | |
| 154 | - $meta = spyc_load( $matches[2] ); |
|
| 155 | - if ( isset( $meta['permalink'] ) ) { |
|
| 156 | - $meta['permalink'] = str_replace( home_url(), '', $meta['permalink'] ); |
|
| 154 | + $meta = spyc_load($matches[2]); |
|
| 155 | + if (isset($meta['permalink'])) { |
|
| 156 | + $meta['permalink'] = str_replace(home_url(), '', $meta['permalink']); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | // $data->type = 'blob'; |
| 196 | 196 | |
| 197 | 197 | $data->path = $this->path(); |
| 198 | - $data->content = base64_encode( $this->content() ); |
|
| 198 | + $data->content = base64_encode($this->content()); |
|
| 199 | 199 | $data->sha = $this->sha; |
| 200 | 200 | |
| 201 | 201 | return $data; |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | /** |
| 205 | 205 | * Interprets the blob's data into properties. |
| 206 | 206 | */ |
| 207 | - protected function interpret_data( $data ) { |
|
| 208 | - $this->sha = isset( $data->sha ) ? $data->sha : ''; |
|
| 209 | - $this->path = isset( $data->path ) ? $data->path : ''; |
|
| 207 | + protected function interpret_data($data) { |
|
| 208 | + $this->sha = isset($data->sha) ? $data->sha : ''; |
|
| 209 | + $this->path = isset($data->path) ? $data->path : ''; |
|
| 210 | 210 | |
| 211 | 211 | $this->set_content( |
| 212 | - isset( $data->content ) ? trim( $data->content ) : '', |
|
| 213 | - isset( $data->encoding ) && 'base64' === $data->encoding ? true : false |
|
| 212 | + isset($data->content) ? trim($data->content) : '', |
|
| 213 | + isset($data->encoding) && 'base64' === $data->encoding ? true : false |
|
| 214 | 214 | ); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -13,16 +13,16 @@ discard block |
||
| 13 | 13 | * Hook into GitHub API |
| 14 | 14 | */ |
| 15 | 15 | public function __construct() { |
| 16 | - add_action( 'admin_menu', array( $this, 'add_admin_menu' ) ); |
|
| 17 | - add_action( 'admin_init', array( $this, 'register_settings' ) ); |
|
| 18 | - add_action( 'current_screen', array( $this, 'trigger_cron' ) ); |
|
| 16 | + add_action('admin_menu', array($this, 'add_admin_menu')); |
|
| 17 | + add_action('admin_init', array($this, 'register_settings')); |
|
| 18 | + add_action('current_screen', array($this, 'trigger_cron')); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Callback to render the settings page view |
| 23 | 23 | */ |
| 24 | 24 | public function settings_page() { |
| 25 | - include dirname( dirname( __FILE__ ) ) . '/views/options.php'; |
|
| 25 | + include dirname(dirname(__FILE__)) . '/views/options.php'; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -32,63 +32,63 @@ discard block |
||
| 32 | 32 | add_settings_section( |
| 33 | 33 | 'general', |
| 34 | 34 | 'General Settings', |
| 35 | - array( $this, 'section_callback' ), |
|
| 35 | + array($this, 'section_callback'), |
|
| 36 | 36 | Writing_On_GitHub::$text_domain |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_host' ); |
|
| 40 | - add_settings_field( 'wogh_host', __( 'GitHub hostname', 'writing-on-github' ), array( $this, 'field_callback' ), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 39 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_host'); |
|
| 40 | + add_settings_field('wogh_host', __('GitHub hostname', 'writing-on-github'), array($this, 'field_callback'), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 41 | 41 | 'default' => 'https://api.github.com', |
| 42 | 42 | 'name' => 'wogh_host', |
| 43 | - 'help_text' => __( 'The GitHub host to use. This only needs to be changed to support a GitHub Enterprise installation.', 'writing-on-github' ), |
|
| 43 | + 'help_text' => __('The GitHub host to use. This only needs to be changed to support a GitHub Enterprise installation.', 'writing-on-github'), |
|
| 44 | 44 | ) |
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_repository' ); |
|
| 48 | - add_settings_field( 'wogh_repository', __( 'Repository', 'writing-on-github' ), array( $this, 'field_callback' ), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 47 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_repository'); |
|
| 48 | + add_settings_field('wogh_repository', __('Repository', 'writing-on-github'), array($this, 'field_callback'), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 49 | 49 | 'default' => '', |
| 50 | 50 | 'name' => 'wogh_repository', |
| 51 | - 'help_text' => __( 'The GitHub repository to commit to, with owner (<code>[OWNER]/[REPOSITORY]</code>), e.g., <code>github/hubot.github.com</code>. The repository should contain an initial commit, which is satisfied by including a README when you create the repository on GitHub.', 'writing-on-github' ), |
|
| 51 | + 'help_text' => __('The GitHub repository to commit to, with owner (<code>[OWNER]/[REPOSITORY]</code>), e.g., <code>github/hubot.github.com</code>. The repository should contain an initial commit, which is satisfied by including a README when you create the repository on GitHub.', 'writing-on-github'), |
|
| 52 | 52 | ) |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_branch' ); |
|
| 56 | - add_settings_field( 'wogh_branch', __( 'Branch', 'writing-on-github' ), array( $this, 'field_callback' ), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 55 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_branch'); |
|
| 56 | + add_settings_field('wogh_branch', __('Branch', 'writing-on-github'), array($this, 'field_callback'), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 57 | 57 | 'default' => 'master', |
| 58 | 58 | 'name' => 'wogh_branch', |
| 59 | - 'help_text' => __( 'The GitHub branch to commit to, default is master.', 'writing-on-github' ), |
|
| 59 | + 'help_text' => __('The GitHub branch to commit to, default is master.', 'writing-on-github'), |
|
| 60 | 60 | ) |
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_oauth_token' ); |
|
| 64 | - add_settings_field( 'wogh_oauth_token', __( 'Oauth Token', 'writing-on-github' ), array( $this, 'field_callback' ), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 63 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_oauth_token'); |
|
| 64 | + add_settings_field('wogh_oauth_token', __('Oauth Token', 'writing-on-github'), array($this, 'field_callback'), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 65 | 65 | 'default' => '', |
| 66 | 66 | 'name' => 'wogh_oauth_token', |
| 67 | - 'help_text' => __( "A <a href='https://github.com/settings/tokens/new'>personal oauth token</a> with <code>public_repo</code> scope.", 'writing-on-github' ), |
|
| 67 | + 'help_text' => __("A <a href='https://github.com/settings/tokens/new'>personal oauth token</a> with <code>public_repo</code> scope.", 'writing-on-github'), |
|
| 68 | 68 | ) |
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_secret' ); |
|
| 72 | - add_settings_field( 'wogh_secret', __( 'Webhook Secret', 'writing-on-github' ), array( $this, 'field_callback' ), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 71 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_secret'); |
|
| 72 | + add_settings_field('wogh_secret', __('Webhook Secret', 'writing-on-github'), array($this, 'field_callback'), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 73 | 73 | 'default' => '', |
| 74 | 74 | 'name' => 'wogh_secret', |
| 75 | - 'help_text' => __( "The webhook's secret phrase. This should be password strength, as it is used to verify the webhook's payload.", 'writing-on-github' ), |
|
| 75 | + 'help_text' => __("The webhook's secret phrase. This should be password strength, as it is used to verify the webhook's payload.", 'writing-on-github'), |
|
| 76 | 76 | ) |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_default_user' ); |
|
| 80 | - add_settings_field( 'wogh_default_user', __( 'Default Import User', 'writing-on-github' ), array( &$this, 'user_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 79 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_default_user'); |
|
| 80 | + add_settings_field('wogh_default_user', __('Default Import User', 'writing-on-github'), array(&$this, 'user_field_callback'), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 81 | 81 | 'default' => '', |
| 82 | 82 | 'name' => 'wogh_default_user', |
| 83 | - 'help_text' => __( 'The fallback user for import, in case Writing On GitHub cannot find the committer in the database.', 'writing-on-github' ), |
|
| 83 | + 'help_text' => __('The fallback user for import, in case Writing On GitHub cannot find the committer in the database.', 'writing-on-github'), |
|
| 84 | 84 | ) |
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_metas' ); |
|
| 88 | - add_settings_field( 'wogh_ignore_metas', __( 'Ignore post metas', 'writing-on-github' ), array( &$this, 'textarea_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 87 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_ignore_metas'); |
|
| 88 | + add_settings_field('wogh_ignore_metas', __('Ignore post metas', 'writing-on-github'), array(&$this, 'textarea_field_callback'), Writing_On_GitHub::$text_domain, 'general', array( |
|
| 89 | 89 | 'default' => '', |
| 90 | 90 | 'name' => 'wogh_ignore_metas', |
| 91 | - 'help_text' => __( 'These meta keys will be ignored and cannot be imported and exported. One meta key per line.', 'writing-on-github' ), |
|
| 91 | + 'help_text' => __('These meta keys will be ignored and cannot be imported and exported. One meta key per line.', 'writing-on-github'), |
|
| 92 | 92 | ) |
| 93 | 93 | ); |
| 94 | 94 | } |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @param array $args Field arguments. |
| 100 | 100 | */ |
| 101 | - public function field_callback( $args ) { |
|
| 102 | - include dirname( dirname( __FILE__ ) ) . '/views/setting-field.php'; |
|
| 101 | + public function field_callback($args) { |
|
| 102 | + include dirname(dirname(__FILE__)) . '/views/setting-field.php'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @param array $args Field arguments. |
| 109 | 109 | */ |
| 110 | - public function user_field_callback( $args ) { |
|
| 111 | - include dirname( dirname( __FILE__ ) ) . '/views/user-setting-field.php'; |
|
| 110 | + public function user_field_callback($args) { |
|
| 111 | + include dirname(dirname(__FILE__)) . '/views/user-setting-field.php'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -116,58 +116,58 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @param array $args Field arguments. |
| 118 | 118 | */ |
| 119 | - public function textarea_field_callback( $args ) { |
|
| 120 | - include dirname( dirname( __FILE__ ) ) . '/views/textarea-setting-field.php'; |
|
| 119 | + public function textarea_field_callback($args) { |
|
| 120 | + include dirname(dirname(__FILE__)) . '/views/textarea-setting-field.php'; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * Displays settings messages from background processes |
| 125 | 125 | */ |
| 126 | 126 | public function section_callback() { |
| 127 | - if ( get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain ) { |
|
| 127 | + if (get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain) { |
|
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( 'yes' === get_option( '_wogh_export_started' ) ) { ?> |
|
| 131 | + if ('yes' === get_option('_wogh_export_started')) { ?> |
|
| 132 | 132 | <div class="updated"> |
| 133 | - <p><?php esc_html_e( 'Export to GitHub started.', 'writing-on-github' ); ?></p> |
|
| 133 | + <p><?php esc_html_e('Export to GitHub started.', 'writing-on-github'); ?></p> |
|
| 134 | 134 | </div><?php |
| 135 | - delete_option( '_wogh_export_started' ); |
|
| 135 | + delete_option('_wogh_export_started'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if ( $message = get_option( '_wogh_export_error' ) ) { ?> |
|
| 138 | + if ($message = get_option('_wogh_export_error')) { ?> |
|
| 139 | 139 | <div class="error"> |
| 140 | - <p><?php esc_html_e( 'Export to GitHub failed with error:', 'writing-on-github' ); ?> <?php echo esc_html( $message );?></p> |
|
| 140 | + <p><?php esc_html_e('Export to GitHub failed with error:', 'writing-on-github'); ?> <?php echo esc_html($message); ?></p> |
|
| 141 | 141 | </div><?php |
| 142 | - delete_option( '_wogh_export_error' ); |
|
| 142 | + delete_option('_wogh_export_error'); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if ( 'yes' === get_option( '_wogh_export_complete' ) ) { ?> |
|
| 145 | + if ('yes' === get_option('_wogh_export_complete')) { ?> |
|
| 146 | 146 | <div class="updated"> |
| 147 | - <p><?php esc_html_e( 'Export to GitHub completed successfully.', 'writing-on-github' );?></p> |
|
| 147 | + <p><?php esc_html_e('Export to GitHub completed successfully.', 'writing-on-github'); ?></p> |
|
| 148 | 148 | </div><?php |
| 149 | - delete_option( '_wogh_export_complete' ); |
|
| 149 | + delete_option('_wogh_export_complete'); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if ( 'yes' === get_option( '_wogh_import_started' ) ) { ?> |
|
| 152 | + if ('yes' === get_option('_wogh_import_started')) { ?> |
|
| 153 | 153 | <div class="updated"> |
| 154 | - <p><?php esc_html_e( 'Import from GitHub started.', 'writing-on-github' ); ?></p> |
|
| 154 | + <p><?php esc_html_e('Import from GitHub started.', 'writing-on-github'); ?></p> |
|
| 155 | 155 | </div><?php |
| 156 | - delete_option( '_wogh_import_started' ); |
|
| 156 | + delete_option('_wogh_import_started'); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( $message = get_option( '_wogh_import_error' ) ) { ?> |
|
| 159 | + if ($message = get_option('_wogh_import_error')) { ?> |
|
| 160 | 160 | <div class="error"> |
| 161 | - <p><?php esc_html_e( 'Import from GitHub failed with error:', 'writing-on-github' ); ?> <?php echo esc_html( $message );?></p> |
|
| 161 | + <p><?php esc_html_e('Import from GitHub failed with error:', 'writing-on-github'); ?> <?php echo esc_html($message); ?></p> |
|
| 162 | 162 | </div><?php |
| 163 | - delete_option( '_wogh_import_error' ); |
|
| 163 | + delete_option('_wogh_import_error'); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( 'yes' === get_option( '_wogh_import_complete' ) ) { ?> |
|
| 166 | + if ('yes' === get_option('_wogh_import_complete')) { ?> |
|
| 167 | 167 | <div class="updated"> |
| 168 | - <p><?php esc_html_e( 'Import from GitHub completed successfully.', 'writing-on-github' );?></p> |
|
| 168 | + <p><?php esc_html_e('Import from GitHub completed successfully.', 'writing-on-github'); ?></p> |
|
| 169 | 169 | </div><?php |
| 170 | - delete_option( '_wogh_import_complete' ); |
|
| 170 | + delete_option('_wogh_import_complete'); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function add_admin_menu() { |
| 178 | 178 | add_options_page( |
| 179 | - __( 'Writing On GitHub', 'writing-on-github' ), |
|
| 180 | - __( 'Writing On GitHub', 'writing-on-github' ), |
|
| 179 | + __('Writing On GitHub', 'writing-on-github'), |
|
| 180 | + __('Writing On GitHub', 'writing-on-github'), |
|
| 181 | 181 | 'manage_options', |
| 182 | 182 | Writing_On_GitHub::$text_domain, |
| 183 | - array( $this, 'settings_page' ) |
|
| 183 | + array($this, 'settings_page') |
|
| 184 | 184 | ); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -188,27 +188,27 @@ discard block |
||
| 188 | 188 | * Admin callback to trigger import/export because WordPress admin routing lol |
| 189 | 189 | */ |
| 190 | 190 | public function trigger_cron() { |
| 191 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 191 | + if ( ! current_user_can('manage_options')) { |
|
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if ( get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain ) { |
|
| 195 | + if (get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain) { |
|
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if ( ! isset( $_GET['action'] ) ) { |
|
| 199 | + if ( ! isset($_GET['action'])) { |
|
| 200 | 200 | return; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( 'export' === $_GET['action'] ) { |
|
| 203 | + if ('export' === $_GET['action']) { |
|
| 204 | 204 | Writing_On_GitHub::$instance->start_export(); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( 'import' === $_GET['action'] ) { |
|
| 207 | + if ('import' === $_GET['action']) { |
|
| 208 | 208 | Writing_On_GitHub::$instance->start_import(); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - wp_redirect( admin_url( 'options-general.php?page=writing-on-github' ) ); |
|
| 211 | + wp_redirect(admin_url('options-general.php?page=writing-on-github')); |
|
| 212 | 212 | die; |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -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,32 +359,32 @@ discard block |
||
| 359 | 359 | public function meta() { |
| 360 | 360 | $meta = array( |
| 361 | 361 | 'ID' => $this->id, |
| 362 | - 'post_title' => get_the_title( $this->post ), |
|
| 363 | - 'author' => ( $author = get_userdata( $this->post->post_author ) ) ? $author->display_name : '', |
|
| 362 | + 'post_title' => get_the_title($this->post), |
|
| 363 | + 'author' => ($author = get_userdata($this->post->post_author)) ? $author->display_name : '', |
|
| 364 | 364 | 'post_date' => $this->post->post_date, |
| 365 | 365 | 'post_excerpt' => $this->post->post_excerpt, |
| 366 | - 'layout' => get_post_type( $this->post ), |
|
| 367 | - 'permalink' => get_permalink( $this->post ), |
|
| 366 | + 'layout' => get_post_type($this->post), |
|
| 367 | + 'permalink' => get_permalink($this->post), |
|
| 368 | 368 | 'published' => 'publish' === $this->status() ? true : false, |
| 369 | - 'tags' => wp_get_post_tags( $this->id, array( 'fields' => 'names' ) ), |
|
| 370 | - 'categories' => wp_get_post_categories( $this->id, array( 'fields' => 'names' ) ) |
|
| 369 | + 'tags' => wp_get_post_tags($this->id, array('fields' => 'names')), |
|
| 370 | + 'categories' => wp_get_post_categories($this->id, array('fields' => 'names')) |
|
| 371 | 371 | ); |
| 372 | - if ( !empty($this->post->post_name) ) { |
|
| 372 | + if ( ! empty($this->post->post_name)) { |
|
| 373 | 373 | $meta['post_name'] = $this->post->post_name; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | //convert traditional post_meta values, hide hidden values, skip already populated values |
| 377 | - foreach ( get_post_custom( $this->id ) as $key => $value ) { |
|
| 377 | + foreach (get_post_custom($this->id) as $key => $value) { |
|
| 378 | 378 | |
| 379 | - if ( '_' === substr( $key, 0, 1 ) || isset( $meta[ $key ] ) ) { |
|
| 379 | + if ('_' === substr($key, 0, 1) || isset($meta[$key])) { |
|
| 380 | 380 | continue; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - $meta[ $key ] = $value; |
|
| 383 | + $meta[$key] = $value; |
|
| 384 | 384 | |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - return apply_filters( 'wogh_post_meta', $meta, $this ); |
|
| 387 | + return apply_filters('wogh_post_meta', $meta, $this); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * |
| 402 | 402 | * @param array $meta |
| 403 | 403 | */ |
| 404 | - public function set_meta( $meta ) { |
|
| 404 | + public function set_meta($meta) { |
|
| 405 | 405 | $this->meta = $meta; |
| 406 | 406 | } |
| 407 | 407 | |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | * |
| 431 | 431 | * @return $this |
| 432 | 432 | */ |
| 433 | - public function set_post( WP_Post $post ) { |
|
| 433 | + public function set_post(WP_Post $post) { |
|
| 434 | 434 | $this->post = $post; |
| 435 | 435 | $this->id = $post->ID; |
| 436 | 436 | |
@@ -449,6 +449,6 @@ discard block |
||
| 449 | 449 | $data->content = $this->github_content(); |
| 450 | 450 | $data->sha = $this->sha(); |
| 451 | 451 | |
| 452 | - return new Writing_On_GitHub_Blob( $data ); |
|
| 452 | + return new Writing_On_GitHub_Blob($data); |
|
| 453 | 453 | } |
| 454 | 454 | } |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @return array[Writing_On_GitHub_File_Info]|WP_Error |
| 18 | 18 | */ |
| 19 | - public function compare( $sha ) { |
|
| 19 | + public function compare($sha) { |
|
| 20 | 20 | // https://api.github.com/repos/litefeel/testwpsync/compare/861f87e8851b8debb78db548269d29f8da4d94ac...master |
| 21 | 21 | $endpoint = $this->compare_endpoint(); |
| 22 | 22 | $branch = $this->branch(); |
| 23 | - $data = $this->call( 'GET', "$endpoint/$sha...$branch" ); |
|
| 23 | + $data = $this->call('GET', "$endpoint/$sha...$branch"); |
|
| 24 | 24 | |
| 25 | - if ( is_wp_error( $data ) ) { |
|
| 25 | + if (is_wp_error($data)) { |
|
| 26 | 26 | return $data; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return mixed |
| 46 | 46 | */ |
| 47 | - public function remote_contents( $post ) { |
|
| 48 | - return $this->call( 'GET', $this->content_endpoint( $post->github_path() ) ); |
|
| 47 | + public function remote_contents($post) { |
|
| 48 | + return $this->call('GET', $this->content_endpoint($post->github_path())); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function exists( $path ) { |
|
| 52 | - $result = $this->call( 'GET', $this->content_endpoint( $path ) ); |
|
| 53 | - if ( is_wp_error( $result ) ) { |
|
| 51 | + public function exists($path) { |
|
| 52 | + $result = $this->call('GET', $this->content_endpoint($path)); |
|
| 53 | + if (is_wp_error($result)) { |
|
| 54 | 54 | return false; |
| 55 | 55 | } |
| 56 | 56 | return true; |
@@ -63,27 +63,27 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return Writing_On_GitHub_Tree|WP_Error |
| 65 | 65 | */ |
| 66 | - public function tree_recursive( $sha = '_default' ) { |
|
| 66 | + public function tree_recursive($sha = '_default') { |
|
| 67 | 67 | |
| 68 | - if ( '_default' === $sha ) { |
|
| 68 | + if ('_default' === $sha) { |
|
| 69 | 69 | $sha = $this->branch(); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $data = $this->call( 'GET', $this->tree_endpoint() . '/' . $sha . '?recursive=1' ); |
|
| 72 | + $data = $this->call('GET', $this->tree_endpoint() . '/' . $sha . '?recursive=1'); |
|
| 73 | 73 | |
| 74 | - if ( is_wp_error( $data ) ) { |
|
| 74 | + if (is_wp_error($data)) { |
|
| 75 | 75 | return $data; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $files = array(); |
| 79 | 79 | |
| 80 | - foreach ( $data->tree as $index => $thing ) { |
|
| 80 | + foreach ($data->tree as $index => $thing) { |
|
| 81 | 81 | // We need to remove the trees because |
| 82 | 82 | // the recursive tree includes both |
| 83 | 83 | // the subtrees as well the subtrees' blobs. |
| 84 | - if ( 'blob' === $thing->type ) { |
|
| 84 | + if ('blob' === $thing->type) { |
|
| 85 | 85 | $thing->status = ''; |
| 86 | - $files[] = new Writing_On_GitHub_File_Info( $thing ); |
|
| 86 | + $files[] = new Writing_On_GitHub_File_Info($thing); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
@@ -97,20 +97,20 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return Writing_On_GitHub_Blob|WP_Error |
| 99 | 99 | */ |
| 100 | - public function blob( $blob ) { |
|
| 101 | - if ( $cache = $this->app->cache()->fetch_blob( $blob->sha ) ) { |
|
| 100 | + public function blob($blob) { |
|
| 101 | + if ($cache = $this->app->cache()->fetch_blob($blob->sha)) { |
|
| 102 | 102 | return $cache; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $data = $this->call( 'GET', $this->blob_endpoint() . '/' . $blob->sha ); |
|
| 105 | + $data = $this->call('GET', $this->blob_endpoint() . '/' . $blob->sha); |
|
| 106 | 106 | |
| 107 | - if ( is_wp_error( $data ) ) { |
|
| 107 | + if (is_wp_error($data)) { |
|
| 108 | 108 | return $data; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $data->path = $blob->path; |
| 112 | - $obj = new Writing_On_GitHub_Blob( $data ); |
|
| 112 | + $obj = new Writing_On_GitHub_Blob($data); |
|
| 113 | 113 | |
| 114 | - return $this->app->cache()->set_blob( $obj->sha(), $obj ); |
|
| 114 | + return $this->app->cache()->set_blob($obj->sha(), $obj); |
|
| 115 | 115 | } |
| 116 | 116 | } |
@@ -21,21 +21,21 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @var array |
| 23 | 23 | */ |
| 24 | - protected $whitelisted_post_types = array( 'post', 'page' ); |
|
| 24 | + protected $whitelisted_post_types = array('post', 'page'); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Currently whitelisted post statuses. |
| 28 | 28 | * |
| 29 | 29 | * @var array |
| 30 | 30 | */ |
| 31 | - protected $whitelisted_post_statuses = array( 'publish' ); |
|
| 31 | + protected $whitelisted_post_statuses = array('publish'); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Instantiates a new Database object. |
| 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,31 +45,31 @@ discard block |
||
| 45 | 45 | * @return Writing_On_GitHub_Post[]|WP_Error |
| 46 | 46 | */ |
| 47 | 47 | public function fetch_all_supported(bool $force = false, bool aaa cc) { |
| 48 | - $args = array( |
|
| 48 | + $args = array( |
|
| 49 | 49 | 'post_type' => $this->get_whitelisted_post_types(), |
| 50 | 50 | 'post_status' => $this->get_whitelisted_post_statuses(), |
| 51 | 51 | 'nopaging' => true, |
| 52 | 52 | 'fields' => 'ids', |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - $query = new WP_Query( apply_filters( 'wogh_pre_fetch_all_supported', $args ) ); |
|
| 55 | + $query = new WP_Query(apply_filters('wogh_pre_fetch_all_supported', $args)); |
|
| 56 | 56 | |
| 57 | 57 | $post_ids = $query->get_posts(); |
| 58 | 58 | |
| 59 | - if ( ! $post_ids ) { |
|
| 59 | + if ( ! $post_ids) { |
|
| 60 | 60 | return new WP_Error( |
| 61 | 61 | 'no_results', |
| 62 | - __( 'Querying for supported posts returned no results.', 'writing-on-github' ) |
|
| 62 | + __('Querying for supported posts returned no results.', 'writing-on-github') |
|
| 63 | 63 | ); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $results = array(); |
| 67 | - foreach ( $post_ids as $post_id ) { |
|
| 67 | + foreach ($post_ids as $post_id) { |
|
| 68 | 68 | // Do not export posts that have already been exported |
| 69 | - if ( ! get_post_meta( $post_id, '_wogh_sha', true ) || |
|
| 70 | - ! get_post_meta( $post_id, '_wogh_github_path', true) ) { |
|
| 69 | + if ( ! get_post_meta($post_id, '_wogh_sha', true) || |
|
| 70 | + ! get_post_meta($post_id, '_wogh_github_path', true)) { |
|
| 71 | 71 | |
| 72 | - $results[] = new Writing_On_GitHub_Post( $post_id, $this->app->api() ); |
|
| 72 | + $results[] = new Writing_On_GitHub_Post($post_id, $this->app->api()); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return WP_Error|Writing_On_GitHub_Post |
| 85 | 85 | */ |
| 86 | - public function fetch_by_id( $post_id ) { |
|
| 87 | - $post = new Writing_On_GitHub_Post( $post_id, $this->app->api() ); |
|
| 86 | + public function fetch_by_id($post_id) { |
|
| 87 | + $post = new Writing_On_GitHub_Post($post_id, $this->app->api()); |
|
| 88 | 88 | |
| 89 | - if ( ! $this->is_post_supported( $post ) ) { |
|
| 89 | + if ( ! $this->is_post_supported($post)) { |
|
| 90 | 90 | return new WP_Error( |
| 91 | 91 | 'unsupported_post', |
| 92 | 92 | sprintf( |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return string|WP_Error |
| 113 | 113 | */ |
| 114 | - public function save_posts( array $posts ) { |
|
| 114 | + public function save_posts(array $posts) { |
|
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * Whether an error has occurred. |
@@ -120,20 +120,19 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | $error = false; |
| 122 | 122 | |
| 123 | - foreach ( $posts as $post ) { |
|
| 124 | - $args = apply_filters( 'wogh_pre_import_args', $this->post_args( $post ), $post ); |
|
| 123 | + foreach ($posts as $post) { |
|
| 124 | + $args = apply_filters('wogh_pre_import_args', $this->post_args($post), $post); |
|
| 125 | 125 | |
| 126 | 126 | remove_filter('content_save_pre', 'wp_filter_post_kses'); |
| 127 | 127 | $post_id = $post->is_new() ? |
| 128 | - wp_insert_post( $args, true ) : |
|
| 129 | - wp_update_post( $args, true ); |
|
| 128 | + wp_insert_post($args, true) : wp_update_post($args, true); |
|
| 130 | 129 | add_filter('content_save_pre', 'wp_filter_post_kses'); |
| 131 | 130 | |
| 132 | - if ( is_wp_error( $post_id ) ) { |
|
| 133 | - if ( ! $error ) { |
|
| 131 | + if (is_wp_error($post_id)) { |
|
| 132 | + if ( ! $error) { |
|
| 134 | 133 | $error = $post_id; |
| 135 | 134 | } else { |
| 136 | - $error->add( $post_id->get_error_code(), $post_id->get_error_message() ); |
|
| 135 | + $error->add($post_id->get_error_code(), $post_id->get_error_message()); |
|
| 137 | 136 | } |
| 138 | 137 | |
| 139 | 138 | // Abort saving if updating the post fails. |
@@ -142,53 +141,53 @@ discard block |
||
| 142 | 141 | |
| 143 | 142 | // $this->set_revision_author( $post_id, $user_id ); |
| 144 | 143 | |
| 145 | - if ( $post->is_new() ) { |
|
| 144 | + if ($post->is_new()) { |
|
| 146 | 145 | $author = false; |
| 147 | 146 | $meta = $post->get_meta(); |
| 148 | - if ( ! empty( $meta ) && ! empty( $meta['author'] ) ) { |
|
| 147 | + if ( ! empty($meta) && ! empty($meta['author'])) { |
|
| 149 | 148 | $author = $meta['author']; |
| 150 | 149 | } |
| 151 | - $user = $this->fetch_commit_user( $author ); |
|
| 152 | - $user_id = ! is_wp_error( $user ) ? $user->ID : 0; |
|
| 153 | - $this->set_post_author( $post_id, $user_id ); |
|
| 150 | + $user = $this->fetch_commit_user($author); |
|
| 151 | + $user_id = ! is_wp_error($user) ? $user->ID : 0; |
|
| 152 | + $this->set_post_author($post_id, $user_id); |
|
| 154 | 153 | } |
| 155 | 154 | |
| 156 | - $post->set_post( get_post( $post_id ) ); |
|
| 155 | + $post->set_post(get_post($post_id)); |
|
| 157 | 156 | |
| 158 | - $meta = apply_filters( 'wogh_pre_import_meta', $post->get_meta(), $post ); |
|
| 157 | + $meta = apply_filters('wogh_pre_import_meta', $post->get_meta(), $post); |
|
| 159 | 158 | |
| 160 | - unset( $meta['tags'] ); |
|
| 161 | - unset( $meta['categories'] ); |
|
| 162 | - unset( $meta['author'] ); |
|
| 163 | - unset( $meta['post_date'] ); |
|
| 164 | - unset( $meta['post_excerpt'] ); |
|
| 165 | - unset( $meta['permalink'] ); |
|
| 159 | + unset($meta['tags']); |
|
| 160 | + unset($meta['categories']); |
|
| 161 | + unset($meta['author']); |
|
| 162 | + unset($meta['post_date']); |
|
| 163 | + unset($meta['post_excerpt']); |
|
| 164 | + unset($meta['permalink']); |
|
| 166 | 165 | |
| 167 | - foreach ( $meta as $key => $value ) { |
|
| 168 | - update_post_meta( $post_id, $key, $value ); |
|
| 166 | + foreach ($meta as $key => $value) { |
|
| 167 | + update_post_meta($post_id, $key, $value); |
|
| 169 | 168 | } |
| 170 | 169 | } |
| 171 | 170 | |
| 172 | - if ( $error ) { |
|
| 171 | + if ($error) { |
|
| 173 | 172 | return $error; |
| 174 | 173 | } |
| 175 | 174 | |
| 176 | - return __( 'Successfully saved posts.', 'writing-on-github' ); |
|
| 175 | + return __('Successfully saved posts.', 'writing-on-github'); |
|
| 177 | 176 | } |
| 178 | 177 | |
| 179 | - protected function post_args( $post ) { |
|
| 178 | + protected function post_args($post) { |
|
| 180 | 179 | $args = $post->get_args(); |
| 181 | 180 | $meta = $post->get_meta(); |
| 182 | 181 | |
| 183 | 182 | // update tags |
| 184 | - if ( isset( $meta['tags'] ) && $meta['tags'] ) { |
|
| 183 | + if (isset($meta['tags']) && $meta['tags']) { |
|
| 185 | 184 | $args['tags_input'] = $meta['tags']; |
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 | // update categories |
| 189 | - if ( isset( $meta['categories'] ) && $meta['categories'] ) { |
|
| 188 | + if (isset($meta['categories']) && $meta['categories']) { |
|
| 190 | 189 | $categories = $meta['categories']; |
| 191 | - if (!is_array($categories)) { |
|
| 190 | + if ( ! is_array($categories)) { |
|
| 192 | 191 | $categories = array($categories); |
| 193 | 192 | } |
| 194 | 193 | $terms = get_terms(array( |
@@ -204,7 +203,7 @@ discard block |
||
| 204 | 203 | } |
| 205 | 204 | |
| 206 | 205 | $ids = array(); |
| 207 | - if (!empty($terms)) { |
|
| 206 | + if ( ! empty($terms)) { |
|
| 208 | 207 | foreach ($terms as $id => $name) { |
| 209 | 208 | $ids[] = $id; |
| 210 | 209 | unset($map[$name]); |
@@ -212,7 +211,7 @@ discard block |
||
| 212 | 211 | } |
| 213 | 212 | |
| 214 | 213 | // create new terms |
| 215 | - if (!empty($map)) { |
|
| 214 | + if ( ! empty($map)) { |
|
| 216 | 215 | foreach ($map as $name => $value) { |
| 217 | 216 | $term = wp_insert_term($name, 'category', array('parent' => 0)); |
| 218 | 217 | // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
@@ -233,77 +232,77 @@ discard block |
||
| 233 | 232 | * |
| 234 | 233 | * @return string|WP_Error |
| 235 | 234 | */ |
| 236 | - public function delete_post_by_path( $path ) { |
|
| 237 | - $query = new WP_Query( array( |
|
| 235 | + public function delete_post_by_path($path) { |
|
| 236 | + $query = new WP_Query(array( |
|
| 238 | 237 | 'meta_key' => '_wogh_github_path', |
| 239 | 238 | 'meta_value' => $path, |
| 240 | 239 | 'meta_compare' => '=', |
| 241 | 240 | 'posts_per_page' => 1, |
| 242 | 241 | 'fields' => 'ids', |
| 243 | - ) ); |
|
| 242 | + )); |
|
| 244 | 243 | |
| 245 | 244 | $post_id = $query->get_posts(); |
| 246 | - $post_id = array_pop( $post_id ); |
|
| 245 | + $post_id = array_pop($post_id); |
|
| 247 | 246 | |
| 248 | - if ( ! $post_id ) { |
|
| 249 | - $parts = explode( '/', $path ); |
|
| 250 | - $filename = array_pop( $parts ); |
|
| 251 | - $directory = $parts ? array_shift( $parts ) : ''; |
|
| 247 | + if ( ! $post_id) { |
|
| 248 | + $parts = explode('/', $path); |
|
| 249 | + $filename = array_pop($parts); |
|
| 250 | + $directory = $parts ? array_shift($parts) : ''; |
|
| 252 | 251 | |
| 253 | - if ( false !== strpos( $directory, 'post' ) ) { |
|
| 254 | - preg_match( '/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md/', $filename, $matches ); |
|
| 252 | + if (false !== strpos($directory, 'post')) { |
|
| 253 | + preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md/', $filename, $matches); |
|
| 255 | 254 | $title = $matches[4]; |
| 256 | 255 | |
| 257 | - $query = new WP_Query( array( |
|
| 256 | + $query = new WP_Query(array( |
|
| 258 | 257 | 'name' => $title, |
| 259 | 258 | 'posts_per_page' => 1, |
| 260 | 259 | 'post_type' => $this->get_whitelisted_post_types(), |
| 261 | 260 | 'fields' => 'ids', |
| 262 | - ) ); |
|
| 261 | + )); |
|
| 263 | 262 | |
| 264 | 263 | $post_id = $query->get_posts(); |
| 265 | - $post_id = array_pop( $post_id ); |
|
| 264 | + $post_id = array_pop($post_id); |
|
| 266 | 265 | } |
| 267 | 266 | |
| 268 | - if ( ! $post_id ) { |
|
| 269 | - preg_match( '/(.*)\.md/', $filename, $matches ); |
|
| 267 | + if ( ! $post_id) { |
|
| 268 | + preg_match('/(.*)\.md/', $filename, $matches); |
|
| 270 | 269 | $title = $matches[1]; |
| 271 | 270 | |
| 272 | - $query = new WP_Query( array( |
|
| 271 | + $query = new WP_Query(array( |
|
| 273 | 272 | 'name' => $title, |
| 274 | 273 | 'posts_per_page' => 1, |
| 275 | 274 | 'post_type' => $this->get_whitelisted_post_types(), |
| 276 | 275 | 'fields' => 'ids', |
| 277 | - ) ); |
|
| 276 | + )); |
|
| 278 | 277 | |
| 279 | 278 | $post_id = $query->get_posts(); |
| 280 | - $post_id = array_pop( $post_id ); |
|
| 279 | + $post_id = array_pop($post_id); |
|
| 281 | 280 | } |
| 282 | 281 | } |
| 283 | 282 | |
| 284 | - if ( ! $post_id ) { |
|
| 283 | + if ( ! $post_id) { |
|
| 285 | 284 | return new WP_Error( |
| 286 | 285 | 'path_not_found', |
| 287 | 286 | sprintf( |
| 288 | - __( 'Post not found for path %s.', 'writing-on-github' ), |
|
| 287 | + __('Post not found for path %s.', 'writing-on-github'), |
|
| 289 | 288 | $path |
| 290 | 289 | ) |
| 291 | 290 | ); |
| 292 | 291 | } |
| 293 | 292 | |
| 294 | - $result = wp_delete_post( $post_id ); |
|
| 293 | + $result = wp_delete_post($post_id); |
|
| 295 | 294 | |
| 296 | 295 | // If deleting fails... |
| 297 | - if ( false === $result ) { |
|
| 298 | - $post = get_post( $post_id ); |
|
| 296 | + if (false === $result) { |
|
| 297 | + $post = get_post($post_id); |
|
| 299 | 298 | |
| 300 | 299 | // ...and the post both exists and isn't in the trash... |
| 301 | - if ( $post && 'trash' !== $post->post_status ) { |
|
| 300 | + if ($post && 'trash' !== $post->post_status) { |
|
| 302 | 301 | // ... then something went wrong. |
| 303 | 302 | return new WP_Error( |
| 304 | 303 | 'db_error', |
| 305 | 304 | sprintf( |
| 306 | - __( 'Failed to delete post ID %d.', 'writing-on-github' ), |
|
| 305 | + __('Failed to delete post ID %d.', 'writing-on-github'), |
|
| 307 | 306 | $post_id |
| 308 | 307 | ) |
| 309 | 308 | ); |
@@ -311,25 +310,25 @@ discard block |
||
| 311 | 310 | } |
| 312 | 311 | |
| 313 | 312 | return sprintf( |
| 314 | - __( 'Successfully deleted post ID %d.', 'writing-on-github' ), |
|
| 313 | + __('Successfully deleted post ID %d.', 'writing-on-github'), |
|
| 315 | 314 | $post_id |
| 316 | 315 | ); |
| 317 | 316 | } |
| 318 | 317 | |
| 319 | - public function delete_post( $post_id ) { |
|
| 320 | - $result = wp_delete_post( $post_id ); |
|
| 318 | + public function delete_post($post_id) { |
|
| 319 | + $result = wp_delete_post($post_id); |
|
| 321 | 320 | |
| 322 | 321 | // If deleting fails... |
| 323 | - if ( false === $result ) { |
|
| 324 | - $post = get_post( $post_id ); |
|
| 322 | + if (false === $result) { |
|
| 323 | + $post = get_post($post_id); |
|
| 325 | 324 | |
| 326 | 325 | // ...and the post both exists and isn't in the trash... |
| 327 | - if ( $post && 'trash' !== $post->post_status ) { |
|
| 326 | + if ($post && 'trash' !== $post->post_status) { |
|
| 328 | 327 | // ... then something went wrong. |
| 329 | 328 | return new WP_Error( |
| 330 | 329 | 'db_error', |
| 331 | 330 | sprintf( |
| 332 | - __( 'Failed to delete post ID %d.', 'writing-on-github' ), |
|
| 331 | + __('Failed to delete post ID %d.', 'writing-on-github'), |
|
| 333 | 332 | $post_id |
| 334 | 333 | ) |
| 335 | 334 | ); |
@@ -337,7 +336,7 @@ discard block |
||
| 337 | 336 | } |
| 338 | 337 | |
| 339 | 338 | return sprintf( |
| 340 | - __( 'Successfully deleted post ID %d.', 'writing-on-github' ), |
|
| 339 | + __('Successfully deleted post ID %d.', 'writing-on-github'), |
|
| 341 | 340 | $post_id |
| 342 | 341 | ); |
| 343 | 342 | } |
@@ -348,7 +347,7 @@ discard block |
||
| 348 | 347 | * @return array |
| 349 | 348 | */ |
| 350 | 349 | protected function get_whitelisted_post_types() { |
| 351 | - return apply_filters( 'wogh_whitelisted_post_types', $this->whitelisted_post_types ); |
|
| 350 | + return apply_filters('wogh_whitelisted_post_types', $this->whitelisted_post_types); |
|
| 352 | 351 | } |
| 353 | 352 | |
| 354 | 353 | /** |
@@ -357,7 +356,7 @@ discard block |
||
| 357 | 356 | * @return array |
| 358 | 357 | */ |
| 359 | 358 | protected function get_whitelisted_post_statuses() { |
| 360 | - return apply_filters( 'wogh_whitelisted_post_statuses', $this->whitelisted_post_statuses ); |
|
| 359 | + return apply_filters('wogh_whitelisted_post_statuses', $this->whitelisted_post_statuses); |
|
| 361 | 360 | } |
| 362 | 361 | |
| 363 | 362 | /** |
@@ -367,12 +366,12 @@ discard block |
||
| 367 | 366 | * |
| 368 | 367 | * @return string Whitelist formatted for query |
| 369 | 368 | */ |
| 370 | - protected function format_for_query( $whitelist ) { |
|
| 371 | - foreach ( $whitelist as $key => $value ) { |
|
| 372 | - $whitelist[ $key ] = "'$value'"; |
|
| 369 | + protected function format_for_query($whitelist) { |
|
| 370 | + foreach ($whitelist as $key => $value) { |
|
| 371 | + $whitelist[$key] = "'$value'"; |
|
| 373 | 372 | } |
| 374 | 373 | |
| 375 | - return implode( ', ', $whitelist ); |
|
| 374 | + return implode(', ', $whitelist); |
|
| 376 | 375 | } |
| 377 | 376 | |
| 378 | 377 | /** |
@@ -383,25 +382,25 @@ discard block |
||
| 383 | 382 | * |
| 384 | 383 | * @return boolean True if supported, false if not. |
| 385 | 384 | */ |
| 386 | - protected function is_post_supported( Writing_On_GitHub_Post $post ) { |
|
| 387 | - if ( wp_is_post_revision( $post->id ) ) { |
|
| 385 | + protected function is_post_supported(Writing_On_GitHub_Post $post) { |
|
| 386 | + if (wp_is_post_revision($post->id)) { |
|
| 388 | 387 | return false; |
| 389 | 388 | } |
| 390 | 389 | |
| 391 | 390 | // We need to allow trashed posts to be queried, but they are not whitelisted for export. |
| 392 | - if ( ! in_array( $post->status(), $this->get_whitelisted_post_statuses() ) && 'trash' !== $post->status() ) { |
|
| 391 | + if ( ! in_array($post->status(), $this->get_whitelisted_post_statuses()) && 'trash' !== $post->status()) { |
|
| 393 | 392 | return false; |
| 394 | 393 | } |
| 395 | 394 | |
| 396 | - if ( ! in_array( $post->type(), $this->get_whitelisted_post_types() ) ) { |
|
| 395 | + if ( ! in_array($post->type(), $this->get_whitelisted_post_types())) { |
|
| 397 | 396 | return false; |
| 398 | 397 | } |
| 399 | 398 | |
| 400 | - if ( $post->has_password() ) { |
|
| 399 | + if ($post->has_password()) { |
|
| 401 | 400 | return false; |
| 402 | 401 | } |
| 403 | 402 | |
| 404 | - return apply_filters( 'wogh_is_post_supported', true, $post ); |
|
| 403 | + return apply_filters('wogh_is_post_supported', true, $post); |
|
| 405 | 404 | } |
| 406 | 405 | |
| 407 | 406 | /** |
@@ -414,35 +413,35 @@ discard block |
||
| 414 | 413 | * |
| 415 | 414 | * @return WP_Error|WP_User |
| 416 | 415 | */ |
| 417 | - protected function fetch_commit_user( $display_name ) { |
|
| 416 | + protected function fetch_commit_user($display_name) { |
|
| 418 | 417 | // If we can't find a user and a default hasn't been set, |
| 419 | 418 | // we're just going to set the revision author to 0. |
| 420 | 419 | $user = false; |
| 421 | 420 | |
| 422 | - if ( ! empty( $display_name ) ) { |
|
| 423 | - $search_string = esc_attr( $display_name ); |
|
| 424 | - $query = new WP_User_Query( array( |
|
| 421 | + if ( ! empty($display_name)) { |
|
| 422 | + $search_string = esc_attr($display_name); |
|
| 423 | + $query = new WP_User_Query(array( |
|
| 425 | 424 | 'search' => "{$search_string}", |
| 426 | 425 | 'search_columns' => array( |
| 427 | 426 | 'display_name', |
| 428 | 427 | 'user_nicename', |
| 429 | 428 | 'user_login', |
| 430 | 429 | ) |
| 431 | - ) ); |
|
| 430 | + )); |
|
| 432 | 431 | $users = $query->get_results(); |
| 433 | 432 | $user = empty($users) ? false : $users[0]; |
| 434 | 433 | } |
| 435 | 434 | |
| 436 | - if ( ! $user ) { |
|
| 435 | + if ( ! $user) { |
|
| 437 | 436 | // Use the default user. |
| 438 | - $user = get_user_by( 'id', (int) get_option( 'wogh_default_user' ) ); |
|
| 437 | + $user = get_user_by('id', (int) get_option('wogh_default_user')); |
|
| 439 | 438 | } |
| 440 | 439 | |
| 441 | - if ( ! $user ) { |
|
| 440 | + if ( ! $user) { |
|
| 442 | 441 | return new WP_Error( |
| 443 | 442 | 'user_not_found', |
| 444 | 443 | sprintf( |
| 445 | - __( 'Commit user not found for email %s', 'writing-on-github' ), |
|
| 444 | + __('Commit user not found for email %s', 'writing-on-github'), |
|
| 446 | 445 | |
| 447 | 446 | ) |
| 448 | 447 | ); |
@@ -460,28 +459,28 @@ discard block |
||
| 460 | 459 | * |
| 461 | 460 | * @return string|WP_Error |
| 462 | 461 | */ |
| 463 | - protected function set_revision_author( $post_id, $user_id ) { |
|
| 464 | - $revision = wp_get_post_revisions( $post_id ); |
|
| 462 | + protected function set_revision_author($post_id, $user_id) { |
|
| 463 | + $revision = wp_get_post_revisions($post_id); |
|
| 465 | 464 | |
| 466 | - if ( ! $revision ) { |
|
| 467 | - $new_revision = wp_save_post_revision( $post_id ); |
|
| 465 | + if ( ! $revision) { |
|
| 466 | + $new_revision = wp_save_post_revision($post_id); |
|
| 468 | 467 | |
| 469 | - if ( ! $new_revision || is_wp_error( $new_revision ) ) { |
|
| 470 | - return new WP_Error( 'db_error', 'There was a problem saving a new revision.' ); |
|
| 468 | + if ( ! $new_revision || is_wp_error($new_revision)) { |
|
| 469 | + return new WP_Error('db_error', 'There was a problem saving a new revision.'); |
|
| 471 | 470 | } |
| 472 | 471 | |
| 473 | 472 | // `wp_save_post_revision` returns the ID, whereas `get_post_revision` returns the whole object |
| 474 | 473 | // in order to be consistent, let's make sure we have the whole object before continuing. |
| 475 | - $revision = get_post( $new_revision ); |
|
| 474 | + $revision = get_post($new_revision); |
|
| 476 | 475 | |
| 477 | - if ( ! $revision ) { |
|
| 478 | - return new WP_Error( 'db_error', 'There was a problem retrieving the newly recreated revision.' ); |
|
| 476 | + if ( ! $revision) { |
|
| 477 | + return new WP_Error('db_error', 'There was a problem retrieving the newly recreated revision.'); |
|
| 479 | 478 | } |
| 480 | 479 | } else { |
| 481 | - $revision = array_shift( $revision ); |
|
| 480 | + $revision = array_shift($revision); |
|
| 482 | 481 | } |
| 483 | 482 | |
| 484 | - return $this->set_post_author( $revision->ID, $user_id ); |
|
| 483 | + return $this->set_post_author($revision->ID, $user_id); |
|
| 485 | 484 | } |
| 486 | 485 | |
| 487 | 486 | /** |
@@ -494,7 +493,7 @@ discard block |
||
| 494 | 493 | * |
| 495 | 494 | * @return string|WP_Error |
| 496 | 495 | */ |
| 497 | - protected function set_post_author( $post_id, $user_id ) { |
|
| 496 | + protected function set_post_author($post_id, $user_id) { |
|
| 498 | 497 | global $wpdb; |
| 499 | 498 | |
| 500 | 499 | $result = $wpdb->update( |
@@ -505,25 +504,25 @@ discard block |
||
| 505 | 504 | array( |
| 506 | 505 | 'ID' => (int) $post_id, |
| 507 | 506 | ), |
| 508 | - array( '%d' ), |
|
| 509 | - array( '%d' ) |
|
| 507 | + array('%d'), |
|
| 508 | + array('%d') |
|
| 510 | 509 | ); |
| 511 | 510 | |
| 512 | - if ( false === $result ) { |
|
| 513 | - return new WP_Error( 'db_error', $wpdb->last_error ); |
|
| 511 | + if (false === $result) { |
|
| 512 | + return new WP_Error('db_error', $wpdb->last_error); |
|
| 514 | 513 | } |
| 515 | 514 | |
| 516 | - if ( 0 === $result ) { |
|
| 515 | + if (0 === $result) { |
|
| 517 | 516 | return sprintf( |
| 518 | - __( 'No change for post ID %d.', 'writing-on-github' ), |
|
| 517 | + __('No change for post ID %d.', 'writing-on-github'), |
|
| 519 | 518 | $post_id |
| 520 | 519 | ); |
| 521 | 520 | } |
| 522 | 521 | |
| 523 | - clean_post_cache( $post_id ); |
|
| 522 | + clean_post_cache($post_id); |
|
| 524 | 523 | |
| 525 | 524 | return sprintf( |
| 526 | - __( 'Successfully updated post ID %d.', 'writing-on-github' ), |
|
| 525 | + __('Successfully updated post ID %d.', 'writing-on-github'), |
|
| 527 | 526 | $post_id |
| 528 | 527 | ); |
| 529 | 528 | } |
@@ -536,7 +535,7 @@ discard block |
||
| 536 | 535 | * |
| 537 | 536 | * @return bool|int |
| 538 | 537 | */ |
| 539 | - public function set_post_sha( $post, $sha ) { |
|
| 540 | - return update_post_meta( $post->id, '_wogh_sha', $sha ); |
|
| 538 | + public function set_post_sha($post, $sha) { |
|
| 539 | + return update_post_meta($post->id, '_wogh_sha', $sha); |
|
| 541 | 540 | } |
| 542 | 541 | } |