Skip to content

Commit

Permalink
Merge branch 'master' of github.com:WP2Static/wp2static
Browse files Browse the repository at this point in the history
  • Loading branch information
leonstafford committed May 5, 2020
2 parents 8fb9971 + b3e08f5 commit 43944a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
11 changes: 6 additions & 5 deletions src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,16 @@ public static function wp2static_ui_save_job_options() : void {
}

public static function wp2static_save_post_handler( int $post_id ) : void {
if ( get_post_status( $post_id ) !== 'publish' ) {
return;
if ( CoreOptions::getValue( 'queueJobOnPostSave' ) &&
get_post_status( $post_id ) === 'publish' ) {
self::wp2static_enqueue_jobs();
}

self::wp2static_enqueue_jobs();
}

public static function wp2static_trashed_post_handler() : void {
self::wp2static_enqueue_jobs();
if ( CoreOptions::getValue( 'queueJobOnPostDelete' ) ) {
self::wp2static_enqueue_jobs();
}
}

public static function wp2static_enqueue_jobs() : void {
Expand Down
28 changes: 0 additions & 28 deletions src/CoreOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,34 +421,6 @@ public static function savePosted( string $screen = 'core' ) : void {
[ 'name' => 'queueJobOnPostDelete' ]
);

if ( $queue_on_post_save ) {
add_action(
'save_post',
[ 'WP2Static\Controller', 'wp2static_save_post_handler' ],
0
);
} else {
remove_action(
'save_post',
[ 'WP2Static\Controller', 'wp2static_save_post_handler' ],
0
);
}

if ( $queue_on_post_delete ) {
add_action(
'trashed_post',
[ 'WP2Static\Controller', 'wp2static_trashed_post_handler' ],
0
);
} else {
remove_action(
'trashed_post',
[ 'WP2Static\Controller', 'wp2static_trashed_post_handler' ],
0
);
}

$process_queue_interval =
isset( $_POST['processQueueInterval'] ) ?
$_POST['processQueueInterval'] : 0;
Expand Down
12 changes: 12 additions & 0 deletions src/WordPressAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ public static function registerHooks( string $bootstrap_file ) : void {
1
);

add_action(
'save_post',
[ 'WP2Static\Controller', 'wp2static_save_post_handler' ],
0
);

add_action(
'trashed_post',
[ 'WP2Static\Controller', 'wp2static_trashed_post_handler' ],
0
);

/*
* Register actions for when we should invalidate cache for
* a URL(s) or whole site
Expand Down

0 comments on commit 43944a8

Please sign in to comment.