Passed
Push — ci ( 5ed1e2...c06359 )
by litefeel
02:46
created
lib/client/persist.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/response.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/admin.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/blob.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -152,9 +152,9 @@
 block discarded – undo
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
 			// }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/payload.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param Writing_On_GitHub $app      Application container.
30 30
 	 * @param string                $raw_data Raw request data.
31 31
 	 */
32
-	public function __construct( Writing_On_GitHub $app, $raw_data ) {
32
+	public function __construct(Writing_On_GitHub $app, $raw_data) {
33 33
 		$this->app  = $app;
34
-		$this->data = json_decode( $raw_data );
34
+		$this->data = json_decode($raw_data);
35 35
 	}
36 36
 
37 37
 	/**
@@ -41,32 +41,32 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function should_import() {
43 43
 		// @todo how do we get this without importing the whole api object just for this?
44
-		if ( strtolower( $this->data->repository->full_name ) !== strtolower( $this->app->api()->fetch()->repository() ) ) {
44
+		if (strtolower($this->data->repository->full_name) !== strtolower($this->app->api()->fetch()->repository())) {
45 45
 			return false;
46 46
 		}
47 47
 
48 48
 		// The last term in the ref is the payload_branch name.
49
-		$refs   = explode( '/', $this->data->ref );
50
-		$payload_branch = array_pop( $refs );
49
+		$refs   = explode('/', $this->data->ref);
50
+		$payload_branch = array_pop($refs);
51 51
 
52 52
 		$branch = $this->app->api()->fetch()->branch();
53 53
 
54
-		if ( $branch !== $payload_branch ) {
54
+		if ($branch !== $payload_branch) {
55 55
 			return false;
56 56
 		}
57 57
 
58 58
 		// We add a tag to commits we push out, so we shouldn't pull them in again.
59
-		$tag = apply_filters( 'wogh_commit_msg_tag', 'wogh' );
59
+		$tag = apply_filters('wogh_commit_msg_tag', 'wogh');
60 60
 
61
-		if ( ! $tag ) {
62
-			throw new Exception( __( 'Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github' ) );
61
+		if ( ! $tag) {
62
+			throw new Exception(__('Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github'));
63 63
 		}
64 64
 
65
-		if ( $tag === substr( $this->message(), -1 * strlen( $tag ) ) ) {
65
+		if ($tag === substr($this->message(), -1 * strlen($tag))) {
66 66
 			return false;
67 67
 		}
68 68
 
69
-		if ( ! $this->get_commit_id() ) {
69
+		if ( ! $this->get_commit_id()) {
70 70
 			return false;
71 71
 		}
72 72
 
Please login to merge, or discard this patch.
lib/api.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param Writing_On_GitHub $app Application container.
37 37
 	 */
38
-	public function __construct( Writing_On_GitHub $app ) {
38
+	public function __construct(Writing_On_GitHub $app) {
39 39
 		$this->app = $app;
40 40
 	}
41 41
 
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @return Writing_On_GitHub_Fetch_Client
46 46
 	 */
47 47
 	public function fetch() {
48
-		if ( ! $this->fetch ) {
49
-			$this->fetch = new Writing_On_GitHub_Fetch_Client( $this->app );
48
+		if ( ! $this->fetch) {
49
+			$this->fetch = new Writing_On_GitHub_Fetch_Client($this->app);
50 50
 		}
51 51
 
52 52
 		return $this->fetch;
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 * @return Writing_On_GitHub_Persist_Client
59 59
 	 */
60 60
 	public function persist() {
61
-		if ( ! $this->persist ) {
62
-			$this->persist = new Writing_On_GitHub_Persist_Client( $this->app );
61
+		if ( ! $this->persist) {
62
+			$this->persist = new Writing_On_GitHub_Persist_Client($this->app);
63 63
 		}
64 64
 
65 65
 		return $this->persist;
Please login to merge, or discard this patch.
lib/fileinfo.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
  */
7 7
 class Writing_On_GitHub_File_Info {
8 8
 
9
-	public function __construct( stdClass $data ) {
9
+	public function __construct(stdClass $data) {
10 10
 		$this->sha 			= $data->sha;
11 11
 		$this->path 		= $data->path;
12
-		$this->status 		= $data->status;
12
+		$this->status = $data->status;
13 13
 	}
14 14
 
15 15
 	public $sha;
16 16
 	public $path;
17
-	public $status;  // added removed modified
17
+	public $status; // added removed modified
18 18
 }
Please login to merge, or discard this patch.
lib/semaphore.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * Clean up the old values on instantiation.
29 29
 	 */
30 30
 	public function __construct() {
31
-		delete_option( self::KEY );
31
+		delete_option(self::KEY);
32 32
 	}
33 33
 
34 34
 	/**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return bool
41 41
 	 */
42 42
 	public function is_open() {
43
-		if ( self::VALUE_LOCKED === get_transient( self::KEY ) ) {
43
+		if (self::VALUE_LOCKED === get_transient(self::KEY)) {
44 44
 			return false;
45 45
 		}
46 46
 
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 	 * Enables the push lock.
52 52
 	 */
53 53
 	public function lock() {
54
-		set_transient( self::KEY, self::VALUE_LOCKED, MINUTE_IN_SECONDS );
54
+		set_transient(self::KEY, self::VALUE_LOCKED, MINUTE_IN_SECONDS);
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * Disables the push lock.
59 59
 	 */
60 60
 	public function unlock() {
61
-		set_transient( self::KEY, self::VALUE_UNLOCKED, MINUTE_IN_SECONDS );
61
+		set_transient(self::KEY, self::VALUE_UNLOCKED, MINUTE_IN_SECONDS);
62 62
 	}
63 63
 }
Please login to merge, or discard this patch.
lib/cli.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -44,28 +44,28 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @param array $args Command arguments.
46 46
 	 */
47
-	public function export( $args ) {
48
-		list( $post_id, $user_id ) = $args;
47
+	public function export($args) {
48
+		list($post_id, $user_id) = $args;
49 49
 
50
-		if ( ! is_numeric( $user_id ) ) {
51
-			WP_CLI::error( __( 'Invalid user ID', 'writing-on-github' ) );
50
+		if ( ! is_numeric($user_id)) {
51
+			WP_CLI::error(__('Invalid user ID', 'writing-on-github'));
52 52
 		}
53 53
 
54
-		$this->app->export()->set_user( $user_id );
54
+		$this->app->export()->set_user($user_id);
55 55
 
56
-		if ( 'all' === $post_id ) {
57
-			WP_CLI::line( __( 'Starting full export to GitHub.', 'writing-on-github' ) );
56
+		if ('all' === $post_id) {
57
+			WP_CLI::line(__('Starting full export to GitHub.', 'writing-on-github'));
58 58
 			$this->app->controller()->export_all();
59
-		} elseif ( is_numeric( $post_id ) ) {
59
+		} elseif (is_numeric($post_id)) {
60 60
 			WP_CLI::line(
61 61
 				sprintf(
62
-					__( 'Exporting post ID to GitHub: %d', 'writing-on-github' ),
62
+					__('Exporting post ID to GitHub: %d', 'writing-on-github'),
63 63
 					$post_id
64 64
 				)
65 65
 			);
66
-			$this->app->controller()->export_post( (int) $post_id );
66
+			$this->app->controller()->export_post((int) $post_id);
67 67
 		} else {
68
-			WP_CLI::error( __( 'Invalid post ID', 'writing-on-github' ) );
68
+			WP_CLI::error(__('Invalid post ID', 'writing-on-github'));
69 69
 		}
70 70
 	}
71 71
 
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param array $args Command arguments.
88 88
 	 */
89
-	public function import( $args ) {
90
-		list( $user_id ) = $args;
89
+	public function import($args) {
90
+		list($user_id) = $args;
91 91
 
92
-		if ( ! is_numeric( $user_id ) ) {
93
-			WP_CLI::error( __( 'Invalid user ID', 'writing-on-github' ) );
92
+		if ( ! is_numeric($user_id)) {
93
+			WP_CLI::error(__('Invalid user ID', 'writing-on-github'));
94 94
 		}
95 95
 
96
-		update_option( '_wogh_export_user_id', (int) $user_id );
96
+		update_option('_wogh_export_user_id', (int) $user_id);
97 97
 
98
-		WP_CLI::line( __( 'Starting import from GitHub.', 'writing-on-github' ) );
98
+		WP_CLI::line(__('Starting import from GitHub.', 'writing-on-github'));
99 99
 
100 100
 		$this->app->controller()->import_master();
101 101
 	}
@@ -119,40 +119,40 @@  discard block
 block discarded – undo
119 119
 	 * @param array $args Command arguments.
120 120
 	 * @param array $assoc_args Command associated arguments.
121 121
 	 */
122
-	public function prime( $args, $assoc_args ) {
123
-		if ( isset( $assoc_args['branch'] ) ) {
124
-			WP_CLI::line( __( 'Starting branch import.', 'writing-on-github' ) );
122
+	public function prime($args, $assoc_args) {
123
+		if (isset($assoc_args['branch'])) {
124
+			WP_CLI::line(__('Starting branch import.', 'writing-on-github'));
125 125
 
126 126
 			$commit = $this->app->api()->fetch()->master();
127 127
 
128
-			if ( is_wp_error( $commit ) ) {
128
+			if (is_wp_error($commit)) {
129 129
 				WP_CLI::error(
130 130
 					sprintf(
131
-						__( 'Failed to import and cache branch with error: %s', 'writing-on-github' ),
131
+						__('Failed to import and cache branch with error: %s', 'writing-on-github'),
132 132
 						$commit->get_error_message()
133 133
 					)
134 134
 				);
135 135
 			} else {
136 136
 				WP_CLI::success(
137 137
 					sprintf(
138
-						__( 'Successfully imported and cached commit %s from branch.', 'writing-on-github' ),
138
+						__('Successfully imported and cached commit %s from branch.', 'writing-on-github'),
139 139
 						$commit->sha()
140 140
 					)
141 141
 				);
142 142
 			}
143
-		} else if ( isset( $assoc_args['sha'] ) ) {
144
-			WP_CLI::line( 'Starting sha import.' );
143
+		} else if (isset($assoc_args['sha'])) {
144
+			WP_CLI::line('Starting sha import.');
145 145
 
146
-			$commit = $this->app->api()->fetch()->commit( $assoc_args['sha'] );
146
+			$commit = $this->app->api()->fetch()->commit($assoc_args['sha']);
147 147
 
148 148
 			WP_CLI::success(
149 149
 				sprintf(
150
-					__( 'Successfully imported and cached commit %s.', 'writing-on-github' ),
150
+					__('Successfully imported and cached commit %s.', 'writing-on-github'),
151 151
 					$commit->sha()
152 152
 				)
153 153
 			);
154 154
 		} else {
155
-			WP_CLI::error( 'Invalid fetch.' );
155
+			WP_CLI::error('Invalid fetch.');
156 156
 		}
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.