-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
203 lines (174 loc) · 5.55 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
<?php
add_action( 'after_setup_theme', 'openkitchen_setup' );
function openkitchen_setup() {
load_theme_textdomain( 'openkitchen', get_template_directory() . '/languages' );
add_theme_support( 'title-tag' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
global $content_width;
if ( ! isset( $content_width ) ) $content_width = 1456;
register_nav_menus(
array( 'main-menu' => __( 'Main Menu', 'openkitchen' ) )
);
}
add_action( 'comment_form_before', 'openkitchen_enqueue_comment_reply_script' );
function openkitchen_enqueue_comment_reply_script() {
if ( get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_default_scripts', 'remove_unnecessary' );
function remove_unnecessary( $scripts ) {
if ( is_admin() ) return;
// Remove jQuery and the oEmbed script.
$scripts->remove( 'jquery' );
$scripts->remove( 'wp-embed' );
// Remove WordPress Ultimate Recipe Plugin CSS and font.
wp_dequeue_style( 'wpurp_style_minified' );
wp_dequeue_style( 'wpurp_style1' );
// Remove the oEmbed REST API endpoint.
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
// Turn off oEmbed auto discovery.
add_filter( 'embed_oembed_discover', '__return_false' );
// Don't filter oEmbed results.
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
// Remove oEmbed discovery links.
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
// Remove oEmbed-specific JavaScript from the front-end and back-end.
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
// Remove all embeds rewrite rules.
add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
// Remove emoji support for old browsers.
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
add_filter( 'emoji_svg_url', '__return_false' );
}
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
function _remove_script_version($src) {
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'post_class','remove_hentry' );
function remove_hentry( $classes ) {
$classes = array_diff( $classes, array( 'hentry' ) );
return $classes;
}
add_filter( 'the_title', 'openkitchen_title' );
function openkitchen_title( $title ) {
if ( $title == '' ) {
return '→';
} else {
return $title;
}
}
add_filter( 'wp_title', 'openkitchen_filter_wp_title' );
function openkitchen_filter_wp_title( $title ) {
return $title . esc_attr( get_bloginfo( 'name' ) );
}
add_action( 'widgets_init', 'openkitchen_widgets_init' );
function openkitchen_widgets_init() {
register_sidebar( array (
'name' => __( 'Footer Widgets', 'openkitchen' ),
'id' => 'footer-widgets',
'before_widget' => '<li class="%2$s">',
'after_widget' => "</li>",
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
register_sidebar( array (
'name' => __( 'Sidebar Widgets', 'openkitchen' ),
'id' => 'sidebar-widgets',
'before_widget' => '<li class="%2$s">',
'after_widget' => "</li>",
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
}
function openkitchen_custom_pings( $comment ) {
$GLOBALS['comment'] = $comment;
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><?php echo comment_author_link(); ?></li>
<?php
}
add_filter( 'get_comments_number', 'openkitchen_comments_number' );
function openkitchen_comments_number( $count ) {
if ( !is_admin() ) {
global $id;
$comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
return count( $comments_by_type['comment'] );
} else {
return $count;
}
}
add_shortcode( 'ad', 'ad_func' );
function ad_func() {
ob_start();
get_template_part( 'ad', 'middle' );
return ob_get_clean();
}
add_shortcode( 'cookbooks', 'cookbooks_func' );
function cookbooks_func() {
ob_start();
get_template_part( 'shortcode', 'cookbooks' );
echo( '<script type="application/ld+json">' );
get_template_part( 'json', 'books' );
echo( '</script>' );
return ob_get_clean();
}
add_shortcode( 'cost', 'cost_func' );
function cost_func( $atts ) {
$a = shortcode_atts( array(
'total' => '$X',
'per' => '$X',
'unit' => 'serving',
), $atts );
return "<div class=\"ok-shortcode-cost\"><div>{$a['total']} total</div><div>{$a['per']} / {$a['unit']}</div></div>";
}
add_shortcode( 'fs', 'fromscratch_func' );
function fromscratch_func() {
ob_start();
get_template_part( 'shortcode', 'fs' );
return ob_get_clean();
}
add_shortcode( 'gc', 'goodandcheap_func' );
function goodandcheap_func() {
ob_start();
get_template_part( 'shortcode', 'gc' );
return ob_get_clean();
}
add_shortcode( 'ge', 'goodenough_func' );
function goodenough_func() {
ob_start();
get_template_part( 'shortcode', 'ge' );
return ob_get_clean();
}
add_shortcode( 'impactlist', 'impactlist_func' );
function impactlist_func() {
ob_start();
get_template_part( 'shortcode', 'impactlist' );
return ob_get_clean();
}
add_shortcode( 'impactmap', 'impactmap_func' );
function impactmap_func() {
ob_start();
get_template_part( 'shortcode', 'impactmap' );
return ob_get_clean();
}
add_shortcode( 'json', 'json_func' );
function json_func( $atts ) {
$a = shortcode_atts( array(
'template' => 'leanne',
), $atts );
ob_start();
echo( '<script type="application/ld+json">' );
get_template_part( 'json', $a['template'] );
echo( '</script>' );
return ob_get_clean();
}
add_shortcode( 'social', 'social_func' );
function social_func() {
ob_start();
get_template_part( 'shortcode', 'social' );
return ob_get_clean();
}