/
functions.php
106 lines (80 loc) · 2.89 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
<?php
//-------------
// Set up CSS file-loading
//-------------
function theme_dir() {
return get_template_directory_uri();
}
function theme_styles() {
wp_enqueue_style('main_css', theme_dir() . '/dist/style.min.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
//-------------
// Set up JS script-loading
//-------------
function theme_js(){
global $wp_scripts;
wp_register_script(
'html5_shiv', // handle
'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', //link-to-file
'', //dependencies
'', //version #
false //load in header(`true` loads in footer)
);
wp_register_script(
'respond_js',
'https://oss.maxcdn.com/respond/1.4.2/respond.min.js',
'',
'',
false
);
$wp_scripts->add_data('html5_shiv', 'conditional', 'lt IE 9');
$wp_scripts->add_data('respond_js', 'conditional', 'lt IE 9');
wp_enqueue_script('bootstrap_js', theme_dir() . '/js/bootstrap.min.js', ['jquery'] , '', true);
wp_enqueue_script('theme_js', theme_dir() . '/js/theme.js', ['jquery','bootstrap_js'], '', true);
}
add_action('wp_enqueue_scripts', 'theme_js');
//-------------
//Adding theme support
//-------------
//allows us to create a new header menu on the backend that will also show on the frontend
add_theme_support('menus');
//allows us to create custom post types that lets us dynamically populate posts w images
add_theme_support('post-thumbnails');
function register_theme_menus(){
register_nav_menus(
[
'header-menu' => __('Header Menu'),
'landing'=> __('Landing Sub Menu'),
'about'=> __('About Sub Menu'),
'contact'=> __('Contact Sub Menu'),
'solutions'=> __('Solutions Sub Menu'),
'products'=> __('Products Sub Menu'),
'footer-menu'=>__('Footer Menu')
]
);
}
add_action('init', 'register_ s' );
//-------------
//creting/registering a sidebar widget
//------------
function create_widget($name, $id, $description){
$widget_options = [
'name' => __($name),
'id' => $id,
'description' => __($description),
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
];
register_sidebar($widget_options);
}
create_widget('Front Page Left', 'front-left', 'Displays on left of hompage');
create_widget('Front Page Center', 'front-center', 'Displays on center of hompage');
create_widget('Front Page Right', 'front-right', 'Displays on right of hompage');
create_widget('Page Sidebar', 'page', 'Displays on pages w sidebar');
create_widget('Blog Sidebar', 'blog', 'Displays on the side of pages in the blog section');
create_widget('Company-Description', 'company-desc', 'Wall of Text');
create_widget('Company-Contact', 'company-address', 'Phone-Email');
?>