-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.php
141 lines (118 loc) · 3.63 KB
/
functions.php
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* Functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package grigora-blocks
* @since 1.0.0
*/
/**
* The theme version.
*
* @since 1.0.0
*/
define( 'GRIGORA_DEBUG', false );
define( 'GRIGORA_VERSION', wp_get_theme()->get( 'Version' ) );
define( 'GRIGORA_HOME', 'https://wpgrigora.com/');
/**
* Add theme support for block styles and editor style.
*
* @since 1.0.0
*
* @return void
*/
function grigora_setup() {
// load translations
load_theme_textdomain( 'grigora-blocks' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'status' ) );
add_theme_support( 'woocommerce' );
add_theme_support( 'title-tag' );
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'script', 'style' ) );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'editor-styles' );
// Enqueue editor styles and fonts.
add_editor_style(
array(
'./assets/css/grigora-editor.min.css'
)
);
}
add_action( 'after_setup_theme', 'grigora_setup' );
// Recommend Plugins
require_once get_theme_file_path( 'inc/recommend-plugins.php' );
/**
* Enqueue the CSS files.
*
* @since 1.0.0
*
* @return void
*/
function grigora_styles() {
$ver = GRIGORA_DEBUG ? time() : GRIGORA_VERSION;
$extension = GRIGORA_DEBUG ? ".css" : ".min.css";
if( is_rtl() ){
wp_enqueue_style(
'grigora-rtl',
get_theme_file_uri( 'assets/css/rtl' . $extension ),
[],
$ver
);
}
else{
wp_enqueue_style(
'grigora-style',
get_theme_file_uri( 'assets/css/global' . $extension ),
[],
$ver
);
}
wp_register_script('grigora_main_js', get_theme_file_uri('js/main.js'), [], $ver, true);
wp_enqueue_script('grigora_main_js');
}
add_action( 'wp_enqueue_scripts', 'grigora_styles' );
// WPTT Webfont Loader.
require_once get_theme_file_path( 'inc/wptt-webfont-loader.php' );
// Filters.
require_once get_theme_file_path( 'inc/filters.php' );
// REST API.
require_once get_theme_file_path( 'inc/register-rest-api.php' );
// Block variation example.
require_once get_theme_file_path( 'inc/register-block-variations.php' );
// Block style examples.
require_once get_theme_file_path( 'inc/register-block-styles.php' );
// Load Styles CSS conditionally.
require_once get_theme_file_path( 'inc/smart-styles.php' );
// Block pattern and block category examples.
require_once get_theme_file_path( 'inc/register-block-patterns.php' );
// Block pattern and block category examples.
require_once get_theme_file_path( 'inc/enqueue-dynamic-fonts.php' );
function grigora_site_editor_script($hook) {
$ver = GRIGORA_DEBUG ? time() : GRIGORA_VERSION;
$extension = GRIGORA_DEBUG ? ".css" : ".min.css";
$path = get_template_directory_uri() . '/inc/sidebar/build/index.js';
wp_enqueue_style(
'grigora-site-editor-settings-css',
get_theme_file_uri( 'inc/sidebar/assets/css/main' . $extension ),
[],
$ver
);
wp_register_script(
'grigora-site-editor-settings',
$path,
array( 'react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-site', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-primitives' ),
$ver,
true
);
wp_localize_script( 'grigora-site-editor-settings', 'grigora_constants',
array(
'current_screen' => get_current_screen()->id,
)
);
wp_enqueue_script( 'grigora-site-editor-settings' );
}
add_action( 'enqueue_block_editor_assets', 'grigora_site_editor_script' );