Functions
**Site relevance:** FFTAC.org
**Memory type:** theme source memory
**Source path:** FFTAC/wp-content/themes/fftac-who-we-are/functions.php
**Size:** 8.2 KB
Summary
FFTAC Who We Are theme functions.
Source Preview
This source file is short enough to preview directly on its source-memory page.
<?php
/**
* FFTAC Who We Are theme functions.
*
* @package FFTAC_Who_We_Are
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'FFTAC_WHO_WE_ARE_VERSION', '3.28.0' );
if ( ! function_exists( 'fftac_who_we_are_setup' ) ) {
/**
* Configure theme support.
*/
function fftac_who_we_are_setup() {
load_theme_textdomain( 'fftac-who-we-are', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'align-wide' );
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
)
);
add_theme_support(
'custom-logo',
array(
'height' => 256,
'width' => 256,
'flex-height' => true,
'flex-width' => true,
)
);
register_nav_menus(
array(
'primary' => __( 'Primary Menu', 'fftac-who-we-are' ),
'footer' => __( 'Footer Menu', 'fftac-who-we-are' ),
)
);
}
}
add_action( 'after_setup_theme', 'fftac_who_we_are_setup' );
/**
* Enqueue self-contained theme assets.
*/
function fftac_who_we_are_scripts() {
wp_enqueue_style( 'fftac-who-we-are-style', get_stylesheet_uri(), array(), FFTAC_WHO_WE_ARE_VERSION );
wp_enqueue_script( 'fftac-who-we-are-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), FFTAC_WHO_WE_ARE_VERSION, true );
}
add_action( 'wp_enqueue_scripts', 'fftac_who_we_are_scripts' );
/**
* Return an escaped URI for a bundled image.
*
* @param string $filename Image filename in assets/images.
* @return string
*/
function fftac_image_uri( $filename ) {
return esc_url( get_template_directory_uri() . '/assets/images/' . ltrim( $filename, '/' ) );
}
require_once get_template_directory() . '/inc/antichrist-resource-pages.php';
/**
* Get a theme mod with a default value.
*
* @param string $key Theme mod key.
* @param string $default Default value.
* @return string
*/
function fftac_theme_mod( $key, $default ) {
$value = get_theme_mod( $key, $default );
return is_string( $value ) ? $value : $default;
}
/**
* Fallback menu for fresh installs.
*/
function fftac_primary_menu_fallback() {
$items = array(
array( 'href' => fftac_resource_url( 'hub' ), 'label' => __( 'Antichrist Hub', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'biblical-foundations' ), 'label' => __( 'Bible', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'history' ), 'label' => __( 'History', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'legends-mythology' ), 'label' => __( 'Legends', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'books' ), 'label' => __( 'Books', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'apocalyptic-ai' ), 'label' => __( 'AI', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'glossary' ), 'label' => __( 'Glossary', 'fftac-who-we-are' ) ),
);
echo '<ul class="menu">';
foreach ( $items as $item ) {
printf(
'<li class="menu-item"><a href="%1$s">%2$s</a></li>',
esc_url( $item['href'] ),
esc_html( $item['label'] )
);
}
echo '</ul>';
}
/**
* Fallback footer menu.
*/
function fftac_footer_menu_fallback() {
$items = array(
array( 'href' => home_url( '/#who-we-are' ), 'label' => __( 'Who We Are', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'hub' ), 'label' => __( 'Antichrist Hub', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'biblical-foundations' ), 'label' => __( 'Biblical Foundations', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'history' ), 'label' => __( 'History', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'legends-mythology' ), 'label' => __( 'Legends And Mythology', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'books' ), 'label' => __( 'Books', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'fiction-pop-culture' ), 'label' => __( 'Fiction And Culture', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'positive-interpretations' ), 'label' => __( 'Positive Interpretations', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'current-web-landscape' ), 'label' => __( 'Current Web Landscape', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'apocalyptic-ai' ), 'label' => __( 'Apocalyptic AI', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'spiralism-ai' ), 'label' => __( 'Spiralism And AI', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'glossary' ), 'label' => __( 'Glossary', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'research-method' ), 'label' => __( 'Research Method', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_url( 'faq' ), 'label' => __( 'FAQ', 'fftac-who-we-are' ) ),
array( 'href' => fftac_resource_sitemap_url(), 'label' => __( 'XML Sitemap', 'fftac-who-we-are' ) ),
array( 'href' => home_url( '/#boundaries' ), 'label' => __( 'Community Rules', 'fftac-who-we-are' ) ),
array( 'href' => '#contact', 'label' => __( 'Contact', 'fftac-who-we-are' ) ),
);
echo '<ul class="footer-links">';
foreach ( $items as $item ) {
printf(
'<li><a href="%1$s">%2$s</a></li>',
esc_url( $item['href'] ),
esc_html( $item['label'] )
);
}
echo '</ul>';
}
/**
* Customize homepage copy without editing PHP.
*
* @param WP_Customize_Manager $wp_customize Customizer object.
*/
function fftac_customize_register( $wp_customize ) {
$wp_customize->add_section(
'fftac_homepage',
array(
'title' => __( 'FFTAC Homepage', 'fftac-who-we-are' ),
'description' => __( 'Adjust the built-in homepage copy for the self-contained theme.', 'fftac-who-we-are' ),
'priority' => 35,
)
);
$settings = array(
'fftac_home_kicker' => array(
'label' => __( 'Hero kicker', 'fftac-who-we-are' ),
'default' => __( 'FFTAC.org / public information', 'fftac-who-we-are' ),
'type' => 'text',
),
'fftac_home_title_line_1' => array(
'label' => __( 'Hero title line 1', 'fftac-who-we-are' ),
'default' => __( 'Who', 'fftac-who-we-are' ),
'type' => 'text',
),
'fftac_home_title_line_2' => array(
'label' => __( 'Hero title line 2', 'fftac-who-we-are' ),
'default' => __( 'We Are', 'fftac-who-we-are' ),
'type' => 'text',
),
'fftac_home_lede' => array(
'label' => __( 'Hero lede', 'fftac-who-we-are' ),
'default' => __( 'The Foundation For The Anti-Christ is presented here as a nonviolent, source-led, human-centered information project: adversarial in symbolism, disciplined in ethics, and committed to learning without scapegoating.', 'fftac-who-we-are' ),
'type' => 'textarea',
),
'fftac_contact_email' => array(
'label' => __( 'Contact email', 'fftac-who-we-are' ),
'default' => __( 'contact@fftac.org', 'fftac-who-we-are' ),
'type' => 'text',
),
'fftac_footer_note' => array(
'label' => __( 'Footer note', 'fftac-who-we-are' ),
'default' => __( 'This site rejects harassment, doxxing, violent extremism, and real-person villainization. Study the symbol. Do not turn people into targets.', 'fftac-who-we-are' ),
'type' => 'textarea',
),
);
foreach ( $settings as $setting_id => $data ) {
$wp_customize->add_setting(
$setting_id,
array(
'default' => $data['default'],
'sanitize_callback' => 'textarea' === $data['type'] ? 'sanitize_textarea_field' : 'sanitize_text_field',
)
);
$control_class = 'textarea' === $data['type'] ? 'WP_Customize_Control' : 'WP_Customize_Control';
$wp_customize->add_control(
new $control_class(
$wp_customize,
$setting_id,
array(
'label' => $data['label'],
'section' => 'fftac_homepage',
'settings' => $setting_id,
'type' => $data['type'],
)
)
);
}
}
add_action( 'customize_register', 'fftac_customize_register' );
/**
* Add a small body class when the front page template is active.
*
* @param array $classes Body classes.
* @return array
*/
function fftac_body_classes( $classes ) {
if ( is_front_page() ) {
$classes[] = 'fftac-front-page';
}
return $classes;
}
add_filter( 'body_class', 'fftac_body_classes' );