forked from bootscore/bootscore-child
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
266 lines (237 loc) · 9.48 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
// style and scripts
add_action('wp_enqueue_scripts', 'bootscore_child_enqueue_styles');
function bootscore_child_enqueue_styles() {
// style.css
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
// Compiled main.css
$modified_bootscoreChildCss = date('YmdHi', filemtime(get_stylesheet_directory() . '/css/main.css'));
wp_enqueue_style('main', get_stylesheet_directory_uri() . '/css/main.css', array('parent-style'), $modified_bootscoreChildCss);
// custom.js
wp_enqueue_script('custom-js', get_stylesheet_directory_uri() . '/js/custom.js', false, '', true);
}
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
// Widgets
if (!function_exists('bootscore_widgets_init')) :
function bootscore_widgets_init() {
// Top Nav
register_sidebar(array(
'name' => esc_html__('Top Nav', 'bootscore'),
'id' => 'top-nav',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="ms-3">',
'after_widget' => '</div>',
'before_title' => '<div class="widget-title d-none">',
'after_title' => '</div>'
));
// Top Nav End
// Top Nav Search
register_sidebar(array(
'name' => esc_html__('Top Nav Search', 'bootscore'),
'id' => 'top-nav-search',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="top-nav-search">',
'after_widget' => '</div>',
'before_title' => '<div class="widget-title d-none">',
'after_title' => '</div>'
));
// Top Nav Search End
// Sidebar
register_sidebar(array(
'name' => esc_html__('Sidebar', 'bootscore'),
'id' => 'sidebar-1',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<section id="%1$s" class="widget %2$s card card-body mb-4 bg-light border-0">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title card-title border-bottom py-2">',
'after_title' => '</h2>',
));
// Sidebar End
// Top Footer
register_sidebar(array(
'name' => esc_html__('Top Footer', 'bootscore'),
'id' => 'top-footer',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="footer_widget mb-5">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>'
));
// Top Footer End
// Footer 1
register_sidebar(array(
'name' => esc_html__('Footer 1', 'bootscore'),
'id' => 'footer-1',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="footer_widget mb-4">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title h4">',
'after_title' => '</h2>'
));
// Footer 1 End
// Footer 2
register_sidebar(array(
'name' => esc_html__('Footer 2', 'bootscore'),
'id' => 'footer-2',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="footer_widget mb-4">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title h4">',
'after_title' => '</h2>'
));
// Footer 2 End
// Footer 3
register_sidebar(array(
'name' => esc_html__('Footer 3', 'bootscore'),
'id' => 'footer-3',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="footer_widget mb-4">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title h4">',
'after_title' => '</h2>'
));
// Footer 3 End
// Footer 4
register_sidebar(array(
'name' => esc_html__('Footer 4', 'bootscore'),
'id' => 'footer-4',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="footer_widget mb-4">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title h4">',
'after_title' => '</h2>'
));
// Footer 4 End
// 404 Page
register_sidebar(array(
'name' => esc_html__('404 Page', 'bootscore'),
'id' => '404-page',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="mb-4">',
'after_widget' => '</div>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>'
));
// 404 Page End
// Bottom Footer
register_sidebar(array(
'name' => esc_html__('Bottom Footer', 'bootscore'),
'id' => 'bottom-footer',
'description' => esc_html__('Add widgets here.', 'bootscore'),
'before_widget' => '<div class="footer_widget">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>'
));
}
add_action('widgets_init', 'bootscore_widgets_init');
endif;
// Widgets END
/**
* Onion service functions and definitions.
*
* Implements multi-domain support for onion domains using WordPress filter hooks.
*
* Acknowledgements: https://blog.paranoidpenguin.net/2017/09/how-to-configure-wordpress-as-a-tor-hidden-service/
*/
if ($_SERVER["HTTP_HOST"] == 'testing.onion') {
add_filter('option_home', 'rewrite_permalinks');
add_filter('option_siteurl', 'rewrite_permalinks');
#add_filter('bloginfo', 'rewrite_blogname');
#add_filter('option_blogname', 'rewrite_blogname');
add_filter('post_link', 'rewrite_permalinks');
add_filter('page_link', 'rewrite_permalinks');
add_filter('post_type_link', 'rewrite_permalinks');
add_filter('category_link', 'rewrite_permalinks');
add_filter('tag_link', 'rewrite_permalinks');
add_filter('author_link', 'rewrite_permalinks');
add_filter('day_link', 'rewrite_permalinks');
add_filter('month_link', 'rewrite_permalinks');
add_filter('year_link', 'rewrite_permalinks');
add_filter('nav_menu_link_attributes', 'rewrite_permalinks');
add_filter('includes_url', 'rewrite_permalinks');
add_filter('content_url', 'rewrite_permalinks');
add_filter('admin_url', 'rewrite_permalinks');
add_filter('feed_link', 'rewrite_permalinks');
add_filter('stylesheet_uri', 'rewrite_permalinks');
add_filter('attachment_link', 'rewrite_permalinks');
add_filter('wp_get_attachment_image_src', 'rewrite_permalinks');
add_filter('wp_get_attachment_link', 'rewrite_permalinks');
add_filter('the_excerpt', 'rewrite_permalinks');
add_filter('the_content', 'rewrite_permalinks');
}
function rewrite_blogname($content) {
$content = str_replace('Centre for Postdigital Cultures', 'Centre for Postdigital Cultures: onion service', $content);
return $content;
}
function rewrite_permalinks($content) {
$content = preg_replace('/https?:\/\/postdigitalcultures.org/', 'http://testing.onion', $content);
return $content;
}
/**
* Prints HTML with meta information for the current post-date/time.
* Overwrites existing ./inc/template-tags.php function
*/
function bootscore_date() {
$time_string = '<time class="entry-date whatever published updated" datetime="%1$s">%2$s</time>';
// if (get_the_time('U') !== get_the_modified_time('U')) {
// $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time> <span class="time-updated-separator">/</span> <time class="updated" datetime="%3$s">%4$s</time>';
// }
$time_string = sprintf(
$time_string,
esc_attr(get_the_date(DATE_W3C)),
esc_html(get_the_date()),
//esc_attr(get_the_modified_date(DATE_W3C)),
//esc_html(get_the_modified_date())
);
$posted_on = sprintf(
/* translators: %s: post date. */
'%s',
'<span rel="bookmark">' . $time_string . '</span>'
);
echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK.
}
/**
* function to add custom JavaScript
*/
function custom_javascript() {
?>
<script>
try {
// jQuery to wrap project-blocks in their own div
jQuery(".project-block").wrapAll( "<div id='project-blocks-wrapper' />");
// select that div
var collection = document.querySelector('#project-blocks-wrapper');
// randomise the children of that wrapper div
for (var i = collection.children.length; i >= 0; i--) {
collection.appendChild(collection.children[Math.random() * i | 0]);
}
if (jQuery("body").hasClass("home")) {
// remove all but 6 children from the wrapper
for (var x = collection.children.length - 1; x >= 3; x--) {
collection.children[x].remove()
}
}
} catch (error) {
console.error(error);
}
// try {
// // jQuery to wrap publication-blocks in their own div
// jQuery(".publications-block").wrapAll( "<div id='publications-block-wrapper' />");
// // select that div
// var collection = document.querySelector('#publications-block-wrapper');
// // randomise the children of that wrapper div
// for (var i = collection.children.length; i >= 0; i--) {
// collection.appendChild(collection.children[Math.random() * i | 0]);
// }
// } catch (error) {
// console.error(error);
// }
</script>
<?php
}
add_action('wp_footer', 'custom_javascript');