Repository navigation
Expand file tree
/
Copy pathfunctions.php
More file actions
67 lines (57 loc) · 2.33 KB
/
Copy pathfunctions.php
File metadata and controls
67 lines (57 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* راهاندازی قالب و بارگذاری فایلها
*/
// مسیر قالب
if ( ! defined( 'MYTHEME_DIR' ) ) {
define( 'MYTHEME_DIR', get_template_directory() );
}
if ( ! defined( 'THEME_NAME' ) ) {
define( 'THEME_NAME', 'opcaspain' );
}
// URL قالب
if ( ! defined( 'MYTHEME_URI' ) ) {
define( 'MYTHEME_URI', get_template_directory_uri() );
}
// فعالسازی پشتیبانی از امکانات قالب
function mytheme_setup() {
add_theme_support( 'title-tag' ); // تایتل خودکار
add_theme_support( 'post-thumbnails' ); // تصاویر شاخص
add_theme_support( 'html5', [ 'search-form', 'gallery', 'caption' ] );
register_nav_menus( [ 'primary' => 'منوی اصلی' ] );
register_nav_menus( [ 'footer_menu' => 'منوی فوتر' ] );
}
add_action( 'after_setup_theme', 'mytheme_setup' );
// بارگذاری Tailwind و فایلهای JS
function mytheme_enqueue_scripts() {
// استایل اصلی Tailwind با preload
wp_enqueue_style( 'mytheme-style', MYTHEME_URI . '/dist/css/style.min.css', [], filemtime( MYTHEME_DIR . '/dist/css/style.min.css' ) );
add_filter( 'style_loader_tag', function( $html, $handle ) {
if ( 'mytheme-style' === $handle ) {
$html = str_replace( "rel='stylesheet'", "rel='preload' as='style' onload=\"this.onload=null;this.rel='stylesheet'\"", $html );
}
return $html;
}, 10, 2 );
// اسکریپت اصلی JS با defer
wp_enqueue_script( 'mytheme-script', MYTHEME_URI . '/dist/js/app.js', [], filemtime( MYTHEME_DIR . '/dist/js/app.js' ), true );
add_filter( 'script_loader_tag', function( $tag, $handle ) {
if ( 'mytheme-script' === $handle ) {
$tag = str_replace( ' src', ' defer src', $tag );
}
if ( 'alpinejs' === $handle ) {
$tag = str_replace( ' src', ' defer src', $tag );
}
return $tag;
}, 10, 2 );
// Alpine.js
wp_enqueue_script('alpinejs','https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js', [], null, true);
}
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_scripts' );
// require فایل پست تایپ
require MYTHEME_DIR . '/inc/portfolio-posttype.php';
// include require file
include_once MYTHEME_DIR . '/include/opt/redux-core/framework.php';
require_once MYTHEME_DIR . '/include/cmb2/init.php';
include_once MYTHEME_DIR . '/admin/redux-config.php';
require_once MYTHEME_DIR . '/admin/meta-box.php';
?>