Functions - Source Excerpt 05
Summary
This source excerpt preserves a bounded section of Antichrist.net/wp-content/themes/antichrist-net/functions.php so readers can inspect the evidence without opening the full source file.
**Source path:** Antichrist.net/wp-content/themes/antichrist-net/functions.php
return preg_replace_callback(
'#(<option\b[^>]*>)(.*?)(</option>)#is',
function ( $matches ) {
$label = trim( wp_strip_all_tags( (string) $matches[2] ) );
$label = trim( preg_replace( '/\s*(?:\([^)]*\)|([^)]*))\s*/u', ' ', $label ) );
if ( '' === $label ) {
return $matches[0];
}
return $matches[1] . esc_html( $label ) . $matches[3];
},
$markup
);
}
/**
* Translate small theme chrome strings through NS12 when present.
*
* @param string $key Translation key.
* @param string $fallback English fallback.
* @return string
*/
function acn_ui_t( $key, $fallback ) {
if ( function_exists( 'uaixlr_t' ) ) {
return uaixlr_t( $key, $fallback );
}
if ( function_exists( 'ns12lr_t' ) ) {
return ns12lr_t( $key, $fallback );
}
return __( $fallback, 'antichrist-net' );
}
/**
* Primary menu fallback for fresh Studio installs.
*/
function acn_fallback_menu() {
$items = array(
'' => acn_ui_t( 'acn.nav.home', 'Home' ),
'archive' => acn_ui_t( 'acn.nav.archive', 'Archive' ),
'research-agenda' => acn_ui_t( 'acn.nav.research_agenda', 'Research Agenda' ),
'research-library' => acn_ui_t( 'acn.nav.library', 'Library' ),
'timeline' => acn_ui_t( 'acn.nav.timeline', 'Timeline' ),
'symbols' => acn_ui_t( 'acn.nav.symbols', 'Symbols' ),
'apocalyptic-ai' => acn_ui_t( 'acn.nav.ai', 'Apocalyptic AI' ),
'state-and-religion' => acn_ui_t( 'acn.nav.state_religion', 'State & Religion' ),
'surveillance' => acn_ui_t( 'acn.nav.surveillance', 'Surveillance' ),
'community-baseline' => acn_ui_t( 'acn.nav.community_baseline', 'Community Baseline' ),
'about' => acn_ui_t( 'acn.nav.about', 'About' ),
);
echo '<ul id="primary-menu" class="menu">';
foreach ( $items as $slug => $label ) {
printf( '<li><a href="%1$s">%2$s</a></li>', esc_url( acn_page_url( $slug ) ), esc_html( $label ) );
}
echo '</ul>';
}
/**
* Footer menu fallback for the complete section set.
*/
function acn_fallback_footer_menu() {
$items = array(
'archive' => acn_ui_t( 'acn.nav.archive', 'Archive' ),
'topics' => acn_ui_t( 'acn.nav.topics', 'Topics Directory' ),
'timeline' => acn_ui_t( 'acn.nav.timeline', 'Timeline' ),
'symbols' => acn_ui_t( 'acn.nav.symbols', 'Symbols' ),
'state-and-religion' => acn_ui_t( 'acn.nav.state_religion', 'State & Religion' ),
'surveillance' => acn_ui_t( 'acn.nav.surveillance', 'Surveillance' ),
'pre-christian-antichrist-history' => acn_ui_t( 'acn.nav.pre_christian_antichrist_history', 'Pre-Christian Antichrist History' ),
'antichrist-like-figures-eastern-philosophy' => acn_ui_t( 'acn.nav.eastern_antichrist_figures', 'Antichrist-Like Figures in Eastern Philosophy' ),
'katechon' => __( 'Katechon', 'antichrist-net' ),
'apocalyptic-ai' => acn_ui_t( 'acn.nav.ai', 'Apocalyptic AI' ),
'eschatological-accelerationism' => __( 'Eschatological Accelerationism', 'antichrist-net' ),
'prophecy-tracking-resource-curation' => __( 'Prophecy Tracking and Resource Curation', 'antichrist-net' ),
'apocalyptic-optimism' => __( 'Apocalyptic Optimism', 'antichrist-net' ),
'doomsday-preparedness' => __( 'Doomsday Preparedness', 'antichrist-net' ),
'antichrist-as-redeemer-of-mankind' => acn_ui_t( 'acn.nav.redeemer_mankind', 'Antichrist as Redeemer of Mankind' ),
'antichrist-redeemer-second-coming' => __( 'Antichrist as Redeemer and Second Coming', 'antichrist-net' ),
'message-board' => acn_ui_t( 'acn.nav.message_board', 'Message Board' ),
'members' => acn_ui_t( 'acn.nav.members', 'Members' ),
'community-baseline' => acn_ui_t( 'acn.nav.community_baseline', 'Community Baseline' ),
'about' => acn_ui_t( 'acn.nav.about', 'About' ),
'editorial-policy' => __( 'Editorial Policy', 'antichrist-net' ),
'research-agenda' => acn_ui_t( 'acn.nav.research_agenda', 'Research Agenda' ),
'research-library' => acn_ui_t( 'acn.nav.research_library', 'Research Library' ),
);
echo '<ul class="menu">';
foreach ( $items as $slug => $label ) {
printf( '<li><a href="%1$s">%2$s</a></li>', esc_url( acn_page_url( $slug ) ), esc_html( $label ) );
}
echo '</ul>';
}
/**
* Simple cards used by the home page and templates.
*
* @param array $cards Card data.
*/
function acn_card_grid( $cards ) {
if ( empty( $cards ) || ! is_array( $cards ) ) {
return;
}
echo '<div class="acn-card-grid">';
foreach ( $cards as $card ) {
$title = isset( $card['title'] ) ? $card['title'] : '';
$text = isset( $card['text'] ) ? $card['text'] : '';
$url = isset( $card['url'] ) ? $card['url'] : '#';
$kicker = isset( $card['kicker'] ) ? $card['kicker'] : '';
echo '<article class="acn-card">';
if ( $kicker ) {
printf( '<p class="kicker">%s</p>', esc_html( $kicker ) );
}
printf( '<h3><a href="%1$s">%2$s</a></h3>', esc_url( $url ), esc_html( $title ) );
if ( $text ) {
printf( '<p>%s</p>', esc_html( $text ) );
}
printf( '<a class="text-link" href="%1$s">%2$s <span aria-hidden="true">-></span></a>', esc_url( $url ), esc_html__( 'Open', 'antichrist-net' ) );
echo '</article>';
}
echo '</div>';
}
/**
* Display post meta.
*/
function acn_entry_meta() {
printf(
'<div class="entry-meta"><span>%1$s</span><span>%2$s</span><span>%3$s</span></div>',
esc_html( get_the_date() ),
esc_html( get_the_author() ),
esc_html( acn_reading_time() )
);
}
/**
* Estimate reading time.
*
* @return string
*/
function acn_reading_time() {
$content = wp_strip_all_tags( get_post_field( 'post_content', get_the_ID() ) );
$words = str_word_count( $content );
$minutes = max( 1, (int) ceil( $words / 225 ) );
return sprintf( _n( '%s min read', '%s min read', $minutes, 'antichrist-net' ), number_format_i18n( $minutes ) );
}
/**
* Basic breadcrumbs.
*/
function acn_breadcrumbs() {
if ( is_front_page() ) {
return;
}
echo '<nav class="breadcrumbs" aria-label="' . esc_attr__( 'Breadcrumbs', 'antichrist-net' ) . '">';
echo '<a href="' . esc_url( home_url( '/' ) ) . '">' . esc_html__( 'Home', 'antichrist-net' ) . '</a>';
if ( is_singular() ) {
$post_type = get_post_type_object( get_post_type() );
if ( $post_type && 'post' !== $post_type->name && ! empty( $post_type->labels->name ) ) {
echo '<span aria-hidden="true">/</span><span>' . esc_html( $post_type->labels->name ) . '</span>';
}
echo '<span aria-hidden="true">/</span><span>' . esc_html( get_the_title() ) . '</span>';
} elseif ( is_archive() ) {
echo '<span aria-hidden="true">/</span><span>' . esc_html( get_the_archive_title() ) . '</span>';
} elseif ( is_search() ) {
echo '<span aria-hidden="true">/</span><span>' . esc_html__( 'Search', 'antichrist-net' ) . '</span>';
} elseif ( is_404() ) {
echo '<span aria-hidden="true">/</span><span>' . esc_html__( 'Not found', 'antichrist-net' ) . '</span>';
}
echo '</nav>';
}
/**
* Body classes.
*
* @param array $classes Classes.
* @return array
*/
function acn_body_classes( $classes ) {
$classes[] = 'acn-theme';
if ( is_user_logged_in() ) {
$classes[] = 'is-logged-in';
}
return $classes;
}
add_filter( 'body_class', 'acn_body_classes' );
/**
* Warn when Participants Database is not active.
*/
function acn_participants_database_notice() {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
if ( class_exists( 'Participants_Db' ) || defined( 'PDB_PLUGIN_VERSION' ) ) {
return;
}
$plugin_url = esc_url( admin_url( 'plugin-install.php?s=Participants%2520Database&tab=search&type=term' ) );
echo '<div class="notice notice-warning"><p>';
echo wp_kses_post( sprintf( __( '<strong>Antichrist.net:</strong> install and activate <a href="%s">Participants Database</a> to enable the member signup, profile, and directory shortcodes used by this theme package.', 'antichrist-net' ), $plugin_url ) );
echo '</p></div>';
}
add_action( 'admin_notices', 'acn_participants_database_notice' );