Made fictioneer_cleanup_discord_meta() generic
This commit is contained in:
parent
65d64c7b83
commit
899f730eac
@ -315,7 +315,7 @@ Fictioneer customizes WordPress by using as many standard action and filter hook
|
||||
| `wp_default_scripts` | `fictioneer_remove_jquery_migrate`
|
||||
| `wp_enqueue_scripts` | `fictioneer_add_custom_scripts`, `fictioneer_customizer_queue`, `fictioneer_style_queue`
|
||||
| `wp_footer` | `fictioneer_render_taxonomy_submenu`
|
||||
| `wp_head` | `fictioneer_output_head_seo`, `fictioneer_output_rss`, `fictioneer_output_schemas`, `fictioneer_add_fiction_css`, `fictioneer_output_head_fonts`, `fictioneer_output_head_translations`, `fictioneer_remove_mu_registration_styles`, `fictioneer_output_mu_registration_style`, `fictioneer_output_head_meta`, `fictioneer_output_head_critical_scripts`. `fictioneer_output_head_anti_flicker`
|
||||
| `wp_head` | `fictioneer_output_head_seo`, `fictioneer_output_rss`, `fictioneer_output_schemas`, `fictioneer_add_fiction_css`, `fictioneer_output_head_fonts`, `fictioneer_output_head_translations`, `fictioneer_remove_mu_registration_styles`, `fictioneer_output_mu_registration_style`, `fictioneer_output_head_meta`, `fictioneer_output_head_critical_scripts`. `fictioneer_output_head_anti_flicker`, `fictioneer_cleanup_discord_meta`
|
||||
| `wp_insert_comment` | `fictioneer_delete_cached_story_card_by_comment`, `fictioneer_increment_story_comment_count`
|
||||
| `wp_update_nav_menu` | `fictioneer_purge_nav_menu_transients`
|
||||
|
||||
|
@ -393,16 +393,6 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
$comment_count = 0;
|
||||
$visible_chapter_ids = [];
|
||||
$indexed_chapter_ids = [];
|
||||
$post_timestamp = get_post_time( 'U', true, $story_id );
|
||||
$current_timestamp = current_time( 'U', true );
|
||||
|
||||
// Remove Discord trigger meta field if outdated
|
||||
if (
|
||||
get_post_meta( $story_id, 'fictioneer_discord_post_trigger' ) &&
|
||||
( $current_timestamp - $post_timestamp ) > DAY_IN_SECONDS
|
||||
) {
|
||||
delete_post_meta( $story_id, 'fictioneer_discord_post_trigger' );
|
||||
}
|
||||
|
||||
// Assign correct icon
|
||||
if ( $status != 'Ongoing' ) {
|
||||
|
@ -763,31 +763,3 @@ function fictioneer_chapter_suggestion_tools() {
|
||||
if ( get_option( 'fictioneer_enable_suggestions' ) ) {
|
||||
add_action( 'fictioneer_chapter_after_main', 'fictioneer_chapter_suggestion_tools', 10 );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// CHAPTER DISCORD META FIELD CLEANUP
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Removes Discord trigger meta field if outdated
|
||||
*
|
||||
* @since 5.24.1
|
||||
*
|
||||
* @param array $args Chapter arguments passed to the hook.
|
||||
*/
|
||||
|
||||
function fictioneer_cleanup_discord_meta( $args ) {
|
||||
$chapter_id = $args['chapter_id'] ?? 0;
|
||||
|
||||
if ( ! get_post_meta( $chapter_id, 'fictioneer_discord_post_trigger' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_timestamp = get_post_time( 'U', true, $chapter_id );
|
||||
$current_timestamp = current_time( 'U', true );
|
||||
|
||||
if ( $current_timestamp - $post_timestamp > DAY_IN_SECONDS ) {
|
||||
delete_post_meta( $chapter_id, 'fictioneer_discord_post_trigger' );
|
||||
}
|
||||
}
|
||||
add_action( 'fictioneer_chapter_before_header', 'fictioneer_cleanup_discord_meta' );
|
||||
|
@ -1154,3 +1154,30 @@ function fictioneer_render_character_submenu() {
|
||||
function fictioneer_render_warning_submenu() {
|
||||
fictioneer_render_taxonomy_submenu( 'fcn_content_warning' );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// DISCORD META FIELD CLEANUP
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Removes Discord trigger meta field if outdated
|
||||
*
|
||||
* @since 5.24.1
|
||||
* @global WP_Post $post
|
||||
*/
|
||||
|
||||
function fictioneer_cleanup_discord_meta() {
|
||||
global $post;
|
||||
|
||||
if ( ! is_singular() || ! $post || ! get_post_meta( $post->ID, 'fictioneer_discord_post_trigger' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_timestamp = get_post_time( 'U', true, $post->ID );
|
||||
$current_timestamp = current_time( 'U', true );
|
||||
|
||||
if ( $current_timestamp - $post_timestamp > DAY_IN_SECONDS ) {
|
||||
delete_post_meta( $post->ID, 'fictioneer_discord_post_trigger' );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_head', 'fictioneer_cleanup_discord_meta' );
|
||||
|
Loading…
x
Reference in New Issue
Block a user