forked from babobski/Bootstrap-on-WordPress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
209 lines (144 loc) · 7.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
/**
* Bootstrap 4 on Wordpress functions and definitions
*
* For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
*
* @package WordPress
* @subpackage Bootstrap 4.0.0
* @autor Babobski
*/
/* ========================================================================================================================
Add language support to theme
======================================================================================================================== */
add_action('after_setup_theme', 'my_theme_setup');
function my_theme_setup(){
load_theme_textdomain('wp_babobski', get_template_directory() . '/language');
}
/* ========================================================================================================================
Required external files
======================================================================================================================== */
require_once( 'external/bootstrap-utilities.php' );
require_once( 'external/bs4navwalker.php' );
/* ========================================================================================================================
Add html 5 support to wordpress elements
======================================================================================================================== */
add_theme_support( 'html5', array(
'comment-list',
'search-form',
'comment-form',
'gallery',
'caption',
) );
/* ========================================================================================================================
Theme specific settings
======================================================================================================================== */
add_theme_support('post-thumbnails');
//add_image_size( 'name', width, height, crop true|false );
register_nav_menus(array('primary' => 'Primary Navigation'));
/* ========================================================================================================================
Actions and Filters
======================================================================================================================== */
add_action( 'wp_enqueue_scripts', 'bootstrap_script_init' );
add_filter( 'body_class', array( 'BsWp', 'add_slug_to_body_class' ) );
/* ========================================================================================================================
Custom Post Types - include custom post types and taxonomies here e.g.
e.g. require_once( 'custom-post-types/your-custom-post-type.php' );
======================================================================================================================== */
/* ========================================================================================================================
Scripts
======================================================================================================================== */
/**
* Add scripts via wp_head()
*
* @return void
* @author Keir Whitaker
*/
function bootstrap_script_init() {
wp_register_script('popper', '//cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js', array( 'jquery' ), '1.12.3', true);
wp_enqueue_script('popper');
wp_register_script('bootstrap', get_template_directory_uri(). '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '3.3.7', true);
wp_enqueue_script('bootstrap');
wp_register_script( 'site', get_template_directory_uri().'/js/site.js', array( 'jquery', 'bootstrap' ), '0.0.1', true );
wp_enqueue_script( 'site' );
wp_register_style( 'bootstrap', get_stylesheet_directory_uri().'/css/bootstrap.min.css', '', '3.3.7', 'all' );
wp_enqueue_style( 'bootstrap' );
wp_register_style( 'screen', get_stylesheet_directory_uri().'/style.css', '', array(), 'screen' );
wp_enqueue_style( 'screen' );
}
/* ========================================================================================================================
Security & cleanup wp admin
======================================================================================================================== */
//remove wp version
function theme_remove_version() {
return '';
}
add_filter('the_generator', 'theme_remove_version');
//remove default footer text
function remove_footer_admin () {
echo "";
}
add_filter('admin_footer_text', 'remove_footer_admin');
//remove wordpress logo from adminbar
function wp_logo_admin_bar_remove() {
global $wp_admin_bar;
/* Remove their stuff */
$wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'wp_logo_admin_bar_remove', 0);
// Remove default Dashboard widgets
function disable_default_dashboard_widgets() {
//remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_activity', 'dashboard', 'core');
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
remove_meta_box('dashboard_plugins', 'dashboard', 'core');
remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
remove_meta_box('dashboard_primary', 'dashboard', 'core');
remove_meta_box('dashboard_secondary', 'dashboard', 'core');
}
add_action('admin_menu', 'disable_default_dashboard_widgets');
remove_action('welcome_panel', 'wp_welcome_panel');
/* ========================================================================================================================
Custom login
======================================================================================================================== */
// Add custom css
function my_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/css/custom-login-style.css" />';
}
add_action('login_head', 'my_custom_login');
// Link the logo to the home of our website
function my_login_logo_url() {
return get_bloginfo( 'url' );
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
// Change the title text
function my_login_logo_url_title() {
return 'Bootstrap 4 on WordPress';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
/* ========================================================================================================================
Comments
======================================================================================================================== */
/**
* Custom callback for outputting comments
*
* @return void
* @author Keir Whitaker
*/
function bootstrap_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
?>
<?php if ( $comment->comment_approved == '1' ): ?>
<li class="media">
<div class="media-left">
<?php echo get_avatar( $comment ); ?>
</div>
<div class="media-body">
<h4 class="media-heading"><?php comment_author_link() ?></h4>
<time><a href="#comment-<?php comment_ID() ?>" pubdate><?php comment_date() ?> at <?php comment_time() ?></a></time>
<?php comment_text() ?>
</div>
<?php endif;
}