Passed
Push — master ( cdcc0c...410349 )
by litefeel
22:03 queued 03:07
created
lib/admin.php 1 patch
Spacing   +66 added lines, -66 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,71 +32,71 @@  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
 
95
-        register_setting( Writing_On_GitHub::$text_domain, 'wogh_dont_export_content' );
96
-        add_settings_field( 'wogh_dont_export_content', __( 'Don\'t export content', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(
95
+        register_setting(Writing_On_GitHub::$text_domain, 'wogh_dont_export_content');
96
+        add_settings_field('wogh_dont_export_content', __('Don\'t export content', 'writing-on-github'), array(&$this, 'checkbox_field_callback'), Writing_On_GitHub::$text_domain, 'general', array(
97 97
                 'default'   => '',
98 98
                 'name'      => 'wogh_dont_export_content',
99
-                'help_text' => __( 'Do not export post content to github, only export meta.', 'writing-on-github' ),
99
+                'help_text' => __('Do not export post content to github, only export meta.', 'writing-on-github'),
100 100
             )
101 101
         );
102 102
 
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
      *
115 115
      * @param array $args Field arguments.
116 116
      */
117
-    public function field_callback( $args ) {
118
-        include dirname( dirname( __FILE__ ) ) . '/views/setting-field.php';
117
+    public function field_callback($args) {
118
+        include dirname(dirname(__FILE__)) . '/views/setting-field.php';
119 119
     }
120 120
 
121 121
     /**
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @param array $args Field arguments.
125 125
      */
126
-    public function user_field_callback( $args ) {
127
-        include dirname( dirname( __FILE__ ) ) . '/views/user-setting-field.php';
126
+    public function user_field_callback($args) {
127
+        include dirname(dirname(__FILE__)) . '/views/user-setting-field.php';
128 128
     }
129 129
 
130 130
     /**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @param array $args Field arguments.
134 134
      */
135
-    public function textarea_field_callback( $args ) {
136
-        include dirname( dirname( __FILE__ ) ) . '/views/textarea-setting-field.php';
135
+    public function textarea_field_callback($args) {
136
+        include dirname(dirname(__FILE__)) . '/views/textarea-setting-field.php';
137 137
     }
138 138
 
139 139
     /**
@@ -141,58 +141,58 @@  discard block
 block discarded – undo
141 141
      *
142 142
      * @param array $args Field arguments.
143 143
      */
144
-    public function checkbox_field_callback( $args ) {
145
-        include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';
144
+    public function checkbox_field_callback($args) {
145
+        include dirname(dirname(__FILE__)) . '/views/checkbox-setting-field.php';
146 146
     }
147 147
 
148 148
     /**
149 149
      * Displays settings messages from background processes
150 150
      */
151 151
     public function section_callback() {
152
-        if ( get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain ) {
152
+        if (get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain) {
153 153
             return;
154 154
         }
155 155
 
156
-        if ( 'yes' === get_option( '_wogh_export_started' ) ) { ?>
156
+        if ('yes' === get_option('_wogh_export_started')) { ?>
157 157
             <div class="updated">
158
-                <p><?php esc_html_e( 'Export to GitHub started.', 'writing-on-github' ); ?></p>
158
+                <p><?php esc_html_e('Export to GitHub started.', 'writing-on-github'); ?></p>
159 159
             </div><?php
160
-            delete_option( '_wogh_export_started' );
160
+            delete_option('_wogh_export_started');
161 161
         }
162 162
 
163
-        if ( $message = get_option( '_wogh_export_error' ) ) { ?>
163
+        if ($message = get_option('_wogh_export_error')) { ?>
164 164
             <div class="error">
165
-                <p><?php esc_html_e( 'Export to GitHub failed with error:', 'writing-on-github' ); ?> <?php echo esc_html( $message );?></p>
165
+                <p><?php esc_html_e('Export to GitHub failed with error:', 'writing-on-github'); ?> <?php echo esc_html($message); ?></p>
166 166
             </div><?php
167
-            delete_option( '_wogh_export_error' );
167
+            delete_option('_wogh_export_error');
168 168
         }
169 169
 
170
-        if ( 'yes' === get_option( '_wogh_export_complete' ) ) { ?>
170
+        if ('yes' === get_option('_wogh_export_complete')) { ?>
171 171
             <div class="updated">
172
-                <p><?php esc_html_e( 'Export to GitHub completed successfully.', 'writing-on-github' );?></p>
172
+                <p><?php esc_html_e('Export to GitHub completed successfully.', 'writing-on-github'); ?></p>
173 173
             </div><?php
174
-            delete_option( '_wogh_export_complete' );
174
+            delete_option('_wogh_export_complete');
175 175
         }
176 176
 
177
-        if ( 'yes' === get_option( '_wogh_import_started' ) ) { ?>
177
+        if ('yes' === get_option('_wogh_import_started')) { ?>
178 178
             <div class="updated">
179
-            <p><?php esc_html_e( 'Import from GitHub started.', 'writing-on-github' ); ?></p>
179
+            <p><?php esc_html_e('Import from GitHub started.', 'writing-on-github'); ?></p>
180 180
             </div><?php
181
-            delete_option( '_wogh_import_started' );
181
+            delete_option('_wogh_import_started');
182 182
         }
183 183
 
184
-        if ( $message = get_option( '_wogh_import_error' ) ) { ?>
184
+        if ($message = get_option('_wogh_import_error')) { ?>
185 185
             <div class="error">
186
-            <p><?php esc_html_e( 'Import from GitHub failed with error:', 'writing-on-github' ); ?> <?php echo esc_html( $message );?></p>
186
+            <p><?php esc_html_e('Import from GitHub failed with error:', 'writing-on-github'); ?> <?php echo esc_html($message); ?></p>
187 187
             </div><?php
188
-            delete_option( '_wogh_import_error' );
188
+            delete_option('_wogh_import_error');
189 189
         }
190 190
 
191
-        if ( 'yes' === get_option( '_wogh_import_complete' ) ) { ?>
191
+        if ('yes' === get_option('_wogh_import_complete')) { ?>
192 192
             <div class="updated">
193
-            <p><?php esc_html_e( 'Import from GitHub completed successfully.', 'writing-on-github' );?></p>
193
+            <p><?php esc_html_e('Import from GitHub completed successfully.', 'writing-on-github'); ?></p>
194 194
             </div><?php
195
-            delete_option( '_wogh_import_complete' );
195
+            delete_option('_wogh_import_complete');
196 196
         }
197 197
     }
198 198
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function add_admin_menu() {
203 203
         add_options_page(
204
-            __( 'Writing On GitHub', 'writing-on-github' ),
205
-            __( 'Writing On GitHub', 'writing-on-github' ),
204
+            __('Writing On GitHub', 'writing-on-github'),
205
+            __('Writing On GitHub', 'writing-on-github'),
206 206
             'manage_options',
207 207
             Writing_On_GitHub::$text_domain,
208
-            array( $this, 'settings_page' )
208
+            array($this, 'settings_page')
209 209
         );
210 210
     }
211 211
 
@@ -213,31 +213,31 @@  discard block
 block discarded – undo
213 213
      * Admin callback to trigger import/export because WordPress admin routing lol
214 214
      */
215 215
     public function trigger_cron() {
216
-        if ( ! current_user_can( 'manage_options' ) ) {
216
+        if ( ! current_user_can('manage_options')) {
217 217
             return;
218 218
         }
219 219
 
220
-        if ( get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain ) {
220
+        if (get_current_screen()->id !== 'settings_page_' . Writing_On_GitHub::$text_domain) {
221 221
             return;
222 222
         }
223 223
 
224
-        if ( ! isset( $_GET['action'] ) ) {
224
+        if ( ! isset($_GET['action'])) {
225 225
             return;
226 226
         }
227 227
 
228
-        if ( 'export' === $_GET['action'] ) {
228
+        if ('export' === $_GET['action']) {
229 229
             Writing_On_GitHub::$instance->start_export();
230 230
         }
231 231
 
232
-        if ( 'force_export' === $_GET['action'] ) {
232
+        if ('force_export' === $_GET['action']) {
233 233
             Writing_On_GitHub::$instance->start_export(true);
234 234
         }
235 235
 
236
-        if ( 'import' === $_GET['action'] ) {
236
+        if ('import' === $_GET['action']) {
237 237
             Writing_On_GitHub::$instance->start_import();
238 238
         }
239 239
 
240
-        wp_redirect( admin_url( 'options-general.php?page=writing-on-github' ) );
240
+        wp_redirect(admin_url('options-general.php?page=writing-on-github'));
241 241
         die;
242 242
     }
243 243
 }
Please login to merge, or discard this patch.