-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
283 lines (233 loc) · 9.79 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
267
268
269
270
<?php
require_once(get_theme_file_path("/inc/tgm.php"));
require_once(get_theme_file_path("/inc/customizer.php"));
require_once(get_theme_file_path("/widgets/social-icons-widget.php"));
require_once(get_theme_file_path("/inc/acf-metabox.php"));
if (class_exists("Attachments")){
require_once(get_theme_file_path("/inc/attachments.php"));
}
if (!isset($content_width)) $content_width = 900;
function philosophy_setup_theme()
{
load_theme_textdomain("philosophy", get_theme_file_path("/languages"));
add_theme_support("title-tag");
add_theme_support("post-thumbnails");
add_theme_support("custom-logo");
add_theme_support('automatic-feed-links');
add_theme_support("html5", array('search-form', 'comment-list'));
add_theme_support("post-formats", array('image', 'gallery', 'audio', 'video', 'quote', 'link'));
add_editor_style("assets/css/editor-style.css");
add_image_size('philosophy-home-square', 400, 400, true);
register_nav_menu("top_menu", __("Top Menu", "philosophy"));
}
add_action("after_setup_theme", "philosophy_setup_theme");
function philosophy_assets()
{
wp_enqueue_style("fontawesome-css", get_theme_file_uri("/assets/css/font-awesome/css/font-awesome.css"), "1.0");
wp_enqueue_style("fonts-css", get_theme_file_uri("/assets/css/font.css"), "1.0");
wp_enqueue_style("base-css", get_theme_file_uri("/assets/css/base.css"), "1.0");
wp_enqueue_style("vendor-css", get_theme_file_uri("/assets/css/vendor.css"), "1.0");
wp_enqueue_style("main-css", get_theme_file_uri("/assets/css/main.css"), "1.0");
wp_enqueue_style("philosophy-css", get_stylesheet_uri(), NULL);
wp_enqueue_script("modernizr", get_theme_file_uri("/assets/js/modernizr.js"), NULL, "1.0", false);
wp_enqueue_script("pace-js", get_theme_file_uri("/assets/js/pace.min.js"), NULL, "1.0", false);
wp_enqueue_script("plugins-js", get_theme_file_uri("/assets/js/plugins.js"), array("jquery"), "1.0", true);
if (is_singular() && comments_open() && (get_option('thread_comments') == 1)) {
wp_enqueue_script('comment-reply');
}
wp_enqueue_script("main-js", get_theme_file_uri("/assets/js/main.js"), array("jquery"), "1.0", true);
}
add_action("wp_enqueue_scripts", "philosophy_assets");
function philosophy_pagination()
{
global $wp_query;
$links = paginate_links(array(
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'type' => 'list',
'mid_size' => 3,
));
$links = str_replace('page-numbers', 'pgn__num', $links);
$links = str_replace("<ul class='pgn__num'>", "<ul>", $links);
$links = str_replace('prev pgn__num', 'pgn__prev', $links);
$links = str_replace('next pgn__num', 'pgn__next', $links);
echo wp_kses_post($links);
}
function philosophy_widgets()
{
register_sidebar(
array(
'name' => __('About Us Page', 'philosophy'),
'id' => 'about-us',
'description' => __('About us page widgets', 'philosophy'),
'before_widget' => '<div id="%1$s" class="col-block %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="quarter-top-margin">',
'after_title' => '</h3>',
)
);
register_sidebar(
array(
'name' => __('Contact page maps', 'philosophy'),
'id' => 'contact-maps',
'description' => __('Contact page maps section', 'philosophy'),
'before_widget' => '<div id="map-wrap %1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
register_sidebar(
array(
'name' => __('Contact Page info box', 'philosophy'),
'id' => 'contact-info',
'description' => __('Contact Page info box widgets', 'philosophy'),
'before_widget' => '<div id="%1$s" class="col-block %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="quarter-top-margin">',
'after_title' => '</h3>',
)
);
register_sidebar(
array(
'name' => __('Before Footer section', 'philosophy'),
'id' => 'before-footer',
'description' => __('Before Footer section', 'philosophy'),
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
register_sidebar(
array(
'name' => __('Footer Left Widget', 'philosophy'),
'id' => 'footer-left',
'description' => __('Footer Left Widget', 'philosophy'),
'before_widget' => '<div id="%1$s" class="col-two md-four mob-full s-footer__sitelinks %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
)
);
register_sidebar(
array(
'name' => __('Footer Right Widget', 'philosophy'),
'id' => 'footer-right',
'description' => __('Footer right Widget', 'philosophy'),
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
)
);
register_sidebar(
array(
'name' => __('Footer bottom Widget', 'philosophy'),
'id' => 'footer-bottom',
'description' => __('Footer bottom Widget', 'philosophy'),
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
)
);
register_sidebar(
array(
'name' => __('Header section widget', 'philosophy'),
'id' => 'header-info',
'description' => __('Header section widget', 'philosophy'),
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
register_sidebar(
array(
'name' => __('Footer Tag section widget', 'philosophy'),
'id' => 'tags-widgets',
'description' => __('This Widget Show on Footer Tag section', 'philosophy'),
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
}
add_action('widgets_init', 'philosophy_widgets');
function philosophy_search_highlight($text)
{
if (is_search()) {
$pattern = '/(' . join('|', explode(' ', get_search_query())) . ')/i';
$text = preg_replace($pattern, '<span class="highlight__text">\0</span>', $text);
}
return $text;
}
add_filter("the_title", "philosophy_search_highlight");
add_filter("the_excerpt", "philosophy_search_highlight");
add_filter("the_content", "philosophy_search_highlight");
remove_action("term_description", "wpautop");
function philosophy_search_form($form)
{
$homedir = home_url("/");
$label = __("Search for:", "philosophy");
$btn_label = __("Search", "philosophy");
$placeholder = __("Type Keywords", "philosophy");
$newform = <<<FORM
<form role = "search" method = "get" class="header__search-form" action = "{$homedir}" >
<label >
<span class="hide-content" >{$label}</span >
<input type = "search" class="search-field" placeholder = "{$placeholder}" value = "" name = "s"
title = "{$label}" autocomplete = "off" >
</label>
<input type = "submit" class="search-submit" value = "{$btn_label}" >
</form>
FORM;
return $newform;
}
add_filter("get_search_form", "philosophy_search_form");
function philosophy_comment_cb($comment, $args, $depth)
{
if ('div' == $args['style']) {
$tag = 'div';
$add_below = 'div-comment';
} else {
$tag = 'li';
$add_below = 'comment';
}
?>
<<?php echo esc_html($tag) ?><?php comment_class(empty($args['has_children']) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
<div class="comment__avatar">
<?php if (0 != $args['avatar_size']) {
echo get_avatar($comment, $args['avatar_size']);
} ?>
</div>
<div class="comment__content">
<div class="comment__info">
<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>', 'philosophy'), get_comment_author_link()); ?>
<div class="comment__meta">
<a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?>">
<?php printf(__('%1$s at %2$s', 'philosophy'), get_comment_date(), get_comment_time()); ?>
</a>
<?php edit_comment_link(__('Edit', 'philosophy'), ' ', '');
?>
<?php
$comments_reply_args = array(
'add_below' => $add_below,
'depth' => $depth,
'max_depth' => $args['max_depth'],
);
comment_reply_link(array_merge($args, $comments_reply_args)); ?>
</div>
</div>
<div class="comment__text">
<?php comment_text(); ?>
</div>
</div>
<?php if ('li' == $args['style']) : ?>
</<?php echo esc_html($tag); ?>>
<?php endif; ?>
<?php
}
define('ACF_EARLY_ACCESS', '5');