86 lines
2.3 KiB
PHP
86 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Enqueue scripts and styles
|
|
*
|
|
* @package HomeProz
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Enqueue frontend scripts and styles
|
|
*/
|
|
function homeproz_scripts() {
|
|
// Main stylesheet (Vite compiled)
|
|
if (file_exists(HOMEPROZ_DIR . '/dist/assets/main.css')) {
|
|
wp_enqueue_style(
|
|
'homeproz-style',
|
|
HOMEPROZ_URI . '/dist/assets/main.css',
|
|
array(),
|
|
HOMEPROZ_VERSION
|
|
);
|
|
}
|
|
|
|
// jQuery is already included in WordPress, just ensure it's loaded
|
|
wp_enqueue_script('jquery');
|
|
|
|
// Main JavaScript (Vite compiled)
|
|
if (file_exists(HOMEPROZ_DIR . '/dist/assets/main.js')) {
|
|
wp_enqueue_script(
|
|
'homeproz-script',
|
|
HOMEPROZ_URI . '/dist/assets/main.js',
|
|
array('jquery'),
|
|
HOMEPROZ_VERSION,
|
|
true
|
|
);
|
|
|
|
// Localize script with useful data
|
|
wp_localize_script('homeproz-script', 'homeproz', array(
|
|
'ajaxurl' => admin_url('admin-ajax.php'),
|
|
'nonce' => wp_create_nonce('homeproz_nonce'),
|
|
'siteurl' => get_site_url(),
|
|
));
|
|
}
|
|
|
|
// Google Fonts - Abril Fatface and Inter
|
|
wp_enqueue_style(
|
|
'homeproz-fonts',
|
|
'https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Inter:wght@400;500;600;700&display=swap',
|
|
array(),
|
|
null
|
|
);
|
|
}
|
|
add_action('wp_enqueue_scripts', 'homeproz_scripts');
|
|
|
|
/**
|
|
* Enqueue editor styles
|
|
*/
|
|
function homeproz_editor_styles() {
|
|
add_editor_style('dist/assets/editor.css');
|
|
|
|
// Google Fonts for editor
|
|
add_editor_style('https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Inter:wght@400;500;600;700&display=swap');
|
|
}
|
|
add_action('after_setup_theme', 'homeproz_editor_styles');
|
|
|
|
/**
|
|
* Add preconnect for Google Fonts
|
|
*/
|
|
function homeproz_resource_hints($urls, $relation_type) {
|
|
if ($relation_type === 'preconnect') {
|
|
$urls[] = array(
|
|
'href' => 'https://fonts.googleapis.com',
|
|
'crossorigin' => 'anonymous',
|
|
);
|
|
$urls[] = array(
|
|
'href' => 'https://fonts.gstatic.com',
|
|
'crossorigin' => 'anonymous',
|
|
);
|
|
}
|
|
return $urls;
|
|
}
|
|
add_filter('wp_resource_hints', 'homeproz_resource_hints', 10, 2);
|