- Removed the old SVG file for the dashboard chart and replaced it with a new implementation directly in the PHP file. - Updated the SVG structure to improve accessibility and styling, including the use of CSS classes for dynamic theming. - Enhanced the bar charts, line graph, and pie chart with new gradients and animations. - Adjusted the enqueue script for the dashboard animator to include versioning based on file modification time.
120 lines
3.1 KiB
PHP
120 lines
3.1 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
|
|
);
|
|
|
|
// 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 );
|
|
}
|