@@ -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 | } |
@@ -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> |
@@ -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 name="<?php echo esc_attr( $args['name'] ); ?>" id="<?php echo esc_attr( $args['name'] ); ?>" type="<?php echo 'wogh_secret' === $args['name'] ? 'password' : 'text'; ?>" value="<?php echo esc_attr( $value ); ?>" /> |
|
| 8 | +<?php $value = get_option($args['name'], $args['default']); ?> |
|
| 9 | +<input name="<?php echo esc_attr($args['name']); ?>" id="<?php echo esc_attr($args['name']); ?>" type="<?php echo 'wogh_secret' === $args['name'] ? 'password' : 'text'; ?>" value="<?php echo esc_attr($value); ?>" /> |
|
| 10 | 10 | <p class="description"><?php echo $args['help_text']; ?></p> |
@@ -159,6 +159,9 @@ |
||
| 159 | 159 | // } |
| 160 | 160 | // } |
| 161 | 161 | |
| 162 | + /** |
|
| 163 | + * @param string $repo |
|
| 164 | + */ |
|
| 162 | 165 | protected function malformed_repo( $repo ) { |
| 163 | 166 | update_option( Base::REPO_OPTION_KEY, $repo ); |
| 164 | 167 | |
@@ -9,77 +9,77 @@ discard block |
||
| 9 | 9 | public function setUp() { |
| 10 | 10 | parent::setUp(); |
| 11 | 11 | |
| 12 | - $this->fetch = new Writing_On_GitHub_Fetch_Client( $this->app ); |
|
| 12 | + $this->fetch = new Writing_On_GitHub_Fetch_Client($this->app); |
|
| 13 | 13 | $this->api_cache |
| 14 | - ->shouldReceive( 'fetch_blob' ) |
|
| 15 | - ->andReturn( false ) |
|
| 14 | + ->shouldReceive('fetch_blob') |
|
| 15 | + ->andReturn(false) |
|
| 16 | 16 | ->byDefault(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function test_should_fail_if_missing_token() { |
| 20 | - delete_option( Base::TOKEN_OPTION_KEY ); |
|
| 20 | + delete_option(Base::TOKEN_OPTION_KEY); |
|
| 21 | 21 | |
| 22 | - $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() ); |
|
| 23 | - $this->assertSame( 'missing_token', $error->get_error_code() ); |
|
| 22 | + $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive()); |
|
| 23 | + $this->assertSame('missing_token', $error->get_error_code()); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function test_should_fail_if_missing_repo() { |
| 27 | - delete_option( Base::REPO_OPTION_KEY ); |
|
| 27 | + delete_option(Base::REPO_OPTION_KEY); |
|
| 28 | 28 | |
| 29 | - $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() ); |
|
| 30 | - $this->assertSame( 'missing_repository', $error->get_error_code() ); |
|
| 29 | + $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive()); |
|
| 30 | + $this->assertSame('missing_repository', $error->get_error_code()); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function test_should_fail_if_malformed_repo() { |
| 34 | 34 | // If you find a particular name passing that shouldn't, |
| 35 | 35 | // add it to the list here and make it pass. |
| 36 | - $this->malformed_repo( 'repositoryname' ); |
|
| 36 | + $this->malformed_repo('repositoryname'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function test_should_return_files_with_tree() { |
| 40 | 40 | // $this->set_get_refs_heads_master( true ); |
| 41 | 41 | // $this->set_get_commits( true ); |
| 42 | - $this->set_get_trees( true, 'master' ); |
|
| 42 | + $this->set_get_trees(true, 'master'); |
|
| 43 | 43 | |
| 44 | - $this->assertCount( 3, $this->fetch->tree_recursive() ); |
|
| 44 | + $this->assertCount(3, $this->fetch->tree_recursive()); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function test_should_fail_if_cant_fetch_tree() { |
| 48 | - $this->set_get_trees( false, 'master' ); |
|
| 48 | + $this->set_get_trees(false, 'master'); |
|
| 49 | 49 | |
| 50 | - $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() ); |
|
| 51 | - $this->assertSame( '422_unprocessable_entity', $error->get_error_code() ); |
|
| 50 | + $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive()); |
|
| 51 | + $this->assertSame('422_unprocessable_entity', $error->get_error_code()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function test_should_return_commit_with_blobs_from_cache() { |
| 55 | - $this->set_get_trees( true, 'master' ); |
|
| 56 | - $this->set_get_blobs( true ); |
|
| 55 | + $this->set_get_trees(true, 'master'); |
|
| 56 | + $this->set_get_blobs(true); |
|
| 57 | 57 | $this->api_cache |
| 58 | - ->shouldReceive( 'fetch_blob' ) |
|
| 59 | - ->times( 3 ) |
|
| 60 | - ->with( Mockery::anyOf( |
|
| 58 | + ->shouldReceive('fetch_blob') |
|
| 59 | + ->times(3) |
|
| 60 | + ->with(Mockery::anyOf( |
|
| 61 | 61 | '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25', |
| 62 | 62 | '8d9b2e6fd93761211dc03abd71f4a9189d680fd0', |
| 63 | 63 | '2d73165945b0ccbe4932f1363457986b0ed49f19' |
| 64 | - ) ) |
|
| 65 | - ->andReturn( $this->blob ); |
|
| 64 | + )) |
|
| 65 | + ->andReturn($this->blob); |
|
| 66 | 66 | |
| 67 | - $this->assertCount( 3, $files = $this->fetch->tree_recursive() ); |
|
| 67 | + $this->assertCount(3, $files = $this->fetch->tree_recursive()); |
|
| 68 | 68 | |
| 69 | - foreach ( $files as $file ) { |
|
| 70 | - $this->assertSame( $this->blob, $this->fetch->blob( $file ) ); |
|
| 69 | + foreach ($files as $file) { |
|
| 70 | + $this->assertSame($this->blob, $this->fetch->blob($file)); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function test_should_return_commit_with_no_blobs_if_api_fails() { |
| 75 | - $this->set_get_trees( true, 'master' ); |
|
| 76 | - $this->set_get_blobs( false ); |
|
| 75 | + $this->set_get_trees(true, 'master'); |
|
| 76 | + $this->set_get_blobs(false); |
|
| 77 | 77 | |
| 78 | - $this->assertCount( 3, $files = $this->fetch->tree_recursive() ); |
|
| 78 | + $this->assertCount(3, $files = $this->fetch->tree_recursive()); |
|
| 79 | 79 | |
| 80 | - foreach ( $files as $file ) { |
|
| 81 | - $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->blob( $file ) ); |
|
| 82 | - $this->assertSame( '404_not_found', $error->get_error_code() ); |
|
| 80 | + foreach ($files as $file) { |
|
| 81 | + $this->assertInstanceOf('WP_Error', $error = $this->fetch->blob($file)); |
|
| 82 | + $this->assertSame('404_not_found', $error->get_error_code()); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | // } |
| 160 | 160 | // } |
| 161 | 161 | |
| 162 | - protected function malformed_repo( $repo ) { |
|
| 163 | - update_option( Base::REPO_OPTION_KEY, $repo ); |
|
| 162 | + protected function malformed_repo($repo) { |
|
| 163 | + update_option(Base::REPO_OPTION_KEY, $repo); |
|
| 164 | 164 | |
| 165 | - $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() ); |
|
| 166 | - $this->assertSame( 'malformed_repository', $error->get_error_code() ); |
|
| 165 | + $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive()); |
|
| 166 | + $this->assertSame('malformed_repository', $error->get_error_code()); |
|
| 167 | 167 | } |
| 168 | 168 | } |
@@ -417,7 +417,7 @@ |
||
| 417 | 417 | /** |
| 418 | 418 | * Kicks of an import or export cronjob. |
| 419 | 419 | * |
| 420 | - * @param $type |
|
| 420 | + * @param string $type |
|
| 421 | 421 | */ |
| 422 | 422 | protected function start_cron( $type ) { |
| 423 | 423 | update_option( '_wogh_' . $type . '_started', 'yes' ); |
@@ -186,7 +186,7 @@ |
||
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - return $link; |
|
| 189 | + return $link; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public function ignore_post_meta($meta) { |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // If the functions have already been autoloaded, don't reload. |
| 14 | 14 | // This fixes function duplication during unit testing. |
| 15 | -if ( defined( 'WRITING_ON_GITHUB_TEST' ) && WRITING_ON_GITHUB_TEST ) { |
|
| 16 | - $path = dirname( __FILE__ ) . '/vendor/autoload_52.php'; |
|
| 15 | +if (defined('WRITING_ON_GITHUB_TEST') && WRITING_ON_GITHUB_TEST) { |
|
| 16 | + $path = dirname(__FILE__) . '/vendor/autoload_52.php'; |
|
| 17 | 17 | include_once $path; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | // require_once(dirname(__FILE__) . '/views/options.php'); |
| 42 | 42 | // require_once(dirname(__FILE__) . '/views/user-setting-field.php'); |
| 43 | 43 | |
| 44 | -add_action( 'plugins_loaded', array( new Writing_On_GitHub, 'boot' ) ); |
|
| 44 | +add_action('plugins_loaded', array(new Writing_On_GitHub, 'boot')); |
|
| 45 | 45 | |
| 46 | 46 | class Writing_On_GitHub { |
| 47 | 47 | |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | public function __construct() { |
| 145 | 145 | self::$instance = $this; |
| 146 | 146 | |
| 147 | - if ( is_admin() ) { |
|
| 147 | + if (is_admin()) { |
|
| 148 | 148 | $this->admin = new Writing_On_GitHub_Admin; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $this->controller = new Writing_On_GitHub_Controller( $this ); |
|
| 151 | + $this->controller = new Writing_On_GitHub_Controller($this); |
|
| 152 | 152 | |
| 153 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 154 | - WP_CLI::add_command( 'wogh', $this->cli() ); |
|
| 153 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 154 | + WP_CLI::add_command('wogh', $this->cli()); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
@@ -159,29 +159,29 @@ discard block |
||
| 159 | 159 | * Attaches the plugin's hooks into WordPress. |
| 160 | 160 | */ |
| 161 | 161 | public function boot() { |
| 162 | - register_activation_hook( __FILE__, array( $this, 'activate' ) ); |
|
| 163 | - add_action( 'admin_notices', array( $this, 'activation_notice' ) ); |
|
| 162 | + register_activation_hook(__FILE__, array($this, 'activate')); |
|
| 163 | + add_action('admin_notices', array($this, 'activation_notice')); |
|
| 164 | 164 | |
| 165 | - add_action( 'init', array( $this, 'l10n' ) ); |
|
| 165 | + add_action('init', array($this, 'l10n')); |
|
| 166 | 166 | |
| 167 | 167 | // Controller actions. |
| 168 | - add_action( 'save_post', array( $this->controller, 'export_post' ) ); |
|
| 169 | - add_action( 'delete_post', array( $this->controller, 'delete_post' ) ); |
|
| 170 | - add_action( 'wp_ajax_nopriv_wogh_push_request', array( $this->controller, 'pull_posts' ) ); |
|
| 171 | - add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 1 ); |
|
| 172 | - add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 ); |
|
| 173 | - add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 ); |
|
| 168 | + add_action('save_post', array($this->controller, 'export_post')); |
|
| 169 | + add_action('delete_post', array($this->controller, 'delete_post')); |
|
| 170 | + add_action('wp_ajax_nopriv_wogh_push_request', array($this->controller, 'pull_posts')); |
|
| 171 | + add_action('wogh_export', array($this->controller, 'export_all'), 10, 1); |
|
| 172 | + add_action('wogh_import', array($this->controller, 'import_master'), 10, 1); |
|
| 173 | + add_filter('get_edit_post_link', array($this, 'edit_post_link'), 10, 3); |
|
| 174 | 174 | |
| 175 | - add_filter( 'wogh_post_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
|
| 176 | - add_filter( 'wogh_pre_import_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
|
| 175 | + add_filter('wogh_post_meta', array($this, 'ignore_post_meta'), 10, 1); |
|
| 176 | + add_filter('wogh_pre_import_meta', array($this, 'ignore_post_meta'), 10, 1); |
|
| 177 | 177 | |
| 178 | - do_action( 'wogh_boot', $this ); |
|
| 178 | + do_action('wogh_boot', $this); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | public function edit_post_link($link, $postID, $context) { |
| 182 | - if ( ! wp_is_post_revision( $postID ) ) { |
|
| 183 | - $post = new Writing_On_GitHub_Post( $postID, Writing_On_GitHub::$instance->api() ); |
|
| 184 | - if ( $post->is_on_github() ) { |
|
| 182 | + if ( ! wp_is_post_revision($postID)) { |
|
| 183 | + $post = new Writing_On_GitHub_Post($postID, Writing_On_GitHub::$instance->api()); |
|
| 184 | + if ($post->is_on_github()) { |
|
| 185 | 185 | return $post->github_edit_url(); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -216,29 +216,29 @@ discard block |
||
| 216 | 216 | * Init i18n files |
| 217 | 217 | */ |
| 218 | 218 | public function l10n() { |
| 219 | - load_plugin_textdomain( self::$text_domain ); |
|
| 219 | + load_plugin_textdomain(self::$text_domain); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * Sets and kicks off the export cronjob |
| 224 | 224 | */ |
| 225 | 225 | public function start_export() { |
| 226 | - $this->start_cron( 'export' ); |
|
| 226 | + $this->start_cron('export'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | 230 | * Sets and kicks off the import cronjob |
| 231 | 231 | */ |
| 232 | 232 | public function start_import() { |
| 233 | - $this->start_cron( 'import' ); |
|
| 233 | + $this->start_cron('import'); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * Enables the admin notice on initial activation |
| 238 | 238 | */ |
| 239 | 239 | public function activate() { |
| 240 | - if ( 'yes' !== get_option( '_wogh_fully_exported' ) ) { |
|
| 241 | - set_transient( '_wogh_activated', 'yes' ); |
|
| 240 | + if ('yes' !== get_option('_wogh_fully_exported')) { |
|
| 241 | + set_transient('_wogh_activated', 'yes'); |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
@@ -246,18 +246,18 @@ discard block |
||
| 246 | 246 | * Displays the activation admin notice |
| 247 | 247 | */ |
| 248 | 248 | public function activation_notice() { |
| 249 | - if ( ! get_transient( '_wogh_activated' ) ) { |
|
| 249 | + if ( ! get_transient('_wogh_activated')) { |
|
| 250 | 250 | return; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - delete_transient( '_wogh_activated' ); |
|
| 253 | + delete_transient('_wogh_activated'); |
|
| 254 | 254 | |
| 255 | 255 | ?><div class="updated"> |
| 256 | 256 | <p> |
| 257 | 257 | <?php |
| 258 | 258 | printf( |
| 259 | - __( 'To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github' ), |
|
| 260 | - admin_url( 'options-general.php?page=' . static::$text_domain) |
|
| 259 | + __('To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github'), |
|
| 260 | + admin_url('options-general.php?page=' . static::$text_domain) |
|
| 261 | 261 | ); |
| 262 | 262 | ?> |
| 263 | 263 | </p> |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * @return Writing_On_GitHub_CLI |
| 280 | 280 | */ |
| 281 | 281 | public function cli() { |
| 282 | - if ( ! $this->cli ) { |
|
| 282 | + if ( ! $this->cli) { |
|
| 283 | 283 | $this->cli = new Writing_On_GitHub_CLI; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | * @return Writing_On_GitHub_Request |
| 293 | 293 | */ |
| 294 | 294 | public function request() { |
| 295 | - if ( ! $this->request ) { |
|
| 296 | - $this->request = new Writing_On_GitHub_Request( $this ); |
|
| 295 | + if ( ! $this->request) { |
|
| 296 | + $this->request = new Writing_On_GitHub_Request($this); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | return $this->request; |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | * @return Writing_On_GitHub_Response |
| 306 | 306 | */ |
| 307 | 307 | public function response() { |
| 308 | - if ( ! $this->response ) { |
|
| 309 | - $this->response = new Writing_On_GitHub_Response( $this ); |
|
| 308 | + if ( ! $this->response) { |
|
| 309 | + $this->response = new Writing_On_GitHub_Response($this); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | return $this->response; |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | * @return Writing_On_GitHub_Api |
| 319 | 319 | */ |
| 320 | 320 | public function api() { |
| 321 | - if ( ! $this->api ) { |
|
| 322 | - $this->api = new Writing_On_GitHub_Api( $this ); |
|
| 321 | + if ( ! $this->api) { |
|
| 322 | + $this->api = new Writing_On_GitHub_Api($this); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | return $this->api; |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | * @return Writing_On_GitHub_Import |
| 332 | 332 | */ |
| 333 | 333 | public function import() { |
| 334 | - if ( ! $this->import ) { |
|
| 335 | - $this->import = new Writing_On_GitHub_Import( $this ); |
|
| 334 | + if ( ! $this->import) { |
|
| 335 | + $this->import = new Writing_On_GitHub_Import($this); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | return $this->import; |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | * @return Writing_On_GitHub_Export |
| 345 | 345 | */ |
| 346 | 346 | public function export() { |
| 347 | - if ( ! $this->export ) { |
|
| 348 | - $this->export = new Writing_On_GitHub_Export( $this ); |
|
| 347 | + if ( ! $this->export) { |
|
| 348 | + $this->export = new Writing_On_GitHub_Export($this); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | return $this->export; |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | * @return Writing_On_GitHub_Semaphore |
| 358 | 358 | */ |
| 359 | 359 | public function semaphore() { |
| 360 | - if ( ! $this->semaphore ) { |
|
| 360 | + if ( ! $this->semaphore) { |
|
| 361 | 361 | $this->semaphore = new Writing_On_GitHub_Semaphore; |
| 362 | 362 | } |
| 363 | 363 | |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | * @return Writing_On_GitHub_Database |
| 371 | 371 | */ |
| 372 | 372 | public function database() { |
| 373 | - if ( ! $this->database ) { |
|
| 374 | - $this->database = new Writing_On_GitHub_Database( $this ); |
|
| 373 | + if ( ! $this->database) { |
|
| 374 | + $this->database = new Writing_On_GitHub_Database($this); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | return $this->database; |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @return Writing_On_GitHub_Cache |
| 384 | 384 | */ |
| 385 | 385 | public function cache() { |
| 386 | - if ( ! $this->cache ) { |
|
| 386 | + if ( ! $this->cache) { |
|
| 387 | 387 | $this->cache = new Writing_On_GitHub_Cache; |
| 388 | 388 | } |
| 389 | 389 | |
@@ -398,18 +398,18 @@ discard block |
||
| 398 | 398 | * @param mixed $msg |
| 399 | 399 | * @param string $write |
| 400 | 400 | */ |
| 401 | - public static function write_log( $msg, $write = 'line' ) { |
|
| 402 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 403 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
| 404 | - WP_CLI::print_value( $msg ); |
|
| 401 | + public static function write_log($msg, $write = 'line') { |
|
| 402 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 403 | + if (is_array($msg) || is_object($msg)) { |
|
| 404 | + WP_CLI::print_value($msg); |
|
| 405 | 405 | } else { |
| 406 | - WP_CLI::$write( $msg ); |
|
| 406 | + WP_CLI::$write($msg); |
|
| 407 | 407 | } |
| 408 | - } elseif ( true === WP_DEBUG ) { |
|
| 409 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
| 410 | - error_log( print_r( $msg, true ) ); |
|
| 408 | + } elseif (true === WP_DEBUG) { |
|
| 409 | + if (is_array($msg) || is_object($msg)) { |
|
| 410 | + error_log(print_r($msg, true)); |
|
| 411 | 411 | } else { |
| 412 | - error_log( $msg ); |
|
| 412 | + error_log($msg); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | } |
@@ -419,10 +419,10 @@ discard block |
||
| 419 | 419 | * |
| 420 | 420 | * @param $type |
| 421 | 421 | */ |
| 422 | - protected function start_cron( $type ) { |
|
| 423 | - update_option( '_wogh_' . $type . '_started', 'yes' ); |
|
| 422 | + protected function start_cron($type) { |
|
| 423 | + update_option('_wogh_' . $type . '_started', 'yes'); |
|
| 424 | 424 | $user_id = get_current_user_id(); |
| 425 | - wp_schedule_single_event( time(), 'wogh_' . $type . '', array( $user_id ) ); |
|
| 425 | + wp_schedule_single_event(time(), 'wogh_' . $type . '', array($user_id)); |
|
| 426 | 426 | spawn_cron(); |
| 427 | 427 | } |
| 428 | 428 | } |