-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
114 lines (74 loc) · 3.11 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
<?php
/* to have WP load dynamically the title tag
and it works as long as wp_head(); is in header.php */
function hamlet_theme_support() {
add_theme_support('title-tag');
add_theme_support('custom-logo'); // adding option to add and customize logo from WP back end
add_theme_support('post-thumbnails'); // adding option to set a featured image to posts
}
add_action('after_setup_theme', 'hamlet_theme_support');
// to add WP menus
function hamlet_menus(){
$locations = array(
'primary' => "Desktop Primary Left Sidebar",
'footer' => "Footer Menu Items"
);
register_nav_menus($locations);
}
add_action('init', 'hamlet_menus');
// to register and enqueue style.css, bootstrap and font awesome
function hamlet_register_styles(){
$version = wp_get_theme()->get('Version');
/* array('hamlet-bootstrap') allows boostrap to load before style.css
because style.css is dependent on bootstrap */
// enqueued stylesheet
wp_enqueue_style('hamlet-style', get_template_directory_uri() . "/style.css"
, array('hamlet-bootstrap'), $version, 'all');
// enqueued bootstrap
wp_enqueue_style('hamlet-bootstrap',
"https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
, array(), '4.4.1', 'all');
//enqueued font awesome
wp_enqueue_style('hamlet-fontawesome'
, "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"
, array(), '5.13.0', 'all');
}
add_action('wp_enqueue_scripts', 'hamlet_register_styles');
// to register and enqueue scripts
function hamlet_register_scripts(){
wp_enqueue_script('hamlet-jquery', "https://code.jquery.com/jquery-3.4.1.slim.min.js"
, array(), '3.4.1', true);
wp_enqueue_script('hamlet-popper', "https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
, array(), '1.16.0', true);
wp_enqueue_script('hamlet-bootstrap', "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
, array(), '4.4.1', true);
wp_enqueue_script('hamlet-main', get_template_directory_uri() . "/assets/js/main.js"
, array(), '1.0', true);
}
add_action('wp_enqueue_scripts', 'hamlet_register_scripts');
function hamlet_widget_areas() {
register_sidebar(
array(
'before_title' => '',
'after_title' => '',
'before_widget' => '<ul class="social-list list-inline py-3 mx-auto">',
'after_widget' => '</ul>',
'name' => 'Sidebar Area',
'id' => 'sidebar-1',
'description' => 'Sidebar Widget Area'
)
);
register_sidebar(
array(
'before_title' => '',
'after_title' => '',
'before_widget' => '<ul class="social-list list-inline py-3 mx-auto">',
'after_widget' => '</ul>',
'name' => 'Footer Area',
'id' => 'footer-1',
'description' => 'Footer Widget Area'
)
);
}
add_action( 'widgets_init', 'hamlet_widget_areas' );
?>