Skip to content
wiki.fftac.org

Customizer

**Site relevance:** 2IA.org

**Memory type:** theme source memory

**Source path:** 2IA.org/wp-content/themes/twoia-intelligence/inc/customizer.php

**Size:** 7.2 KB

Summary

Theme Customizer settings.

Source Preview

This source file is short enough to preview directly on its source-memory page.

<?php
/**
 * Theme Customizer settings.
 *
 * @package TwoIA
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Sanitize a checkbox value.
 *
 * @param mixed $checked Raw checkbox value.
 * @return bool
 */
function twoia_sanitize_checkbox( $checked ) {
	return (bool) $checked;
}

/**
 * Sanitize long-form Customizer HTML. Allows basic editorial markup only.
 *
 * @param string $value Raw value.
 * @return string
 */
function twoia_sanitize_limited_html( $value ) {
	return wp_kses(
		$value,
		array(
			'a'      => array(
				'href'   => true,
				'title'  => true,
				'target' => true,
				'rel'    => true,
			),
			'br'     => array(),
			'em'     => array(),
			'strong' => array(),
			'span'   => array(
				'class' => true,
			),
		)
	);
}

/**
 * Register Customizer settings.
 *
 * @param WP_Customize_Manager $wp_customize Customizer object.
 */
function twoia_customize_register( $wp_customize ) {
	$wp_customize->add_section(
		'twoia_branding',
		array(
			'title'       => esc_html__( '2IA Intelligence Settings', 'two-identities-anonymous' ),
			'description' => esc_html__( 'Brand, hero, disclaimer, and privacy-first theme options.', 'two-identities-anonymous' ),
			'priority'    => 30,
		)
	);

	$settings = array(
		'twoia_hero_eyebrow' => array(
			'label'    => esc_html__( 'Hero eyebrow text', 'two-identities-anonymous' ),
			'default'  => esc_html__( 'PUBLIC INTELLIGENCE / IDENTITY / SURVEILLANCE', 'two-identities-anonymous' ),
			'type'     => 'text',
			'sanitize' => 'sanitize_text_field',
		),
		'twoia_hero_title' => array(
			'label'    => esc_html__( 'Hero title', 'two-identities-anonymous' ),
			'default'  => esc_html__( '2IA – Two Identities Of Anonymous', 'two-identities-anonymous' ),
			'type'     => 'text',
			'sanitize' => 'sanitize_text_field',
		),
		'twoia_hero_subtitle' => array(
			'label'    => esc_html__( 'Hero subtitle', 'two-identities-anonymous' ),
			'default'  => esc_html__( 'Public intelligence for people tired of being managed by systems they are not allowed to inspect.', 'two-identities-anonymous' ),
			'type'     => 'text',
			'sanitize' => 'sanitize_text_field',
		),
		'twoia_hero_body' => array(
			'label'    => esc_html__( 'Hero body', 'two-identities-anonymous' ),
			'default'  => esc_html__( '2IA follows the paperwork of control: surveillance contracts, broker files, court pressure, risk scores, public-records delays, metadata trails, and correction failures. Pull the record. Name who benefits. Show who gets hurt. No classified material, no doxxing, no exploit trading, no personal-data dumps.', 'two-identities-anonymous' ),
			'type'     => 'textarea',
			'sanitize' => 'twoia_sanitize_limited_html',
		),
		'twoia_hero_primary_text' => array(
			'label'    => esc_html__( 'Hero primary button text', 'two-identities-anonymous' ),
			'default'  => esc_html__( 'Start Here', 'two-identities-anonymous' ),
			'type'     => 'text',
			'sanitize' => 'sanitize_text_field',
		),
		'twoia_hero_primary_url' => array(
			'label'    => esc_html__( 'Hero primary button URL', 'two-identities-anonymous' ),
			'default'  => '/start-here/',
			'type'     => 'url',
			'sanitize' => 'esc_url_raw',
		),
		'twoia_hero_secondary_text' => array(
			'label'    => esc_html__( 'Hero secondary button text', 'two-identities-anonymous' ),
			'default'  => esc_html__( 'Methodology', 'two-identities-anonymous' ),
			'type'     => 'text',
			'sanitize' => 'sanitize_text_field',
		),
		'twoia_hero_secondary_url' => array(
			'label'    => esc_html__( 'Hero secondary button URL', 'two-identities-anonymous' ),
			'default'  => '/methodology/',
			'type'     => 'url',
			'sanitize' => 'esc_url_raw',
		),
		'twoia_disclaimer' => array(
			'label'    => esc_html__( 'Site disclaimer text', 'two-identities-anonymous' ),
			'default'  => esc_html__( '2IA is an independent public-intelligence research project. It is not affiliated with any government, intelligence service, law-enforcement agency, or surveillance vendor.', 'two-identities-anonymous' ),
			'type'     => 'textarea',
			'sanitize' => 'twoia_sanitize_limited_html',
		),
		'twoia_footer_mission' => array(
			'label'    => esc_html__( 'Footer mission text', 'two-identities-anonymous' ),
			'default'  => esc_html__( '2IA is an independent research project studying modern communications surveillance, public intelligence, identity, metadata, civil liberties, and the anonymous space between the given self and the chosen self.', 'two-identities-anonymous' ),
			'type'     => 'textarea',
			'sanitize' => 'twoia_sanitize_limited_html',
		),
		'twoia_accent_color' => array(
			'label'    => esc_html__( 'Accent color', 'two-identities-anonymous' ),
			'default'  => '#6ee7d8',
			'type'     => 'color',
			'sanitize' => 'sanitize_hex_color',
		),
		'twoia_analytics_placeholder' => array(
			'label'    => esc_html__( 'Privacy-first analytics placeholder', 'two-identities-anonymous' ),
			'default'  => esc_html__( 'No analytics are installed by this theme. If analytics are added later, document provider, purpose, consent, retention, and opt-out behavior in the Privacy Policy.', 'two-identities-anonymous' ),
			'type'     => 'textarea',
			'sanitize' => 'twoia_sanitize_limited_html',
		),
	);

	foreach ( $settings as $setting_id => $setting ) {
		$wp_customize->add_setting(
			$setting_id,
			array(
				'default'           => $setting['default'],
				'sanitize_callback' => $setting['sanitize'],
				'transport'         => 'refresh',
			)
		);

		$wp_customize->add_control(
			$setting_id,
			array(
				'label'   => $setting['label'],
				'section' => 'twoia_branding',
				'type'    => $setting['type'],
			)
		);
	}

	$wp_customize->add_setting(
		'twoia_show_seed_notice',
		array(
			'default'           => true,
			'sanitize_callback' => 'twoia_sanitize_checkbox',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'twoia_show_seed_notice',
		array(
			'label'       => esc_html__( 'Show seeded content notice in admin', 'two-identities-anonymous' ),
			'description' => esc_html__( 'Display an admin notice with a link to create safe draft starter pages when the site has no pages.', 'two-identities-anonymous' ),
			'section'     => 'twoia_branding',
			'type'        => 'checkbox',
		)
	);

	$wp_customize->add_setting(
		'twoia_enable_comments',
		array(
			'default'           => false,
			'sanitize_callback' => 'twoia_sanitize_checkbox',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'twoia_enable_comments',
		array(
			'label'       => esc_html__( 'Enable comment display', 'two-identities-anonymous' ),
			'description' => esc_html__( 'Comments are closed by default for a privacy-first research site. Enable this only if you plan to moderate comments.', 'two-identities-anonymous' ),
			'section'     => 'twoia_branding',
			'type'        => 'checkbox',
		)
	);
}
add_action( 'customize_register', 'twoia_customize_register' );

/**
 * Output Customizer accent color CSS safely.
 */
function twoia_customizer_css() {
	$accent = sanitize_hex_color( get_theme_mod( 'twoia_accent_color', '#6ee7d8' ) );

	if ( ! $accent ) {
		return;
	}
	?>
	<style id="twoia-customizer-css">
		:root { --color-accent: <?php echo esc_html( $accent ); ?>; }
	</style>
	<?php
}
add_action( 'wp_head', 'twoia_customizer_css', 12 );