@@ -34,7 +34,7 @@ discard block  | 
                                                    ||
| 34 | 34 | *  | 
                                                        
| 35 | 35 | * @param Writing_On_GitHub $app Application container.  | 
                                                        
| 36 | 36 | */  | 
                                                        
| 37 | -	public function __construct( Writing_On_GitHub $app ) { | 
                                                        |
| 37 | +	public function __construct(Writing_On_GitHub $app) { | 
                                                        |
| 38 | 38 | $this->app = $app;  | 
                                                        
| 39 | 39 | }  | 
                                                        
| 40 | 40 | |
@@ -49,8 +49,8 @@ discard block  | 
                                                    ||
| 49 | 49 | $this->raw_data = $this->read_raw_data();  | 
                                                        
| 50 | 50 | |
| 51 | 51 | // Validate request secret.  | 
                                                        
| 52 | - $hash = hash_hmac( 'sha1', $this->raw_data, $this->secret() );  | 
                                                        |
| 53 | -		if ( 'sha1=' . $hash !== $headers['X-Hub-Signature'] ) { | 
                                                        |
| 52 | +		$hash = hash_hmac('sha1', $this->raw_data, $this->secret()); | 
                                                        |
| 53 | +		if ('sha1=' . $hash !== $headers['X-Hub-Signature']) { | 
                                                        |
| 54 | 54 | return false;  | 
                                                        
| 55 | 55 | }  | 
                                                        
| 56 | 56 | |
@@ -90,7 +90,7 @@ discard block  | 
                                                    ||
| 90 | 90 | * @return Writing_On_GitHub_Payload  | 
                                                        
| 91 | 91 | */  | 
                                                        
| 92 | 92 |  	public function payload() { | 
                                                        
| 93 | - return new Writing_On_GitHub_Payload( $this->app, $this->raw_data );  | 
                                                        |
| 93 | + return new Writing_On_GitHub_Payload($this->app, $this->raw_data);  | 
                                                        |
| 94 | 94 | }  | 
                                                        
| 95 | 95 | |
| 96 | 96 | /**  | 
                                                        
@@ -101,11 +101,11 @@ discard block  | 
                                                    ||
| 101 | 101 | * @return array  | 
                                                        
| 102 | 102 | */  | 
                                                        
| 103 | 103 |  	protected function headers() { | 
                                                        
| 104 | -		if ( $this->headers ) { | 
                                                        |
| 104 | +		if ($this->headers) { | 
                                                        |
| 105 | 105 | return $this->headers;  | 
                                                        
| 106 | 106 | }  | 
                                                        
| 107 | 107 | |
| 108 | -		if ( function_exists( 'getallheaders' ) ) { | 
                                                        |
| 108 | +		if (function_exists('getallheaders')) { | 
                                                        |
| 109 | 109 | |
| 110 | 110 | $this->headers = getallheaders();  | 
                                                        
| 111 | 111 | return $this->headers;  | 
                                                        
@@ -115,9 +115,9 @@ discard block  | 
                                                    ||
| 115 | 115 | * @see http://www.php.net/manual/en/function.getallheaders.php  | 
                                                        
| 116 | 116 | */  | 
                                                        
| 117 | 117 | $this->headers = array();  | 
                                                        
| 118 | -		foreach ( $_SERVER as $name => $value ) { | 
                                                        |
| 119 | -			if ( 'HTTP_' === substr( $name, 0, 5 ) ) { | 
                                                        |
| 120 | - $this->headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;  | 
                                                        |
| 118 | +		foreach ($_SERVER as $name => $value) { | 
                                                        |
| 119 | +			if ('HTTP_' === substr($name, 0, 5)) { | 
                                                        |
| 120 | +				$this->headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; | 
                                                        |
| 121 | 121 | }  | 
                                                        
| 122 | 122 | }  | 
                                                        
| 123 | 123 | |
@@ -130,7 +130,7 @@ discard block  | 
                                                    ||
| 130 | 130 | * @return string  | 
                                                        
| 131 | 131 | */  | 
                                                        
| 132 | 132 |  	protected function read_raw_data() { | 
                                                        
| 133 | - return file_get_contents( 'php://input' );  | 
                                                        |
| 133 | +		return file_get_contents('php://input'); | 
                                                        |
| 134 | 134 | }  | 
                                                        
| 135 | 135 | |
| 136 | 136 | /**  | 
                                                        
@@ -139,6 +139,6 @@ discard block  | 
                                                    ||
| 139 | 139 | * @return string  | 
                                                        
| 140 | 140 | */  | 
                                                        
| 141 | 141 |  	protected function secret() { | 
                                                        
| 142 | - return get_option( 'wogh_secret' );  | 
                                                        |
| 142 | +		return get_option('wogh_secret'); | 
                                                        |
| 143 | 143 | }  | 
                                                        
| 144 | 144 | }  | 
                                                        
@@ -29,9 +29,9 @@ discard block  | 
                                                    ||
| 29 | 29 | /**  | 
                                                        
| 30 | 30 | * Updates all of the current posts in the database on master.  | 
                                                        
| 31 | 31 | *  | 
                                                        
| 32 | - * @param bool $force_all  | 
                                                        |
| 33 | - * @return string|WP_Error  | 
                                                        |
| 34 | - */  | 
                                                        |
| 32 | + * @param bool $force_all  | 
                                                        |
| 33 | + * @return string|WP_Error  | 
                                                        |
| 34 | + */  | 
                                                        |
| 35 | 35 |  	public function full( $force_all = false ) { | 
                                                        
| 36 | 36 | $posts = $this->app->database()->fetch_all_supported($force_all);  | 
                                                        
| 37 | 37 | |
@@ -39,24 +39,24 @@ discard block  | 
                                                    ||
| 39 | 39 | return $posts;  | 
                                                        
| 40 | 40 | }  | 
                                                        
| 41 | 41 | |
| 42 | - $error = false;  | 
                                                        |
| 42 | + $error = false;  | 
                                                        |
| 43 | 43 | |
| 44 | -        foreach ( $posts as $post ) { | 
                                                        |
| 45 | - $result = $this->update( $post->id() );  | 
                                                        |
| 46 | -            if ( is_wp_error( $result ) ) { | 
                                                        |
| 47 | -                if ( $error ) { | 
                                                        |
| 48 | - $error->add( $result->get_error_code(), $result->get_error_message() );  | 
                                                        |
| 49 | -                } else { | 
                                                        |
| 50 | - $error = $result;  | 
                                                        |
| 51 | - }  | 
                                                        |
| 52 | - }  | 
                                                        |
| 53 | - }  | 
                                                        |
| 44 | +		foreach ( $posts as $post ) { | 
                                                        |
| 45 | + $result = $this->update( $post->id() );  | 
                                                        |
| 46 | +			if ( is_wp_error( $result ) ) { | 
                                                        |
| 47 | +				if ( $error ) { | 
                                                        |
| 48 | + $error->add( $result->get_error_code(), $result->get_error_message() );  | 
                                                        |
| 49 | +				} else { | 
                                                        |
| 50 | + $error = $result;  | 
                                                        |
| 51 | + }  | 
                                                        |
| 52 | + }  | 
                                                        |
| 53 | + }  | 
                                                        |
| 54 | 54 | |
| 55 | -        if ( is_wp_error( $error ) ) { | 
                                                        |
| 56 | - return $error;  | 
                                                        |
| 57 | - }  | 
                                                        |
| 55 | +		if ( is_wp_error( $error ) ) { | 
                                                        |
| 56 | + return $error;  | 
                                                        |
| 57 | + }  | 
                                                        |
| 58 | 58 | |
| 59 | - return __( 'Export to GitHub completed successfully.', 'writing-on-github' );  | 
                                                        |
| 59 | + return __( 'Export to GitHub completed successfully.', 'writing-on-github' );  | 
                                                        |
| 60 | 60 | }  | 
                                                        
| 61 | 61 | |
| 62 | 62 | |
@@ -22,7 +22,7 @@ discard block  | 
                                                    ||
| 22 | 22 | *  | 
                                                        
| 23 | 23 | * @param Writing_On_GitHub $app Application container.  | 
                                                        
| 24 | 24 | */  | 
                                                        
| 25 | -	public function __construct( Writing_On_GitHub $app ) { | 
                                                        |
| 25 | +	public function __construct(Writing_On_GitHub $app) { | 
                                                        |
| 26 | 26 | $this->app = $app;  | 
                                                        
| 27 | 27 | }  | 
                                                        
| 28 | 28 | |
@@ -32,31 +32,31 @@ discard block  | 
                                                    ||
| 32 | 32 | * @param bool $force_all  | 
                                                        
| 33 | 33 | * @return string|WP_Error  | 
                                                        
| 34 | 34 | */  | 
                                                        
| 35 | -	public function full( $force_all = false ) { | 
                                                        |
| 35 | +	public function full($force_all = false) { | 
                                                        |
| 36 | 36 | $posts = $this->app->database()->fetch_all_supported($force_all);  | 
                                                        
| 37 | 37 | |
| 38 | -		if ( is_wp_error( $posts ) ) { | 
                                                        |
| 38 | +		if (is_wp_error($posts)) { | 
                                                        |
| 39 | 39 | return $posts;  | 
                                                        
| 40 | 40 | }  | 
                                                        
| 41 | 41 | |
| 42 | 42 | $error = false;  | 
                                                        
| 43 | 43 | |
| 44 | -        foreach ( $posts as $post ) { | 
                                                        |
| 45 | - $result = $this->update( $post->id() );  | 
                                                        |
| 46 | -            if ( is_wp_error( $result ) ) { | 
                                                        |
| 47 | -                if ( $error ) { | 
                                                        |
| 48 | - $error->add( $result->get_error_code(), $result->get_error_message() );  | 
                                                        |
| 44 | +        foreach ($posts as $post) { | 
                                                        |
| 45 | + $result = $this->update($post->id());  | 
                                                        |
| 46 | +            if (is_wp_error($result)) { | 
                                                        |
| 47 | +                if ($error) { | 
                                                        |
| 48 | + $error->add($result->get_error_code(), $result->get_error_message());  | 
                                                        |
| 49 | 49 |                  } else { | 
                                                        
| 50 | 50 | $error = $result;  | 
                                                        
| 51 | 51 | }  | 
                                                        
| 52 | 52 | }  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
| 55 | -        if ( is_wp_error( $error ) ) { | 
                                                        |
| 55 | +        if (is_wp_error($error)) { | 
                                                        |
| 56 | 56 | return $error;  | 
                                                        
| 57 | 57 | }  | 
                                                        
| 58 | 58 | |
| 59 | - return __( 'Export to GitHub completed successfully.', 'writing-on-github' );  | 
                                                        |
| 59 | +        return __('Export to GitHub completed successfully.', 'writing-on-github'); | 
                                                        |
| 60 | 60 | }  | 
                                                        
| 61 | 61 | |
| 62 | 62 | |
@@ -65,10 +65,10 @@ discard block  | 
                                                    ||
| 65 | 65 | * @param int $post_id  | 
                                                        
| 66 | 66 | * @return boolean  | 
                                                        
| 67 | 67 | */  | 
                                                        
| 68 | -	protected function github_path( $post_id ) { | 
                                                        |
| 69 | - $github_path = get_post_meta( $post_id, '_wogh_github_path', true );  | 
                                                        |
| 68 | +	protected function github_path($post_id) { | 
                                                        |
| 69 | + $github_path = get_post_meta($post_id, '_wogh_github_path', true);  | 
                                                        |
| 70 | 70 | |
| 71 | -		if ( $github_path && $this->app->api()->fetch()->exists( $github_path ) ) { | 
                                                        |
| 71 | +		if ($github_path && $this->app->api()->fetch()->exists($github_path)) { | 
                                                        |
| 72 | 72 | return $github_path;  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | 74 | |
@@ -82,29 +82,29 @@ discard block  | 
                                                    ||
| 82 | 82 | *  | 
                                                        
| 83 | 83 | * @return string|WP_Error  | 
                                                        
| 84 | 84 | */  | 
                                                        
| 85 | -	public function update( $post_id ) { | 
                                                        |
| 86 | - $post = $this->app->database()->fetch_by_id( $post_id );  | 
                                                        |
| 85 | +	public function update($post_id) { | 
                                                        |
| 86 | + $post = $this->app->database()->fetch_by_id($post_id);  | 
                                                        |
| 87 | 87 | |
| 88 | -		if ( is_wp_error( $post ) ) { | 
                                                        |
| 88 | +		if (is_wp_error($post)) { | 
                                                        |
| 89 | 89 | return $post;  | 
                                                        
| 90 | 90 | }  | 
                                                        
| 91 | 91 | |
| 92 | -		if ( 'trash' === $post->status() ) { | 
                                                        |
| 93 | - return $this->delete( $post_id );  | 
                                                        |
| 92 | +		if ('trash' === $post->status()) { | 
                                                        |
| 93 | + return $this->delete($post_id);  | 
                                                        |
| 94 | 94 | }  | 
                                                        
| 95 | 95 | |
| 96 | -		if ( $old_github_path = $this->github_path( $post->id() ) ) { | 
                                                        |
| 96 | +		if ($old_github_path = $this->github_path($post->id())) { | 
                                                        |
| 97 | 97 |  			error_log("old_github_path: $old_github_path"); | 
                                                        
| 98 | 98 | $post->set_old_github_path($old_github_path);  | 
                                                        
| 99 | 99 | }  | 
                                                        
| 100 | 100 | |
| 101 | - $result = $this->new_posts( array( $post ) );  | 
                                                        |
| 101 | + $result = $this->new_posts(array($post));  | 
                                                        |
| 102 | 102 | |
| 103 | -		if ( is_wp_error( $result ) ) { | 
                                                        |
| 103 | +		if (is_wp_error($result)) { | 
                                                        |
| 104 | 104 | return $result;  | 
                                                        
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
| 107 | - return __( 'Export to GitHub completed successfully.', 'writing-on-github' );  | 
                                                        |
| 107 | +		return __('Export to GitHub completed successfully.', 'writing-on-github'); | 
                                                        |
| 108 | 108 | }  | 
                                                        
| 109 | 109 | |
| 110 | 110 | /**  | 
                                                        
@@ -114,16 +114,16 @@ discard block  | 
                                                    ||
| 114 | 114 | *  | 
                                                        
| 115 | 115 | * @return string|WP_Error  | 
                                                        
| 116 | 116 | */  | 
                                                        
| 117 | -	public function new_posts( array $posts ) { | 
                                                        |
| 117 | +	public function new_posts(array $posts) { | 
                                                        |
| 118 | 118 | $error = false;  | 
                                                        
| 119 | 119 | |
| 120 | 120 | $persist = $this->app->api()->persist();  | 
                                                        
| 121 | 121 | |
| 122 | -		foreach ( $posts as $post ) { | 
                                                        |
| 123 | - $result = $this->new_post( $post, $persist );  | 
                                                        |
| 124 | -			if ( is_wp_error( $result ) ) { | 
                                                        |
| 125 | -				if ( $error ) { | 
                                                        |
| 126 | - $error->add( $result->get_error_code(), $result->get_error_message() );  | 
                                                        |
| 122 | +		foreach ($posts as $post) { | 
                                                        |
| 123 | + $result = $this->new_post($post, $persist);  | 
                                                        |
| 124 | +			if (is_wp_error($result)) { | 
                                                        |
| 125 | +				if ($error) { | 
                                                        |
| 126 | + $error->add($result->get_error_code(), $result->get_error_message());  | 
                                                        |
| 127 | 127 |  				} else { | 
                                                        
| 128 | 128 | $error = $result;  | 
                                                        
| 129 | 129 | }  | 
                                                        
@@ -134,7 +134,7 @@ discard block  | 
                                                    ||
| 134 | 134 | |
| 135 | 135 | // $result = $this->app->api()->persist()->commit( $master );  | 
                                                        
| 136 | 136 | |
| 137 | -		if ( is_wp_error( $error ) ) { | 
                                                        |
| 137 | +		if (is_wp_error($error)) { | 
                                                        |
| 138 | 138 | return $error;  | 
                                                        
| 139 | 139 | }  | 
                                                        
| 140 | 140 | |
@@ -142,13 +142,13 @@ discard block  | 
                                                    ||
| 142 | 142 | return true;  | 
                                                        
| 143 | 143 | }  | 
                                                        
| 144 | 144 | |
| 145 | -	protected function new_post( $post, $persist ) { | 
                                                        |
| 145 | +	protected function new_post($post, $persist) { | 
                                                        |
| 146 | 146 | $github_path = $post->github_path();  | 
                                                        
| 147 | 147 | $old_github_path = $post->old_github_path();  | 
                                                        
| 148 | 148 | $blob = $post->to_blob();  | 
                                                        
| 149 | 149 | $result = false;  | 
                                                        
| 150 | 150 | |
| 151 | -		if ( $old_github_path && $old_github_path != $github_path ) { | 
                                                        |
| 151 | +		if ($old_github_path && $old_github_path != $github_path) { | 
                                                        |
| 152 | 152 | // rename  | 
                                                        
| 153 | 153 | $message = apply_filters(  | 
                                                        
| 154 | 154 | 'wogh_commit_msg_move_post',  | 
                                                        
@@ -156,20 +156,20 @@ discard block  | 
                                                    ||
| 156 | 156 | 'Move %s to %s via WordPress at %s (%s)',  | 
                                                        
| 157 | 157 | $old_github_path, $github_path,  | 
                                                        
| 158 | 158 | site_url(),  | 
                                                        
| 159 | - get_bloginfo( 'name' )  | 
                                                        |
| 159 | +					get_bloginfo('name') | 
                                                        |
| 160 | 160 | )  | 
                                                        
| 161 | 161 | ) . $this->get_commit_msg_tag();  | 
                                                        
| 162 | 162 | |
| 163 | - $result = $persist->delete_file( $post->old_github_path(), $blob->sha(), $message );  | 
                                                        |
| 164 | -			if ( is_wp_error( $result ) ) { | 
                                                        |
| 163 | + $result = $persist->delete_file($post->old_github_path(), $blob->sha(), $message);  | 
                                                        |
| 164 | +			if (is_wp_error($result)) { | 
                                                        |
| 165 | 165 | return $result;  | 
                                                        
| 166 | 166 | }  | 
                                                        
| 167 | 167 | |
| 168 | - $result = $persist->create_file( $blob, $message );  | 
                                                        |
| 169 | -			if ( is_wp_error( $result ) ) { | 
                                                        |
| 168 | + $result = $persist->create_file($blob, $message);  | 
                                                        |
| 169 | +			if (is_wp_error($result)) { | 
                                                        |
| 170 | 170 | return $result;  | 
                                                        
| 171 | 171 | }  | 
                                                        
| 172 | -		} elseif ( ! $old_github_path ) { | 
                                                        |
| 172 | +		} elseif ( ! $old_github_path) { | 
                                                        |
| 173 | 173 | // create new  | 
                                                        
| 174 | 174 | $message = apply_filters(  | 
                                                        
| 175 | 175 | 'wogh_commit_msg_new_post',  | 
                                                        
@@ -177,14 +177,14 @@ discard block  | 
                                                    ||
| 177 | 177 | 'Create new post %s from WordPress at %s (%s)',  | 
                                                        
| 178 | 178 | $github_path,  | 
                                                        
| 179 | 179 | site_url(),  | 
                                                        
| 180 | - get_bloginfo( 'name' )  | 
                                                        |
| 180 | +					get_bloginfo('name') | 
                                                        |
| 181 | 181 | )  | 
                                                        
| 182 | 182 | ) . $this->get_commit_msg_tag();  | 
                                                        
| 183 | - $result = $persist->create_file( $blob, $message );  | 
                                                        |
| 184 | -			if ( is_wp_error( $result ) ) { | 
                                                        |
| 183 | + $result = $persist->create_file($blob, $message);  | 
                                                        |
| 184 | +			if (is_wp_error($result)) { | 
                                                        |
| 185 | 185 | return $result;  | 
                                                        
| 186 | 186 | }  | 
                                                        
| 187 | -		} elseif ( $old_github_path && $old_github_path == $github_path ) { | 
                                                        |
| 187 | +		} elseif ($old_github_path && $old_github_path == $github_path) { | 
                                                        |
| 188 | 188 | // update  | 
                                                        
| 189 | 189 | $message = apply_filters(  | 
                                                        
| 190 | 190 | 'wogh_commit_msg_update_post',  | 
                                                        
@@ -192,11 +192,11 @@ discard block  | 
                                                    ||
| 192 | 192 | 'Update post %s from WordPress at %s (%s)',  | 
                                                        
| 193 | 193 | $github_path,  | 
                                                        
| 194 | 194 | site_url(),  | 
                                                        
| 195 | - get_bloginfo( 'name' )  | 
                                                        |
| 195 | +					get_bloginfo('name') | 
                                                        |
| 196 | 196 | )  | 
                                                        
| 197 | 197 | ) . $this->get_commit_msg_tag();  | 
                                                        
| 198 | - $result = $persist->update_file( $blob, $message );  | 
                                                        |
| 199 | -			if ( is_wp_error( $result ) ) { | 
                                                        |
| 198 | + $result = $persist->update_file($blob, $message);  | 
                                                        |
| 199 | +			if (is_wp_error($result)) { | 
                                                        |
| 200 | 200 | return $result;  | 
                                                        
| 201 | 201 | }  | 
                                                        
| 202 | 202 | }  | 
                                                        
@@ -215,14 +215,14 @@ discard block  | 
                                                    ||
| 215 | 215 | *  | 
                                                        
| 216 | 216 | * @return string|WP_Error  | 
                                                        
| 217 | 217 | */  | 
                                                        
| 218 | -	public function delete( $post_id ) { | 
                                                        |
| 219 | - $post = $this->app->database()->fetch_by_id( $post_id );  | 
                                                        |
| 218 | +	public function delete($post_id) { | 
                                                        |
| 219 | + $post = $this->app->database()->fetch_by_id($post_id);  | 
                                                        |
| 220 | 220 | |
| 221 | -		if ( is_wp_error( $post ) ) { | 
                                                        |
| 221 | +		if (is_wp_error($post)) { | 
                                                        |
| 222 | 222 | return $post;  | 
                                                        
| 223 | 223 | }  | 
                                                        
| 224 | 224 | |
| 225 | - $github_path = get_post_meta( $post_id, '_wogh_github_path', true );  | 
                                                        |
| 225 | + $github_path = get_post_meta($post_id, '_wogh_github_path', true);  | 
                                                        |
| 226 | 226 | |
| 227 | 227 | $message = apply_filters(  | 
                                                        
| 228 | 228 | 'wogh_commit_msg_delete',  | 
                                                        
@@ -230,18 +230,18 @@ discard block  | 
                                                    ||
| 230 | 230 | 'Deleting %s via WordPress at %s (%s)',  | 
                                                        
| 231 | 231 | $github_path,  | 
                                                        
| 232 | 232 | site_url(),  | 
                                                        
| 233 | - get_bloginfo( 'name' )  | 
                                                        |
| 233 | +				get_bloginfo('name') | 
                                                        |
| 234 | 234 | ),  | 
                                                        
| 235 | 235 | $post  | 
                                                        
| 236 | 236 | ) . $this->get_commit_msg_tag();  | 
                                                        
| 237 | 237 | |
| 238 | - $result = $this->app->api()->persist()->delete_file( $github_path, $post->sha(), $message );  | 
                                                        |
| 238 | + $result = $this->app->api()->persist()->delete_file($github_path, $post->sha(), $message);  | 
                                                        |
| 239 | 239 | |
| 240 | -		if ( is_wp_error( $result ) ) { | 
                                                        |
| 240 | +		if (is_wp_error($result)) { | 
                                                        |
| 241 | 241 | return $result;  | 
                                                        
| 242 | 242 | }  | 
                                                        
| 243 | 243 | |
| 244 | - return __( 'Export to GitHub completed successfully.', 'writing-on-github' );  | 
                                                        |
| 244 | +		return __('Export to GitHub completed successfully.', 'writing-on-github'); | 
                                                        |
| 245 | 245 | }  | 
                                                        
| 246 | 246 | |
| 247 | 247 | |
@@ -252,8 +252,8 @@ discard block  | 
                                                    ||
| 252 | 252 | *  | 
                                                        
| 253 | 253 | * @return bool  | 
                                                        
| 254 | 254 | */  | 
                                                        
| 255 | -	public function set_user( $user_id ) { | 
                                                        |
| 256 | - return update_option( self::EXPORT_USER_OPTION, (int) $user_id );  | 
                                                        |
| 255 | +	public function set_user($user_id) { | 
                                                        |
| 256 | + return update_option(self::EXPORT_USER_OPTION, (int) $user_id);  | 
                                                        |
| 257 | 257 | }  | 
                                                        
| 258 | 258 | |
| 259 | 259 | /**  | 
                                                        
@@ -262,10 +262,10 @@ discard block  | 
                                                    ||
| 262 | 262 | * @return string  | 
                                                        
| 263 | 263 | */  | 
                                                        
| 264 | 264 |  	protected function get_commit_msg_tag() { | 
                                                        
| 265 | - $tag = apply_filters( 'wogh_commit_msg_tag', 'wogh' );  | 
                                                        |
| 265 | +		$tag = apply_filters('wogh_commit_msg_tag', 'wogh'); | 
                                                        |
| 266 | 266 | |
| 267 | -		if ( ! $tag ) { | 
                                                        |
| 268 | - throw new Exception( __( 'Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github' ) );  | 
                                                        |
| 267 | +		if ( ! $tag) { | 
                                                        |
| 268 | +			throw new Exception(__('Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github')); | 
                                                        |
| 269 | 269 | }  | 
                                                        
| 270 | 270 | |
| 271 | 271 | return ' - ' . $tag;  | 
                                                        
@@ -126,10 +126,10 @@  | 
                                                    ||
| 126 | 126 | /**  | 
                                                        
| 127 | 127 | * Export all the posts in the database to GitHub.  | 
                                                        
| 128 | 128 | *  | 
                                                        
| 129 | - * @param int $user_id  | 
                                                        |
| 130 | - * @param boolean $force  | 
                                                        |
| 131 | - * @return boolean  | 
                                                        |
| 132 | - */  | 
                                                        |
| 129 | + * @param int $user_id  | 
                                                        |
| 130 | + * @param boolean $force  | 
                                                        |
| 131 | + * @return boolean  | 
                                                        |
| 132 | + */  | 
                                                        |
| 133 | 133 |  	public function export_all( $user_id, $force = false ) { | 
                                                        
| 134 | 134 |  		if ( ! $this->app->semaphore()->is_open() ) { | 
                                                        
| 135 | 135 | return $this->app->response()->error( new WP_Error(  | 
                                                        
@@ -21,7 +21,7 @@ discard block  | 
                                                    ||
| 21 | 21 | *  | 
                                                        
| 22 | 22 | * @param Writing_On_GitHub $app Applicatio container.  | 
                                                        
| 23 | 23 | */  | 
                                                        
| 24 | -	public function __construct( Writing_On_GitHub $app ) { | 
                                                        |
| 24 | +	public function __construct(Writing_On_GitHub $app) { | 
                                                        |
| 25 | 25 | $this->app = $app;  | 
                                                        
| 26 | 26 | }  | 
                                                        
| 27 | 27 | |
@@ -34,57 +34,57 @@ discard block  | 
                                                    ||
| 34 | 34 | */  | 
                                                        
| 35 | 35 |  	public function pull_posts() { | 
                                                        
| 36 | 36 | $this->set_ajax();  | 
                                                        
| 37 | -		if ( ! $this->app->semaphore()->is_open() ) { | 
                                                        |
| 38 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 37 | +		if ( ! $this->app->semaphore()->is_open()) { | 
                                                        |
| 38 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 39 | 39 | 'semaphore_locked',  | 
                                                        
| 40 | - sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::pull_posts()' )  | 
                                                        |
| 41 | - ) );  | 
                                                        |
| 40 | +				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::pull_posts()') | 
                                                        |
| 41 | + ));  | 
                                                        |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
| 44 | -		if ( ! $this->app->request()->is_secret_valid() ) { | 
                                                        |
| 45 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 44 | +		if ( ! $this->app->request()->is_secret_valid()) { | 
                                                        |
| 45 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 46 | 46 | 'invalid_headers',  | 
                                                        
| 47 | - __( 'Failed to validate secret.', 'writing-on-github' )  | 
                                                        |
| 48 | - ) );  | 
                                                        |
| 47 | +				__('Failed to validate secret.', 'writing-on-github') | 
                                                        |
| 48 | + ));  | 
                                                        |
| 49 | 49 | }  | 
                                                        
| 50 | 50 | |
| 51 | 51 | // ping  | 
                                                        
| 52 | -		if ( $this->app->request()->is_ping() ) { | 
                                                        |
| 53 | - return $this->app->response()->success( __( 'Wordpress is ready.', 'writing-on-github' ) );  | 
                                                        |
| 52 | +		if ($this->app->request()->is_ping()) { | 
                                                        |
| 53 | +			return $this->app->response()->success(__('Wordpress is ready.', 'writing-on-github')); | 
                                                        |
| 54 | 54 | }  | 
                                                        
| 55 | 55 | |
| 56 | 56 | // push  | 
                                                        
| 57 | -		if ( ! $this->app->request()->is_push() ) { | 
                                                        |
| 58 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 57 | +		if ( ! $this->app->request()->is_push()) { | 
                                                        |
| 58 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 59 | 59 | 'invalid_headers',  | 
                                                        
| 60 | - __( 'Failed to validate webhook event.', 'writing-on-github' )  | 
                                                        |
| 61 | - ) );  | 
                                                        |
| 60 | +				__('Failed to validate webhook event.', 'writing-on-github') | 
                                                        |
| 61 | + ));  | 
                                                        |
| 62 | 62 | }  | 
                                                        
| 63 | 63 | $payload = $this->app->request()->payload();  | 
                                                        
| 64 | 64 | |
| 65 | -		if ( ! $payload->should_import() ) { | 
                                                        |
| 66 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 65 | +		if ( ! $payload->should_import()) { | 
                                                        |
| 66 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 67 | 67 | 'invalid_payload',  | 
                                                        
| 68 | 68 | sprintf(  | 
                                                        
| 69 | - __( "%s won't be imported.", 'writing-on-github' ),  | 
                                                        |
| 70 | - strtolower( $payload->get_commit_id() ) ? : '[Missing Commit ID]'  | 
                                                        |
| 69 | +					__("%s won't be imported.", 'writing-on-github'), | 
                                                        |
| 70 | + strtolower($payload->get_commit_id()) ?: '[Missing Commit ID]'  | 
                                                        |
| 71 | 71 | )  | 
                                                        
| 72 | - ) );  | 
                                                        |
| 72 | + ));  | 
                                                        |
| 73 | 73 | }  | 
                                                        
| 74 | 74 | |
| 75 | 75 | $this->app->semaphore()->lock();  | 
                                                        
| 76 | - remove_action( 'save_post', array( $this, 'export_post' ) );  | 
                                                        |
| 77 | - remove_action( 'delete_post', array( $this, 'delete_post' ) );  | 
                                                        |
| 76 | +		remove_action('save_post', array($this, 'export_post')); | 
                                                        |
| 77 | +		remove_action('delete_post', array($this, 'delete_post')); | 
                                                        |
| 78 | 78 | |
| 79 | - $result = $this->app->import()->payload( $payload );  | 
                                                        |
| 79 | + $result = $this->app->import()->payload($payload);  | 
                                                        |
| 80 | 80 | |
| 81 | 81 | $this->app->semaphore()->unlock();  | 
                                                        
| 82 | 82 | |
| 83 | -		if ( is_wp_error( $result ) ) { | 
                                                        |
| 84 | - return $this->app->response()->error( $result );  | 
                                                        |
| 83 | +		if (is_wp_error($result)) { | 
                                                        |
| 84 | + return $this->app->response()->error($result);  | 
                                                        |
| 85 | 85 | }  | 
                                                        
| 86 | 86 | |
| 87 | - return $this->app->response()->success( $result );  | 
                                                        |
| 87 | + return $this->app->response()->success($result);  | 
                                                        |
| 88 | 88 | }  | 
                                                        
| 89 | 89 | |
| 90 | 90 | /**  | 
                                                        
@@ -92,35 +92,35 @@ discard block  | 
                                                    ||
| 92 | 92 | *  | 
                                                        
| 93 | 93 | * @return boolean  | 
                                                        
| 94 | 94 | */  | 
                                                        
| 95 | -	public function import_master( $user_id ) { | 
                                                        |
| 96 | -		if ( ! $this->app->semaphore()->is_open() ) { | 
                                                        |
| 97 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 95 | +	public function import_master($user_id) { | 
                                                        |
| 96 | +		if ( ! $this->app->semaphore()->is_open()) { | 
                                                        |
| 97 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 98 | 98 | 'semaphore_locked',  | 
                                                        
| 99 | - sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::import_master()' )  | 
                                                        |
| 100 | - ) );  | 
                                                        |
| 99 | +				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::import_master()') | 
                                                        |
| 100 | + ));  | 
                                                        |
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
| 103 | 103 | $this->app->semaphore()->lock();  | 
                                                        
| 104 | - remove_action( 'save_post', array( $this, 'export_post' ) );  | 
                                                        |
| 105 | - remove_action( 'save_post', array( $this, 'delete_post' ) );  | 
                                                        |
| 104 | +		remove_action('save_post', array($this, 'export_post')); | 
                                                        |
| 105 | +		remove_action('save_post', array($this, 'delete_post')); | 
                                                        |
| 106 | 106 | |
| 107 | -		if ( $user_id ) { | 
                                                        |
| 108 | - wp_set_current_user( $user_id );  | 
                                                        |
| 107 | +		if ($user_id) { | 
                                                        |
| 108 | + wp_set_current_user($user_id);  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | $result = $this->app->import()->master();  | 
                                                        
| 112 | 112 | |
| 113 | 113 | $this->app->semaphore()->unlock();  | 
                                                        
| 114 | 114 | |
| 115 | -		if ( is_wp_error( $result ) ) { | 
                                                        |
| 116 | - update_option( '_wogh_import_error', $result->get_error_message() );  | 
                                                        |
| 115 | +		if (is_wp_error($result)) { | 
                                                        |
| 116 | +			update_option('_wogh_import_error', $result->get_error_message()); | 
                                                        |
| 117 | 117 | |
| 118 | - return $this->app->response()->error( $result );  | 
                                                        |
| 118 | + return $this->app->response()->error($result);  | 
                                                        |
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
| 121 | - update_option( '_wogh_import_complete', 'yes' );  | 
                                                        |
| 121 | +		update_option('_wogh_import_complete', 'yes'); | 
                                                        |
| 122 | 122 | |
| 123 | - return $this->app->response()->success( $result );  | 
                                                        |
| 123 | + return $this->app->response()->success($result);  | 
                                                        |
| 124 | 124 | }  | 
                                                        
| 125 | 125 | |
| 126 | 126 | /**  | 
                                                        
@@ -130,33 +130,33 @@ discard block  | 
                                                    ||
| 130 | 130 | * @param boolean $force  | 
                                                        
| 131 | 131 | * @return boolean  | 
                                                        
| 132 | 132 | */  | 
                                                        
| 133 | -	public function export_all( $user_id, $force = false ) { | 
                                                        |
| 134 | -		if ( ! $this->app->semaphore()->is_open() ) { | 
                                                        |
| 135 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 133 | +	public function export_all($user_id, $force = false) { | 
                                                        |
| 134 | +		if ( ! $this->app->semaphore()->is_open()) { | 
                                                        |
| 135 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 136 | 136 | 'semaphore_locked',  | 
                                                        
| 137 | - sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::export_all()' )  | 
                                                        |
| 138 | - ) );  | 
                                                        |
| 137 | +				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::export_all()') | 
                                                        |
| 138 | + ));  | 
                                                        |
| 139 | 139 | }  | 
                                                        
| 140 | 140 | |
| 141 | 141 | $this->app->semaphore()->lock();  | 
                                                        
| 142 | 142 | |
| 143 | -		if ( $user_id ) { | 
                                                        |
| 144 | - wp_set_current_user( $user_id );  | 
                                                        |
| 143 | +		if ($user_id) { | 
                                                        |
| 144 | + wp_set_current_user($user_id);  | 
                                                        |
| 145 | 145 | }  | 
                                                        
| 146 | 146 | |
| 147 | 147 | $result = $this->app->export()->full($force);  | 
                                                        
| 148 | 148 | $this->app->semaphore()->unlock();  | 
                                                        
| 149 | 149 | |
| 150 | 150 | // Maybe move option updating out of this class/upgrade message display?  | 
                                                        
| 151 | -		if ( is_wp_error( $result ) ) { | 
                                                        |
| 152 | - update_option( '_wogh_export_error', $result->get_error_message() );  | 
                                                        |
| 151 | +		if (is_wp_error($result)) { | 
                                                        |
| 152 | +			update_option('_wogh_export_error', $result->get_error_message()); | 
                                                        |
| 153 | 153 | |
| 154 | - return $this->app->response()->error( $result );  | 
                                                        |
| 154 | + return $this->app->response()->error($result);  | 
                                                        |
| 155 | 155 |  		} else { | 
                                                        
| 156 | - update_option( '_wogh_export_complete', 'yes' );  | 
                                                        |
| 157 | - update_option( '_wogh_fully_exported', 'yes' );  | 
                                                        |
| 156 | +			update_option('_wogh_export_complete', 'yes'); | 
                                                        |
| 157 | +			update_option('_wogh_fully_exported', 'yes'); | 
                                                        |
| 158 | 158 | |
| 159 | - return $this->app->response()->success( $result );  | 
                                                        |
| 159 | + return $this->app->response()->success($result);  | 
                                                        |
| 160 | 160 | }  | 
                                                        
| 161 | 161 | }  | 
                                                        
| 162 | 162 | |
@@ -169,27 +169,27 @@ discard block  | 
                                                    ||
| 169 | 169 | *  | 
                                                        
| 170 | 170 | * @return boolean  | 
                                                        
| 171 | 171 | */  | 
                                                        
| 172 | -	public function export_post( $post_id ) { | 
                                                        |
| 173 | -		if ( wp_is_post_revision( $post_id ) ) { | 
                                                        |
| 172 | +	public function export_post($post_id) { | 
                                                        |
| 173 | +		if (wp_is_post_revision($post_id)) { | 
                                                        |
| 174 | 174 | return;  | 
                                                        
| 175 | 175 | }  | 
                                                        
| 176 | 176 | |
| 177 | -		if ( ! $this->app->semaphore()->is_open() ) { | 
                                                        |
| 178 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 177 | +		if ( ! $this->app->semaphore()->is_open()) { | 
                                                        |
| 178 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 179 | 179 | 'semaphore_locked',  | 
                                                        
| 180 | - sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::export_post()' )  | 
                                                        |
| 181 | - ) );  | 
                                                        |
| 180 | +				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::export_post()') | 
                                                        |
| 181 | + ));  | 
                                                        |
| 182 | 182 | }  | 
                                                        
| 183 | 183 | |
| 184 | 184 | $this->app->semaphore()->lock();  | 
                                                        
| 185 | - $result = $this->app->export()->update( $post_id );  | 
                                                        |
| 185 | + $result = $this->app->export()->update($post_id);  | 
                                                        |
| 186 | 186 | $this->app->semaphore()->unlock();  | 
                                                        
| 187 | 187 | |
| 188 | -		if ( is_wp_error( $result ) ) { | 
                                                        |
| 189 | - return $this->app->response()->error( $result );  | 
                                                        |
| 188 | +		if (is_wp_error($result)) { | 
                                                        |
| 189 | + return $this->app->response()->error($result);  | 
                                                        |
| 190 | 190 | }  | 
                                                        
| 191 | 191 | |
| 192 | - return $this->app->response()->success( $result );  | 
                                                        |
| 192 | + return $this->app->response()->success($result);  | 
                                                        |
| 193 | 193 | }  | 
                                                        
| 194 | 194 | |
| 195 | 195 | /**  | 
                                                        
@@ -201,27 +201,27 @@ discard block  | 
                                                    ||
| 201 | 201 | *  | 
                                                        
| 202 | 202 | * @return boolean  | 
                                                        
| 203 | 203 | */  | 
                                                        
| 204 | -	public function delete_post( $post_id ) { | 
                                                        |
| 205 | -		if ( wp_is_post_revision( $post_id ) ) { | 
                                                        |
| 204 | +	public function delete_post($post_id) { | 
                                                        |
| 205 | +		if (wp_is_post_revision($post_id)) { | 
                                                        |
| 206 | 206 | return;  | 
                                                        
| 207 | 207 | }  | 
                                                        
| 208 | 208 | |
| 209 | -		if ( ! $this->app->semaphore()->is_open() ) { | 
                                                        |
| 210 | - return $this->app->response()->error( new WP_Error(  | 
                                                        |
| 209 | +		if ( ! $this->app->semaphore()->is_open()) { | 
                                                        |
| 210 | + return $this->app->response()->error(new WP_Error(  | 
                                                        |
| 211 | 211 | 'semaphore_locked',  | 
                                                        
| 212 | - sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'writing-on-github' ), 'Controller::delete_post()' )  | 
                                                        |
| 213 | - ) );  | 
                                                        |
| 212 | +				sprintf(__('%s : Semaphore is locked, import/export already in progress.', 'writing-on-github'), 'Controller::delete_post()') | 
                                                        |
| 213 | + ));  | 
                                                        |
| 214 | 214 | }  | 
                                                        
| 215 | 215 | |
| 216 | 216 | $this->app->semaphore()->lock();  | 
                                                        
| 217 | - $result = $this->app->export()->delete( $post_id );  | 
                                                        |
| 217 | + $result = $this->app->export()->delete($post_id);  | 
                                                        |
| 218 | 218 | $this->app->semaphore()->unlock();  | 
                                                        
| 219 | 219 | |
| 220 | -		if ( is_wp_error( $result ) ) { | 
                                                        |
| 221 | - return $this->app->response()->error( $result );  | 
                                                        |
| 220 | +		if (is_wp_error($result)) { | 
                                                        |
| 221 | + return $this->app->response()->error($result);  | 
                                                        |
| 222 | 222 | }  | 
                                                        
| 223 | 223 | |
| 224 | - return $this->app->response()->success( $result );  | 
                                                        |
| 224 | + return $this->app->response()->success($result);  | 
                                                        |
| 225 | 225 | }  | 
                                                        
| 226 | 226 | |
| 227 | 227 | /**  | 
                                                        
@@ -230,8 +230,8 @@ discard block  | 
                                                    ||
| 230 | 230 | * than just returning data.  | 
                                                        
| 231 | 231 | */  | 
                                                        
| 232 | 232 |  	protected function set_ajax() { | 
                                                        
| 233 | -		if ( ! defined( 'WOGH_AJAX' ) ) { | 
                                                        |
| 234 | - define( 'WOGH_AJAX', true );  | 
                                                        |
| 233 | +		if ( ! defined('WOGH_AJAX')) { | 
                                                        |
| 234 | +			define('WOGH_AJAX', true); | 
                                                        |
| 235 | 235 | }  | 
                                                        
| 236 | 236 | }  | 
                                                        
| 237 | 237 | }  | 
                                                        
@@ -16,9 +16,9 @@ discard block  | 
                                                    ||
| 16 | 16 | */  | 
                                                        
| 17 | 17 |  	protected function export_user() { | 
                                                        
| 18 | 18 | $user_id = get_current_user_id();  | 
                                                        
| 19 | - $user = get_userdata( $user_id );  | 
                                                        |
| 19 | + $user = get_userdata($user_id);  | 
                                                        |
| 20 | 20 | |
| 21 | -		if ( $user ) { | 
                                                        |
| 21 | +		if ($user) { | 
                                                        |
| 22 | 22 | return array(  | 
                                                        
| 23 | 23 | 'name' => $user->display_name,  | 
                                                        
| 24 | 24 | 'email' => $user->user_email,  | 
                                                        
@@ -33,17 +33,17 @@ discard block  | 
                                                    ||
| 33 | 33 | *  | 
                                                        
| 34 | 34 | * @return array  | 
                                                        
| 35 | 35 | */  | 
                                                        
| 36 | -	public function delete_file( $path, $sha, $message ) { | 
                                                        |
| 36 | +	public function delete_file($path, $sha, $message) { | 
                                                        |
| 37 | 37 | $body = new stdClass();  | 
                                                        
| 38 | 38 | $body->message = $message;  | 
                                                        
| 39 | 39 | $body->sha = $sha;  | 
                                                        
| 40 | 40 | $body->branch = $this->branch();  | 
                                                        
| 41 | 41 | |
| 42 | -		if ( $author = $this->export_user() ) { | 
                                                        |
| 42 | +		if ($author = $this->export_user()) { | 
                                                        |
| 43 | 43 | $body->author = $author;  | 
                                                        
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | - return $this->call( 'DELETE', $this->content_endpoint( $path ), $body );  | 
                                                        |
| 46 | +		return $this->call('DELETE', $this->content_endpoint($path), $body); | 
                                                        |
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | 49 | /**  | 
                                                        
@@ -51,17 +51,17 @@ discard block  | 
                                                    ||
| 51 | 51 | *  | 
                                                        
| 52 | 52 | * @return array  | 
                                                        
| 53 | 53 | */  | 
                                                        
| 54 | -	public function create_file( $blob, $message ) { | 
                                                        |
| 54 | +	public function create_file($blob, $message) { | 
                                                        |
| 55 | 55 | $body = $blob->to_body();  | 
                                                        
| 56 | 56 | $body->message = $message;  | 
                                                        
| 57 | 57 | $body->branch = $this->branch();  | 
                                                        
| 58 | 58 | unset($body->sha);  | 
                                                        
| 59 | 59 | |
| 60 | -		if ( $author = $this->export_user() ) { | 
                                                        |
| 60 | +		if ($author = $this->export_user()) { | 
                                                        |
| 61 | 61 | $body->author = $author;  | 
                                                        
| 62 | 62 | }  | 
                                                        
| 63 | 63 | |
| 64 | - return $this->call( 'PUT', $this->content_endpoint( $blob->path() ), $body );  | 
                                                        |
| 64 | +		return $this->call('PUT', $this->content_endpoint($blob->path()), $body); | 
                                                        |
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | 67 | /**  | 
                                                        
@@ -69,15 +69,15 @@ discard block  | 
                                                    ||
| 69 | 69 | *  | 
                                                        
| 70 | 70 | * @return array  | 
                                                        
| 71 | 71 | */  | 
                                                        
| 72 | -	public function update_file( $blob, $message ) { | 
                                                        |
| 72 | +	public function update_file($blob, $message) { | 
                                                        |
| 73 | 73 | $body = $blob->to_body();  | 
                                                        
| 74 | 74 | $body->message = $message;  | 
                                                        
| 75 | 75 | $body->branch = $this->branch();  | 
                                                        
| 76 | 76 | |
| 77 | -		if ( $author = $this->export_user() ) { | 
                                                        |
| 77 | +		if ($author = $this->export_user()) { | 
                                                        |
| 78 | 78 | $body->author = $author;  | 
                                                        
| 79 | 79 | }  | 
                                                        
| 80 | 80 | |
| 81 | - return $this->call( 'PUT', $this->content_endpoint( $blob->path() ), $body );  | 
                                                        |
| 81 | +		return $this->call('PUT', $this->content_endpoint($blob->path()), $body); | 
                                                        |
| 82 | 82 | }  | 
                                                        
| 83 | 83 | }  | 
                                                        
@@ -26,7 +26,7 @@ discard block  | 
                                                    ||
| 26 | 26 | *  | 
                                                        
| 27 | 27 | * @param Writing_On_GitHub $app Application container.  | 
                                                        
| 28 | 28 | */  | 
                                                        
| 29 | -	public function __construct( Writing_On_GitHub $app ) { | 
                                                        |
| 29 | +	public function __construct(Writing_On_GitHub $app) { | 
                                                        |
| 30 | 30 | $this->app = $app;  | 
                                                        
| 31 | 31 | }  | 
                                                        
| 32 | 32 | |
@@ -39,8 +39,8 @@ discard block  | 
                                                    ||
| 39 | 39 | *  | 
                                                        
| 40 | 40 | * @return stdClass|WP_Error  | 
                                                        
| 41 | 41 | */  | 
                                                        
| 42 | -	protected function call( $method, $endpoint, $body = array() ) { | 
                                                        |
| 43 | -		if ( is_wp_error( $error = $this->can_call() ) ) { | 
                                                        |
| 42 | +	protected function call($method, $endpoint, $body = array()) { | 
                                                        |
| 43 | +		if (is_wp_error($error = $this->can_call())) { | 
                                                        |
| 44 | 44 | return $error;  | 
                                                        
| 45 | 45 | }  | 
                                                        
| 46 | 46 | |
@@ -51,24 +51,23 @@ discard block  | 
                                                    ||
| 51 | 51 | ),  | 
                                                        
| 52 | 52 | );  | 
                                                        
| 53 | 53 | |
| 54 | -		if ( 'GET' !== $method ) { | 
                                                        |
| 55 | - $args['body'] = function_exists( 'wp_json_encode' ) ?  | 
                                                        |
| 56 | - wp_json_encode( $body ) :  | 
                                                        |
| 57 | - json_encode( $body );  | 
                                                        |
| 54 | +		if ('GET' !== $method) { | 
                                                        |
| 55 | +			$args['body'] = function_exists('wp_json_encode') ? | 
                                                        |
| 56 | + wp_json_encode($body) : json_encode($body);  | 
                                                        |
| 58 | 57 | }  | 
                                                        
| 59 | 58 | |
| 60 | 59 | $tmpbody = isset($args['body']) ? $args['body'] : '';  | 
                                                        
| 61 | 60 |  		error_log("writing-on-github-call $method $endpoint $tmpbody"); | 
                                                        
| 62 | 61 | |
| 63 | - $response = wp_remote_request( $endpoint, $args );  | 
                                                        |
| 64 | - $status = wp_remote_retrieve_header( $response, 'status' );  | 
                                                        |
| 65 | - $body = json_decode( wp_remote_retrieve_body( $response ) );  | 
                                                        |
| 62 | + $response = wp_remote_request($endpoint, $args);  | 
                                                        |
| 63 | + $status = wp_remote_retrieve_header($response, 'status');  | 
                                                        |
| 64 | + $body = json_decode(wp_remote_retrieve_body($response));  | 
                                                        |
| 66 | 65 | |
| 67 | -		if ( '2' !== substr( $status, 0, 1 ) && '3' !== substr( $status, 0, 1 ) ) { | 
                                                        |
| 66 | +		if ('2' !== substr($status, 0, 1) && '3' !== substr($status, 0, 1)) { | 
                                                        |
| 68 | 67 | return new WP_Error(  | 
                                                        
| 69 | - strtolower( str_replace( ' ', '_', $status ) ),  | 
                                                        |
| 68 | +				strtolower(str_replace(' ', '_', $status)), | 
                                                        |
| 70 | 69 | sprintf(  | 
                                                        
| 71 | - __( 'Method %s to endpoint %s failed with error: %s', 'writing-on-github' ),  | 
                                                        |
| 70 | +					__('Method %s to endpoint %s failed with error: %s', 'writing-on-github'), | 
                                                        |
| 72 | 71 | $method,  | 
                                                        
| 73 | 72 | $endpoint,  | 
                                                        
| 74 | 73 | $body && $body->message ? $body->message : 'Unknown error'  | 
                                                        
@@ -85,28 +84,28 @@ discard block  | 
                                                    ||
| 85 | 84 | * @return true|WP_Error  | 
                                                        
| 86 | 85 | */  | 
                                                        
| 87 | 86 |  	protected function can_call() { | 
                                                        
| 88 | -		if ( ! $this->oauth_token() ) { | 
                                                        |
| 87 | +		if ( ! $this->oauth_token()) { | 
                                                        |
| 89 | 88 | return new WP_Error(  | 
                                                        
| 90 | 89 | 'missing_token',  | 
                                                        
| 91 | - __( 'Writing On GitHub needs an auth token. Please update your settings.', 'writing-on-github' )  | 
                                                        |
| 90 | +				__('Writing On GitHub needs an auth token. Please update your settings.', 'writing-on-github') | 
                                                        |
| 92 | 91 | );  | 
                                                        
| 93 | 92 | }  | 
                                                        
| 94 | 93 | |
| 95 | 94 | $repo = $this->repository();  | 
                                                        
| 96 | 95 | |
| 97 | -		if ( ! $repo ) { | 
                                                        |
| 96 | +		if ( ! $repo) { | 
                                                        |
| 98 | 97 | return new WP_Error(  | 
                                                        
| 99 | 98 | 'missing_repository',  | 
                                                        
| 100 | - __( 'Writing On GitHub needs a repository. Please update your settings.', 'writing-on-github' )  | 
                                                        |
| 99 | +				__('Writing On GitHub needs a repository. Please update your settings.', 'writing-on-github') | 
                                                        |
| 101 | 100 | );  | 
                                                        
| 102 | 101 | }  | 
                                                        
| 103 | 102 | |
| 104 | - $parts = explode( '/', $repo );  | 
                                                        |
| 103 | +		$parts = explode('/', $repo); | 
                                                        |
| 105 | 104 | |
| 106 | -		if ( 2 !== count( $parts ) ) { | 
                                                        |
| 105 | +		if (2 !== count($parts)) { | 
                                                        |
| 107 | 106 | return new WP_Error(  | 
                                                        
| 108 | 107 | 'malformed_repository',  | 
                                                        
| 109 | - __( 'Writing On GitHub needs a properly formed repository. Please update your settings.', 'writing-on-github' )  | 
                                                        |
| 108 | +				__('Writing On GitHub needs a properly formed repository. Please update your settings.', 'writing-on-github') | 
                                                        |
| 110 | 109 | );  | 
                                                        
| 111 | 110 | }  | 
                                                        
| 112 | 111 | |
@@ -119,7 +118,7 @@ discard block  | 
                                                    ||
| 119 | 118 | * @return string  | 
                                                        
| 120 | 119 | */  | 
                                                        
| 121 | 120 |  	public function repository() { | 
                                                        
| 122 | - return (string) get_option( self::REPO_OPTION_KEY );  | 
                                                        |
| 121 | + return (string) get_option(self::REPO_OPTION_KEY);  | 
                                                        |
| 123 | 122 | }  | 
                                                        
| 124 | 123 | |
| 125 | 124 | /**  | 
                                                        
@@ -128,18 +127,18 @@ discard block  | 
                                                    ||
| 128 | 127 | * @return string  | 
                                                        
| 129 | 128 | */  | 
                                                        
| 130 | 129 |  	public function oauth_token() { | 
                                                        
| 131 | - return (string) get_option( self::TOKEN_OPTION_KEY );  | 
                                                        |
| 130 | + return (string) get_option(self::TOKEN_OPTION_KEY);  | 
                                                        |
| 132 | 131 | }  | 
                                                        
| 133 | 132 | |
| 134 | 133 | /**  | 
                                                        
| 135 | 134 | * Returns the GitHub host to sync with (for GitHub Enterprise support)  | 
                                                        
| 136 | 135 | */  | 
                                                        
| 137 | 136 |  	public function api_base() { | 
                                                        
| 138 | - return get_option( self::HOST_OPTION_KEY );  | 
                                                        |
| 137 | + return get_option(self::HOST_OPTION_KEY);  | 
                                                        |
| 139 | 138 | }  | 
                                                        
| 140 | 139 | |
| 141 | 140 |  	public function branch() { | 
                                                        
| 142 | - $branch = get_option( self::BRANCH_OPTION_KEY );  | 
                                                        |
| 141 | + $branch = get_option(self::BRANCH_OPTION_KEY);  | 
                                                        |
| 143 | 142 | return $branch ? $branch : 'master';  | 
                                                        
| 144 | 143 | }  | 
                                                        
| 145 | 144 | |
@@ -200,11 +199,11 @@ discard block  | 
                                                    ||
| 200 | 199 | *  | 
                                                        
| 201 | 200 | * Returns String the relative API call path  | 
                                                        
| 202 | 201 | */  | 
                                                        
| 203 | -	public function content_endpoint( $path = false ) { | 
                                                        |
| 202 | +	public function content_endpoint($path = false) { | 
                                                        |
| 204 | 203 | $url = $this->api_base() . '/repos/';  | 
                                                        
| 205 | 204 | $url = $url . $this->repository() . '/contents';  | 
                                                        
| 206 | 205 | |
| 207 | -		if ( ! empty($path) ) { | 
                                                        |
| 206 | +		if ( ! empty($path)) { | 
                                                        |
| 208 | 207 | $url .= '/' . $path;  | 
                                                        
| 209 | 208 | }  | 
                                                        
| 210 | 209 | |
@@ -42,9 +42,9 @@ discard block  | 
                                                    ||
| 42 | 42 | /**  | 
                                                        
| 43 | 43 | * Queries the database for all of the supported posts.  | 
                                                        
| 44 | 44 | *  | 
                                                        
| 45 | - * @param bool $force  | 
                                                        |
| 46 | - * @return Writing_On_GitHub_Post[]|WP_Error  | 
                                                        |
| 47 | - */  | 
                                                        |
| 45 | + * @param bool $force  | 
                                                        |
| 46 | + * @return Writing_On_GitHub_Post[]|WP_Error  | 
                                                        |
| 47 | + */  | 
                                                        |
| 48 | 48 |  	public function fetch_all_supported( $force = false ) { | 
                                                        
| 49 | 49 | $args = array(  | 
                                                        
| 50 | 50 | 'post_type' => $this->get_whitelisted_post_types(),  | 
                                                        
@@ -187,45 +187,45 @@ discard block  | 
                                                    ||
| 187 | 187 | |
| 188 | 188 | // update tags  | 
                                                        
| 189 | 189 |  		if ( isset( $meta['tags'] ) && $meta['tags'] ) { | 
                                                        
| 190 | - $args['tags_input'] = $meta['tags'];  | 
                                                        |
| 190 | + $args['tags_input'] = $meta['tags'];  | 
                                                        |
| 191 | 191 | }  | 
                                                        
| 192 | 192 | |
| 193 | 193 | // update categories  | 
                                                        
| 194 | 194 |  		if ( isset( $meta['categories'] ) && $meta['categories'] ) { | 
                                                        
| 195 | - $categories = $meta['categories'];  | 
                                                        |
| 196 | -		    if (!is_array($categories)) { | 
                                                        |
| 197 | - $categories = array($categories);  | 
                                                        |
| 198 | - }  | 
                                                        |
| 199 | - $terms = get_terms(array(  | 
                                                        |
| 200 | - 'taxonomy' => 'category',  | 
                                                        |
| 201 | - 'fields' => 'id=>name',  | 
                                                        |
| 202 | - 'hide_empty' => 0,  | 
                                                        |
| 203 | - 'name' => $categories  | 
                                                        |
| 204 | - )  | 
                                                        |
| 205 | - );  | 
                                                        |
| 206 | - $map = array();  | 
                                                        |
| 207 | -		    foreach ($categories as $name) { | 
                                                        |
| 208 | - $map[$name] = 1;  | 
                                                        |
| 209 | - }  | 
                                                        |
| 210 | -  | 
                                                        |
| 211 | - $ids = array();  | 
                                                        |
| 212 | -		    if (!empty($terms)) { | 
                                                        |
| 213 | -		        foreach ($terms as $id => $name) { | 
                                                        |
| 214 | - $ids[] = $id;  | 
                                                        |
| 215 | - unset($map[$name]);  | 
                                                        |
| 216 | - }  | 
                                                        |
| 217 | - }  | 
                                                        |
| 218 | -  | 
                                                        |
| 219 | - // create new terms  | 
                                                        |
| 220 | -		    if (!empty($map)) { | 
                                                        |
| 221 | -		        foreach ($map as $name => $value) { | 
                                                        |
| 222 | -		            $term = wp_insert_term($name, 'category', array('parent' => 0)); | 
                                                        |
| 223 | -		            // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); | 
                                                        |
| 224 | - $ids[] = $term['term_id'];  | 
                                                        |
| 225 | - }  | 
                                                        |
| 226 | - }  | 
                                                        |
| 227 | -  | 
                                                        |
| 228 | - $args['post_category'] = $ids;  | 
                                                        |
| 195 | + $categories = $meta['categories'];  | 
                                                        |
| 196 | +			if (!is_array($categories)) { | 
                                                        |
| 197 | + $categories = array($categories);  | 
                                                        |
| 198 | + }  | 
                                                        |
| 199 | + $terms = get_terms(array(  | 
                                                        |
| 200 | + 'taxonomy' => 'category',  | 
                                                        |
| 201 | + 'fields' => 'id=>name',  | 
                                                        |
| 202 | + 'hide_empty' => 0,  | 
                                                        |
| 203 | + 'name' => $categories  | 
                                                        |
| 204 | + )  | 
                                                        |
| 205 | + );  | 
                                                        |
| 206 | + $map = array();  | 
                                                        |
| 207 | +			foreach ($categories as $name) { | 
                                                        |
| 208 | + $map[$name] = 1;  | 
                                                        |
| 209 | + }  | 
                                                        |
| 210 | +  | 
                                                        |
| 211 | + $ids = array();  | 
                                                        |
| 212 | +			if (!empty($terms)) { | 
                                                        |
| 213 | +				foreach ($terms as $id => $name) { | 
                                                        |
| 214 | + $ids[] = $id;  | 
                                                        |
| 215 | + unset($map[$name]);  | 
                                                        |
| 216 | + }  | 
                                                        |
| 217 | + }  | 
                                                        |
| 218 | +  | 
                                                        |
| 219 | + // create new terms  | 
                                                        |
| 220 | +			if (!empty($map)) { | 
                                                        |
| 221 | +				foreach ($map as $name => $value) { | 
                                                        |
| 222 | +					$term = wp_insert_term($name, 'category', array('parent' => 0)); | 
                                                        |
| 223 | +					// array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); | 
                                                        |
| 224 | + $ids[] = $term['term_id'];  | 
                                                        |
| 225 | + }  | 
                                                        |
| 226 | + }  | 
                                                        |
| 227 | +  | 
                                                        |
| 228 | + $args['post_category'] = $ids;  | 
                                                        |
| 229 | 229 | }  | 
                                                        
| 230 | 230 | |
| 231 | 231 | return $args;  | 
                                                        
@@ -427,12 +427,12 @@ discard block  | 
                                                    ||
| 427 | 427 |  		if ( ! empty( $display_name ) ) { | 
                                                        
| 428 | 428 | $search_string = esc_attr( $display_name );  | 
                                                        
| 429 | 429 | $query = new WP_User_Query( array(  | 
                                                        
| 430 | -			    'search'         => "{$search_string}", | 
                                                        |
| 431 | - 'search_columns' => array(  | 
                                                        |
| 432 | - 'display_name',  | 
                                                        |
| 433 | - 'user_nicename',  | 
                                                        |
| 434 | - 'user_login',  | 
                                                        |
| 435 | - )  | 
                                                        |
| 430 | +				'search'         => "{$search_string}", | 
                                                        |
| 431 | + 'search_columns' => array(  | 
                                                        |
| 432 | + 'display_name',  | 
                                                        |
| 433 | + 'user_nicename',  | 
                                                        |
| 434 | + 'user_login',  | 
                                                        |
| 435 | + )  | 
                                                        |
| 436 | 436 | ) );  | 
                                                        
| 437 | 437 | $users = $query->get_results();  | 
                                                        
| 438 | 438 | $user = empty($users) ? false : $users[0];  | 
                                                        
@@ -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,32 +45,32 @@ discard block  | 
                                                    ||
| 45 | 45 | * @param bool $force  | 
                                                        
| 46 | 46 | * @return Writing_On_GitHub_Post[]|WP_Error  | 
                                                        
| 47 | 47 | */  | 
                                                        
| 48 | -	public function fetch_all_supported( $force = false ) { | 
                                                        |
| 49 | - $args = array(  | 
                                                        |
| 48 | +	public function fetch_all_supported($force = false) { | 
                                                        |
| 49 | + $args = array(  | 
                                                        |
| 50 | 50 | 'post_type' => $this->get_whitelisted_post_types(),  | 
                                                        
| 51 | 51 | 'post_status' => $this->get_whitelisted_post_statuses(),  | 
                                                        
| 52 | 52 | 'nopaging' => true,  | 
                                                        
| 53 | 53 | 'fields' => 'ids',  | 
                                                        
| 54 | 54 | );  | 
                                                        
| 55 | 55 | |
| 56 | - $query = new WP_Query( apply_filters( 'wogh_pre_fetch_all_supported', $args ) );  | 
                                                        |
| 56 | +		$query = new WP_Query(apply_filters('wogh_pre_fetch_all_supported', $args)); | 
                                                        |
| 57 | 57 | |
| 58 | 58 | $post_ids = $query->get_posts();  | 
                                                        
| 59 | 59 | |
| 60 | -		if ( ! $post_ids ) { | 
                                                        |
| 60 | +		if ( ! $post_ids) { | 
                                                        |
| 61 | 61 | return new WP_Error(  | 
                                                        
| 62 | 62 | 'no_results',  | 
                                                        
| 63 | - __( 'Querying for supported posts returned no results.', 'writing-on-github' )  | 
                                                        |
| 63 | +				__('Querying for supported posts returned no results.', 'writing-on-github') | 
                                                        |
| 64 | 64 | );  | 
                                                        
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | 67 | $results = array();  | 
                                                        
| 68 | -		foreach ( $post_ids as $post_id ) { | 
                                                        |
| 68 | +		foreach ($post_ids as $post_id) { | 
                                                        |
| 69 | 69 | // Do not export posts that have already been exported  | 
                                                        
| 70 | - if ( $force || ! get_post_meta( $post_id, '_wogh_sha', true ) ||  | 
                                                        |
| 71 | -				 ! get_post_meta( $post_id, '_wogh_github_path', true) ) { | 
                                                        |
| 70 | + if ($force || ! get_post_meta($post_id, '_wogh_sha', true) ||  | 
                                                        |
| 71 | +				 ! get_post_meta($post_id, '_wogh_github_path', true)) { | 
                                                        |
| 72 | 72 | |
| 73 | - $results[] = new Writing_On_GitHub_Post( $post_id, $this->app->api() );  | 
                                                        |
| 73 | + $results[] = new Writing_On_GitHub_Post($post_id, $this->app->api());  | 
                                                        |
| 74 | 74 | }  | 
                                                        
| 75 | 75 | }  | 
                                                        
| 76 | 76 | |
@@ -84,10 +84,10 @@ discard block  | 
                                                    ||
| 84 | 84 | *  | 
                                                        
| 85 | 85 | * @return WP_Error|Writing_On_GitHub_Post  | 
                                                        
| 86 | 86 | */  | 
                                                        
| 87 | -	public function fetch_by_id( $post_id ) { | 
                                                        |
| 88 | - $post = new Writing_On_GitHub_Post( $post_id, $this->app->api() );  | 
                                                        |
| 87 | +	public function fetch_by_id($post_id) { | 
                                                        |
| 88 | + $post = new Writing_On_GitHub_Post($post_id, $this->app->api());  | 
                                                        |
| 89 | 89 | |
| 90 | -		if ( ! $this->is_post_supported( $post ) ) { | 
                                                        |
| 90 | +		if ( ! $this->is_post_supported($post)) { | 
                                                        |
| 91 | 91 | return new WP_Error(  | 
                                                        
| 92 | 92 | 'unsupported_post',  | 
                                                        
| 93 | 93 | sprintf(  | 
                                                        
@@ -112,7 +112,7 @@ discard block  | 
                                                    ||
| 112 | 112 | *  | 
                                                        
| 113 | 113 | * @return string|WP_Error  | 
                                                        
| 114 | 114 | */  | 
                                                        
| 115 | -	public function save_posts( array $posts ) { | 
                                                        |
| 115 | +	public function save_posts(array $posts) { | 
                                                        |
| 116 | 116 | |
| 117 | 117 | /**  | 
                                                        
| 118 | 118 | * Whether an error has occurred.  | 
                                                        
@@ -121,20 +121,19 @@ discard block  | 
                                                    ||
| 121 | 121 | */  | 
                                                        
| 122 | 122 | $error = false;  | 
                                                        
| 123 | 123 | |
| 124 | -		foreach ( $posts as $post ) { | 
                                                        |
| 125 | - $args = apply_filters( 'wogh_pre_import_args', $this->post_args( $post ), $post );  | 
                                                        |
| 124 | +		foreach ($posts as $post) { | 
                                                        |
| 125 | +			$args = apply_filters('wogh_pre_import_args', $this->post_args($post), $post); | 
                                                        |
| 126 | 126 | |
| 127 | 127 |  			remove_filter('content_save_pre', 'wp_filter_post_kses'); | 
                                                        
| 128 | 128 | $post_id = $post->is_new() ?  | 
                                                        
| 129 | - wp_insert_post( $args, true ) :  | 
                                                        |
| 130 | - wp_update_post( $args, true );  | 
                                                        |
| 129 | + wp_insert_post($args, true) : wp_update_post($args, true);  | 
                                                        |
| 131 | 130 |  			add_filter('content_save_pre', 'wp_filter_post_kses'); | 
                                                        
| 132 | 131 | |
| 133 | -			if ( is_wp_error( $post_id ) ) { | 
                                                        |
| 134 | -				if ( ! $error ) { | 
                                                        |
| 132 | +			if (is_wp_error($post_id)) { | 
                                                        |
| 133 | +				if ( ! $error) { | 
                                                        |
| 135 | 134 | $error = $post_id;  | 
                                                        
| 136 | 135 |  				} else { | 
                                                        
| 137 | - $error->add( $post_id->get_error_code(), $post_id->get_error_message() );  | 
                                                        |
| 136 | + $error->add($post_id->get_error_code(), $post_id->get_error_message());  | 
                                                        |
| 138 | 137 | }  | 
                                                        
| 139 | 138 | |
| 140 | 139 | // Abort saving if updating the post fails.  | 
                                                        
@@ -143,42 +142,42 @@ discard block  | 
                                                    ||
| 143 | 142 | |
| 144 | 143 | // $this->set_revision_author( $post_id, $user_id );  | 
                                                        
| 145 | 144 | |
| 146 | -			if ( $post->is_new() ) { | 
                                                        |
| 145 | +			if ($post->is_new()) { | 
                                                        |
| 147 | 146 | $author = false;  | 
                                                        
| 148 | 147 | $meta = $post->get_meta();  | 
                                                        
| 149 | -				if ( ! empty( $meta ) && ! empty( $meta['author'] ) ) { | 
                                                        |
| 148 | +				if ( ! empty($meta) && ! empty($meta['author'])) { | 
                                                        |
| 150 | 149 | $author = $meta['author'];  | 
                                                        
| 151 | 150 | }  | 
                                                        
| 152 | - $user = $this->fetch_commit_user( $author );  | 
                                                        |
| 153 | - $user_id = ! is_wp_error( $user ) ? $user->ID : 0;  | 
                                                        |
| 154 | - $this->set_post_author( $post_id, $user_id );  | 
                                                        |
| 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);  | 
                                                        |
| 155 | 154 | }  | 
                                                        
| 156 | 155 | |
| 157 | - $post->set_post( get_post( $post_id ) );  | 
                                                        |
| 156 | + $post->set_post(get_post($post_id));  | 
                                                        |
| 158 | 157 | |
| 159 | - $meta = apply_filters( 'wogh_pre_import_meta', $post->get_meta(), $post );  | 
                                                        |
| 158 | +			$meta = apply_filters('wogh_pre_import_meta', $post->get_meta(), $post); | 
                                                        |
| 160 | 159 | |
| 161 | - unset( $meta['tags'] );  | 
                                                        |
| 162 | - unset( $meta['categories'] );  | 
                                                        |
| 163 | - unset( $meta['author'] );  | 
                                                        |
| 164 | - unset( $meta['post_date'] );  | 
                                                        |
| 165 | - unset( $meta['post_excerpt'] );  | 
                                                        |
| 166 | - unset( $meta['permalink'] );  | 
                                                        |
| 167 | - unset( $meta['link'] );  | 
                                                        |
| 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']);  | 
                                                        |
| 166 | + unset($meta['link']);  | 
                                                        |
| 168 | 167 | |
| 169 | -			foreach ( $meta as $key => $value ) { | 
                                                        |
| 170 | - update_post_meta( $post_id, $key, $value );  | 
                                                        |
| 168 | +			foreach ($meta as $key => $value) { | 
                                                        |
| 169 | + update_post_meta($post_id, $key, $value);  | 
                                                        |
| 171 | 170 | }  | 
                                                        
| 172 | 171 | }  | 
                                                        
| 173 | 172 | |
| 174 | -		if ( $error ) { | 
                                                        |
| 173 | +		if ($error) { | 
                                                        |
| 175 | 174 | return $error;  | 
                                                        
| 176 | 175 | }  | 
                                                        
| 177 | 176 | |
| 178 | - return __( 'Successfully saved posts.', 'writing-on-github' );  | 
                                                        |
| 177 | +		return __('Successfully saved posts.', 'writing-on-github'); | 
                                                        |
| 179 | 178 | }  | 
                                                        
| 180 | 179 | |
| 181 | -	protected function post_args( $post ) { | 
                                                        |
| 180 | +	protected function post_args($post) { | 
                                                        |
| 182 | 181 | $args = $post->get_args();  | 
                                                        
| 183 | 182 | $meta = $post->get_meta();  | 
                                                        
| 184 | 183 | |
@@ -186,14 +185,14 @@ discard block  | 
                                                    ||
| 186 | 185 | $args['post_content'] = addslashes($args['post_content']);  | 
                                                        
| 187 | 186 | |
| 188 | 187 | // update tags  | 
                                                        
| 189 | -		if ( isset( $meta['tags'] ) && $meta['tags'] ) { | 
                                                        |
| 188 | +		if (isset($meta['tags']) && $meta['tags']) { | 
                                                        |
| 190 | 189 | $args['tags_input'] = $meta['tags'];  | 
                                                        
| 191 | 190 | }  | 
                                                        
| 192 | 191 | |
| 193 | 192 | // update categories  | 
                                                        
| 194 | -		if ( isset( $meta['categories'] ) && $meta['categories'] ) { | 
                                                        |
| 193 | +		if (isset($meta['categories']) && $meta['categories']) { | 
                                                        |
| 195 | 194 | $categories = $meta['categories'];  | 
                                                        
| 196 | -		    if (!is_array($categories)) { | 
                                                        |
| 195 | +		    if ( ! is_array($categories)) { | 
                                                        |
| 197 | 196 | $categories = array($categories);  | 
                                                        
| 198 | 197 | }  | 
                                                        
| 199 | 198 | $terms = get_terms(array(  | 
                                                        
@@ -209,7 +208,7 @@ discard block  | 
                                                    ||
| 209 | 208 | }  | 
                                                        
| 210 | 209 | |
| 211 | 210 | $ids = array();  | 
                                                        
| 212 | -		    if (!empty($terms)) { | 
                                                        |
| 211 | +		    if ( ! empty($terms)) { | 
                                                        |
| 213 | 212 |  		        foreach ($terms as $id => $name) { | 
                                                        
| 214 | 213 | $ids[] = $id;  | 
                                                        
| 215 | 214 | unset($map[$name]);  | 
                                                        
@@ -217,7 +216,7 @@ discard block  | 
                                                    ||
| 217 | 216 | }  | 
                                                        
| 218 | 217 | |
| 219 | 218 | // create new terms  | 
                                                        
| 220 | -		    if (!empty($map)) { | 
                                                        |
| 219 | +		    if ( ! empty($map)) { | 
                                                        |
| 221 | 220 |  		        foreach ($map as $name => $value) { | 
                                                        
| 222 | 221 |  		            $term = wp_insert_term($name, 'category', array('parent' => 0)); | 
                                                        
| 223 | 222 |  		            // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); | 
                                                        
@@ -238,77 +237,77 @@ discard block  | 
                                                    ||
| 238 | 237 | *  | 
                                                        
| 239 | 238 | * @return string|WP_Error  | 
                                                        
| 240 | 239 | */  | 
                                                        
| 241 | -	public function delete_post_by_path( $path ) { | 
                                                        |
| 242 | - $query = new WP_Query( array(  | 
                                                        |
| 240 | +	public function delete_post_by_path($path) { | 
                                                        |
| 241 | + $query = new WP_Query(array(  | 
                                                        |
| 243 | 242 | 'meta_key' => '_wogh_github_path',  | 
                                                        
| 244 | 243 | 'meta_value' => $path,  | 
                                                        
| 245 | 244 | 'meta_compare' => '=',  | 
                                                        
| 246 | 245 | 'posts_per_page' => 1,  | 
                                                        
| 247 | 246 | 'fields' => 'ids',  | 
                                                        
| 248 | - ) );  | 
                                                        |
| 247 | + ));  | 
                                                        |
| 249 | 248 | |
| 250 | 249 | $post_id = $query->get_posts();  | 
                                                        
| 251 | - $post_id = array_pop( $post_id );  | 
                                                        |
| 250 | + $post_id = array_pop($post_id);  | 
                                                        |
| 252 | 251 | |
| 253 | -		if ( ! $post_id ) { | 
                                                        |
| 254 | - $parts = explode( '/', $path );  | 
                                                        |
| 255 | - $filename = array_pop( $parts );  | 
                                                        |
| 256 | - $directory = $parts ? array_shift( $parts ) : '';  | 
                                                        |
| 252 | +		if ( ! $post_id) { | 
                                                        |
| 253 | +			$parts     = explode('/', $path); | 
                                                        |
| 254 | + $filename = array_pop($parts);  | 
                                                        |
| 255 | + $directory = $parts ? array_shift($parts) : '';  | 
                                                        |
| 257 | 256 | |
| 258 | -			if ( false !== strpos( $directory, 'post' ) ) { | 
                                                        |
| 259 | -				preg_match( '/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md/', $filename, $matches ); | 
                                                        |
| 257 | +			if (false !== strpos($directory, 'post')) { | 
                                                        |
| 258 | +				preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md/', $filename, $matches); | 
                                                        |
| 260 | 259 | $title = $matches[4];  | 
                                                        
| 261 | 260 | |
| 262 | - $query = new WP_Query( array(  | 
                                                        |
| 261 | + $query = new WP_Query(array(  | 
                                                        |
| 263 | 262 | 'name' => $title,  | 
                                                        
| 264 | 263 | 'posts_per_page' => 1,  | 
                                                        
| 265 | 264 | 'post_type' => $this->get_whitelisted_post_types(),  | 
                                                        
| 266 | 265 | 'fields' => 'ids',  | 
                                                        
| 267 | - ) );  | 
                                                        |
| 266 | + ));  | 
                                                        |
| 268 | 267 | |
| 269 | 268 | $post_id = $query->get_posts();  | 
                                                        
| 270 | - $post_id = array_pop( $post_id );  | 
                                                        |
| 269 | + $post_id = array_pop($post_id);  | 
                                                        |
| 271 | 270 | }  | 
                                                        
| 272 | 271 | |
| 273 | -			if ( ! $post_id ) { | 
                                                        |
| 274 | - preg_match( '/(.*)\.md/', $filename, $matches );  | 
                                                        |
| 272 | +			if ( ! $post_id) { | 
                                                        |
| 273 | +				preg_match('/(.*)\.md/', $filename, $matches); | 
                                                        |
| 275 | 274 | $title = $matches[1];  | 
                                                        
| 276 | 275 | |
| 277 | - $query = new WP_Query( array(  | 
                                                        |
| 276 | + $query = new WP_Query(array(  | 
                                                        |
| 278 | 277 | 'name' => $title,  | 
                                                        
| 279 | 278 | 'posts_per_page' => 1,  | 
                                                        
| 280 | 279 | 'post_type' => $this->get_whitelisted_post_types(),  | 
                                                        
| 281 | 280 | 'fields' => 'ids',  | 
                                                        
| 282 | - ) );  | 
                                                        |
| 281 | + ));  | 
                                                        |
| 283 | 282 | |
| 284 | 283 | $post_id = $query->get_posts();  | 
                                                        
| 285 | - $post_id = array_pop( $post_id );  | 
                                                        |
| 284 | + $post_id = array_pop($post_id);  | 
                                                        |
| 286 | 285 | }  | 
                                                        
| 287 | 286 | }  | 
                                                        
| 288 | 287 | |
| 289 | -		if ( ! $post_id ) { | 
                                                        |
| 288 | +		if ( ! $post_id) { | 
                                                        |
| 290 | 289 | return new WP_Error(  | 
                                                        
| 291 | 290 | 'path_not_found',  | 
                                                        
| 292 | 291 | sprintf(  | 
                                                        
| 293 | - __( 'Post not found for path %s.', 'writing-on-github' ),  | 
                                                        |
| 292 | +					__('Post not found for path %s.', 'writing-on-github'), | 
                                                        |
| 294 | 293 | $path  | 
                                                        
| 295 | 294 | )  | 
                                                        
| 296 | 295 | );  | 
                                                        
| 297 | 296 | }  | 
                                                        
| 298 | 297 | |
| 299 | - $result = wp_delete_post( $post_id );  | 
                                                        |
| 298 | + $result = wp_delete_post($post_id);  | 
                                                        |
| 300 | 299 | |
| 301 | 300 | // If deleting fails...  | 
                                                        
| 302 | -		if ( false === $result ) { | 
                                                        |
| 303 | - $post = get_post( $post_id );  | 
                                                        |
| 301 | +		if (false === $result) { | 
                                                        |
| 302 | + $post = get_post($post_id);  | 
                                                        |
| 304 | 303 | |
| 305 | 304 | // ...and the post both exists and isn't in the trash...  | 
                                                        
| 306 | -			if ( $post && 'trash' !== $post->post_status ) { | 
                                                        |
| 305 | +			if ($post && 'trash' !== $post->post_status) { | 
                                                        |
| 307 | 306 | // ... then something went wrong.  | 
                                                        
| 308 | 307 | return new WP_Error(  | 
                                                        
| 309 | 308 | 'db_error',  | 
                                                        
| 310 | 309 | sprintf(  | 
                                                        
| 311 | - __( 'Failed to delete post ID %d.', 'writing-on-github' ),  | 
                                                        |
| 310 | +						__('Failed to delete post ID %d.', 'writing-on-github'), | 
                                                        |
| 312 | 311 | $post_id  | 
                                                        
| 313 | 312 | )  | 
                                                        
| 314 | 313 | );  | 
                                                        
@@ -316,25 +315,25 @@ discard block  | 
                                                    ||
| 316 | 315 | }  | 
                                                        
| 317 | 316 | |
| 318 | 317 | return sprintf(  | 
                                                        
| 319 | - __( 'Successfully deleted post ID %d.', 'writing-on-github' ),  | 
                                                        |
| 318 | +			__('Successfully deleted post ID %d.', 'writing-on-github'), | 
                                                        |
| 320 | 319 | $post_id  | 
                                                        
| 321 | 320 | );  | 
                                                        
| 322 | 321 | }  | 
                                                        
| 323 | 322 | |
| 324 | -	public function delete_post( $post_id ) { | 
                                                        |
| 325 | - $result = wp_delete_post( $post_id );  | 
                                                        |
| 323 | +	public function delete_post($post_id) { | 
                                                        |
| 324 | + $result = wp_delete_post($post_id);  | 
                                                        |
| 326 | 325 | |
| 327 | 326 | // If deleting fails...  | 
                                                        
| 328 | -		if ( false === $result ) { | 
                                                        |
| 329 | - $post = get_post( $post_id );  | 
                                                        |
| 327 | +		if (false === $result) { | 
                                                        |
| 328 | + $post = get_post($post_id);  | 
                                                        |
| 330 | 329 | |
| 331 | 330 | // ...and the post both exists and isn't in the trash...  | 
                                                        
| 332 | -			if ( $post && 'trash' !== $post->post_status ) { | 
                                                        |
| 331 | +			if ($post && 'trash' !== $post->post_status) { | 
                                                        |
| 333 | 332 | // ... then something went wrong.  | 
                                                        
| 334 | 333 | return new WP_Error(  | 
                                                        
| 335 | 334 | 'db_error',  | 
                                                        
| 336 | 335 | sprintf(  | 
                                                        
| 337 | - __( 'Failed to delete post ID %d.', 'writing-on-github' ),  | 
                                                        |
| 336 | +						__('Failed to delete post ID %d.', 'writing-on-github'), | 
                                                        |
| 338 | 337 | $post_id  | 
                                                        
| 339 | 338 | )  | 
                                                        
| 340 | 339 | );  | 
                                                        
@@ -342,7 +341,7 @@ discard block  | 
                                                    ||
| 342 | 341 | }  | 
                                                        
| 343 | 342 | |
| 344 | 343 | return sprintf(  | 
                                                        
| 345 | - __( 'Successfully deleted post ID %d.', 'writing-on-github' ),  | 
                                                        |
| 344 | +			__('Successfully deleted post ID %d.', 'writing-on-github'), | 
                                                        |
| 346 | 345 | $post_id  | 
                                                        
| 347 | 346 | );  | 
                                                        
| 348 | 347 | }  | 
                                                        
@@ -353,7 +352,7 @@ discard block  | 
                                                    ||
| 353 | 352 | * @return array  | 
                                                        
| 354 | 353 | */  | 
                                                        
| 355 | 354 |  	protected function get_whitelisted_post_types() { | 
                                                        
| 356 | - return apply_filters( 'wogh_whitelisted_post_types', $this->whitelisted_post_types );  | 
                                                        |
| 355 | +		return apply_filters('wogh_whitelisted_post_types', $this->whitelisted_post_types); | 
                                                        |
| 357 | 356 | }  | 
                                                        
| 358 | 357 | |
| 359 | 358 | /**  | 
                                                        
@@ -362,7 +361,7 @@ discard block  | 
                                                    ||
| 362 | 361 | * @return array  | 
                                                        
| 363 | 362 | */  | 
                                                        
| 364 | 363 |  	protected function get_whitelisted_post_statuses() { | 
                                                        
| 365 | - return apply_filters( 'wogh_whitelisted_post_statuses', $this->whitelisted_post_statuses );  | 
                                                        |
| 364 | +		return apply_filters('wogh_whitelisted_post_statuses', $this->whitelisted_post_statuses); | 
                                                        |
| 366 | 365 | }  | 
                                                        
| 367 | 366 | |
| 368 | 367 | /**  | 
                                                        
@@ -372,12 +371,12 @@ discard block  | 
                                                    ||
| 372 | 371 | *  | 
                                                        
| 373 | 372 | * @return string Whitelist formatted for query  | 
                                                        
| 374 | 373 | */  | 
                                                        
| 375 | -	protected function format_for_query( $whitelist ) { | 
                                                        |
| 376 | -		foreach ( $whitelist as $key => $value ) { | 
                                                        |
| 377 | - $whitelist[ $key ] = "'$value'";  | 
                                                        |
| 374 | +	protected function format_for_query($whitelist) { | 
                                                        |
| 375 | +		foreach ($whitelist as $key => $value) { | 
                                                        |
| 376 | + $whitelist[$key] = "'$value'";  | 
                                                        |
| 378 | 377 | }  | 
                                                        
| 379 | 378 | |
| 380 | - return implode( ', ', $whitelist );  | 
                                                        |
| 379 | +		return implode(', ', $whitelist); | 
                                                        |
| 381 | 380 | }  | 
                                                        
| 382 | 381 | |
| 383 | 382 | /**  | 
                                                        
@@ -388,25 +387,25 @@ discard block  | 
                                                    ||
| 388 | 387 | *  | 
                                                        
| 389 | 388 | * @return boolean True if supported, false if not.  | 
                                                        
| 390 | 389 | */  | 
                                                        
| 391 | -	protected function is_post_supported( Writing_On_GitHub_Post $post ) { | 
                                                        |
| 392 | -		if ( wp_is_post_revision( $post->id ) ) { | 
                                                        |
| 390 | +	protected function is_post_supported(Writing_On_GitHub_Post $post) { | 
                                                        |
| 391 | +		if (wp_is_post_revision($post->id)) { | 
                                                        |
| 393 | 392 | return false;  | 
                                                        
| 394 | 393 | }  | 
                                                        
| 395 | 394 | |
| 396 | 395 | // We need to allow trashed posts to be queried, but they are not whitelisted for export.  | 
                                                        
| 397 | -		if ( ! in_array( $post->status(), $this->get_whitelisted_post_statuses() ) && 'trash' !== $post->status() ) { | 
                                                        |
| 396 | +		if ( ! in_array($post->status(), $this->get_whitelisted_post_statuses()) && 'trash' !== $post->status()) { | 
                                                        |
| 398 | 397 | return false;  | 
                                                        
| 399 | 398 | }  | 
                                                        
| 400 | 399 | |
| 401 | -		if ( ! in_array( $post->type(), $this->get_whitelisted_post_types() ) ) { | 
                                                        |
| 400 | +		if ( ! in_array($post->type(), $this->get_whitelisted_post_types())) { | 
                                                        |
| 402 | 401 | return false;  | 
                                                        
| 403 | 402 | }  | 
                                                        
| 404 | 403 | |
| 405 | -		if ( $post->has_password() ) { | 
                                                        |
| 404 | +		if ($post->has_password()) { | 
                                                        |
| 406 | 405 | return false;  | 
                                                        
| 407 | 406 | }  | 
                                                        
| 408 | 407 | |
| 409 | - return apply_filters( 'wogh_is_post_supported', true, $post );  | 
                                                        |
| 408 | +		return apply_filters('wogh_is_post_supported', true, $post); | 
                                                        |
| 410 | 409 | }  | 
                                                        
| 411 | 410 | |
| 412 | 411 | /**  | 
                                                        
@@ -419,35 +418,35 @@ discard block  | 
                                                    ||
| 419 | 418 | *  | 
                                                        
| 420 | 419 | * @return WP_Error|WP_User  | 
                                                        
| 421 | 420 | */  | 
                                                        
| 422 | -	protected function fetch_commit_user( $display_name ) { | 
                                                        |
| 421 | +	protected function fetch_commit_user($display_name) { | 
                                                        |
| 423 | 422 | // If we can't find a user and a default hasn't been set,  | 
                                                        
| 424 | 423 | // we're just going to set the revision author to 0.  | 
                                                        
| 425 | 424 | $user = false;  | 
                                                        
| 426 | 425 | |
| 427 | -		if ( ! empty( $display_name ) ) { | 
                                                        |
| 428 | - $search_string = esc_attr( $display_name );  | 
                                                        |
| 429 | - $query = new WP_User_Query( array(  | 
                                                        |
| 426 | +		if ( ! empty($display_name)) { | 
                                                        |
| 427 | + $search_string = esc_attr($display_name);  | 
                                                        |
| 428 | + $query = new WP_User_Query(array(  | 
                                                        |
| 430 | 429 |  			    'search'         => "{$search_string}", | 
                                                        
| 431 | 430 | 'search_columns' => array(  | 
                                                        
| 432 | 431 | 'display_name',  | 
                                                        
| 433 | 432 | 'user_nicename',  | 
                                                        
| 434 | 433 | 'user_login',  | 
                                                        
| 435 | 434 | )  | 
                                                        
| 436 | - ) );  | 
                                                        |
| 435 | + ));  | 
                                                        |
| 437 | 436 | $users = $query->get_results();  | 
                                                        
| 438 | 437 | $user = empty($users) ? false : $users[0];  | 
                                                        
| 439 | 438 | }  | 
                                                        
| 440 | 439 | |
| 441 | -		if ( ! $user ) { | 
                                                        |
| 440 | +		if ( ! $user) { | 
                                                        |
| 442 | 441 | // Use the default user.  | 
                                                        
| 443 | - $user = get_user_by( 'id', (int) get_option( 'wogh_default_user' ) );  | 
                                                        |
| 442 | +			$user = get_user_by('id', (int) get_option('wogh_default_user')); | 
                                                        |
| 444 | 443 | }  | 
                                                        
| 445 | 444 | |
| 446 | -		if ( ! $user ) { | 
                                                        |
| 445 | +		if ( ! $user) { | 
                                                        |
| 447 | 446 | return new WP_Error(  | 
                                                        
| 448 | 447 | 'user_not_found',  | 
                                                        
| 449 | 448 | sprintf(  | 
                                                        
| 450 | - __( 'Commit user not found for email %s', 'writing-on-github' ),  | 
                                                        |
| 449 | +					__('Commit user not found for email %s', 'writing-on-github'), | 
                                                        |
| 451 | 450 | |
| 452 | 451 | )  | 
                                                        
| 453 | 452 | );  | 
                                                        
@@ -465,28 +464,28 @@ discard block  | 
                                                    ||
| 465 | 464 | *  | 
                                                        
| 466 | 465 | * @return string|WP_Error  | 
                                                        
| 467 | 466 | */  | 
                                                        
| 468 | -	protected function set_revision_author( $post_id, $user_id ) { | 
                                                        |
| 469 | - $revision = wp_get_post_revisions( $post_id );  | 
                                                        |
| 467 | +	protected function set_revision_author($post_id, $user_id) { | 
                                                        |
| 468 | + $revision = wp_get_post_revisions($post_id);  | 
                                                        |
| 470 | 469 | |
| 471 | -		if ( ! $revision ) { | 
                                                        |
| 472 | - $new_revision = wp_save_post_revision( $post_id );  | 
                                                        |
| 470 | +		if ( ! $revision) { | 
                                                        |
| 471 | + $new_revision = wp_save_post_revision($post_id);  | 
                                                        |
| 473 | 472 | |
| 474 | -			if ( ! $new_revision || is_wp_error( $new_revision ) ) { | 
                                                        |
| 475 | - return new WP_Error( 'db_error', 'There was a problem saving a new revision.' );  | 
                                                        |
| 473 | +			if ( ! $new_revision || is_wp_error($new_revision)) { | 
                                                        |
| 474 | +				return new WP_Error('db_error', 'There was a problem saving a new revision.'); | 
                                                        |
| 476 | 475 | }  | 
                                                        
| 477 | 476 | |
| 478 | 477 | // `wp_save_post_revision` returns the ID, whereas `get_post_revision` returns the whole object  | 
                                                        
| 479 | 478 | // in order to be consistent, let's make sure we have the whole object before continuing.  | 
                                                        
| 480 | - $revision = get_post( $new_revision );  | 
                                                        |
| 479 | + $revision = get_post($new_revision);  | 
                                                        |
| 481 | 480 | |
| 482 | -			if ( ! $revision ) { | 
                                                        |
| 483 | - return new WP_Error( 'db_error', 'There was a problem retrieving the newly recreated revision.' );  | 
                                                        |
| 481 | +			if ( ! $revision) { | 
                                                        |
| 482 | +				return new WP_Error('db_error', 'There was a problem retrieving the newly recreated revision.'); | 
                                                        |
| 484 | 483 | }  | 
                                                        
| 485 | 484 |  		} else { | 
                                                        
| 486 | - $revision = array_shift( $revision );  | 
                                                        |
| 485 | + $revision = array_shift($revision);  | 
                                                        |
| 487 | 486 | }  | 
                                                        
| 488 | 487 | |
| 489 | - return $this->set_post_author( $revision->ID, $user_id );  | 
                                                        |
| 488 | + return $this->set_post_author($revision->ID, $user_id);  | 
                                                        |
| 490 | 489 | }  | 
                                                        
| 491 | 490 | |
| 492 | 491 | /**  | 
                                                        
@@ -499,7 +498,7 @@ discard block  | 
                                                    ||
| 499 | 498 | *  | 
                                                        
| 500 | 499 | * @return string|WP_Error  | 
                                                        
| 501 | 500 | */  | 
                                                        
| 502 | -	protected function set_post_author( $post_id, $user_id ) { | 
                                                        |
| 501 | +	protected function set_post_author($post_id, $user_id) { | 
                                                        |
| 503 | 502 | global $wpdb;  | 
                                                        
| 504 | 503 | |
| 505 | 504 | $result = $wpdb->update(  | 
                                                        
@@ -510,25 +509,25 @@ discard block  | 
                                                    ||
| 510 | 509 | array(  | 
                                                        
| 511 | 510 | 'ID' => (int) $post_id,  | 
                                                        
| 512 | 511 | ),  | 
                                                        
| 513 | - array( '%d' ),  | 
                                                        |
| 514 | - array( '%d' )  | 
                                                        |
| 512 | +			array('%d'), | 
                                                        |
| 513 | +			array('%d') | 
                                                        |
| 515 | 514 | );  | 
                                                        
| 516 | 515 | |
| 517 | -		if ( false === $result ) { | 
                                                        |
| 518 | - return new WP_Error( 'db_error', $wpdb->last_error );  | 
                                                        |
| 516 | +		if (false === $result) { | 
                                                        |
| 517 | +			return new WP_Error('db_error', $wpdb->last_error); | 
                                                        |
| 519 | 518 | }  | 
                                                        
| 520 | 519 | |
| 521 | -		if ( 0 === $result ) { | 
                                                        |
| 520 | +		if (0 === $result) { | 
                                                        |
| 522 | 521 | return sprintf(  | 
                                                        
| 523 | - __( 'No change for post ID %d.', 'writing-on-github' ),  | 
                                                        |
| 522 | +				__('No change for post ID %d.', 'writing-on-github'), | 
                                                        |
| 524 | 523 | $post_id  | 
                                                        
| 525 | 524 | );  | 
                                                        
| 526 | 525 | }  | 
                                                        
| 527 | 526 | |
| 528 | - clean_post_cache( $post_id );  | 
                                                        |
| 527 | + clean_post_cache($post_id);  | 
                                                        |
| 529 | 528 | |
| 530 | 529 | return sprintf(  | 
                                                        
| 531 | - __( 'Successfully updated post ID %d.', 'writing-on-github' ),  | 
                                                        |
| 530 | +			__('Successfully updated post ID %d.', 'writing-on-github'), | 
                                                        |
| 532 | 531 | $post_id  | 
                                                        
| 533 | 532 | );  | 
                                                        
| 534 | 533 | }  | 
                                                        
@@ -541,7 +540,7 @@ discard block  | 
                                                    ||
| 541 | 540 | *  | 
                                                        
| 542 | 541 | * @return bool|int  | 
                                                        
| 543 | 542 | */  | 
                                                        
| 544 | -	public function set_post_sha( $post, $sha ) { | 
                                                        |
| 545 | - return update_post_meta( $post->id, '_wogh_sha', $sha );  | 
                                                        |
| 543 | +	public function set_post_sha($post, $sha) { | 
                                                        |
| 544 | + return update_post_meta($post->id, '_wogh_sha', $sha);  | 
                                                        |
| 546 | 545 | }  | 
                                                        
| 547 | 546 | }  | 
                                                        
@@ -21,7 +21,7 @@ discard block  | 
                                                    ||
| 21 | 21 | *  | 
                                                        
| 22 | 22 | * @param Writing_On_GitHub $app Application container.  | 
                                                        
| 23 | 23 | */  | 
                                                        
| 24 | -	public function __construct( Writing_On_GitHub $app ) { | 
                                                        |
| 24 | +	public function __construct(Writing_On_GitHub $app) { | 
                                                        |
| 25 | 25 | $this->app = $app;  | 
                                                        
| 26 | 26 | }  | 
                                                        
| 27 | 27 | |
@@ -32,30 +32,30 @@ discard block  | 
                                                    ||
| 32 | 32 | *  | 
                                                        
| 33 | 33 | * @return false  | 
                                                        
| 34 | 34 | */  | 
                                                        
| 35 | -	public function error( WP_Error $error ) { | 
                                                        |
| 35 | +	public function error(WP_Error $error) { | 
                                                        |
| 36 | 36 | global $wp_version;  | 
                                                        
| 37 | 37 | |
| 38 | - $this->log( $error );  | 
                                                        |
| 38 | + $this->log($error);  | 
                                                        |
| 39 | 39 | |
| 40 | -		if ( defined( 'DOING_AJAX' ) && DOING_AJAX && defined( 'WOGH_AJAX' ) && WOGH_AJAX ) { | 
                                                        |
| 40 | +		if (defined('DOING_AJAX') && DOING_AJAX && defined('WOGH_AJAX') && WOGH_AJAX) { | 
                                                        |
| 41 | 41 | /**  | 
                                                        
| 42 | 42 | * WordPress 4.1.0 introduced allowing WP_Error objects to be  | 
                                                        
| 43 | 43 | * passed directly into `wp_send_json_error`. This shims in  | 
                                                        
| 44 | 44 | * compatibility for older versions. We're currently supporting 3.9+.  | 
                                                        
| 45 | 45 | */  | 
                                                        
| 46 | -			if ( version_compare( $wp_version, '4.1.0', '<' ) ) { | 
                                                        |
| 46 | +			if (version_compare($wp_version, '4.1.0', '<')) { | 
                                                        |
| 47 | 47 | $result = array();  | 
                                                        
| 48 | 48 | |
| 49 | -				foreach ( $error->errors as $code => $messages ) { | 
                                                        |
| 50 | -					foreach ( $messages as $message ) { | 
                                                        |
| 51 | - $result[] = array( 'code' => $code, 'message' => $message );  | 
                                                        |
| 49 | +				foreach ($error->errors as $code => $messages) { | 
                                                        |
| 50 | +					foreach ($messages as $message) { | 
                                                        |
| 51 | +						$result[] = array('code' => $code, 'message' => $message); | 
                                                        |
| 52 | 52 | }  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
| 55 | 55 | $error = $result;  | 
                                                        
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
| 58 | - wp_send_json_error( $error );  | 
                                                        |
| 58 | + wp_send_json_error($error);  | 
                                                        |
| 59 | 59 | }  | 
                                                        
| 60 | 60 | |
| 61 | 61 | return false;  | 
                                                        
@@ -68,11 +68,11 @@ discard block  | 
                                                    ||
| 68 | 68 | *  | 
                                                        
| 69 | 69 | * @return true  | 
                                                        
| 70 | 70 | */  | 
                                                        
| 71 | -	public function success( $success ) { | 
                                                        |
| 72 | - $this->log( $success );  | 
                                                        |
| 71 | +	public function success($success) { | 
                                                        |
| 72 | + $this->log($success);  | 
                                                        |
| 73 | 73 | |
| 74 | -		if ( defined( 'DOING_AJAX' ) && DOING_AJAX && defined( 'WOGH_AJAX' ) && WOGH_AJAX ) { | 
                                                        |
| 75 | - wp_send_json_success( $success );  | 
                                                        |
| 74 | +		if (defined('DOING_AJAX') && DOING_AJAX && defined('WOGH_AJAX') && WOGH_AJAX) { | 
                                                        |
| 75 | + wp_send_json_success($success);  | 
                                                        |
| 76 | 76 | }  | 
                                                        
| 77 | 77 | |
| 78 | 78 | return true;  | 
                                                        
@@ -85,11 +85,11 @@ discard block  | 
                                                    ||
| 85 | 85 | *  | 
                                                        
| 86 | 86 | * @param string|WP_Error $msg Message to log.  | 
                                                        
| 87 | 87 | */  | 
                                                        
| 88 | -	protected function log( $msg ) { | 
                                                        |
| 89 | -		if ( is_wp_error( $msg ) ) { | 
                                                        |
| 88 | +	protected function log($msg) { | 
                                                        |
| 89 | +		if (is_wp_error($msg)) { | 
                                                        |
| 90 | 90 | $msg = $msg->get_error_message();  | 
                                                        
| 91 | 91 | }  | 
                                                        
| 92 | 92 | |
| 93 | - Writing_On_GitHub::write_log( $msg );  | 
                                                        |
| 93 | + Writing_On_GitHub::write_log($msg);  | 
                                                        |
| 94 | 94 | }  | 
                                                        
| 95 | 95 | }  | 
                                                        
@@ -84,13 +84,13 @@ discard block  | 
                                                    ||
| 84 | 84 | )  | 
                                                        
| 85 | 85 | );  | 
                                                        
| 86 | 86 | |
| 87 | - register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_author' );  | 
                                                        |
| 88 | - add_settings_field( 'wogh_ignore_author', __( 'Ignore author', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(  | 
                                                        |
| 89 | - 'default' => '',  | 
                                                        |
| 90 | - 'name' => 'wogh_ignore_author',  | 
                                                        |
| 91 | - 'help_text' => __( 'Do not export author and do not use author info from GitHub.', 'writing-on-github' ),  | 
                                                        |
| 92 | - )  | 
                                                        |
| 93 | - );  | 
                                                        |
| 87 | + register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_author' );  | 
                                                        |
| 88 | + add_settings_field( 'wogh_ignore_author', __( 'Ignore author', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(  | 
                                                        |
| 89 | + 'default' => '',  | 
                                                        |
| 90 | + 'name' => 'wogh_ignore_author',  | 
                                                        |
| 91 | + 'help_text' => __( 'Do not export author and do not use author info from GitHub.', 'writing-on-github' ),  | 
                                                        |
| 92 | + )  | 
                                                        |
| 93 | + );  | 
                                                        |
| 94 | 94 | |
| 95 | 95 | // register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_metas' );  | 
                                                        
| 96 | 96 | // add_settings_field( 'wogh_ignore_metas', __( 'Ignore post metas', 'writing-on-github' ), array( &$this, 'textarea_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(  | 
                                                        
@@ -128,14 +128,14 @@ discard block  | 
                                                    ||
| 128 | 128 | include dirname( dirname( __FILE__ ) ) . '/views/textarea-setting-field.php';  | 
                                                        
| 129 | 129 | }  | 
                                                        
| 130 | 130 | |
| 131 | - /**  | 
                                                        |
| 132 | - * Callback to render the checkbox field.  | 
                                                        |
| 133 | - *  | 
                                                        |
| 134 | - * @param array $args Field arguments.  | 
                                                        |
| 135 | - */  | 
                                                        |
| 136 | -    public function checkbox_field_callback( $args ) { | 
                                                        |
| 137 | - include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';  | 
                                                        |
| 138 | - }  | 
                                                        |
| 131 | + /**  | 
                                                        |
| 132 | + * Callback to render the checkbox field.  | 
                                                        |
| 133 | + *  | 
                                                        |
| 134 | + * @param array $args Field arguments.  | 
                                                        |
| 135 | + */  | 
                                                        |
| 136 | +	public function checkbox_field_callback( $args ) { | 
                                                        |
| 137 | + include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';  | 
                                                        |
| 138 | + }  | 
                                                        |
| 139 | 139 | |
| 140 | 140 | /**  | 
                                                        
| 141 | 141 | * Displays settings messages from background processes  | 
                                                        
@@ -221,9 +221,9 @@ discard block  | 
                                                    ||
| 221 | 221 | Writing_On_GitHub::$instance->start_export();  | 
                                                        
| 222 | 222 | }  | 
                                                        
| 223 | 223 | |
| 224 | -        if ( 'force_export' === $_GET['action'] ) { | 
                                                        |
| 225 | - Writing_On_GitHub::$instance->start_export(true);  | 
                                                        |
| 226 | - }  | 
                                                        |
| 224 | +		if ( 'force_export' === $_GET['action'] ) { | 
                                                        |
| 225 | + Writing_On_GitHub::$instance->start_export(true);  | 
                                                        |
| 226 | + }  | 
                                                        |
| 227 | 227 | |
| 228 | 228 |  		if ( 'import' === $_GET['action'] ) { | 
                                                        
| 229 | 229 | Writing_On_GitHub::$instance->start_import();  | 
                                                        
@@ -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_author' );  | 
                                                        |
| 88 | - add_settings_field( 'wogh_ignore_author', __( 'Ignore author', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(  | 
                                                        |
| 87 | + register_setting(Writing_On_GitHub::$text_domain, 'wogh_ignore_author');  | 
                                                        |
| 88 | +        add_settings_field('wogh_ignore_author', __('Ignore author', 'writing-on-github'), array(&$this, 'checkbox_field_callback'), Writing_On_GitHub::$text_domain, 'general', array( | 
                                                        |
| 89 | 89 | 'default' => '',  | 
                                                        
| 90 | 90 | 'name' => 'wogh_ignore_author',  | 
                                                        
| 91 | - 'help_text' => __( 'Do not export author and do not use author info from GitHub.', 'writing-on-github' ),  | 
                                                        |
| 91 | +                'help_text' => __('Do not export author and do not use author info from GitHub.', 'writing-on-github'), | 
                                                        |
| 92 | 92 | )  | 
                                                        
| 93 | 93 | );  | 
                                                        
| 94 | 94 | |
@@ -106,8 +106,8 @@ discard block  | 
                                                    ||
| 106 | 106 | *  | 
                                                        
| 107 | 107 | * @param array $args Field arguments.  | 
                                                        
| 108 | 108 | */  | 
                                                        
| 109 | -	public function field_callback( $args ) { | 
                                                        |
| 110 | - include dirname( dirname( __FILE__ ) ) . '/views/setting-field.php';  | 
                                                        |
| 109 | +	public function field_callback($args) { | 
                                                        |
| 110 | + include dirname(dirname(__FILE__)) . '/views/setting-field.php';  | 
                                                        |
| 111 | 111 | }  | 
                                                        
| 112 | 112 | |
| 113 | 113 | /**  | 
                                                        
@@ -115,8 +115,8 @@ discard block  | 
                                                    ||
| 115 | 115 | *  | 
                                                        
| 116 | 116 | * @param array $args Field arguments.  | 
                                                        
| 117 | 117 | */  | 
                                                        
| 118 | -	public function user_field_callback( $args ) { | 
                                                        |
| 119 | - include dirname( dirname( __FILE__ ) ) . '/views/user-setting-field.php';  | 
                                                        |
| 118 | +	public function user_field_callback($args) { | 
                                                        |
| 119 | + include dirname(dirname(__FILE__)) . '/views/user-setting-field.php';  | 
                                                        |
| 120 | 120 | }  | 
                                                        
| 121 | 121 | |
| 122 | 122 | /**  | 
                                                        
@@ -124,8 +124,8 @@ discard block  | 
                                                    ||
| 124 | 124 | *  | 
                                                        
| 125 | 125 | * @param array $args Field arguments.  | 
                                                        
| 126 | 126 | */  | 
                                                        
| 127 | -	public function textarea_field_callback( $args ) { | 
                                                        |
| 128 | - include dirname( dirname( __FILE__ ) ) . '/views/textarea-setting-field.php';  | 
                                                        |
| 127 | +	public function textarea_field_callback($args) { | 
                                                        |
| 128 | + include dirname(dirname(__FILE__)) . '/views/textarea-setting-field.php';  | 
                                                        |
| 129 | 129 | }  | 
                                                        
| 130 | 130 | |
| 131 | 131 | /**  | 
                                                        
@@ -133,58 +133,58 @@ discard block  | 
                                                    ||
| 133 | 133 | *  | 
                                                        
| 134 | 134 | * @param array $args Field arguments.  | 
                                                        
| 135 | 135 | */  | 
                                                        
| 136 | -    public function checkbox_field_callback( $args ) { | 
                                                        |
| 137 | - include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';  | 
                                                        |
| 136 | +    public function checkbox_field_callback($args) { | 
                                                        |
| 137 | + include dirname(dirname(__FILE__)) . '/views/checkbox-setting-field.php';  | 
                                                        |
| 138 | 138 | }  | 
                                                        
| 139 | 139 | |
| 140 | 140 | /**  | 
                                                        
| 141 | 141 | * Displays settings messages from background processes  | 
                                                        
| 142 | 142 | */  | 
                                                        
| 143 | 143 |  	public function section_callback() { | 
                                                        
| 144 | -		if ( get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain ) { | 
                                                        |
| 144 | +		if (get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain) { | 
                                                        |
| 145 | 145 | return;  | 
                                                        
| 146 | 146 | }  | 
                                                        
| 147 | 147 | |
| 148 | -		if ( 'yes' === get_option( '_wogh_export_started' ) ) { ?> | 
                                                        |
| 148 | +		if ('yes' === get_option('_wogh_export_started')) { ?> | 
                                                        |
| 149 | 149 | <div class="updated">  | 
                                                        
| 150 | - <p><?php esc_html_e( 'Export to GitHub started.', 'writing-on-github' ); ?></p>  | 
                                                        |
| 150 | +				<p><?php esc_html_e('Export to GitHub started.', 'writing-on-github'); ?></p> | 
                                                        |
| 151 | 151 | </div><?php  | 
                                                        
| 152 | - delete_option( '_wogh_export_started' );  | 
                                                        |
| 152 | +			delete_option('_wogh_export_started'); | 
                                                        |
| 153 | 153 | }  | 
                                                        
| 154 | 154 | |
| 155 | -		if ( $message = get_option( '_wogh_export_error' ) ) { ?> | 
                                                        |
| 155 | +		if ($message = get_option('_wogh_export_error')) { ?> | 
                                                        |
| 156 | 156 | <div class="error">  | 
                                                        
| 157 | - <p><?php esc_html_e( 'Export to GitHub failed with error:', 'writing-on-github' ); ?> <?php echo esc_html( $message );?></p>  | 
                                                        |
| 157 | +				<p><?php esc_html_e('Export to GitHub failed with error:', 'writing-on-github'); ?> <?php echo esc_html($message); ?></p> | 
                                                        |
| 158 | 158 | </div><?php  | 
                                                        
| 159 | - delete_option( '_wogh_export_error' );  | 
                                                        |
| 159 | +			delete_option('_wogh_export_error'); | 
                                                        |
| 160 | 160 | }  | 
                                                        
| 161 | 161 | |
| 162 | -		if ( 'yes' === get_option( '_wogh_export_complete' ) ) { ?> | 
                                                        |
| 162 | +		if ('yes' === get_option('_wogh_export_complete')) { ?> | 
                                                        |
| 163 | 163 | <div class="updated">  | 
                                                        
| 164 | - <p><?php esc_html_e( 'Export to GitHub completed successfully.', 'writing-on-github' );?></p>  | 
                                                        |
| 164 | +				<p><?php esc_html_e('Export to GitHub completed successfully.', 'writing-on-github'); ?></p> | 
                                                        |
| 165 | 165 | </div><?php  | 
                                                        
| 166 | - delete_option( '_wogh_export_complete' );  | 
                                                        |
| 166 | +			delete_option('_wogh_export_complete'); | 
                                                        |
| 167 | 167 | }  | 
                                                        
| 168 | 168 | |
| 169 | -		if ( 'yes' === get_option( '_wogh_import_started' ) ) { ?> | 
                                                        |
| 169 | +		if ('yes' === get_option('_wogh_import_started')) { ?> | 
                                                        |
| 170 | 170 | <div class="updated">  | 
                                                        
| 171 | - <p><?php esc_html_e( 'Import from GitHub started.', 'writing-on-github' ); ?></p>  | 
                                                        |
| 171 | +			<p><?php esc_html_e('Import from GitHub started.', 'writing-on-github'); ?></p> | 
                                                        |
| 172 | 172 | </div><?php  | 
                                                        
| 173 | - delete_option( '_wogh_import_started' );  | 
                                                        |
| 173 | +			delete_option('_wogh_import_started'); | 
                                                        |
| 174 | 174 | }  | 
                                                        
| 175 | 175 | |
| 176 | -		if ( $message = get_option( '_wogh_import_error' ) ) { ?> | 
                                                        |
| 176 | +		if ($message = get_option('_wogh_import_error')) { ?> | 
                                                        |
| 177 | 177 | <div class="error">  | 
                                                        
| 178 | - <p><?php esc_html_e( 'Import from GitHub failed with error:', 'writing-on-github' ); ?> <?php echo esc_html( $message );?></p>  | 
                                                        |
| 178 | +			<p><?php esc_html_e('Import from GitHub failed with error:', 'writing-on-github'); ?> <?php echo esc_html($message); ?></p> | 
                                                        |
| 179 | 179 | </div><?php  | 
                                                        
| 180 | - delete_option( '_wogh_import_error' );  | 
                                                        |
| 180 | +			delete_option('_wogh_import_error'); | 
                                                        |
| 181 | 181 | }  | 
                                                        
| 182 | 182 | |
| 183 | -		if ( 'yes' === get_option( '_wogh_import_complete' ) ) { ?> | 
                                                        |
| 183 | +		if ('yes' === get_option('_wogh_import_complete')) { ?> | 
                                                        |
| 184 | 184 | <div class="updated">  | 
                                                        
| 185 | - <p><?php esc_html_e( 'Import from GitHub completed successfully.', 'writing-on-github' );?></p>  | 
                                                        |
| 185 | +			<p><?php esc_html_e('Import from GitHub completed successfully.', 'writing-on-github'); ?></p> | 
                                                        |
| 186 | 186 | </div><?php  | 
                                                        
| 187 | - delete_option( '_wogh_import_complete' );  | 
                                                        |
| 187 | +			delete_option('_wogh_import_complete'); | 
                                                        |
| 188 | 188 | }  | 
                                                        
| 189 | 189 | }  | 
                                                        
| 190 | 190 | |
@@ -193,11 +193,11 @@ discard block  | 
                                                    ||
| 193 | 193 | */  | 
                                                        
| 194 | 194 |  	public function add_admin_menu() { | 
                                                        
| 195 | 195 | add_options_page(  | 
                                                        
| 196 | - __( 'Writing On GitHub', 'writing-on-github' ),  | 
                                                        |
| 197 | - __( 'Writing On GitHub', 'writing-on-github' ),  | 
                                                        |
| 196 | +			__('Writing On GitHub', 'writing-on-github'), | 
                                                        |
| 197 | +			__('Writing On GitHub', 'writing-on-github'), | 
                                                        |
| 198 | 198 | 'manage_options',  | 
                                                        
| 199 | 199 | Writing_On_GitHub::$text_domain,  | 
                                                        
| 200 | - array( $this, 'settings_page' )  | 
                                                        |
| 200 | + array($this, 'settings_page')  | 
                                                        |
| 201 | 201 | );  | 
                                                        
| 202 | 202 | }  | 
                                                        
| 203 | 203 | |
@@ -205,31 +205,31 @@ discard block  | 
                                                    ||
| 205 | 205 | * Admin callback to trigger import/export because WordPress admin routing lol  | 
                                                        
| 206 | 206 | */  | 
                                                        
| 207 | 207 |  	public function trigger_cron() { | 
                                                        
| 208 | -		if ( ! current_user_can( 'manage_options' ) ) { | 
                                                        |
| 208 | +		if ( ! current_user_can('manage_options')) { | 
                                                        |
| 209 | 209 | return;  | 
                                                        
| 210 | 210 | }  | 
                                                        
| 211 | 211 | |
| 212 | -		if ( get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain ) { | 
                                                        |
| 212 | +		if (get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain) { | 
                                                        |
| 213 | 213 | return;  | 
                                                        
| 214 | 214 | }  | 
                                                        
| 215 | 215 | |
| 216 | -		if ( ! isset( $_GET['action'] ) ) { | 
                                                        |
| 216 | +		if ( ! isset($_GET['action'])) { | 
                                                        |
| 217 | 217 | return;  | 
                                                        
| 218 | 218 | }  | 
                                                        
| 219 | 219 | |
| 220 | -		if ( 'export' === $_GET['action'] ) { | 
                                                        |
| 220 | +		if ('export' === $_GET['action']) { | 
                                                        |
| 221 | 221 | Writing_On_GitHub::$instance->start_export();  | 
                                                        
| 222 | 222 | }  | 
                                                        
| 223 | 223 | |
| 224 | -        if ( 'force_export' === $_GET['action'] ) { | 
                                                        |
| 224 | +        if ('force_export' === $_GET['action']) { | 
                                                        |
| 225 | 225 | Writing_On_GitHub::$instance->start_export(true);  | 
                                                        
| 226 | 226 | }  | 
                                                        
| 227 | 227 | |
| 228 | -		if ( 'import' === $_GET['action'] ) { | 
                                                        |
| 228 | +		if ('import' === $_GET['action']) { | 
                                                        |
| 229 | 229 | Writing_On_GitHub::$instance->start_import();  | 
                                                        
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | - wp_redirect( admin_url( 'options-general.php?page=writing-on-github' ) );  | 
                                                        |
| 232 | +		wp_redirect(admin_url('options-general.php?page=writing-on-github')); | 
                                                        |
| 233 | 233 | die;  | 
                                                        
| 234 | 234 | }  | 
                                                        
| 235 | 235 | }  | 
                                                        
@@ -152,9 +152,9 @@  | 
                                                    ||
| 152 | 152 | array_pop( $matches );  | 
                                                        
| 153 | 153 | |
| 154 | 154 | $meta = spyc_load( $matches[2] );  | 
                                                        
| 155 | -            if ( 'yes' == get_option('wogh_ignore_author') ) { | 
                                                        |
| 156 | - unset($meta['author']);  | 
                                                        |
| 157 | - }  | 
                                                        |
| 155 | +			if ( 'yes' == get_option('wogh_ignore_author') ) { | 
                                                        |
| 156 | + unset($meta['author']);  | 
                                                        |
| 157 | + }  | 
                                                        |
| 158 | 158 |  			// if ( isset( $meta['link'] ) ) { | 
                                                        
| 159 | 159 | // $meta['link'] = str_replace( home_url(), '', $meta['link'] );  | 
                                                        
| 160 | 160 | // }  | 
                                                        
@@ -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,13 +146,13 @@ 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 ( 'yes' == get_option('wogh_ignore_author') ) { | 
                                                        |
| 154 | + $meta = spyc_load($matches[2]);  | 
                                                        |
| 155 | +            if ('yes' == get_option('wogh_ignore_author')) { | 
                                                        |
| 156 | 156 | unset($meta['author']);  | 
                                                        
| 157 | 157 | }  | 
                                                        
| 158 | 158 |  			// if ( isset( $meta['link'] ) ) { | 
                                                        
@@ -198,7 +198,7 @@ discard block  | 
                                                    ||
| 198 | 198 | // $data->type = 'blob';  | 
                                                        
| 199 | 199 | |
| 200 | 200 | $data->path = $this->path();  | 
                                                        
| 201 | - $data->content = base64_encode( $this->content() );  | 
                                                        |
| 201 | + $data->content = base64_encode($this->content());  | 
                                                        |
| 202 | 202 | $data->sha = $this->sha;  | 
                                                        
| 203 | 203 | |
| 204 | 204 | return $data;  | 
                                                        
@@ -207,13 +207,13 @@ discard block  | 
                                                    ||
| 207 | 207 | /**  | 
                                                        
| 208 | 208 | * Interprets the blob's data into properties.  | 
                                                        
| 209 | 209 | */  | 
                                                        
| 210 | -	protected function interpret_data( $data ) { | 
                                                        |
| 211 | - $this->sha = isset( $data->sha ) ? $data->sha : '';  | 
                                                        |
| 212 | - $this->path = isset( $data->path ) ? $data->path : '';  | 
                                                        |
| 210 | +	protected function interpret_data($data) { | 
                                                        |
| 211 | + $this->sha = isset($data->sha) ? $data->sha : '';  | 
                                                        |
| 212 | + $this->path = isset($data->path) ? $data->path : '';  | 
                                                        |
| 213 | 213 | |
| 214 | 214 | $this->set_content(  | 
                                                        
| 215 | - isset( $data->content ) ? trim( $data->content ) : '',  | 
                                                        |
| 216 | - isset( $data->encoding ) && 'base64' === $data->encoding ? true : false  | 
                                                        |
| 215 | + isset($data->content) ? trim($data->content) : '',  | 
                                                        |
| 216 | + isset($data->encoding) && 'base64' === $data->encoding ? true : false  | 
                                                        |
| 217 | 217 | );  | 
                                                        
| 218 | 218 | }  | 
                                                        
| 219 | 219 | }  |