Completed
Push — master ( 2d5a2b...8d6624 )
by SILENT
02:29
created

functions.php (6 issues)

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
		/**
41
* Add default posts and comments RSS feed links to head
42
*/
43
		add_theme_support( 'automatic-feed-links' );
44
45
		/**
46
* Enable support for title-tag. Allows themes to add document title tag to HTML <head> (since version 4.1.).
47
*/
48
		add_theme_support( 'title-tag' );
49
50
		/**
51
* Enable support for custom logo.
52
*
53
* @since strip 1.0
54
*/
55
		add_theme_support( 'custom-logo', array(
56
			'height'      => 156,
57
			'width'       => 312,
58
			'flex-height' => true,
59
			'flex-width'  => true,
60
			)
61
		);
62
63
		/**
64
* Enable support for Post Thumbnails on posts and pages
65
*
66
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
67
*/
68
		add_theme_support( 'post-thumbnails' );
69
		set_post_thumbnail_size( 1920, 0 ); // was using add_image_size.
70
		add_image_size( 'story-thumb', 312, 156, true ); // cropped.
71
72
		/**
73
		 * See https://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/
74
		 * http://codex.wordpress.org/Function_Reference/wpautop gets the same result but also removes line blocks: remove_filter( 'the_content', 'wpautop' );
75
		 *
76
		 * @param $strings $content filter_ptags_on_images.
77
		 */
78
		function filter_ptags_on_images( $content ) {
79
			return preg_replace( '/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content );
80
		}
81
		add_filter( 'the_content', 'filter_ptags_on_images' );
82
83
		/**
84
	 	* This theme uses wp_nav_menu() in one location.
85
	 	*/
86
		register_nav_menus(array(
87
			'primary' => __( 'Primary Menu', 'strip' ),
88
		));
89
90
		/*
91
		* Switch default core markup for search form, comment form, and comments
92
		* to output valid HTML5.
93
		*/
94
		add_theme_support( 'html5', array(
95
			'search-form',
96
			'comment-form',
97
			'comment-list',
98
			'gallery',
99
			'caption',
100
		) );
101
102
		/**
103
	 * Enable support for Post Formats
104
	 */
105
		add_theme_support( 'post-formats', array(
106
			'aside',
107
			'image',
108
			'video',
109
			'quote',
110
			'link',
111
			'gallery',
112
			'status',
113
			'audio',
114
			'chat',
115
		) );
116
117
		// Setup the WordPress core custom background feature.
118
		add_theme_support('custom-background', apply_filters('strip_custom_background_args', array(
119
			'default-color' => 'ffffff',
120
			'default-image' => '',
121
		)));
122
	}
123
124
	/**
125
	* This theme styles the visual editor to resemble the theme style,
126
	* specifically font, colors, icons, and column width.
127
	*/
128
	add_editor_style( array( '/assets/css/editor-style.css', '/assets/fonts/fenix.css' ) );
129
130
	// Indicate widget sidebars can use selective refresh in the Customizer.
131
	// See https://make.wordpress.org/core/2016/03/22/implementing-selective-refresh-support-for-widgets/ for detail.
132
	add_theme_support( 'customize-selective-refresh-widgets' );
133
endif; // strip_setup.
134
add_action( 'after_setup_theme', 'strip_setup' );
135
136
/**
137
 * Register widgetized area and update sidebar with default widgets
138
 */
139
function strip_widgets_init() {
140
	register_sidebar(array(
141
		'name'          => __( 'Main Sidebar', 'strip' ),
142
		'id'            => 'sidebar',
143
		'description'   => __( 'The main body widget area', 'strip' ),
144
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
145
		'after_widget'	=> '</aside>',
146
		'before_title'	=> '<h2 class="widget-title">',
147
		'after_title'   => '</h2>',
148
	));
149
150
	// First footer widget area, located in the footer. Empty by default.
151
	register_sidebar( array(
152
		'name'          => __( 'First Footer Widget', 'strip' ),
153
		'id'            => 'first-footer-widget',
154
		'description'   => __( 'The first footer widget', 'strip' ),
155
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
156
		'after_widget'	=> '</aside>',
157
		'before_title'	=> '<h3 class="widget-title">',
158
		'after_title'   => '</h3>',
159
	));
160
161
	// Second Footer Widget Area, located in the footer. Empty by default.
162
	register_sidebar(array(
163
		'name'          => __( 'Second Footer Widget', 'strip' ),
164
		'id'            => 'second-footer-widget',
165
		'description'   => __( 'The second footer widget', 'strip' ),
166
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
167
		'after_widget'	=> '</aside>',
168
		'before_title'	=> '<h3 class="widget-title">',
169
		'after_title'   => '</h3>',
170
	));
171
172
	// Third Footer Widget Area, located in the footer. Empty by default.
173
	register_sidebar(array(
174
		'name'          => __( 'Third Footer Widget', 'strip' ),
175
		'id'            => 'third-footer-widget',
176
		'description'   => __( 'The third footer widget', 'strip' ),
177
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
178
		'after_widget'	=> '</aside>',
179
		'before_title'	=> '<h3 class="widget-title">',
180
		'after_title'   => '</h3>',
181
	));
182
183
	// Fourth Footer Widget Area, located in the footer. Empty by default.
184
	register_sidebar(array(
185
		'name'           => __( 'Fourth Footer Widget', 'strip' ),
186
		'id'             => 'fourth-footer-widget',
187
		'description'    => __( 'The fourth footer widget', 'strip' ),
188
		'before_widget'  => '<aside id="%1$s" class="widget %2$s">',
189
		'after_widget'	 => '</aside>',
190
		'before_title'	 => '<h3 class="widget-title">',
191
		'after_title'    => '</h3>',
192
	));
193
194
}
195
add_action( 'widgets_init', 'strip_widgets_init' );
196
197
/**
198
 * Handles JavaScript detection.
199
 *
200
 * Adds a `js` class to the root `<html>` element when JavaScript is detected.
201
 *
202
 * @since Strip 1.0
203
 */
204
function strip_javascript_detection() {
205
	echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
206
}
207
add_action( 'wp_head', 'strip_javascript_detection', 0 );
208
209
/**
210
 * Enqueue_styles for custom fonts.
211
 */
212
function strip_scripts() {
213
	// add custom font here if any.
214
	wp_enqueue_style( 'fenix', get_template_directory_uri() . '/assets/fonts/fenix.css', array(), null );
215
216
	wp_enqueue_style( 'inconsolata', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null );
217
218
	// Theme stylesheet.
219
	wp_enqueue_style( 'strip-style', get_stylesheet_uri() );
220
221
	// Load the Internet Explorer specific stylesheet. Conditional stylesheet — tested and works with IE9 on Windows7.
222
	wp_enqueue_style( 'strip-ie', get_template_directory_uri() . 'assets/css/ie.css', array( 'strip-style' ), '20160305' );
223
	wp_style_add_data( 'strip-ie', 'conditional', 'lt IE 10' );
224
225
	if ( has_nav_menu( 'primary' ) ) {
226
		wp_enqueue_script( 'strip-navigation', get_template_directory_uri() . '/assets/js/min/navigation-min.js', array(), '20120206', true );
227
	}
228
229
	// Load the html5 shiv.
230
	wp_enqueue_script( 'strip-html5', get_template_directory_uri() . '/assets/js/min/html5-min.js', array(), '3.7.3' );
231
	wp_script_add_data( 'strip-html5', 'conditional', 'lt IE 9' );
232
233
	wp_enqueue_script( 'strip-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/min/skip-link-focus-fix-min.js', array(), '20130115', true );
234
235
	// toggle comments js.
236
	wp_enqueue_script( 'strip-toggle-comments', get_template_directory_uri() . '/assets/js/min/toggle-comments-min.js', array( 'jquery' ), '20160401', false );
237
238
	if ( is_single() && comments_open() && get_option( 'thread_comments' ) ) {
239
		wp_enqueue_script( 'comment-reply' );
240
241
		if ( is_single() && wp_attachment_is_image() ) {
242
			wp_enqueue_script( 'strip-keyboard-image-navigation', get_template_directory_uri() . '/assets/js/min/keyboard-image-navigation-min.js', array( 'jquery' ), '20120202' );
243
		}
244
	}
245
}
246
247
add_action( 'wp_enqueue_scripts', 'strip_scripts' );
248
249
/**
250
 * Implement the Custom Header feature.
251
 */
252
require get_template_directory() . '/inc/custom-header.php';
253
254
/**
255
 * Custom template tags for this theme.
256
 */
257
require get_template_directory() . '/inc/template-tags.php';
258
259
/**
260
 * Custom functions that act independently of the theme templates.
261
 */
262
require get_template_directory() . '/inc/extras.php';
263
264
/**
265
 * Customizer additions.
266
 */
267
require get_template_directory() . '/inc/customizer.php';
268
269
/**
270
 * Load Jetpack compatibility file.
271
 */
272
require get_template_directory() . '/inc/jetpack.php';
273
274
/**
275
 * Get the first image in a post. Strip Version. Retrieve images fine but doesn't resize.
276
 *
277
 * @param string $size get the first image size.
278
 * @link https://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/
279
 * see https://gist.github.com/tommaitland/8001524
280
 */
281
function get_first_image( $size = false ) {
282
	  global $post, $_wp_additional_image_sizes;
283
	  $first_img = '';
0 ignored issues
show
$first_img is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
284
285
	  $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', do_shortcode( $post->post_content, 'gallery' ), $matches );
286
		$first_img = $matches [1][0];
287
288
	if ( empty( $first_img ) ) {
289
			return get_template_directory_uri() . '/assets/images/empty.png'; // path to default image.
290
	}
291
	if ( $size && $_wp_additional_image_sizes[ $size ]['crop'] !== 1 ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $size of type false|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
292
		$size = '-' . $_wp_additional_image_sizes[ $size ]['width'] . 'x' . $_wp_additional_image_sizes[ $size ]['height'] . '.jpg';
293
		$pattern = '/-\d+x\d+\.jpg$/i';
294
		$first_img = preg_replace( $pattern, $size, $first_img );
295
	}
296
	  return $first_img;
297
}
298
			add_filter( 'first_img', 'get_first_image', 'thumbnail' );
299
300
/**
301
 * Register Custom Post Type for comics
302
 */
303
function comic_post_type() {
304
305
	$labels = array(
306
		'name'                       => _x( 'Comics', 'Post Type General Name', 'strip' ),
307
		'singular_name'              => _x( 'Comic', 'Post Type Singular Name', 'strip' ),
308
		'menu_name'                  => _x( 'Comics', 'admin menu', 'strip' ),
309
		'name_admin_bar'             => _x( 'Comic', 'add new on admin bar', 'strip' ),
310
		'parent_item_colon'	         => __( 'Parent Comic:', 'strip' ),
311
		'all_items'                  => __( 'All Comics', 'strip' ),
312
		'add_new_item'               => __( 'Add New Comic', 'strip' ),
313
		'add_new'                    => __( 'Add New Comic', 'strip' ),
314
		'new_item'                   => __( 'New Comic', 'strip' ),
315
		'edit_item'                  => __( 'Edit Comic', 'strip' ),
316
		'update_item'                => __( 'Update Comic', 'strip' ),
317
		'view_item'                  => __( 'View Comic', 'strip' ),
318
		'search_items'               => __( 'Search Item', 'strip' ),
319
		'not_found'                  => __( 'No Comics found', 'strip' ),
320
		'not_found_in_trash'         => __( 'No Comics found in Trash', 'strip' ),
321
		'items_list'                 => __( 'Comics list', 'strip' ),
322
		'items_list_navigation'      => __( 'Comics list navigation', 'strip' ),
323
		'filter_items_list'          => __( 'Filter Comics list', 'strip' ),
324
	);
325
326
	$supports = array(
327
	'title',
328
	'editor',
329
	'excerpt',
330
	'trackbacks',
331
	'custom-fields',
332
	'comments',
333
	'revisions',
334
	'thumbnail',
335
	'author',
336
	'archive',
337
	);
338
339
	$args = array(
340
		'label'                      => __( 'Comic', 'strip' ),
341
		'description'                => __( 'Publish Comics and Webcomics', 'strip' ),
342
		'labels'                     => $labels,
343
		'supports'                   => $supports,
344
		'taxonomies'                 => array( 'story', 'story_term', 'draft' ),
345
		'hierarchical'               => true,
346
		'public'                     => true,
347
		'show_ui'                    => true,
348
		'show_in_menu'               => true,
349
		'menu_position'              => 20,
350
		'menu_icon'                  => 'dashicons-book-alt',
351
		'show_in_admin_bar'	         => true,
352
		'show_in_nav_menus'	         => true,
353
		'can_export'                 => true,
354
		'has_archive'                => true,
355
		'feeds'                      => true,
356
		'exclude_from_search'        => false,
357
		'rewrite'                    => array( 'slug' => 'stories', 'with_front' => true ),
358
		'publicly_queryable'	     => true,
359
		'capability_type'            => 'post',
360
	);
361
	register_post_type( 'comic', $args );
362
}
363
364
// Hook into the 'init' action.
365
add_action( 'init', 'comic_post_type', 0 ); // End of register_cpt_comic().
366
367
	/**
368
	 * Register Custom Taxonomy 'story'
369
	 */
370
function comic_story_taxonomy() {
371
	$labels = array(
372
		'name'                       => _x( 'Comic Story', 'Taxonomy General Name', 'strip' ),
373
		'singular_name'              => _x( 'Comic Story', 'Taxonomy Singular Name', 'strip' ),
374
		'menu_name'                  => __( 'Comic Stories', 'strip' ),
375
		'all_items'                  => __( 'All Comic Stories', 'strip' ),
376
		'parent_item'                => __( 'Parent Story', 'strip' ),
377
		'parent_item_colon'          => __( 'Parent Story:', 'strip' ),
378
		'new_item_name'              => __( 'New Comic Story', 'strip' ),
379
		'add_new_item'               => __( 'Add New Story', 'strip' ),
380
		'edit_item'                  => __( 'Edit Story', 'strip' ),
381
		'update_item'                => __( 'Update Story', 'strip' ),
382
		'view_item'                  => __( 'View Item', 'strip' ),
383
		'separate_items_with_commas' => __( 'Separate stories with commas', 'strip' ),
384
		'add_or_remove_items'        => __( 'Add or Remove Stories', 'strip' ),
385
		'choose_from_most_used'      => __( 'Choose from the most used stories', 'strip' ),
386
		'popular_items'              => __( 'Popular comic stories', 'strip' ),
387
		'search_items'               => __( 'Search Stories', 'strip' ),
388
		'not_found'                  => __( 'No comic Stories found', 'strip' ),
389
		'items_list'                 => __( 'Comic Stories list', 'strip' ),
390
		'items_list_navigation'      => __( 'Comic Stories list navigation', 'strip' ),
391
	);
392
	$args = array(
393
		'labels'                     => $labels,
394
		'label'                      => 'Stories',
395
		'hierarchical'               => true,
396
		'public'                     => true,
397
		'show_ui'                    => true,
398
		'show_admin_column'          => true,
399
		'show_in_nav_menus'          => true,
400
		'show_tagcloud'              => true,
401
		'query_var'	                 => true,
402
		'rewrite'                    => array( 'slug' => 'story' ),
403
	);
404
	register_taxonomy( 'story', array( 'comic' ), $args );
405
	register_taxonomy_for_object_type( 'story', 'comic' );
406
}
407
408
// Hook into the 'init' action.
409
add_action( 'init', 'comic_story_taxonomy', 0 );
410
411
/**
412
 * Function strip rewrite rules.
413
 */
414
function strip_rewrite_rules() {
415
	flush_rewrite_rules();
416
}
417
/* Flush rewrite rules for custom post types. */
418
add_action( 'after_switch_theme', 'strip_rewrite_rules' );
419
420
// Add Print taxonomy, NOT hierarchical (like tags)
421
// Register Custom Taxonomy.
422
	$labels = array(
423
		'name'                       => _x( 'Prints', 'Taxonomy General Name', 'strip' ),
424
		'singular_name'              => _x( 'Print', 'Taxonomy Singular Name', 'strip' ),
425
		'menu_name'                  => __( 'Print', 'strip' ),
426
		'all_items'                  => __( 'All Prints', 'strip' ),
427
		'parent_item'                => __( 'Parent Print', 'strip' ),
428
		'parent_item_colon'          => __( 'Parent Print:', 'strip' ),
429
		'new_item_name'              => __( 'New Print Name', 'strip' ),
430
		'add_new_item'               => __( 'Add New Print', 'strip' ),
431
		'edit_item'                  => __( 'Edit Print', 'strip' ),
432
		'update_item'                => __( 'Update Pring', 'strip' ),
433
		'view_item'                  => __( 'View Print', 'strip' ),
434
		'separate_items_with_commas' => __( 'Separate prints with commas', 'strip' ),
435
		'add_or_remove_items'        => __( 'Add or remove prints', 'strip' ),
436
		'choose_from_most_used'      => __( 'Choose from the most used', 'strip' ),
437
		'popular_items'              => __( 'Popular Prints', 'strip' ),
438
		'search_items'               => __( 'Search Prints', 'strip' ),
439
		'not_found'                  => __( 'Not Found', 'strip' ),
440
		'no_terms'                   => __( 'No prints', 'strip' ),
441
		'items_list'                 => __( 'Prints list', 'strip' ),
442
		'items_list_navigation'      => __( 'Prints list navigation', 'strip' ),
443
	);
444
445
	$args = array(
446
		'labels'                     => $labels,
447
		'hierarchical'               => false,
448
		'public'                     => true,
449
		'show_ui'                    => true,
450
		'show_admin_column'          => true,
451
		'show_in_nav_menus'          => true,
452
		'show_tagcloud'              => true,
453
	);
454
	register_taxonomy( 'print', array( 'comic' ), $args );
455
456
	/*
457
	* WooCommerce Hooks
458
	* Layout
459
	*/
460
	remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
461
	remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
462
	remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
463
	remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
464
	remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
465
	remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
466
467
	add_action( 'woocommerce_before_main_content', 'strip_wrapper_start', 10 );
468
	add_action( 'woocommerce_after_main_content', 'strip_wrapper_end', 10 );
469
470
		 /**
471
		  * WooCommerce wrapper
472
		  */
473
	function strip_wrapper_start() {
474
		echo '<section id="content" class="woocommerce-content" role="main"><div class="entry-wrap wrap clear">';
475
	}
476
477
	/**
478
	 * End WooCommerce wrapper
479
	 */
480
	function strip_wrapper_end() {
481
		echo '</section>';
482
	}
483
484
	add_action( 'after_setup_theme', 'woocommerce_support' );
485
	/**
486
	 * Add WooCommerce support
487
	 * https://docs.woothemes.com/document/third-party-custom-theme-compatibility/*
488
	 */
489
	function woocommerce_support() {
490
		add_theme_support( 'woocommerce' );
491
	}
492
493
	/**
494
	 * Enqueue the theme's own style for WooCommerce.
495
	 */
496
	function wp_enqueue_woocommerce_style() {
497
498
			wp_register_style( 'strip-woocommerce', get_template_directory_uri() . '/assets/css/woocommerce-min.css' );
499
		if ( class_exists( 'woocommerce' ) ) {
500
			wp_enqueue_style( 'strip-woocommerce' );
501
		}
502
	}
503
504
	add_action( 'wp_enqueue_scripts', 'wp_enqueue_woocommerce_style' );
505
506
	/**
507
* Optimize WooCommerce Scripts
508
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
509
*
510
* @link http://gregrickaby.com/remove-woocommerce-styles-and-scripts/
511
* @link https://wordimpress.com/how-to-load-woocommerce-scripts-and-styles-only-in-shop/
512
* @link https://gist.github.com/DevinWalker/7621777
513
* @link http://dessky.com/blog/disable-woocommerce-scripts-and-styles/
514
*/
515
	add_action( 'wp_enqueue_scripts', 'strip_manage_woocommerce_styles', 99 );
516
517
	/**
518
	 * Remove some WooCommerce queries.
519
	 */
520
	function strip_manage_woocommerce_styles() {
521
		// remove generator meta tag.
522
		remove_action( 'wp_head', array( 'woocommerce', 'generator' ) ); // this line when used with $GLOBALS['woocommerce'] prompts an error when Woo is deactivated though.
523
		// first check that woo exists to prevent fatal errors.
524
		if ( function_exists( 'is_woocommerce' ) ) {
525
			// dequeue scripts and styles, unless we're in the store.
526
			if ( ! is_woocommerce() && ! is_page( 'store' ) && ! is_shop() && ! is_product_category() && ! is_product() && ! is_cart() && ! is_checkout() ) {
527
				wp_dequeue_style( 'woocommerce_frontend_styles' );
528
				wp_dequeue_style( 'woocommerce-general' );
529
				wp_dequeue_style( 'woocommerce-layout' );
530
				wp_dequeue_style( 'woocommerce-smallscreen' );
531
				wp_dequeue_style( 'woocommerce_fancybox_styles' );
532
				wp_dequeue_style( 'woocommerce_chosen_styles' );
533
				wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
534
				wp_dequeue_style( 'select2' );
535
				wp_dequeue_style( 'strip-woocommerce' ); // the theme's CSS overwrite.
536
				wp_dequeue_script( 'wc-add-payment-method' );
537
				wp_dequeue_script( 'wc-lost-password' );
538
				wp_dequeue_script( 'wc_price_slider' );
539
				wp_dequeue_script( 'wc-single-product' );
540
				wp_dequeue_script( 'wc-add-to-cart' );
541
				wp_dequeue_script( 'wc-cart-fragments' );
542
				wp_dequeue_script( 'wc-credit-card-form' );
543
				wp_dequeue_script( 'wc-checkout' );
544
				wp_dequeue_script( 'wc-add-to-cart-variation' );
545
				wp_dequeue_script( 'wc-single-product' );
546
				wp_dequeue_script( 'wc-cart' );
547
				wp_dequeue_script( 'wc-chosen' );
548
				wp_dequeue_script( 'woocommerce' );
549
				wp_dequeue_script( 'jquery-cookie' );
550
				wp_dequeue_script( 'prettyPhoto' );
551
				wp_dequeue_script( 'prettyPhoto-init' );
552
				wp_dequeue_script( 'jquery-blockui' );
553
				wp_dequeue_script( 'jquery-placeholder' );
554
				wp_dequeue_script( 'jquery-payment' );
555
				wp_dequeue_script( 'fancybox' );
556
				wp_dequeue_script( 'jqueryui' );
557
			}
558
		}
559
	}
560
561
	add_action( 'pre_get_posts', 'strip_set_posts_per_page' );
562
	/**
563
	 * Set posts, WooCommerce products & comics number per archive page
564
	 * Fixes 404 error on pagination due to CTP conflicting with WordPress posts_per_page default
565
	 * see http://wordpress.stackexchange.com/questions/30757/change-posts-per-page-count/30763#30763
566
	 *
567
	 * @param string $query strip_set_posts_per_page.
568
	 */
569
	function strip_set_posts_per_page( $query ) {
570
571
			global $wp_the_query;
572
573
		if ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_home() ) && ( $query->is_search() ) ) {
0 ignored issues
show
The method is_home cannot be called on $query (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
The method is_search cannot be called on $query (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
574
			 $query->set( 'posts_per_page', 12 );
575
		}
576
		if ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_post_type_archive( 'product' ) ) && (taxonomy_exists( 'category' ) ) ) {
0 ignored issues
show
The method is_post_type_archive cannot be called on $query (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
577
			$query->set( 'posts_per_page', 8 );
578
		} elseif ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_archive() )	&& (is_tax( 'story' ) ) ) {
0 ignored issues
show
The method is_archive cannot be called on $query (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
579
			$query->set( 'posts_per_page', 3 );
580
		}
581
			return $query;
582
	}
583
584
	/**
585
	 * Set an automatic default custom taxonomy for comic posts.
586
	 * When no "story" (taxonomy) is set, comic posts default to “draft”.
587
	 *
588
	 * @param	string $post_id set_default_object_terms.
589
	 * @param	string $post set_default_object_terms.
590
	 */
591
	function set_default_object_terms( $post_id, $post ) {
592
		if ( 'publish' === $post->post_status && 'comic' === $post->post_type ) {
593
			$defaults = array(
594
			'story' => array( 'draft' ),
595
			);
596
			$taxonomies = get_object_taxonomies( $post->post_type );
597
			foreach ( (array) $taxonomies as $taxonomy ) {
598
				$terms = get_the_terms( $post_id, $taxonomy );
599
				if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) {
600
					wp_set_object_terms( $post_id, $defaults[ $taxonomy ], $taxonomy );
601
				}
602
			}
603
		}
604
	}
605
	add_action( 'save_post', 'set_default_object_terms', 0, 2 );
606
607
	/**
608
	 * Remove jquery migrate $scripts for enhanced performance.
609
	 *
610
	 * @param strings $scripts remove_jquery_migrate.
611
	 */
612
	function remove_jquery_migrate( $scripts ) {
613
		if ( is_admin() ) {
614
			return;
615
		}
616
		 $scripts->remove( 'jquery' );
617
		 $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' );
618
	}
619
		add_action( 'wp_default_scripts', 'remove_jquery_migrate' );
620