This repository has been archived by the owner on Sep 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfunctions.php
128 lines (90 loc) · 2.17 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
<?php
require_once('inc/classes/BB-Controller.class.php');
/*
* Set the content width based on the theme's design and stylesheet.
**/
if ( ! isset( $content_width ) ) {
$content_width = 570;
}
/*
* Removing annoying stuff from the HTML-head
**/
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function bb_remove_annoying_stuff() {
wp_deregister_script('l10n');
}
add_action('init', 'bb_remove_annoying_stuff');
/*
* Setting the body-class
**/
function bb_body_class() {
do_action('bb_body_class');
}
/*
* If it's not a search-engine-crawler visiting the site,
* the right body-class is set to hide the empty
* content-element.
**/
function bb_set_body_class() {
$inst = new Backboned();
if ( $inst->request_type() == 'standard' ) {
echo ' class="request-pending"';
}
if ( $inst->request_type() == 'search_engine' ) {
echo ' class="content-ready"';
}
}
add_action('bb_body_class', 'bb_set_body_class', 1);
/*
* Registering hooks
*
* Content-Hook
**/
function bb_content($type) {
do_action('bb_content', $type);
}
function bb_get_content($type) {
$inst = new Backboned();
$inst->content($type);
}
add_action('bb_content', 'bb_get_content', 5);
/*
* JS-Variables-Hook
**/
function bb_get_js_variables() {
$inst = new Backboned();
if ( $inst->request_type() != 'standard' ) {
return;
}
$js_variables = $inst->get('js_variables');
echo '<script>BB = ' . json_encode($js_variables) . ';</script>';
}
add_action('wp_head', 'bb_get_js_variables', 5);
/*
* JS-Scripts-Hook
**/
function bb_get_js_scripts() {
$inst = new Backboned();
if ( $inst->request_type() != 'standard' ) {
return;
}
$scripts = $inst->get('js_scripts');
echo $scripts;
}
add_action('wp_footer', 'bb_get_js_scripts', 5);
/*
* Writing the templates to the DOM
**/
function bb_get_partials() {
$inst = new Backboned();
if ( $inst->request_type() != 'standard' ) {
return;
}
$partials = $inst->get('partials');
echo $partials;
}
add_action('wp_footer', 'bb_get_partials', 5);