Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6eda2a7

Browse files
authored
Modify the delete_expired_transients cron event to run every 6 hours in WordPress Add
1 parent 988d1fd commit 6eda2a7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"generator":"Code Snippets v3.3.0","date_created":"2023年04月22日 00:31","snippets":[{"name":"Modify the delete_expired_transients cron event to run every 6 hours in WordPress","desc":"https:\/\/developer.wordpress.org\/reference\/functions\/delete_expired_transients\/\nhttps:\/\/developer.wordpress.org\/reference\/hooks\/cron_schedules\/\n","tags":["delete","expired","transients","wordpress","cron","event"],"scope":"admin","code":"function modify_delete_expired_transients_schedule() {\n \/\/ Check if the cron event is scheduled\n if ( ! wp_next_scheduled( 'delete_expired_transients' ) ) {\n return;\n }\n \/\/ Unschedule the event\n wp_unschedule_event( wp_next_scheduled( 'delete_expired_transients' ), 'delete_expired_transients' );\n \/\/ Schedule the event to run every 6 hours\n wp_schedule_event( time(), 'six_hours', 'delete_expired_transients' );\n}\nadd_action( 'init', 'modify_delete_expired_transients_schedule' );\n\nfunction add_six_hours_interval( $schedules ) {\n \/\/ Add a new interval for every 6 hours\n $schedules['six_hours'] = array(\n 'interval' => 21600, \/\/ 6 hours in seconds\n 'display' => __( 'Every 6 Hours' ),\n );\n return $schedules;\n}\nadd_filter( 'cron_schedules', 'add_six_hours_interval' );","priority":"10"}]}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /