forked from digisavvy/some-like-it-neat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
360 lines (310 loc) · 12.3 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
<?php
/**
* some_like_it_neat functions and definitions
*
* @package some_like_it_neat
*/
if ( ! function_exists( 'some_like_it_neat_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function some_like_it_neat_setup()
{
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 640; /* pixels */
}
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on some_like_it_neat, use a find and replace
* to change 'some-like-it-neat' to the name of your theme in all the template files
*/
load_theme_textdomain( 'some-like-it-neat', get_template_directory() . '/library/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
/*
* Enable title tag support for all posts.
*
* @link http://codex.wordpress.org/Title_Tag
*/
add_theme_support( 'title-tag' );
/*
* Add Editor Style for adequate styling in text editor.
*
* @link http://codex.wordpress.org/Function_Reference/add_editor_style
*/
add_editor_style( '/assets/css/editor-style.css' );
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary-navigation', __( 'Primary Menu', 'some-like-it-neat' ) );
// Enable support for Post Formats.
if ( 'yes' === get_theme_mod( 'some-like-it-neat_post_format_support' ) ) {
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'status', 'gallery', 'chat', 'audio' ) );
}
// Enable Support for Jetpack Infinite Scroll
if ( 'yes' === get_theme_mod( 'some-like-it-neat_infinite_scroll_support' ) ) {
$scroll_type = get_theme_mod( 'some-like-it-neat_infinite_scroll_type' );
add_theme_support( 'infinite-scroll', array(
'type' => $scroll_type,
'footer_widgets' => false,
'container' => 'content',
'wrapper' => true,
'render' => false,
'posts_per_page' => false,
'render' => 'some_like_it_neat_infinite_scroll_render',
) );
function some_like_it_neat_infinite_scroll_render() {
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'page-templates/partials/content', get_post_format() );
endwhile;
endif;
}
}
// Setup the WordPress core custom background feature.
add_theme_support(
'custom-background', apply_filters(
'some_like_it_neat_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
/**
* Including Theme Hook Alliance (https://github.com/zamoose/themehookalliance).
*/
include 'library/vendors/theme-hook-alliance/tha-theme-hooks.php' ;
/**
* WP Customizer
*/
include get_template_directory() . '/library/vendors/customizer/customizer.php';
/**
* Implement the Custom Header feature.
*/
//require get_template_directory() . '/library/vendors/custom-header.php';
/**
* Custom template tags for this theme.
*/
include get_template_directory() . '/library/vendors/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
include get_template_directory() . '/library/vendors/extras.php';
/**
* Load Jetpack compatibility file.
*/
include get_template_directory() . '/library/vendors/jetpack.php';
/**
* Including TGM Plugin Activation
*/
include_once get_template_directory() . '/library/vendors/tgm-plugin-activation/class-tgm-plugin-activation.php' ;
include_once get_template_directory() . '/library/vendors/tgm-plugin-activation/tgm-plugin-activation.php' ;
}
endif; // some_like_it_neat_setup
add_action( 'after_setup_theme', 'some_like_it_neat_setup' );
/**
* Enqueue scripts and styles.
*/
if ( ! function_exists( 'some_like_it_neat_scripts' ) ) :
function some_like_it_neat_scripts()
{
if ( SCRIPT_DEBUG || WP_DEBUG ) :
// Vendor Scripts
wp_register_script( 'modernizr-js', get_template_directory_uri() . '/assets/js/vendor/modernizr/modernizr.js', array( 'jquery' ), '2.8.2', true );
wp_enqueue_script( 'modernizr-js', get_template_directory_uri() . '/assets/js/vendor/modernizr/modernizr.js', array( 'jquery' ), '2.8.2', true );
wp_register_script( 'selectivizr-js', get_template_directory_uri() . '/assets/js/vendor/selectivizr/selectivizr.js', array( 'jquery' ), '1.0.2b', true );
wp_enqueue_script( 'selectivizr-js', get_template_directory_uri() . '/assets/js/vendor/selectivizr/selectivizr.js', array( 'jquery' ), '1.0.2b', true );
wp_register_script( 'flexnav-js', get_template_directory_uri() . '/assets/js/vendor/flexnav/jquery.flexnav.js', array( 'jquery' ), '1.3.3', true );
wp_enqueue_script( 'flexnav-js', get_template_directory_uri() . '/assets/js/vendor/flexnav/jquery.flexnav.js', array( 'jquery' ), '1.3.3', true );
wp_register_script( 'hoverintent-js', get_template_directory_uri() . '/assets/js/vendor/hoverintent/jquery.hoverIntent.js', array( 'jquery' ), '1.0.0', true );
wp_enqueue_script( 'hoverintent-js', get_template_directory_uri() . '/assets/js/vendor/hoverintent/jquery.hoverIntent.js', array( 'jquery' ), '1.0.0', true );
// Concatonated Scripts
// wp_enqueue_script( 'development-js', get_template_directory_uri() . '/assets/js/development.js', array( 'jquery' ), '1.0.0', false );
// Main Style
wp_enqueue_style( 'some_like_it_neat-style', get_template_directory_uri() . '/assets/css/style.css' );
else :
// Vendor Scripts
wp_register_script( 'modernizr-js', get_template_directory_uri() . '/assets/js/vendor/modernizr/modernizr.js', array( 'jquery' ), '2.8.2', true );
wp_enqueue_script( 'modernizr-js', get_template_directory_uri() . '/assets/js/vendor/modernizr/modernizr.js', array( 'jquery' ), '2.8.2', true );
wp_register_script( 'selectivizr-js', get_template_directory_uri() . '/assets/js/vendor/selectivizr/selectivizr.js', array( 'jquery' ), '1.0.2b', true );
wp_enqueue_script( 'selectivizr-js', get_template_directory_uri() . '/assets/js/vendor/selectivizr/selectivizr.js', array( 'jquery' ), '1.0.2b', true );
wp_register_script( 'flexnav-js', get_template_directory_uri() . '/assets/js/vendor/flexnav/jquery.flexnav.js', array( 'jquery' ), '1.3.3', true );
wp_enqueue_script( 'flexnav-js', get_template_directory_uri() . '/assets/js/vendor/flexnav/jquery.flexnav.js', array( 'jquery' ), '1.3.3', true );
wp_register_script( 'hoverintent-js', get_template_directory_uri() . '/assets/js/vendor/hoverintent/jquery.hoverIntent.js', array( 'jquery' ), '1.0.0', true );
wp_enqueue_script( 'hoverintent-js', get_template_directory_uri() . '/assets/js/vendor/hoverintent/jquery.hoverIntent.js', array( 'jquery' ), '1.0.0', true );
// Concatonated Scripts
// wp_enqueue_script( 'production-js', get_template_directory_uri() . '/assets/js/production-min.js', array( 'jquery' ), '1.0.0', false );
// Main Style
wp_enqueue_style( 'some_like_it_neat-style', get_template_directory_uri() . '/assets/css/style-min.css' );
endif;
// Dashicons
wp_enqueue_style( 'dashicons' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'some_like_it_neat_scripts' );
endif; // Enqueue Scripts and Styles
/**
* Register widgetized area and update sidebar with default widgets.
*/
function some_like_it_neat_widgets_init()
{
register_sidebar(
array(
'name' => __( 'Sidebar', 'some-like-it-neat' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
)
);
}
add_action( 'widgets_init', 'some_like_it_neat_widgets_init' );
/**
* Initializing Flexnav Menu System
*/
if ( ! function_exists( 'dg_add_flexnav' ) ) :
function dg_add_flexnav()
{
?>
<script>
// Init Flexnav Menu
jQuery(document).ready(function($){
$(".flexnav").flexNav({
'animationSpeed' : 250, // default drop animation speed
'transitionOpacity': true, // default opacity animation
'buttonSelector': '.menu-button', // default menu button class
'hoverIntent': true, // use with hoverIntent plugin
'hoverIntentTimeout': 350, // hoverIntent default timeout
'calcItemWidths': false // dynamically calcs top level nav item widths
});
});
</script>
<?php
}
add_action( 'wp_footer', 'dg_add_flexnav' );
endif;
/**
* Add Singular Post Template Navigation
*/
if ( ! function_exists( 'some_like_it_neat_post_navigation' ) ) :
function some_like_it_neat_post_navigation() {
if ( function_exists( 'get_the_post_navigation' ) && is_singular() ) {
echo get_the_post_navigation(
array(
'prev_text' => __( '← %title', 'some-like-it-neat' ),
'next_text' => __( '%title →', 'some-like-it-neat' ),
'screen_reader_text' => __( 'Page navigation', 'some-like-it-neat' )
)
);
} else {
wp_link_pages(
array(
'before' => '<div class="page-links">' . __( 'Pages:', 'some-like-it-neat' ),
'after' => '</div>',
)
);
}
}
endif;
add_action( 'tha_entry_after', 'some_like_it_neat_post_navigation' );
/**
* Custom Hooks and Filters
*/
if ( ! function_exists( 'some_like_it_neat_add_breadcrumbs' ) ) :
function some_like_it_neat_add_breadcrumbs()
{
if ( ! is_front_page() ) {
if ( function_exists( 'HAG_Breadcrumbs' ) ) { HAG_Breadcrumbs(
array(
'prefix' => __( 'You are here: ', 'some-like-it-neat' ),
'last_link' => true,
'separator' => '|',
'excluded_taxonomies' => array(
'post_format'
),
'taxonomy_excluded_terms' => array(
'category' => array( 'uncategorized' )
),
'post_types' => array(
'gizmo' => array(
'last_show' => false,
'taxonomy_preferred' => 'category',
),
'whatzit' => array(
'separator' => '»',
)
)
)
);
}
}
}
add_action( 'tha_content_top', 'some_like_it_neat_add_breadcrumbs' );
endif;
if ( ! function_exists( 'some_like_it_neat_optional_scripts' ) ) :
function some_like_it_neat_optional_scripts()
{
// Link Color
if ( '' != get_theme_mod( 'some_like_it_neat_add_link_color' ) ) {
} ?>
<style type="text/css">
a { color: <?php echo get_theme_mod( 'some_like_it_neat_add_link_color' ); ?>; }
</style>
<?php
}
add_action( 'wp_head', 'some_like_it_neat_optional_scripts' );
endif;
if ( ! function_exists( 'some_like_it_neat_mobile_styles' ) ) :
function some_like_it_neat_mobile_styles()
{
$value = get_theme_mod( 'some_like_it_neat_mobile_hide_arrow' );
if ( 0 == get_theme_mod( 'some_like_it_neat_mobile_hide_arrow' ) ) { ?>
<style>
.menu-button i.navicon {
display: none;
}
</style>
<?php
} else {
}
}
add_action( 'wp_head', 'some_like_it_neat_mobile_styles' );
endif;
if ( ! function_exists( 'some_like_it_neat_add_footer_divs' ) ) :
function some_like_it_neat_add_footer_divs()
{
?>
<div class="footer-left">
<?php echo esc_attr( get_theme_mod( 'some_like_it_neat_footer_left', __( '© All Rights Reserved', 'some-like-it-neat' ) ) ); ?>
</div>
<div class="footer-right">
<?php echo esc_attr( get_theme_mod( 'some_like_it_neat_footer_right', 'Footer Content Right' ) ); ?>
</div>
<?php
}
add_action( 'tha_footer_bottom', 'some_like_it_neat_add_footer_divs' );
endif;
add_action( 'tha_head_bottom', 'some_like_it_neat_add_selectivizr' );
function some_like_it_neat_add_selectivizr()
{
?>
<!--[if (gte IE 6)&(lte IE 8)]>
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/assets/js/selectivizr/selectivizr-min.js"></script>
<noscript><link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/style.css" /></noscript>
<![endif]-->
<?php
}