@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | add_action( 'save_post', array( $this->controller, 'export_post' ) ); |
| 163 | 163 | add_action( 'delete_post', array( $this->controller, 'delete_post' ) ); |
| 164 | 164 | add_action( 'wp_ajax_nopriv_wogh_push_request', array( $this->controller, 'pull_posts' ) ); |
| 165 | - add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 ); |
|
| 165 | + add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 ); |
|
| 166 | 166 | add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 ); |
| 167 | 167 | add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 ); |
| 168 | 168 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - return $link; |
|
| 184 | + return $link; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | public function ignore_post_meta($meta) { |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | /** |
| 437 | 437 | * Kicks of an import or export cronjob. |
| 438 | 438 | * |
| 439 | - * @param bool $force |
|
| 440 | - * @param string $type |
|
| 441 | - */ |
|
| 439 | + * @param bool $force |
|
| 440 | + * @param string $type |
|
| 441 | + */ |
|
| 442 | 442 | protected function start_cron( $type, $force = false ) { |
| 443 | 443 | update_option( '_wogh_' . $type . '_started', 'yes' ); |
| 444 | 444 | $user_id = get_current_user_id(); |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // If the functions have already been autoloaded, don't reload. |
| 14 | 14 | // This fixes function duplication during unit testing. |
| 15 | -if ( defined( 'WRITING_ON_GITHUB_TEST' ) && WRITING_ON_GITHUB_TEST ) { |
|
| 16 | - $path = dirname( __FILE__ ) . '/vendor/autoload.php'; |
|
| 15 | +if (defined('WRITING_ON_GITHUB_TEST') && WRITING_ON_GITHUB_TEST) { |
|
| 16 | + $path = dirname(__FILE__) . '/vendor/autoload.php'; |
|
| 17 | 17 | include_once $path; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | // require_once(dirname(__FILE__) . '/views/options.php'); |
| 41 | 41 | // require_once(dirname(__FILE__) . '/views/user-setting-field.php'); |
| 42 | 42 | |
| 43 | -add_action( 'plugins_loaded', array( new Writing_On_GitHub, 'boot' ) ); |
|
| 43 | +add_action('plugins_loaded', array(new Writing_On_GitHub, 'boot')); |
|
| 44 | 44 | |
| 45 | 45 | class Writing_On_GitHub { |
| 46 | 46 | |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | public function __construct() { |
| 131 | 131 | self::$instance = $this; |
| 132 | 132 | |
| 133 | - if ( is_admin() ) { |
|
| 133 | + if (is_admin()) { |
|
| 134 | 134 | $this->admin = new Writing_On_GitHub_Admin; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $this->controller = new Writing_On_GitHub_Controller( $this ); |
|
| 137 | + $this->controller = new Writing_On_GitHub_Controller($this); |
|
| 138 | 138 | |
| 139 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 140 | - WP_CLI::add_command( 'wogh', $this->cli() ); |
|
| 139 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 140 | + WP_CLI::add_command('wogh', $this->cli()); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
@@ -145,30 +145,30 @@ discard block |
||
| 145 | 145 | * Attaches the plugin's hooks into WordPress. |
| 146 | 146 | */ |
| 147 | 147 | public function boot() { |
| 148 | - register_activation_hook( __FILE__, array( $this, 'activate' ) ); |
|
| 149 | - add_action( 'admin_notices', array( $this, 'activation_notice' ) ); |
|
| 148 | + register_activation_hook(__FILE__, array($this, 'activate')); |
|
| 149 | + add_action('admin_notices', array($this, 'activation_notice')); |
|
| 150 | 150 | |
| 151 | - add_action( 'init', array( $this, 'l10n' ) ); |
|
| 151 | + add_action('init', array($this, 'l10n')); |
|
| 152 | 152 | |
| 153 | 153 | // Controller actions. |
| 154 | - add_action( 'save_post', array( $this->controller, 'export_post' ) ); |
|
| 155 | - add_action( 'delete_post', array( $this->controller, 'delete_post' ) ); |
|
| 156 | - add_action( 'wp_ajax_nopriv_wogh_push_request', array( $this->controller, 'pull_posts' ) ); |
|
| 157 | - add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 ); |
|
| 158 | - add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 ); |
|
| 159 | - add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 ); |
|
| 154 | + add_action('save_post', array($this->controller, 'export_post')); |
|
| 155 | + add_action('delete_post', array($this->controller, 'delete_post')); |
|
| 156 | + add_action('wp_ajax_nopriv_wogh_push_request', array($this->controller, 'pull_posts')); |
|
| 157 | + add_action('wogh_export', array($this->controller, 'export_all'), 10, 2); |
|
| 158 | + add_action('wogh_import', array($this->controller, 'import_master'), 10, 1); |
|
| 159 | + add_filter('get_edit_post_link', array($this, 'edit_post_link'), 10, 3); |
|
| 160 | 160 | |
| 161 | 161 | // add_filter( 'wogh_post_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
| 162 | 162 | // add_filter( 'wogh_pre_import_meta', array( $this, 'ignore_post_meta' ), 10, 1 ); |
| 163 | - add_filter( 'the_content', array( $this, 'the_content' ) ); |
|
| 163 | + add_filter('the_content', array($this, 'the_content')); |
|
| 164 | 164 | |
| 165 | - do_action( 'wogh_boot', $this ); |
|
| 165 | + do_action('wogh_boot', $this); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | public function edit_post_link($link, $postID, $context) { |
| 169 | - if ( ! wp_is_post_revision( $postID ) ) { |
|
| 170 | - $post = new Writing_On_GitHub_Post( $postID, Writing_On_GitHub::$instance->api() ); |
|
| 171 | - if ( $post->is_on_github() ) { |
|
| 169 | + if ( ! wp_is_post_revision($postID)) { |
|
| 170 | + $post = new Writing_On_GitHub_Post($postID, Writing_On_GitHub::$instance->api()); |
|
| 171 | + if ($post->is_on_github()) { |
|
| 172 | 172 | return $post->github_edit_url(); |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -227,29 +227,29 @@ discard block |
||
| 227 | 227 | * Init i18n files |
| 228 | 228 | */ |
| 229 | 229 | public function l10n() { |
| 230 | - load_plugin_textdomain( self::$text_domain ); |
|
| 230 | + load_plugin_textdomain(self::$text_domain); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * Sets and kicks off the export cronjob |
| 235 | 235 | */ |
| 236 | - public function start_export( $force = false ) { |
|
| 237 | - $this->start_cron( 'export', $force ); |
|
| 236 | + public function start_export($force = false) { |
|
| 237 | + $this->start_cron('export', $force); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
| 241 | 241 | * Sets and kicks off the import cronjob |
| 242 | 242 | */ |
| 243 | 243 | public function start_import() { |
| 244 | - $this->start_cron( 'import' ); |
|
| 244 | + $this->start_cron('import'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Enables the admin notice on initial activation |
| 249 | 249 | */ |
| 250 | 250 | public function activate() { |
| 251 | - if ( 'yes' !== get_option( '_wogh_fully_exported' ) ) { |
|
| 252 | - set_transient( '_wogh_activated', 'yes' ); |
|
| 251 | + if ('yes' !== get_option('_wogh_fully_exported')) { |
|
| 252 | + set_transient('_wogh_activated', 'yes'); |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
@@ -257,18 +257,18 @@ discard block |
||
| 257 | 257 | * Displays the activation admin notice |
| 258 | 258 | */ |
| 259 | 259 | public function activation_notice() { |
| 260 | - if ( ! get_transient( '_wogh_activated' ) ) { |
|
| 260 | + if ( ! get_transient('_wogh_activated')) { |
|
| 261 | 261 | return; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - delete_transient( '_wogh_activated' ); |
|
| 264 | + delete_transient('_wogh_activated'); |
|
| 265 | 265 | |
| 266 | 266 | ?><div class="updated"> |
| 267 | 267 | <p> |
| 268 | 268 | <?php |
| 269 | 269 | printf( |
| 270 | - __( 'To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github' ), |
|
| 271 | - admin_url( 'options-general.php?page=' . static::$text_domain) |
|
| 270 | + __('To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github'), |
|
| 271 | + admin_url('options-general.php?page=' . static::$text_domain) |
|
| 272 | 272 | ); |
| 273 | 273 | ?> |
| 274 | 274 | </p> |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @return Writing_On_GitHub_CLI |
| 291 | 291 | */ |
| 292 | 292 | public function cli() { |
| 293 | - if ( ! $this->cli ) { |
|
| 293 | + if ( ! $this->cli) { |
|
| 294 | 294 | $this->cli = new Writing_On_GitHub_CLI; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | * @return Writing_On_GitHub_Request |
| 304 | 304 | */ |
| 305 | 305 | public function request() { |
| 306 | - if ( ! $this->request ) { |
|
| 307 | - $this->request = new Writing_On_GitHub_Request( $this ); |
|
| 306 | + if ( ! $this->request) { |
|
| 307 | + $this->request = new Writing_On_GitHub_Request($this); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | return $this->request; |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | * @return Writing_On_GitHub_Response |
| 317 | 317 | */ |
| 318 | 318 | public function response() { |
| 319 | - if ( ! $this->response ) { |
|
| 320 | - $this->response = new Writing_On_GitHub_Response( $this ); |
|
| 319 | + if ( ! $this->response) { |
|
| 320 | + $this->response = new Writing_On_GitHub_Response($this); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | return $this->response; |
@@ -329,8 +329,8 @@ discard block |
||
| 329 | 329 | * @return Writing_On_GitHub_Api |
| 330 | 330 | */ |
| 331 | 331 | public function api() { |
| 332 | - if ( ! $this->api ) { |
|
| 333 | - $this->api = new Writing_On_GitHub_Api( $this ); |
|
| 332 | + if ( ! $this->api) { |
|
| 333 | + $this->api = new Writing_On_GitHub_Api($this); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | return $this->api; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @return Writing_On_GitHub_Import |
| 343 | 343 | */ |
| 344 | 344 | public function import() { |
| 345 | - if ( ! $this->import ) { |
|
| 346 | - $this->import = new Writing_On_GitHub_Import( $this ); |
|
| 345 | + if ( ! $this->import) { |
|
| 346 | + $this->import = new Writing_On_GitHub_Import($this); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | return $this->import; |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | * @return Writing_On_GitHub_Export |
| 356 | 356 | */ |
| 357 | 357 | public function export() { |
| 358 | - if ( ! $this->export ) { |
|
| 359 | - $this->export = new Writing_On_GitHub_Export( $this ); |
|
| 358 | + if ( ! $this->export) { |
|
| 359 | + $this->export = new Writing_On_GitHub_Export($this); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | return $this->export; |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @return Writing_On_GitHub_Semaphore |
| 369 | 369 | */ |
| 370 | 370 | public function semaphore() { |
| 371 | - if ( ! $this->semaphore ) { |
|
| 371 | + if ( ! $this->semaphore) { |
|
| 372 | 372 | $this->semaphore = new Writing_On_GitHub_Semaphore; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -381,8 +381,8 @@ discard block |
||
| 381 | 381 | * @return Writing_On_GitHub_Database |
| 382 | 382 | */ |
| 383 | 383 | public function database() { |
| 384 | - if ( ! $this->database ) { |
|
| 385 | - $this->database = new Writing_On_GitHub_Database( $this ); |
|
| 384 | + if ( ! $this->database) { |
|
| 385 | + $this->database = new Writing_On_GitHub_Database($this); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | return $this->database; |
@@ -396,18 +396,18 @@ discard block |
||
| 396 | 396 | * @param mixed $msg |
| 397 | 397 | * @param string $write |
| 398 | 398 | */ |
| 399 | - public static function write_log( $msg, $write = 'line' ) { |
|
| 400 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 401 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
| 402 | - WP_CLI::print_value( $msg ); |
|
| 399 | + public static function write_log($msg, $write = 'line') { |
|
| 400 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 401 | + if (is_array($msg) || is_object($msg)) { |
|
| 402 | + WP_CLI::print_value($msg); |
|
| 403 | 403 | } else { |
| 404 | - WP_CLI::$write( $msg ); |
|
| 404 | + WP_CLI::$write($msg); |
|
| 405 | 405 | } |
| 406 | - } elseif ( true === WP_DEBUG ) { |
|
| 407 | - if ( is_array( $msg ) || is_object( $msg ) ) { |
|
| 408 | - error_log( print_r( $msg, true ) ); |
|
| 406 | + } elseif (true === WP_DEBUG) { |
|
| 407 | + if (is_array($msg) || is_object($msg)) { |
|
| 408 | + error_log(print_r($msg, true)); |
|
| 409 | 409 | } else { |
| 410 | - error_log( $msg ); |
|
| 410 | + error_log($msg); |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -418,10 +418,10 @@ discard block |
||
| 418 | 418 | * @param bool $force |
| 419 | 419 | * @param string $type |
| 420 | 420 | */ |
| 421 | - protected function start_cron( $type, $force = false ) { |
|
| 422 | - update_option( '_wogh_' . $type . '_started', 'yes' ); |
|
| 421 | + protected function start_cron($type, $force = false) { |
|
| 422 | + update_option('_wogh_' . $type . '_started', 'yes'); |
|
| 423 | 423 | $user_id = get_current_user_id(); |
| 424 | - wp_schedule_single_event( time(), 'wogh_' . $type . '', array( $user_id, $force ) ); |
|
| 424 | + wp_schedule_single_event(time(), 'wogh_' . $type . '', array($user_id, $force)); |
|
| 425 | 425 | spawn_cron(); |
| 426 | 426 | } |
| 427 | 427 | } |