-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.php
377 lines (323 loc) · 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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<?php
/** Tell WordPress to run theme_setup() when the 'after_setup_theme' hook is run. */
if ( ! function_exists( 'theme_setup' ) ):
function theme_setup() {
$args = array(
'flex-width' => true,
// change the image width here for recommended stuff
'width' => 980,
'flex-height' => true,
// change the image height here for recommended stuff,
'height' => 500,
'default-image' => get_template_directory_uri() . '/images/header.jpg',
);
$defaults = array(
'default-color' => '',
'default-image' => '',
'default-repeat' => '',
'default-position-x' => '',
'default-attachment' => '',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $defaults );
/* This theme uses post thumbnails (aka "featured images")
* all images will be cropped to thumbnail size (below), as well as
* a square size (also below). You can add more of your own crop
* sizes with add_image_size. */
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size(120, 90, true);
add_image_size('square', 150, 150, true);
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'custom-header', $args );
/* This theme uses wp_nav_menu() in one location.
* You can allow clients to create multiple menus by
* adding additional menus to the array. */
register_nav_menus( array(
'primary' => 'Primary Navigation'
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
}
endif;
add_action( 'after_setup_theme', 'theme_setup' );
/* Add all our JavaScript files here.
We'll let WordPress add them to our templates automatically instead
of writing our own script tags in the header and footer. */
function hackeryou_scripts() {
//Don't use WordPress' local copy of jquery, load our own version from a CDN instead
wp_deregister_script('jquery');
wp_enqueue_script(
'jquery',
"http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js",
false, //dependencies
null, //version number
true //load in footer
);
wp_enqueue_script(
'plugins', //handle
get_template_directory_uri() . '/js/plugins.js', //source
false, //dependencies
null, // version number
true //load in footer
);
wp_enqueue_script(
'scripts', //handle
get_template_directory_uri() . '/js/scripts.js', //source
array( 'jquery', 'plugins' ), //dependencies
null, // version number
true //load in footer
);
add_action('wp_print_styles', 'mytheme_dequeue_css_from_plugins', 100);
}
add_action( 'wp_enqueue_scripts', 'hackeryou_scripts' );
/* Custom Title Tags */
function hackeryou_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() ) {
return $title;
}
// Add the site name.
$title .= get_bloginfo( 'name', 'display' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title = "$title $sep $site_description";
}
// Add a page number if necessary.
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title = "$title $sep " . sprintf( __( 'Page %s', 'hackeryou' ), max( $paged, $page ) );
}
return $title;
}
add_filter( 'wp_title', 'hackeryou_wp_title', 10, 2 );
/*
Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*/
function hackeryou_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'hackeryou_page_menu_args' );
/*
* Sets the post excerpt length to 40 characters.
*/
function hackeryou_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'hackeryou_excerpt_length' );
/*
* Returns a "Continue Reading" link for excerpts
*/
function hackeryou_continue_reading_link() {
return ' <a href="'. get_permalink() . '">Continue reading <span class="meta-nav">→</span></a>';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and hackeryou_continue_reading_link().
*/
function hackeryou_auto_excerpt_more( $more ) {
return ' …' . hackeryou_continue_reading_link();
}
add_filter( 'excerpt_more', 'hackeryou_auto_excerpt_more' );
/**
* Adds a pretty "Continue Reading" link to custom post excerpts.
*/
function hackeryou_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= hackeryou_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'hackeryou_custom_excerpt_more' );
/*
* Register a single widget area.
* You can register additional widget areas by using register_sidebar again
* within hackeryou_widgets_init.
* Display in your template with dynamic_sidebar()
*/
function hackeryou_widgets_init() {
// Area 1, located at the top of the sidebar.
register_sidebar( array(
'name' => 'Primary Widget Area',
'id' => 'primary-widget-area',
'description' => 'The primary widget area',
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => 'footer-widget-area',
'id' => 'footer-widget-area',
'description' => 'The footer widget area',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => 'body-widget-area-top',
'id' => 'body-widget-area-1',
'description' => 'The main page widget area',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => 'body-widget-area-bottom',
'id' => 'body-widget-area-2',
'description' => 'The main page widget area',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => 'menu-column1',
'id' => 'menu-column1',
'description' => 'The first column for the drinks menu',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => 'menu-column2',
'id' => 'menu-column2',
'description' => 'The second column for the drinks menu',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => 'menu-column3',
'id' => 'menu-column3',
'description' => 'The third column menu area',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => 'contact-form-section',
'id' => 'contact-form-section',
'description' => 'contact form area',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
}
add_action( 'widgets_init', 'hackeryou_widgets_init' );
/**
* Removes the default styles that are packaged with the Recent Comments widget.
*/
function hackeryou_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
add_action( 'widgets_init', 'hackeryou_remove_recent_comments_style' );
if ( ! function_exists( 'hackeryou_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post—date/time and author.
*/
function hackeryou_posted_on() {
printf('<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s',
'meta-prep meta-prep-author',
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
get_permalink(),
esc_attr( get_the_time() ),
get_the_date()
),
sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
get_author_posts_url( get_the_author_meta( 'ID' ) ),
sprintf( esc_attr( 'View all posts by %s'), get_the_author() ),
get_the_author()
)
);
}
endif;
if ( ! function_exists( 'hackeryou_posted_in' ) ) :
/**
* Prints HTML with meta information for the current post (category, tags and permalink).
*/
function hackeryou_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.';
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.';
} else {
$posted_in = 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.';
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;
/* Get rid of junk! - Gets rid of all the crap in the header that you dont need */
function clean_shit_up() {
// windows live
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
// wordpress gen tag
remove_action('wp_head', 'wp_generator');
// comments RSS
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 3 );
}
add_action('init', 'clean_shit_up');
/* Here are some utility helper functions for use in your templates! */
/* pre_r() - makes for easy debugging. <?php pre_r($post); ?> */
function pre_r($obj) {
echo "<pre>";
print_r($obj);
echo "</pre>";
}
/* is_blog() - checks various conditionals to figure out if you are currently within a blog page */
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
/* get_post_parent() - Returns the current posts parent, if current post if top level, returns itself */
function get_post_parent($post) {
if ($post->post_parent) {
return $post->post_parent;
}
else {
return $post->ID;
}
}
function bitters_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'bitters_logo' ); // Add setting for logo uploader
// Add control for logo uploader (actual uploader)
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'bitters_logo', array(
'label' => __( 'Upload Logo (replaces text)', 'bitters' ),
'section' => 'title_tagline',
'settings' => 'bitters_logo',
) ) );
}
add_action( 'customize_register', 'bitters_customize_register' );
//custom stuff
//dequeue css from plugins
add_action('wp_print_styles', 'mytheme_dequeue_css_from_plugins', 100);
function mytheme_dequeue_css_from_plugins() {
wp_dequeue_style( 'sb_instagram_styles' );
wp_dequeue_style( 'fdm-css-' );
}