HEX
Server: LiteSpeed
System: Linux c7.my-control-panel.com 4.18.0-553.141.2.lve.el8.x86_64 #1 SMP Wed Jul 8 16:10:02 UTC 2026 x86_64
User: bigfreeodds (5956)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/bigfreeodds/public_html/wp-content/themes/neon-kick-live/functions.php
<?php
/**
 * Neon Kick Live — Theme Functions
 *
 * @package NeonKickLive
 */

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

define( 'NEONKICK_THEME_VERSION', file_exists( get_template_directory() . '/assets/css/neon-kick.css' ) ? (string) filemtime( get_template_directory() . '/assets/css/neon-kick.css' ) : '1.0.0' );
define( 'NEONKICK_THEME_DIR', get_template_directory() );
define( 'NEONKICK_THEME_URL', get_template_directory_uri() );

// ─── Theme Setup ─────────────────────────────────────────────────────────────
add_action( 'after_setup_theme', 'neonkick_theme_setup' );

function neonkick_theme_setup() {
	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
	add_theme_support( 'automatic-feed-links' );

	register_nav_menus( array(
		'primary' => __( 'Primary Menu', 'neon-kick-live' ),
	) );
}

add_filter( 'document_title_parts', 'neonkick_frontend_brand_title' );

function neonkick_frontend_brand_title( $parts ) {
	if ( is_admin() ) {
		return $parts;
	}

	$parts['site'] = 'BigFreeOdds';
	return $parts;
}

// ─── Enqueue Assets ──────────────────────────────────────────────────────────
add_action( 'wp_enqueue_scripts', 'neonkick_enqueue_assets' );

function neonkick_enqueue_assets() {
	// Main CSS — exact copy of original Lovable style.css.
	wp_enqueue_style(
		'neonkick-styles',
		NEONKICK_THEME_URL . '/assets/css/neon-kick.css',
		array(),
		NEONKICK_THEME_VERSION
	);

	// Main JS — from plugin (if plugin is active), otherwise from theme.
	if ( defined( 'NEONKICK_URL' ) ) {
		// Plugin is active — enqueue from plugin.
		wp_enqueue_script(
			'neonkick-app',
			NEONKICK_URL . 'assets/js/neon-kick.js',
			array(),
			NEONKICK_VERSION,
			true
		);
	} else {
		// Fallback — enqueue from theme.
		wp_enqueue_script(
			'neonkick-app',
			NEONKICK_THEME_URL . '/assets/js/neon-kick.js',
			array(),
			NEONKICK_THEME_VERSION,
			true
		);
	}

	// Pass WordPress data to JavaScript.
	wp_localize_script( 'neonkick-app', 'neonKickData', neonkick_get_js_data() );
}

/**
 * Build the data object passed to JS via wp_localize_script.
 * This is the ONLY place WordPress URLs and user state reach the frontend.
 */
function neonkick_get_js_data() {
	$user      = wp_get_current_user();
	$logged_in = is_user_logged_in();

	// Get initials from display name.
	$initials = '?';
	if ( $logged_in && $user->display_name ) {
		$words = preg_split( '/\s+/', trim( $user->display_name ) );
		if ( count( $words ) >= 2 ) {
			$initials = strtoupper( substr( $words[0], 0, 1 ) . substr( end( $words ), 0, 1 ) );
		} else {
			$initials = strtoupper( substr( $user->display_name, 0, 2 ) );
		}
	}

	// Helper: get page URL by slug.
	$page_url = function( $slug, $fallback = '/' ) {
		$page = get_page_by_path( $slug );
		return $page ? get_permalink( $page->ID ) : home_url( '/' . $slug . '/' );
	};

	return array(
		// REST API.
		'restUrl'          => esc_url_raw( rest_url( 'neon-kick/v1' ) ),
		'nonce'            => wp_create_nonce( 'wp_rest' ),

		// Auth.
		'isLoggedIn'       => $logged_in,
		'displayName'      => $logged_in ? esc_html( $user->display_name ) : '',
		'email'            => $logged_in ? esc_html( $user->user_email ) : '',
		'initials'         => esc_html( $initials ),
		'joinedDate'       => $logged_in && ! empty( $user->user_registered ) ? esc_html( mysql2date( get_option( 'date_format' ), $user->user_registered ) ) : '',
		'avatarColor'      => $logged_in ? sanitize_key( get_user_meta( $user->ID, 'neonkick_avatar_color', true ) ?: 'green' ) : 'green',
		'themePreference'  => $logged_in ? sanitize_key( get_user_meta( $user->ID, 'neonkick_theme_preference', true ) ?: 'system' ) : '',
		'loginUrl'         => esc_url( $page_url( 'login' ) ),
		'registerUrl'      => esc_url( $page_url( 'register' ) ),
		'forgotPasswordUrl' => esc_url( $page_url( 'forgot-password' ) ),
		'logoutUrl'        => esc_url( wp_logout_url( $page_url( 'profile' ) ) ),
		'editProfileUrl'   => esc_url( $page_url( 'edit-profile' ) ),
		'accountSettingsUrl'=> esc_url( $page_url( 'account-settings' ) ),

		// Page URLs — dynamically resolved from WordPress pages.
		'homeUrl'          => esc_url( home_url( '/' ) ),
		'liveUrl'          => esc_url( $page_url( 'live' ) ),
		'matchDetailUrl'   => esc_url( $page_url( 'match-detail' ) ),
		'favouritesUrl'    => esc_url( $page_url( 'favourites' ) ),
		'leaguesUrl'       => esc_url( $page_url( 'leagues' ) ),
		'searchUrl'        => esc_url( $page_url( 'search' ) ),
		'dashboardUrl'     => esc_url( $page_url( 'dashboard' ) ),
		'notificationsUrl' => esc_url( $page_url( 'notifications' ) ),
		'profileUrl'       => esc_url( $page_url( 'profile' ) ),
		'settingsUrl'      => esc_url( $page_url( 'settings' ) ),
		'aboutUrl'         => esc_url( $page_url( 'about' ) ),
		'contactUrl'       => esc_url( $page_url( 'contact' ) ),
		'fixturesUrl'      => esc_url( $page_url( 'fixtures' ) ),
		'standingsUrl'     => esc_url( $page_url( 'standings' ) ),
	);
}

add_filter( 'template_include', 'neonkick_profile_template_include' );

function neonkick_profile_template_include( $template ) {
	if ( is_page( 'profile' ) ) {
		$profile_template = locate_template( 'page-profile.php' );
		if ( $profile_template ) {
			return $profile_template;
		}
	}
	return $template;
}

// ─── Remove wp_head clutter ──────────────────────────────────────────────────
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'rsd_link' );

// ─── Body classes ─────────────────────────────────────────────────────────────
add_filter( 'body_class', 'neonkick_body_classes' );

function neonkick_body_classes( $classes ) {
	// Add page-slug as data-page for JS routing — appended via wp_body_open hook.
	return $classes;
}

// ─── Set data-page attribute on body ─────────────────────────────────────────
add_action( 'wp_head', 'neonkick_set_data_page_inline', 1 );

function neonkick_set_data_page_inline() {
	$page = neonkick_get_current_page();
	echo "<script>window.neonkickPage = '" . esc_js( $page ) . "'; document.addEventListener('DOMContentLoaded',function(){var b=document.body;if(!b.dataset.page){b.dataset.page='" . esc_js( $page ) . "';}});</script>\n";
}

/**
 * Determine the current page identifier for data-page attribute.
 */
function neonkick_get_current_page() {
	if ( is_front_page() ) return 'home';

	global $post;
	if ( ! $post ) return 'home';

	$slug = $post->post_name;

	$slug_map = array(
		'live'                  => 'live',
		'match-detail'          => 'match',
		'leagues'               => 'leagues',
		'league-detail'         => 'league-detail',
		'favourites'            => 'favourites',
		'profile'               => 'profile',
		'dashboard'             => 'dashboard',
		'search'                => 'search',
		'about'                 => 'about',
		'contact'               => 'contact',
		'notifications'         => 'notifications',
		'settings'              => 'settings',
		'standings'             => 'standings',
		'fixtures'              => 'fixtures',
		'results'               => 'results',
		'login'                 => 'login',
		'register'              => 'register',
		'forgot-password'       => 'forgot-password',
		'lineups'               => 'lineups',
		'player-detail'         => 'player',
		'team-detail'           => 'team',
		'edit-profile'          => 'edit-profile',
		'followed-leagues'      => 'followed-leagues',
		'notification-settings' => 'notification-settings',
		'account-settings'      => 'account-settings',
	);

	return $slug_map[ $slug ] ?? 'home';
}

// ─── Excerpt length ───────────────────────────────────────────────────────────
add_filter( 'excerpt_length', function() { return 20; } );

// ─── Allow SVG upload ─────────────────────────────────────────────────────────
add_filter( 'upload_mimes', function( $mimes ) {
	$mimes['svg'] = 'image/svg+xml';
	return $mimes;
} );

// ─── Remove comments from admin bar ──────────────────────────────────────────
add_action( 'admin_bar_menu', function( $wp_admin_bar ) {
	$wp_admin_bar->remove_node( 'comments' );
}, 999 );