/* ══════════════════════════════════════════════════════════════ 4. AUTO-PROCESS QUICK FACTS ON SAVE ══════════════════════════════════════════════════════════════ */ function tcc_auto_parse_quick_facts( $post_id, $post, $update ) { /* ── Guards ── */ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if ( wp_is_post_revision( $post_id ) ) return; if ( wp_is_post_autosave( $post_id ) ) return; if ( ! in_array( $post->post_type, [ 'post', 'page' ], true ) ) return; if ( ! current_user_can( 'edit_post', $post_id ) ) return; $content = $post->post_content; /* ── Heading keywords to look for ── */ $heading_pattern = 'Quick Facts|Profile|Wiki Facts|About'; /* ── Only proceed if one of the headings exists ── */ if ( ! preg_match( '/(' . $heading_pattern . ')/i', $content ) ) return; /* ── Label map ── */ $label_map = [ 'full name' => '_bio_full_name', 'real name' => '_bio_full_name', 'stage name' => '_bio_stage_name', 'nickname' => '_bio_stage_name', 'known as' => '_bio_stage_name', 'born' => '_bio_born', 'date of birth' => '_bio_born', 'dob' => '_bio_born', 'birth date' => '_bio_born', 'age' => '_bio_age', 'death' => '_bio_death', 'died' => '_bio_death', 'date of death' => '_bio_death', 'passed away' => '_bio_death', 'birthplace' => '_bio_birthplace', 'place of birth' => '_bio_birthplace', 'birth place' => '_bio_birthplace', 'hometown' => '_bio_birthplace', 'born in' => '_bio_birthplace', 'state of origin' => '_bio_state_origin', 'nationality' => '_bio_nationality', 'ethnicity' => '_bio_nationality', 'citizenship' => '_bio_nationality', 'occupation' => '_bio_occupation', 'profession' => '_bio_occupation', 'height' => '_bio_height', 'religion' => '_bio_religion', 'faith' => '_bio_religion', 'parents' => '_bio_parents', 'father' => '_bio_parents', 'mother' => '_bio_parents', 'parent' => '_bio_parents', 'siblings' => '_bio_siblings', 'sibling' => '_bio_siblings', 'spouse' => '_bio_spouse', 'husband' => '_bio_spouse', 'wife' => '_bio_spouse', 'married to' => '_bio_spouse', 'children' => '_bio_children', 'child' => '_bio_children', 'kids' => '_bio_children', 'relationship' => '_bio_relationship', 'relationship status' => '_bio_relationship', 'marital status' => '_bio_relationship', 'net worth' => '_bio_net_worth', 'worth' => '_bio_net_worth', 'wealth' => '_bio_net_worth', 'earnings' => '_bio_net_worth', ]; /* ── Values to skip ── */ $skip_values = [ 'n/a', 'unknown', 'none', 'not available', 'nil', 'not married', 'not dating', 'no', '-', 'tbd', 'tba', ]; /* ── Extract lines from the facts block ── */ $lines = []; $block_start = ''; $block_end = ''; /* * Strategy 1 — Gutenberg block format * Matches: ...
\s*<\/p>\s*)+/', '', $new_content ); $new_content = preg_replace( '/\n{3,}/', "\n\n", $new_content ); $new_content = trim( $new_content ); /* ── Insert [bio_infobox] at top if not already present ── */ if ( strpos( $new_content, '[bio_infobox]' ) === false ) { $new_content = '[bio_infobox]' . "\n\n" . $new_content; } /* ── Update post content only if changed ── */ if ( $new_content !== $content ) { remove_action( 'save_post', 'tcc_auto_parse_quick_facts', 20 ); wp_update_post([ 'ID' => $post_id, 'post_content' => $new_content, ]); add_action( 'save_post', 'tcc_auto_parse_quick_facts', 20, 3 ); } } add_action( 'save_post', 'tcc_auto_parse_quick_facts', 20, 3 );Requested page is unavailable.