Passed
Push — master ( f9c478...f2bc51 )
by SILENT
02:23
created

functions.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Strip functions and definitions
4
 *
5
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
6
 *
7
 * @package WordPress
8
 * @subpackage Strip
9
 */
10
11
	// Set the content width based on the theme's design and stylesheet.
12
if ( ! isset( $content_width ) ) {
13
		$content_width = 1920;
14
} /* pixels */
15
16
if ( ! function_exists( 'strip_setup' ) ) :
17
	/**
18
	 * Sets up theme defaults and registers support for various WordPress features.
19
	 *
20
	 * Note that this function is hooked into the after_setup_theme hook, which runs
21
	 * before the init hook. The init hook is too late for some features, such as indicating
22
	 * support post thumbnails.
23
	 */
24
	function strip_setup() {
25
		/**
26
* Remove some default WordPress dashboard widgets
27
* an example custom dashboard widget
28
* adding custom login css
29
* changing text in footer of admin
30
*/
31
		require_once( 'assets/admin.php' );
32
		/**
33
* Make theme available for translation
34
* Translations can be filed in the /languages/ directory
35
* If you're building a theme based on strip, use a find and replace
36
* to change 'strip' to the name of your theme in all the template files
37
*/
38
		load_theme_textdomain( 'strip', get_template_directory() . '/languages' );
39
40
		// Add default posts and comments RSS feed links to head.
41
		add_theme_support( 'automatic-feed-links' );
42
43
		/**
44
* Enable support for title-tag. Allows themes to add document title tag to HTML <head> (since version 4.1.).
45
*/
46
		add_theme_support( 'title-tag' );
47
48
		/**
49
* Enable support for custom logo.
50
*
51
* @since strip 1.0
52
*/
53
		add_theme_support( 'custom-logo', array(
54
			'height'      => 156,
55
			'width'       => 312,
56
			'flex-height' => true,
57
			'flex-width'  => true,
58
			)
59
		);
60
61
		/**
62
* Enable support for Post Thumbnails on posts and pages
63
*
64
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
65
*/
66
		add_theme_support( 'post-thumbnails' );
67
		add_image_size( 'stri-featured-image', 1920, 960, true );
68
		add_image_size( 'strip-large', 1920, 960, true ); // cropped.
69
		add_image_size( 'strip-medium', 624, 312, true ); // cropped.
70
		add_image_size( 'strip-thumbnail', 312, 156, true ); // cropped.
71
72
		/**
73
		 * Remove paragraph tags around images.
74
		 *
75
		 * @param $strings $content filter p tags.
0 ignored issues
show
The doc-type $strings could not be parsed: Unknown type name "$strings" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
76
		 * @return $content
77
		 * @link https://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/
78
		 * @see http://codex.wordpress.org/Function_Reference/wpautop gets the same result
79
		 * but it removes line blocks: remove_filter( 'the_content', 'wpautop' );
80
		 */
81
		function filter_ptags_on_images( $content ) {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
82
			return preg_replace( '/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content );
83
		}
84
		add_filter( 'the_content', 'filter_ptags_on_images' );
85
86
		/**
87
	 	* This theme uses wp_nav_menu() in one location.
88
	 	*/
89
		register_nav_menus(array(
90
			'primary' => __( 'Primary Menu', 'strip' ),
91
		));
92
93
		/*
94
		* Switch default core markup for search form, comment form, and comments
95
		* to output valid HTML5.
96
		*/
97
		add_theme_support( 'html5', array(
98
			'search-form',
99
			'comment-form',
100
			'comment-list',
101
			'gallery',
102
			'caption',
103
			'widgets',
104
		) );
105
106
		/**
107
	 * Enable support for Post Formats
108
	 */
109
		add_theme_support( 'post-formats', array(
110
			'image',
111
			'video',
112
			'quote',
113
			'link',
114
			'gallery',
115
			'audio',
116
			'chat',
117
		) );
118
119
		// Setup the WordPress core custom background feature.
120
		add_theme_support('custom-background', apply_filters('strip_custom_background_args', array(
121
			'default-color' => 'ffffff',
122
			'default-image' => '',
123
		) ) );
124
	}
125
126
	/**
127
	 * Clean wp_head, remove queries.
128
	 *
129
	 * @since    1.1.3
130
	 * @link: http://cubiq.org/clean-up-and-optimize-wordpress-for-your-next-theme
131
	 */
132
	function strip_cleanup() {
133
			remove_action( 'wp_head', 'wp_generator' );					// WP Version.
134
			remove_action( 'wp_head', 'wlwmanifest_link' );
135
			remove_action( 'wp_head', 'rsd_link' );
136
			remove_action( 'wp_head', 'rel_canonical', 10, 0 );
137
			remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
138
139
			remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );// Parent rel link.
140
			remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );	// Start post rel link.
141
			remove_action( 'wp_head', 'index_rel_link' );
142
143
			remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // Adjacent post rel link.
144
145
			add_filter( 'the_generator', '__return_false' );
146
147
			remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
148
			remove_action( 'wp_print_styles', 'print_emoji_styles' );
149
	}
150
	/**
151
	 * Cleanup head remove rss version
152
	 *
153
	 * @since    1.1.3
154
	 */
155
	function strip_remove_rss_version() {
156
		return '';
157
	}
158
	/**
159
	 * Cleanup head remove X-Pingback
160
	 *
161
	 * @param array $headers remove x pingback.
162
	 * @since    1.1.3
163
	 */
164
	function strip_remove_x_pingback( $headers ) {
165
		unset( $headers['X-Pingback'] );
166
		return $headers;
167
	}
168
169
	/**
170
	 * Cleanup head remove inline CSS comments
171
	 *
172
	 * @since    1.1.3
173
	 */
174
	function strip_remove_comments_inline_styles() {
175
		global $wp_widget_factory;
176
		if ( has_filter( 'wp_head', 'wp_widget_recent_comments_style' ) ) {
177
			remove_filter( 'wp_head', 'wp_widget_recent_comments_style' );
178
		}
179
180
		remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
181
	}
182
183
184
	/**
185
	* This theme styles the visual editor to resemble the theme style,
186
	* specifically font, colors, icons, and column width.
187
	*/
188
	add_editor_style( array( '/assets/css/editor-style.css', '/assets/fonts/fenix.css' ) );
189
190
	// Indicate widget sidebars can use selective refresh in the Customizer.
191
	// See https://make.wordpress.org/core/2016/03/22/implementing-selective-refresh-support-for-widgets/ for detail.
192
	add_theme_support( 'customize-selective-refresh-widgets' );
193
endif; // strip_setup.
194
add_action( 'after_setup_theme', 'strip_setup' );
195
196
/**
197
 * Register widgetized area and update sidebar with default widgets
198
 */
199
function strip_widgets_init() {
200
	register_sidebar(array(
201
		'name'          => __( 'Main Sidebar', 'strip' ),
202
		'id'            => 'sidebar',
203
		'description'   => __( 'The main body widget area', 'strip' ),
204
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
205
		'after_widget'	=> '</aside>',
206
		'before_title'	=> '<h2 class="widget-title">',
207
		'after_title'   => '</h2>',
208
	));
209
210
	// First footer widget area, located in the footer. Empty by default.
211
	register_sidebar( array(
212
		'name'          => __( 'First Footer Widget', 'strip' ),
213
		'id'            => 'first-footer-widget',
214
		'description'   => __( 'The first footer widget', 'strip' ),
215
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
216
		'after_widget'	=> '</aside>',
217
		'before_title'	=> '<h3 class="widget-title">',
218
		'after_title'   => '</h3>',
219
	));
220
221
	// Second Footer Widget Area, located in the footer. Empty by default.
222
	register_sidebar(array(
223
		'name'          => __( 'Second Footer Widget', 'strip' ),
224
		'id'            => 'second-footer-widget',
225
		'description'   => __( 'The second footer widget', 'strip' ),
226
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
227
		'after_widget'	=> '</aside>',
228
		'before_title'	=> '<h3 class="widget-title">',
229
		'after_title'   => '</h3>',
230
	));
231
232
	// Third Footer Widget Area, located in the footer. Empty by default.
233
	register_sidebar(array(
234
		'name'          => __( 'Third Footer Widget', 'strip' ),
235
		'id'            => 'third-footer-widget',
236
		'description'   => __( 'The third footer widget', 'strip' ),
237
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
238
		'after_widget'	=> '</aside>',
239
		'before_title'	=> '<h3 class="widget-title">',
240
		'after_title'   => '</h3>',
241
	));
242
243
	// Fourth Footer Widget Area, located in the footer. Empty by default.
244
	register_sidebar(array(
245
		'name'           => __( 'Fourth Footer Widget', 'strip' ),
246
		'id'             => 'fourth-footer-widget',
247
		'description'    => __( 'The fourth footer widget', 'strip' ),
248
		'before_widget'  => '<aside id="%1$s" class="widget %2$s">',
249
		'after_widget'	 => '</aside>',
250
		'before_title'	 => '<h3 class="widget-title">',
251
		'after_title'    => '</h3>',
252
	));
253
254
}
255
add_action( 'widgets_init', 'strip_widgets_init' );
256
257
/**
258
 * Handles JavaScript detection.
259
 *
260
 * Adds a `js` class to the root `<html>` element when JavaScript is detected.
261
 *
262
 * @since Strip 1.0
263
 */
264
function strip_javascript_detection() {
265
	echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
266
}
267
add_action( 'wp_head', 'strip_javascript_detection', 0 );
268
269
/**
270
 * Enqueue_styles for custom fonts.
271
 */
272
function strip_scripts() {
273
	// add custom font here if any.
274
	wp_enqueue_style( 'fenix', get_template_directory_uri() . '/assets/fonts/fenix.css', array(), null );
275
276
	wp_enqueue_style( 'inconsolata', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null );
277
278
	// Theme stylesheet.
279
	wp_enqueue_style( 'strip-style', get_stylesheet_uri() );
280
281
	// Load the Internet Explorer specific stylesheet. Conditional stylesheet — tested and works with IE9 on Windows7.
282
	wp_enqueue_style( 'strip-ie', get_template_directory_uri() . 'assets/css/ie.css', array( 'strip-style' ), '20160305' );
283
	wp_style_add_data( 'strip-ie', 'conditional', 'lt IE 10' );
284
285
	if ( has_nav_menu( 'primary' ) ) {
286
		wp_enqueue_script( 'strip-navigation', get_template_directory_uri() . '/assets/js/min/navigation-min.js', array(), '1.0', true );
287
	}
288
289
	// Load the html5 shiv.
290
	wp_enqueue_script( 'strip-html5', get_template_directory_uri() . '/assets/js/min/html5-min.js', array(), '3.7.3' );
291
	wp_script_add_data( 'strip-html5', 'conditional', 'lt IE 9' );
292
293
	wp_enqueue_script( 'strip-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/min/skip-link-focus-fix-min.js', array(), '1.0', true );
294
295
	// toggle comments js.
296
	wp_enqueue_script( 'strip-toggle-comments', get_template_directory_uri() . '/assets/js/min/toggle-comments-min.js', array( 'jquery' ), '1.2', true );
297
298
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
299
		wp_enqueue_script( 'comment-reply' );
300
301
		if ( is_single() && wp_attachment_is_image() ) {
302
			wp_enqueue_script( 'strip-keyboard-image-navigation', get_template_directory_uri() . '/assets/js/min/keyboard-image-navigation-min.js', array( 'jquery' ), '20160412', true );
303
		}
304
	}
305
}
306
307
add_action( 'wp_enqueue_scripts', 'strip_scripts' );
308
309
/**
310
 * Implement the Custom Header feature.
311
 */
312
require get_template_directory() . '/inc/custom-header.php';
313
314
/**
315
 * Custom template tags for this theme.
316
 */
317
require get_template_directory() . '/inc/template-tags.php';
318
319
/**
320
 * Custom functions that act independently of the theme templates.
321
 */
322
require get_template_directory() . '/inc/extras.php';
323
324
/**
325
 * Customizer additions.
326
 */
327
require get_template_directory() . '/inc/customizer.php';
328
329
/**
330
 * Load Jetpack compatibility file.
331
 */
332
require get_template_directory() . '/inc/jetpack.php';
333
334
add_action( 'wp_enqueue_scripts', 'enqueue_royal_sliders' );
335
/**
336
 * Register RoyalSLider
337
 */
338
function enqueue_royal_sliders() {
339
	if ( function_exists( 'register_new_royalslider_files' ) ) {
340
		// you could try this: if ( is_single() && is_archive() ) { but you don't really need it.
341
			register_new_royalslider_files( 1 ); // place register_new_royalslider_files function here, 1 is your slider's configuration number
342
		// add } if use is_single etc.
343
	}
344
}
345
346
/**
347
 * Get the first image from each post and resize it.
348
 *
349
 * @return string $first_img.
350
 * @link https://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/
351
 * @link https://gist.github.com/SilentComics/0a7ea47942eb759dbb48eac2b7be1bbc/
352
 */
353
function get_first_image() {
354
	global $post;
355
	$first_img = '';
356
	preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', do_shortcode( $post->post_content, 'gallery' ), $matches );
357
	  $first_img = isset( $matches[1][0] ) ? $matches[1][0] : null;
358
359
	if ( empty( $first_img ) ) {
360
			return get_template_directory_uri() . '/assets/images/empty.png'; // path to default image.
361
	}
362
363
		// Now we have the $first_img but we want the thumbnail of that image.
364
		$explode = explode( '.', $first_img );
365
		$count = count( $explode );
366
		$size = '-624x312'; // Panel ratio (2:1) 312x156 for lighther page, 624x312 for retina; use add_image_size() and Force Regenerate Thumbnails plugin when changing sizes.
367
		$explode[ $count -2 ] = $explode[ $count -2 ] . '' . $size;
368
		$thumb_img = implode( '.', $explode );
369
		return $thumb_img;
370
}
371
	add_filter( 'get_first_image', 'thumbnail' );
372
373
/**
374
 * Register Custom Post Type for comics
375
 */
376
function comic_post_type() {
377
378
	$labels = array(
379
		'name'                       => _x( 'Comics', 'Post Type General Name', 'strip' ),
380
		'singular_name'              => _x( 'Comic', 'Post Type Singular Name', 'strip' ),
381
		'menu_name'                  => _x( 'Comics', 'admin menu', 'strip' ),
382
		'name_admin_bar'             => _x( 'Comic', 'add new on admin bar', 'strip' ),
383
		'archives'             			 => __( 'Item Archives', 'strip' ),
384
		'attributes'           			 => __( 'Item Attributes', 'strip' ),
385
		'parent_item_colon'	         => __( 'Parent Comic:', 'strip' ),
386
		'all_items'                  => __( 'All Comics', 'strip' ),
387
		'add_new_item'               => __( 'Add New Comic', 'strip' ),
388
		'add_new'                    => __( 'Add New Comic', 'strip' ),
389
		'new_item'                   => __( 'New Comic', 'strip' ),
390
		'edit_item'                  => __( 'Edit Comic', 'strip' ),
391
		'update_item'                => __( 'Update Comic', 'strip' ),
392
		'view_item'                  => __( 'View Comic', 'strip' ),
393
		'search_items'               => __( 'Search Item', 'strip' ),
394
		'not_found'                  => __( 'No Comics found', 'strip' ),
395
		'not_found_in_trash'         => __( 'No Comics found in Trash', 'strip' ),
396
		'items_list'                 => __( 'Comics list', 'strip' ),
397
		'items_list_navigation'      => __( 'Comics list navigation', 'strip' ),
398
		'filter_items_list'          => __( 'Filter Comics list', 'strip' ),
399
	);
400
401
	$supports = array(
402
	'title',
403
	'editor',
404
	'excerpt',
405
	'trackbacks',
406
	'custom-fields',
407
	'comments',
408
	'revisions',
409
	'thumbnail',
410
	'author',
411
	'archive',
412
	);
413
414
	$args = array(
415
		'label'                      => __( 'Comic', 'strip' ),
416
		'description'                => __( 'Publish Comics and Webcomics', 'strip' ),
417
		'labels'                     => $labels,
418
		'supports'                   => $supports,
419
		'taxonomies'                 => array( 'story', 'story_term', 'draft' ),
420
		'hierarchical'               => true,
421
		'public'                     => true,
422
		'show_ui'                    => true,
423
		'show_in_menu'               => true,
424
		'menu_position'              => 20,
425
		'menu_icon'                  => 'dashicons-book-alt',
426
		'show_in_admin_bar'	         => true,
427
		'show_in_nav_menus'	         => true,
428
		'can_export'                 => true,
429
		'has_archive'                => true,
430
		'feeds'                      => true,
431
		'exclude_from_search'        => false,
432
		'rewrite'                    => array( 'slug' => 'stories', 'with_front' => true ),
433
		'publicly_queryable'	       => true,
434
		'capability_type'            => 'post',
435
	);
436
	register_post_type( 'comic', $args );
437
}
438
439
// Hook into the 'init' action.
440
add_action( 'init', 'comic_post_type', 0 ); // End of register_cpt_comic().
441
442
	/**
443
	 * Register Custom Taxonomy 'story'
444
	 */
445
function comic_story_taxonomy() {
446
	$labels = array(
447
		'name'                       => _x( 'Comic Story', 'Taxonomy General Name', 'strip' ),
448
		'singular_name'              => _x( 'Comic Story', 'Taxonomy Singular Name', 'strip' ),
449
		'menu_name'                  => __( 'Comic Stories', 'strip' ),
450
		'all_items'                  => __( 'All Comic Stories', 'strip' ),
451
		'parent_item'                => __( 'Parent Story', 'strip' ),
452
		'parent_item_colon'          => __( 'Parent Story:', 'strip' ),
453
		'new_item_name'              => __( 'New Comic Story', 'strip' ),
454
		'add_new_item'               => __( 'Add New Story', 'strip' ),
455
		'edit_item'                  => __( 'Edit Story', 'strip' ),
456
		'update_item'                => __( 'Update Story', 'strip' ),
457
		'view_item'                  => __( 'View Item', 'strip' ),
458
		'separate_items_with_commas' => __( 'Separate stories with commas', 'strip' ),
459
		'add_or_remove_items'        => __( 'Add or Remove Stories', 'strip' ),
460
		'choose_from_most_used'      => __( 'Choose from the most used stories', 'strip' ),
461
		'popular_items'              => __( 'Popular comic stories', 'strip' ),
462
		'search_items'               => __( 'Search Stories', 'strip' ),
463
		'not_found'                  => __( 'No comic Stories found', 'strip' ),
464
		'items_list'                 => __( 'Comic Stories list', 'strip' ),
465
		'items_list_navigation'      => __( 'Comic Stories list navigation', 'strip' ),
466
	);
467
	$args = array(
468
		'labels'                     => $labels,
469
		'label'                      => 'Stories',
470
		'hierarchical'               => true,
471
		'public'                     => true,
472
		'show_ui'                    => true,
473
		'show_admin_column'          => true,
474
		'show_in_nav_menus'          => true,
475
		'show_tagcloud'              => true,
476
		'query_var'	                 => true,
477
		'rewrite'                    => array( 'slug' => 'story' ),
478
	);
479
	register_taxonomy( 'story', array( 'comic' ), $args );
480
	register_taxonomy_for_object_type( 'story', 'comic' );
481
}
482
483
// Hook into the 'init' action.
484
add_action( 'init', 'comic_story_taxonomy', 0 );
485
486
/**
487
 * Function strip rewrite rules.
488
 */
489
function strip_rewrite_rules() {
490
	flush_rewrite_rules();
491
}
492
/* Flush rewrite rules for custom post types. */
493
add_action( 'after_switch_theme', 'strip_rewrite_rules' );
494
495
// Add Print taxonomy, NOT hierarchical (like tags)
496
// Register Custom Taxonomy.
497
	$labels = array(
498
		'name'                       => _x( 'Prints', 'Taxonomy General Name', 'strip' ),
499
		'singular_name'              => _x( 'Print', 'Taxonomy Singular Name', 'strip' ),
500
		'menu_name'                  => __( 'Print', 'strip' ),
501
		'all_items'                  => __( 'All Prints', 'strip' ),
502
		'parent_item'                => __( 'Parent Print', 'strip' ),
503
		'parent_item_colon'          => __( 'Parent Print:', 'strip' ),
504
		'new_item_name'              => __( 'New Print Name', 'strip' ),
505
		'add_new_item'               => __( 'Add New Print', 'strip' ),
506
		'edit_item'                  => __( 'Edit Print', 'strip' ),
507
		'update_item'                => __( 'Update Pring', 'strip' ),
508
		'view_item'                  => __( 'View Print', 'strip' ),
509
		'separate_items_with_commas' => __( 'Separate prints with commas', 'strip' ),
510
		'add_or_remove_items'        => __( 'Add or remove prints', 'strip' ),
511
		'choose_from_most_used'      => __( 'Choose from the most used', 'strip' ),
512
		'popular_items'              => __( 'Popular Prints', 'strip' ),
513
		'search_items'               => __( 'Search Prints', 'strip' ),
514
		'not_found'                  => __( 'Not Found', 'strip' ),
515
		'no_terms'                   => __( 'No prints', 'strip' ),
516
		'items_list'                 => __( 'Prints list', 'strip' ),
517
		'items_list_navigation'      => __( 'Prints list navigation', 'strip' ),
518
	);
519
520
	$args = array(
521
		'labels'                     => $labels,
522
		'hierarchical'               => false,
523
		'public'                     => true,
524
		'show_ui'                    => true,
525
		'show_admin_column'          => true,
526
		'show_in_nav_menus'          => true,
527
		'show_tagcloud'              => true,
528
	);
529
	register_taxonomy( 'print', array( 'comic' ), $args );
530
531
	/*
532
	* WooCommerce Hooks
533
	* Layout
534
	*/
535
	remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
536
	remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
537
	remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
538
	remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
539
	remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
540
	remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
541
542
	add_action( 'woocommerce_before_main_content', 'strip_wrapper_start', 10 );
543
	add_action( 'woocommerce_after_main_content', 'strip_wrapper_end', 10 );
544
545
		 /**
546
		  * WooCommerce wrapper
547
		  */
548
	function strip_wrapper_start() {
549
		echo '<section id="content" class="woocommerce-content" role="main"><div class="entry-wrap wrap clear">';
550
	}
551
552
	/**
553
	 * End WooCommerce wrapper
554
	 */
555
	function strip_wrapper_end() {
556
		echo '</section>';
557
	}
558
559
	add_action( 'after_setup_theme', 'woocommerce_support' );
560
	/**
561
	 * Add WooCommerce support
562
	 * https://docs.woothemes.com/document/third-party-custom-theme-compatibility/*
563
	 */
564
	function woocommerce_support() {
565
		add_theme_support( 'woocommerce' );
566
	}
567
568
	/**
569
	 * Enqueue the theme's own style for WooCommerce.
570
	 */
571
	function wp_enqueue_woocommerce_style() {
572
573
			wp_register_style( 'strip-woocommerce', get_template_directory_uri() . '/assets/css/woocommerce-min.css' );
574
		if ( class_exists( 'woocommerce' ) ) {
575
			wp_enqueue_style( 'strip-woocommerce' );
576
		}
577
	}
578
579
	add_action( 'wp_enqueue_scripts', 'wp_enqueue_woocommerce_style' );
580
581
	/**
582
* Optimize WooCommerce Scripts
583
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
584
*
585
* @link http://gregrickaby.com/remove-woocommerce-styles-and-scripts/
586
* @link https://wordimpress.com/how-to-load-woocommerce-scripts-and-styles-only-in-shop/
587
* @link https://gist.github.com/DevinWalker/7621777
588
* @link http://dessky.com/blog/disable-woocommerce-scripts-and-styles/
589
*/
590
	add_action( 'wp_enqueue_scripts', 'strip_manage_woocommerce_styles', 99 );
591
592
	/**
593
	 * Remove some WooCommerce queries.
594
	 */
595
	function strip_manage_woocommerce_styles() {
596
		// remove generator meta tag.
597
		remove_action( 'wp_head', array( 'woocommerce', 'generator' ) ); // this line when used with $GLOBALS['woocommerce'] prompts an error when Woo is deactivated though.
598
		// first check that woo exists to prevent fatal errors.
599
		if ( function_exists( 'strip_is_woocommerce_activated' ) ) {
600
			// dequeue scripts and styles, unless we're in the store.
601
			if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
602
				wp_dequeue_style( 'woocommerce_frontend_styles' );
603
				wp_dequeue_style( 'woocommerce-general' );
604
				wp_dequeue_style( 'woocommerce-layout' );
605
				wp_dequeue_style( 'woocommerce-smallscreen' );
606
				wp_dequeue_style( 'woocommerce_fancybox_styles' );
607
				wp_dequeue_style( 'woocommerce_chosen_styles' );
608
				wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
609
				wp_dequeue_style( 'select2' );
610
				wp_dequeue_style( 'strip-woocommerce' ); // the theme's CSS overwrite.
611
				wp_dequeue_script( 'wc-add-payment-method' );
612
				wp_dequeue_script( 'wc-lost-password' );
613
				wp_dequeue_script( 'wc_price_slider' );
614
				wp_dequeue_script( 'wc-single-product' );
615
				wp_dequeue_script( 'wc-add-to-cart' );
616
				wp_dequeue_script( 'wc-cart-fragments' );
617
				wp_dequeue_script( 'wc-credit-card-form' );
618
				wp_dequeue_script( 'wc-checkout' );
619
				wp_dequeue_script( 'wc-add-to-cart-variation' );
620
				wp_dequeue_script( 'wc-single-product' );
621
				wp_dequeue_script( 'wc-cart' );
622
				wp_dequeue_script( 'wc-chosen' );
623
				wp_dequeue_script( 'woocommerce' );
624
				wp_dequeue_script( 'jquery-cookie' );
625
				wp_dequeue_script( 'prettyPhoto' );
626
				wp_dequeue_script( 'prettyPhoto-init' );
627
				wp_dequeue_script( 'jquery-blockui' );
628
				wp_dequeue_script( 'jquery-placeholder' );
629
				wp_dequeue_script( 'jquery-payment' );
630
				wp_dequeue_script( 'fancybox' );
631
				wp_dequeue_script( 'jqueryui' );
632
			}
633
		}
634
	}
635
636
	add_action( 'pre_get_posts', 'strip_set_posts_per_page' );
637
	/**
638
	 * Set posts, WooCommerce products & comics number per archive page
639
	 * Fixes 404 error on pagination due to CTP conflicting with WordPress posts_per_page default
640
	 * see http://wordpress.stackexchange.com/questions/30757/change-posts-per-page-count/30763#30763
641
	 *
642
	 * @param string $query strip_set_posts_per_page.
643
	 * @return the posts per page.
644
	 */
645
	function strip_set_posts_per_page( $query ) {
646
		  global $wp_the_query;
647
		if (  ( $query === $wp_the_query ) && ( is_home() ) && ( is_search() ) ) {
648
			$wp_the_query->set( 'post_type', array( 'post', 'comic', 'posts_per_page', 12 ) );
649
		}
650
		if ( ( $query === $wp_the_query ) && ( is_post_type_archive( 'product' ) ) ) {
651
			$wp_the_query->set( 'posts_per_page', 4 );
652
		} elseif ( ( $query === $wp_the_query ) && ( is_archive() ) && ( is_tax( 'story' ) ) ) {
653
			$wp_the_query->set( 'posts_per_page', 3 );
654
		}
655
		return $wp_the_query;
656
	}
657
658
	add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
659
	/**
660
	 * Show 'comics' post types on home page.
661
	 *
662
	 * @param string $query add_my_post_types_to_query.
663
	 */
664
	function add_my_post_types_to_query( $query ) {
665
		if ( is_home() && $query->is_main_query() ) {
666
			$query->set( 'post_type', array( 'post', 'page', 'comic' ) );
667
668
		}
669
		  return $query;
670
	}
671
672
	/**
673
	 * Set an automatic default custom taxonomy for comic posts.
674
	 * When no "story" (taxonomy) is set, comic posts default to “draft”.
675
	 *
676
	 * @param	string $post_id set_default_object_terms.
677
	 * @param	string $post set_default_object_terms.
678
	 */
679
	function set_default_object_terms( $post_id, $post ) {
680
		if ( 'publish' === $post->post_status && 'comic' === $post->post_type ) {
681
			$defaults = array(
682
			'story' => array( 'draft' ),
683
			);
684
			$taxonomies = get_object_taxonomies( $post->post_type );
685
			foreach ( (array) $taxonomies as $taxonomy ) {
686
				$terms = get_the_terms( $post_id, $taxonomy );
687
				if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) {
688
					wp_set_object_terms( $post_id, $defaults[ $taxonomy ], $taxonomy );
689
				}
690
			}
691
		}
692
	}
693
	add_action( 'save_post', 'set_default_object_terms', 0, 2 );
694
695
	/**
696
	 * Remove jquery migrate $scripts for enhanced performance.
697
	 *
698
	 * @param strings $scripts remove_jquery_migrate.
699
	 */
700
	function remove_jquery_migrate( $scripts ) {
701
		if ( is_admin() ) {
702
			return;
703
		}
704
		 $scripts->remove( 'jquery' );
705
		 $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' );
706
	}
707
		add_action( 'wp_default_scripts', 'remove_jquery_migrate' );
708
709
		/**
710
		 * Remove login errors notices (security)
711
		 */
712
	function no_wordpress_errors() {
713
		return 'Something is wrong!';
714
	}
715
		add_filter( 'login_errors', 'no_wordpress_errors' );
716