-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
107 lines (87 loc) · 2.67 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
<?php
$inc = __DIR__ . '/inc';
require_once $inc . '/_helpers.php';
// Abort if required plugins is inactive
if (!Helper::has_required_plugins()) { return; }
// Modules
require_once $inc . '/enqueue.php';
require_once $inc . '/gutenberg.php';
require_once $inc . '/acf.php';
if (is_admin()) {
require_once $inc . '/admin.php';
} else {
// require_once $inc . '/api.php';
require_once $inc . '/frontend.php';
}
if (class_exists('WooCommerce')) {
require_once __DIR__ . '/woocommerce/_functions.php';
}
// Initial setup
my_before_setup_theme();
add_action('after_setup_theme', 'my_after_setup_theme');
add_action('widgets_init', 'my_widgets_init');
/////
/**
* Function that run first
*/
function my_before_setup_theme() {
/**
* Register custom post type
* - Read more at https://github.com/hrsetyono/edje-wp-library/wiki/Custom-Post-Type
*/
// H::register_post_type('product', [ 'menu_icon' => 'dashicons-cart' ]);
// H::register_taxonomy('brand', 'product', []);
}
/**
* Setup theme supports
*
* @action after_setup_theme
*/
function my_after_setup_theme() {
add_theme_support('post-thumbnails');
add_theme_support('menus');
add_theme_support('custom-logo');
add_theme_support('title-tag');
add_theme_support('html5', [
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'navigation-widgets', 'style', 'script'
]);
add_theme_support('automatic-feed-links');
add_post_type_support('page', 'excerpt'); // allow page to have excerpt
add_theme_support('widgets');
add_theme_support('customize-selective-refresh-widgets');
// Edje Support
add_theme_support('h-widget-builder-v2');
add_theme_support('h-mega-menu');
add_theme_support('h-faq-block-v2');
add_theme_support('h-icon-block');
add_theme_support('h-comment-editor'); // Enable this if you allow comment in the website
add_theme_support('h-dark-mode'); // Enable this and uncomment the CSS & JS if you want dark mode
// Gutenberg support
add_theme_support('align-wide');
add_theme_support('responsive-embeds');
remove_theme_support('core-block-patterns');
/**
* ACF Options page
*/
if (function_exists('acf_add_options_page')) {
acf_add_options_sub_page([
'page_title' => 'Theme Options',
'parent_slug' => 'themes.php',
// 'autoload' => true, // load all at once
]);
}
}
/**
* @action widgets_init
*/
function my_widgets_init() {
register_sidebar([
'name' => 'Sidebar',
'id' => 'sidebar',
'description' => 'Appear besides post',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
]);
}