35 lines
838 B
PHP
35 lines
838 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
|
||
|
|
function schedule_async_post_processing( $post_id, $post, $update ) {
|
||
|
|
|
||
|
|
if ( wp_is_post_revision( $post_id ) ||
|
||
|
|
wp_is_post_autosave( $post_id ) ||
|
||
|
|
defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ( ! in_array( $post->post_type, array( 'profile_article', 'anew', 'yellow' ), true ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ( 'publish' !== $post->post_status ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// НЕМЕДЛЕННО ставим одну быструю задачу
|
||
|
|
as_schedule_single_action(
|
||
|
|
time() + 2, // Минимальная задержка
|
||
|
|
'async_post_processing_trigger',
|
||
|
|
array( $post_id ),
|
||
|
|
'async_processing'
|
||
|
|
);
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
add_action( 'save_post', 'schedule_async_post_processing', 99, 3 ); // Низкий приоритет
|
||
|
|
|
||
|
|
|