forked from Codeinwp/oblique
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
405 lines (346 loc) · 10.9 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?php
/**
* Oblique functions and definitions
*
* @package Oblique
*/
define( 'OBLIQUE_VERSION', '2.0.5' );
if ( ! function_exists( 'oblique_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 oblique_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Oblique, use a find and replace
* to change 'oblique' to the name of your theme in all the template files
*/
load_theme_textdomain( 'oblique', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
// Content width
global $content_width;
if ( ! isset( $content_width ) ) {
$content_width = 1040;
}
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* 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' );
add_image_size( 'oblique-entry-thumb', 370 );
add_image_size( 'oblique-single-thumb', 1040 );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'oblique' ),
'social' => __( 'Social', 'oblique' ),
) );
/*
* 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',
) );
/*
* Enable support for Post Formats.
* See http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'oblique_custom_background_args', array(
'default-color' => '1c1c1c',
) ) );
require_once( trailingslashit( get_template_directory() ) . 'inc/class/class-customizer-theme-info-control/class-customizer-theme-info-root.php' );
}
endif; // oblique_setup
add_action( 'after_setup_theme', 'oblique_setup' );
/**
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function oblique_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'oblique' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'oblique_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function oblique_scripts() {
if ( get_theme_mod( 'body_font_name' ) != '' ) {
wp_enqueue_style( 'oblique-body-fonts', '//fonts.googleapis.com/css?family=' . esc_attr( get_theme_mod( 'body_font_name' ) ) );
} else {
wp_enqueue_style( 'oblique-body-fonts', '//fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' );
}
if ( get_theme_mod( 'headings_font_name' ) != '' ) {
wp_enqueue_style( 'oblique-headings-fonts', '//fonts.googleapis.com/css?family=' . esc_attr( get_theme_mod( 'headings_font_name' ) ) );
} else {
wp_enqueue_style( 'oblique-headings-fonts', '//fonts.googleapis.com/css?family=Playfair+Display:400,700,400italic,700italic' );
}
wp_enqueue_style( 'oblique-style', get_stylesheet_uri(), array(), OBLIQUE_VERSION );
wp_enqueue_style( 'oblique-font-awesome', get_template_directory_uri() . '/fonts/font-awesome.min.css' );
wp_enqueue_script( 'oblique-imagesloaded', get_template_directory_uri() . '/js/vendor/imagesloaded.pkgd.min.js', array(), true );
wp_enqueue_script( 'oblique-main', get_template_directory_uri() . '/js/vendor/main.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'oblique-scripts', get_template_directory_uri() . '/js/scripts.js', array( 'jquery' ), true );
wp_enqueue_script( 'oblique-masonry-init', get_template_directory_uri() . '/js/vendor/masonry-init.js', array( 'jquery', 'masonry' ), true );
wp_enqueue_script( 'oblique-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
wp_enqueue_script( 'oblique-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'oblique_scripts' );
/* tgm-plugin-activation */
require_once get_template_directory() . '/vendor/class-tgm-plugin-activation.php';
/**
* TGMPA register
*/
function oblique_register_required_plugins() {
$plugins = array(
array(
'name' => 'Pirate Forms',
'slug' => 'pirate-forms',
'required' => false,
),
array(
'name' => 'Nivo Slider Lite',
'slug' => 'nivo-slider-lite',
'required' => false,
),
);
tgmpa( $plugins );
}
add_action( 'tgmpa_register', 'oblique_register_required_plugins' );
/**
* Enqueue Bootstrap
*/
function oblique_enqueue_bootstrap() {
wp_enqueue_style( 'oblique-bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css', array(), true );
}
add_action( 'wp_enqueue_scripts', 'oblique_enqueue_bootstrap', 9 );
/**
* Change the excerpt length
*/
function oblique_excerpt_length( $length ) {
$excerpt = get_theme_mod( 'exc_lenght', '35' );
return esc_attr( $excerpt );
}
add_filter( 'excerpt_length', 'oblique_excerpt_length', 999 );
/**
* Hide the excerpt more if the excerpt is set to 0 words
*/
function oblique_excerpt_more( $more ) {
$excerpt = get_theme_mod( 'exc_lenght', '35' );
if ( $excerpt == '0' ) {
return '';
} else {
return '[...]';
}
}
add_filter( 'excerpt_more', 'oblique_excerpt_more' );
/**
* Footer credits
*/
function oblique_footer_credits() {
echo '<a href="' . esc_url( __( 'http://wordpress.org/', 'oblique' ) ) . '" rel="nofollow">';
/* translators: WordPress */
printf( __( 'Proudly powered by %s', 'oblique' ), 'WordPress' );
echo '</a>';
echo '<span class="sep"> | </span>';
/* translators: 1 - Theme author 2 - Theme name */
printf( __( 'Theme: %2$s by %1$s.', 'oblique' ), 'Themeisle', '<a href="http://themeisle.com/themes/oblique/" rel="nofollow">Oblique</a>' );
}
add_action( 'oblique_footer', 'oblique_footer_credits' );
/**
* Load html5shiv
*/
function oblique_html5shiv() {
echo '<!--[if lt IE 9]>' . "\n";
echo '<script src="' . esc_url( get_template_directory_uri() . '/js/vendor/html5shiv.js' ) . '"></script>' . "\n";
echo '<![endif]-->' . "\n";
}
add_action( 'wp_head', 'oblique_html5shiv' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* SVGs
*/
require get_template_directory() . '/inc/svg.php';
/**
* Styles
*/
require get_template_directory() . '/inc/styles.php';
/**
* WooCommerce functions
*/
if ( class_exists( 'WooCommerce' ) ) {
require get_template_directory() . '/inc/woocommerce/woocommerce.php';
}
/**
* Header
*/
function oblique_nav_svg_container() {
echo '<div class="svg-container nav-svg svg-block">';
oblique_svg_3();
echo '</div>';
}
add_action( 'oblique_nav_container', 'oblique_nav_svg_container' );
/**
* Footer
* footer svg
*/
function oblique_footer_svg_container() {
echo '<div class="svg-container footer-svg svg-block">';
oblique_svg_1();
echo '</div>';
}
add_action( 'oblique_footer_svg', 'oblique_footer_svg_container' );
/**
* Index
* posts navigation
*/
function oblique_posts_navigation() {
the_posts_navigation();
}
add_action( 'oblique_posts_navigation', 'oblique_posts_navigation' );
/**
* Post
* read more link
*/
function oblique_post_link_to_single() {
if ( ! get_theme_mod( 'read_more' ) ) :?>
<a href="<?php the_permalink(); ?>">
<div class="read-more">
<?php echo apply_filters( 'oblique_post_read_more' , esc_html__( 'Continue reading …','oblique' ) ); ?>
</div>
</a>
<?php endif;
}
add_action( 'oblique_link_to_single','oblique_post_link_to_single' );
/**
* Archive
* archive page title top svg
*/
function oblique_archive_title_top_svg() {
echo '<div class="svg-container svg-block page-header-svg">';
echo oblique_svg_1();
echo '</div>';
}
add_action( 'oblique_archive_title_top_svg', 'oblique_archive_title_top_svg' );
/**
* Archive
* archive page title bottom svg
*/
function oblique_archive_title_bottom_svg() {
oblique_svg_3();
}
add_action( 'oblique_archive_title_bottom_svg', 'oblique_archive_title_bottom_svg' );
/**
* Content page
* single post bottom svg
*/
function oblique_single_post_bottom_svg() {
oblique_svg_3();
}
add_action( 'oblique_single_post_bottom_svg', 'oblique_single_post_bottom_svg' );
/**
* Single post
* change post navigation on single
*/
function oblique_single_post_navigation() {
the_post_navigation();
}
add_action( 'oblique_single_post_navigation', 'oblique_single_post_navigation' );
/**
* Single page post bottom svg
*/
function oblique_single_page_post_svg() {
oblique_svg_4();
}
add_action( 'oblique_single_page_post_svg', 'oblique_single_page_post_svg' );
/**
* Comments title
*/
function oblique_comments_title_text() {
echo '<h2 class="comments-title">';
$comments_number = get_comments_number();
if ( 1 === $comments_number ) {
/* translators: %s: post title */
printf( _x( 'One thought on “%s”', 'comments title', 'oblique' ), '<span>' . get_the_title() . '</span>' );
} else {
printf(
/* translators: 1: number of comments, 2: post title */
_nx(
'%1$s thought on “%2$s”',
'%1$s thoughts on “%2$s”',
$comments_number,
'comments title',
'oblique'
),
number_format_i18n( $comments_number ),
'<span>' . get_the_title() . '</span>'
);
}
echo '</h2>';
}
add_action( 'oblique_comments_title', 'oblique_comments_title_text' );
/**
* Comments list
*/
function oblique_comments_list() {
wp_list_comments( array(
'style' => 'ol',
'short_ping' => true,
'avatar_size' => 60,
) );
}
add_action( 'oblique_comments_list', 'oblique_comments_list' );