- Extend block attributes to include new animation options in index.php - Implement animation rendering logic for each sector in oribi_render_platform_row function - Enqueue new JavaScript file for solutions page animations in enqueue.php - Create solutions-animator.js to handle live data KPI and transit board animations
147 lines
3.9 KiB
PHP
147 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* Asset Enqueuing - frontend styles, scripts, and editor additions.
|
|
*
|
|
* @package OTS_Theme
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/* ── Frontend assets ───────────────────────────────────────── */
|
|
add_action( 'wp_enqueue_scripts', function () {
|
|
|
|
// Main stylesheet (supplements theme.json generated styles)
|
|
wp_enqueue_style(
|
|
'oribi-main',
|
|
ORIBI_URI . '/assets/css/main.css',
|
|
[],
|
|
ORIBI_VERSION
|
|
);
|
|
|
|
// Main JS - dark mode, sticky header, mobile nav, scroll animations
|
|
wp_enqueue_script(
|
|
'oribi-main',
|
|
ORIBI_URI . '/assets/js/main.js',
|
|
[],
|
|
ORIBI_VERSION,
|
|
true
|
|
);
|
|
|
|
// Dashboard chart animator - smooth continuous animations for dashboard cards
|
|
wp_enqueue_script(
|
|
'oribi-dashboard-animator',
|
|
ORIBI_URI . '/assets/js/dashboard-animator.js',
|
|
[],
|
|
ORIBI_VERSION . '.' . filemtime( ORIBI_DIR . '/assets/js/dashboard-animator.js' ),
|
|
true
|
|
);
|
|
|
|
// Gallery TV slideshow - cycles images in TV-frame cards
|
|
wp_enqueue_script(
|
|
'oribi-gallery-tv',
|
|
ORIBI_URI . '/assets/js/industry-animator.js',
|
|
[],
|
|
ORIBI_VERSION . '.' . filemtime( ORIBI_DIR . '/assets/js/industry-animator.js' ),
|
|
true
|
|
);
|
|
|
|
// Video editor timeline animator - animated playhead and preview crossfades
|
|
wp_enqueue_script(
|
|
'oribi-video-editor-animator',
|
|
ORIBI_URI . '/assets/js/video-editor-animator.js',
|
|
[],
|
|
ORIBI_VERSION . '.' . filemtime( ORIBI_DIR . '/assets/js/video-editor-animator.js' ),
|
|
true
|
|
);
|
|
|
|
// Solutions page animators - live data KPI ticker and transit departure board
|
|
wp_enqueue_script(
|
|
'oribi-solutions-animator',
|
|
ORIBI_URI . '/assets/js/solutions-animator.js',
|
|
[],
|
|
ORIBI_VERSION . '.' . filemtime( ORIBI_DIR . '/assets/js/solutions-animator.js' ),
|
|
true
|
|
);
|
|
|
|
// Localize AJAX endpoint for the contact form
|
|
wp_localize_script( 'oribi-main', 'oribiAjax', [
|
|
'url' => admin_url( 'admin-ajax.php' ),
|
|
'nonce' => wp_create_nonce( 'oribi_contact_nonce' ),
|
|
] );
|
|
|
|
// Threaded comments (if ever enabled)
|
|
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
|
wp_enqueue_script( 'comment-reply' );
|
|
}
|
|
} );
|
|
|
|
/* ── Font Awesome 6 Free (CDN) ─────────────────────────────── */
|
|
add_action( 'wp_enqueue_scripts', function () {
|
|
wp_enqueue_style(
|
|
'font-awesome',
|
|
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css',
|
|
[],
|
|
null
|
|
);
|
|
} );
|
|
|
|
add_action( 'enqueue_block_editor_assets', function () {
|
|
wp_enqueue_style(
|
|
'font-awesome',
|
|
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css',
|
|
[],
|
|
null
|
|
);
|
|
} );
|
|
|
|
/* ── Google Fonts - dynamic based on theme settings ────────── */
|
|
add_action( 'wp_enqueue_scripts', 'oribi_enqueue_selected_fonts' );
|
|
add_action( 'enqueue_block_editor_assets', 'oribi_enqueue_selected_fonts' );
|
|
|
|
/**
|
|
* Enqueue Google Fonts stylesheets for the selected body & heading fonts.
|
|
*/
|
|
function oribi_enqueue_selected_fonts() {
|
|
if ( ! function_exists( 'oribi_get_setting' ) ) {
|
|
return;
|
|
}
|
|
|
|
$slugs = array_unique( array_filter( [
|
|
oribi_get_setting( 'font_family' ),
|
|
oribi_get_setting( 'font_heading' ),
|
|
] ) );
|
|
|
|
foreach ( $slugs as $slug ) {
|
|
$url = oribi_get_google_font_url( $slug );
|
|
if ( $url ) {
|
|
wp_enqueue_style(
|
|
'oribi-gf-' . $slug,
|
|
$url,
|
|
[],
|
|
null
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* ── Generated theme CSS (colour / font / spacing overrides) ─ */
|
|
add_action( 'wp_enqueue_scripts', 'oribi_enqueue_generated_css', 20 );
|
|
add_action( 'enqueue_block_editor_assets', 'oribi_enqueue_generated_css', 20 );
|
|
|
|
/**
|
|
* Enqueue the dynamically generated CSS file that applies design-token
|
|
* overrides from the admin settings page.
|
|
*/
|
|
function oribi_enqueue_generated_css() {
|
|
if ( ! function_exists( 'oribi_generated_css_url' ) ) {
|
|
return;
|
|
}
|
|
|
|
$url = oribi_generated_css_url();
|
|
$ver = get_theme_mod( 'oribi_css_version', '1' );
|
|
|
|
wp_enqueue_style( 'oribi-custom-tokens', $url, [ 'oribi-main' ], $ver );
|
|
}
|