@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Set the content width based on the theme's design and stylesheet. |
12 | -if ( ! isset( $content_width ) ) { |
|
12 | +if ( ! isset($content_width)) { |
|
13 | 13 | $content_width = 1920; |
14 | 14 | } /* pixels */ |
15 | 15 | |
16 | -if ( ! function_exists( 'strip_setup' ) ) : |
|
16 | +if ( ! function_exists('strip_setup')) : |
|
17 | 17 | /** |
18 | 18 | * Sets up theme defaults and registers support for various WordPress features. |
19 | 19 | * |
@@ -28,29 +28,29 @@ discard block |
||
28 | 28 | * adding custom login css |
29 | 29 | * changing text in footer of admin |
30 | 30 | */ |
31 | - require_once( 'assets/admin.php' ); |
|
31 | + require_once('assets/admin.php'); |
|
32 | 32 | /** |
33 | 33 | * Make theme available for translation |
34 | 34 | * Translations can be filed in the /languages/ directory |
35 | 35 | * If you're building a theme based on strip, use a find and replace |
36 | 36 | * to change 'strip' to the name of your theme in all the template files |
37 | 37 | */ |
38 | - load_theme_textdomain( 'strip', get_template_directory() . '/languages' ); |
|
38 | + load_theme_textdomain('strip', get_template_directory() . '/languages'); |
|
39 | 39 | |
40 | 40 | // Add default posts and comments RSS feed links to head. |
41 | - add_theme_support( 'automatic-feed-links' ); |
|
41 | + add_theme_support('automatic-feed-links'); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Enable support for title-tag. Allows themes to add document title tag to HTML <head> (since version 4.1.). |
45 | 45 | */ |
46 | - add_theme_support( 'title-tag' ); |
|
46 | + add_theme_support('title-tag'); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Enable support for custom logo. |
50 | 50 | * |
51 | 51 | * @since strip 1.0 |
52 | 52 | */ |
53 | - add_theme_support( 'custom-logo', array( |
|
53 | + add_theme_support('custom-logo', array( |
|
54 | 54 | 'height' => 156, |
55 | 55 | 'width' => 312, |
56 | 56 | 'flex-height' => true, |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ |
65 | 65 | */ |
66 | -add_theme_support( 'post-thumbnails' ); |
|
67 | -add_image_size( 'strip-featured-image', 1920, 480, true ); |
|
68 | -add_image_size( 'strip-large', 1272, 636, true ); // cropped. |
|
69 | -add_image_size( 'strip-medium', 624, 312, true ); // cropped. |
|
70 | -add_image_size( 'strip-thumbnail', 312, 156, true ); // cropped. |
|
66 | +add_theme_support('post-thumbnails'); |
|
67 | +add_image_size('strip-featured-image', 1920, 480, true); |
|
68 | +add_image_size('strip-large', 1272, 636, true); // cropped. |
|
69 | +add_image_size('strip-medium', 624, 312, true); // cropped. |
|
70 | +add_image_size('strip-thumbnail', 312, 156, true); // cropped. |
|
71 | 71 | /** |
72 | 72 | * Remove paragraph tags around images. |
73 | 73 | * |
@@ -75,35 +75,35 @@ discard block |
||
75 | 75 | * @link https://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/ |
76 | 76 | * @see http://codex.wordpress.org/Function_Reference/wpautop gets the same result but removes line blocks: remove_filter( 'the_content', 'wpautop' ); |
77 | 77 | */ |
78 | - function filter_ptags_on_images( $img ) { |
|
79 | - return preg_replace( '/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $img ); |
|
78 | + function filter_ptags_on_images($img) { |
|
79 | + return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $img); |
|
80 | 80 | } |
81 | - add_filter( 'the_content', 'filter_ptags_on_images' ); |
|
81 | + add_filter('the_content', 'filter_ptags_on_images'); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * This theme uses wp_nav_menu() in one location. |
85 | 85 | */ |
86 | 86 | register_nav_menus(array( |
87 | - 'primary' => __( 'Primary Menu', 'strip' ), |
|
87 | + 'primary' => __('Primary Menu', 'strip'), |
|
88 | 88 | )); |
89 | 89 | |
90 | 90 | /* |
91 | 91 | * Switch default core markup for search form, comment form, and comments |
92 | 92 | * to output valid HTML5. |
93 | 93 | */ |
94 | - add_theme_support( 'html5', array( |
|
94 | + add_theme_support('html5', array( |
|
95 | 95 | 'search-form', |
96 | 96 | 'comment-form', |
97 | 97 | 'comment-list', |
98 | 98 | 'gallery', |
99 | 99 | 'caption', |
100 | 100 | 'widgets', |
101 | - ) ); |
|
101 | + )); |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Enable support for Post Formats |
105 | 105 | */ |
106 | - add_theme_support( 'post-formats', array( |
|
106 | + add_theme_support('post-formats', array( |
|
107 | 107 | 'image', |
108 | 108 | 'video', |
109 | 109 | 'quote', |
@@ -111,35 +111,35 @@ discard block |
||
111 | 111 | 'gallery', |
112 | 112 | 'audio', |
113 | 113 | 'chat', |
114 | - ) ); |
|
114 | + )); |
|
115 | 115 | |
116 | 116 | // Setup the WordPress core custom background feature. |
117 | 117 | add_theme_support('custom-background', apply_filters('strip_custom_background_args', array( |
118 | 118 | 'default-color' => 'ffffff', |
119 | 119 | 'default-image' => '', |
120 | - ) ) ); |
|
120 | + ))); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * This theme styles the visual editor to resemble the theme style, |
125 | 125 | * specifically font, colors, icons, and column width. |
126 | 126 | */ |
127 | - add_editor_style( array( '/assets/css/editor-style.css', '/assets/fonts/fenix.css' ) ); |
|
127 | + add_editor_style(array('/assets/css/editor-style.css', '/assets/fonts/fenix.css')); |
|
128 | 128 | |
129 | 129 | // Indicate widget sidebars can use selective refresh in the Customizer. |
130 | 130 | // See https://make.wordpress.org/core/2016/03/22/implementing-selective-refresh-support-for-widgets/ for detail. |
131 | - add_theme_support( 'customize-selective-refresh-widgets' ); |
|
131 | + add_theme_support('customize-selective-refresh-widgets'); |
|
132 | 132 | endif; // strip_setup. |
133 | -add_action( 'after_setup_theme', 'strip_setup' ); |
|
133 | +add_action('after_setup_theme', 'strip_setup'); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Register widgetized area and update sidebar with default widgets |
137 | 137 | */ |
138 | 138 | function strip_widgets_init() { |
139 | 139 | register_sidebar(array( |
140 | - 'name' => __( 'Main Sidebar', 'strip' ), |
|
140 | + 'name' => __('Main Sidebar', 'strip'), |
|
141 | 141 | 'id' => 'sidebar', |
142 | - 'description' => __( 'The main body widget area', 'strip' ), |
|
142 | + 'description' => __('The main body widget area', 'strip'), |
|
143 | 143 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
144 | 144 | 'after_widget' => '</aside>', |
145 | 145 | 'before_title' => '<h2 class="widget-title">', |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | )); |
148 | 148 | |
149 | 149 | // First footer widget area, located in the footer. Empty by default. |
150 | - register_sidebar( array( |
|
151 | - 'name' => __( 'First Footer Widget', 'strip' ), |
|
150 | + register_sidebar(array( |
|
151 | + 'name' => __('First Footer Widget', 'strip'), |
|
152 | 152 | 'id' => 'first-footer-widget', |
153 | - 'description' => __( 'The first footer widget', 'strip' ), |
|
153 | + 'description' => __('The first footer widget', 'strip'), |
|
154 | 154 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
155 | 155 | 'after_widget' => '</aside>', |
156 | 156 | 'before_title' => '<h3 class="widget-title">', |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | |
160 | 160 | // Second Footer Widget Area, located in the footer. Empty by default. |
161 | 161 | register_sidebar(array( |
162 | - 'name' => __( 'Second Footer Widget', 'strip' ), |
|
162 | + 'name' => __('Second Footer Widget', 'strip'), |
|
163 | 163 | 'id' => 'second-footer-widget', |
164 | - 'description' => __( 'The second footer widget', 'strip' ), |
|
164 | + 'description' => __('The second footer widget', 'strip'), |
|
165 | 165 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
166 | 166 | 'after_widget' => '</aside>', |
167 | 167 | 'before_title' => '<h3 class="widget-title">', |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | |
171 | 171 | // Third Footer Widget Area, located in the footer. Empty by default. |
172 | 172 | register_sidebar(array( |
173 | - 'name' => __( 'Third Footer Widget', 'strip' ), |
|
173 | + 'name' => __('Third Footer Widget', 'strip'), |
|
174 | 174 | 'id' => 'third-footer-widget', |
175 | - 'description' => __( 'The third footer widget', 'strip' ), |
|
175 | + 'description' => __('The third footer widget', 'strip'), |
|
176 | 176 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
177 | 177 | 'after_widget' => '</aside>', |
178 | 178 | 'before_title' => '<h3 class="widget-title">', |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | |
182 | 182 | // Fourth Footer Widget Area, located in the footer. Empty by default. |
183 | 183 | register_sidebar(array( |
184 | - 'name' => __( 'Fourth Footer Widget', 'strip' ), |
|
184 | + 'name' => __('Fourth Footer Widget', 'strip'), |
|
185 | 185 | 'id' => 'fourth-footer-widget', |
186 | - 'description' => __( 'The fourth footer widget', 'strip' ), |
|
186 | + 'description' => __('The fourth footer widget', 'strip'), |
|
187 | 187 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
188 | 188 | 'after_widget' => '</aside>', |
189 | 189 | 'before_title' => '<h3 class="widget-title">', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | )); |
192 | 192 | |
193 | 193 | } |
194 | -add_action( 'widgets_init', 'strip_widgets_init' ); |
|
194 | +add_action('widgets_init', 'strip_widgets_init'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Handles JavaScript detection. |
@@ -203,47 +203,47 @@ discard block |
||
203 | 203 | function strip_javascript_detection() { |
204 | 204 | echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n"; |
205 | 205 | } |
206 | -add_action( 'wp_head', 'strip_javascript_detection', 0 ); |
|
206 | +add_action('wp_head', 'strip_javascript_detection', 0); |
|
207 | 207 | |
208 | 208 | /** |
209 | 209 | * Enqueue_styles for custom fonts. |
210 | 210 | */ |
211 | 211 | function strip_scripts() { |
212 | 212 | // add custom font here if any. |
213 | - wp_enqueue_style( 'fenix', get_template_directory_uri() . '/assets/fonts/fenix.css', array(), null ); |
|
213 | + wp_enqueue_style('fenix', get_template_directory_uri() . '/assets/fonts/fenix.css', array(), null); |
|
214 | 214 | |
215 | - wp_enqueue_style( 'inconsolata', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null ); |
|
215 | + wp_enqueue_style('inconsolata', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null); |
|
216 | 216 | |
217 | 217 | // Theme stylesheet. |
218 | - wp_enqueue_style( 'strip-style', get_stylesheet_uri() ); |
|
218 | + wp_enqueue_style('strip-style', get_stylesheet_uri()); |
|
219 | 219 | |
220 | 220 | // Load the Internet Explorer specific stylesheet. Conditional stylesheet — tested and works with IE9 on Windows7. |
221 | - wp_enqueue_style( 'strip-ie', get_template_directory_uri() . '/assets/css/ie.css', array( 'strip-style' ), '20160305' ); |
|
222 | - wp_style_add_data( 'strip-ie', 'conditional', 'lt IE 10' ); |
|
221 | + wp_enqueue_style('strip-ie', get_template_directory_uri() . '/assets/css/ie.css', array('strip-style'), '20160305'); |
|
222 | + wp_style_add_data('strip-ie', 'conditional', 'lt IE 10'); |
|
223 | 223 | |
224 | - if ( has_nav_menu( 'primary' ) ) { |
|
225 | - wp_enqueue_script( 'strip-navigation', get_template_directory_uri() . '/assets/js/min/navigation-min.js', array(), '1.0', true ); |
|
224 | + if (has_nav_menu('primary')) { |
|
225 | + wp_enqueue_script('strip-navigation', get_template_directory_uri() . '/assets/js/min/navigation-min.js', array(), '1.0', true); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Load the html5 shiv. |
229 | - wp_enqueue_script( 'strip-html5', get_template_directory_uri() . '/assets/js/min/html5-min.js', array(), '3.7.3' ); |
|
230 | - wp_script_add_data( 'strip-html5', 'conditional', 'lt IE 9' ); |
|
229 | + wp_enqueue_script('strip-html5', get_template_directory_uri() . '/assets/js/min/html5-min.js', array(), '3.7.3'); |
|
230 | + wp_script_add_data('strip-html5', 'conditional', 'lt IE 9'); |
|
231 | 231 | |
232 | - 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 ); |
|
232 | + 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); |
|
233 | 233 | |
234 | - if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
|
235 | - wp_enqueue_script( 'comment-reply' ); |
|
234 | + if (is_singular() && comments_open() && get_option('thread_comments')) { |
|
235 | + wp_enqueue_script('comment-reply'); |
|
236 | 236 | |
237 | 237 | // toggle comments js. |
238 | - wp_enqueue_script( 'strip-toggle-comments', get_template_directory_uri() . '/assets/js/min/toggle-comments-min.js', array( 'jquery' ), '1.2', true ); |
|
238 | + wp_enqueue_script('strip-toggle-comments', get_template_directory_uri() . '/assets/js/min/toggle-comments-min.js', array('jquery'), '1.2', true); |
|
239 | 239 | |
240 | - if ( is_single() && wp_attachment_is_image() ) { |
|
241 | - wp_enqueue_script( 'strip-keyboard-image-navigation', get_template_directory_uri() . '/assets/js/min/keyboard-image-navigation-min.js', array( 'jquery' ), '20160412', true ); |
|
240 | + if (is_single() && wp_attachment_is_image()) { |
|
241 | + wp_enqueue_script('strip-keyboard-image-navigation', get_template_directory_uri() . '/assets/js/min/keyboard-image-navigation-min.js', array('jquery'), '20160412', true); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | -add_action( 'wp_enqueue_scripts', 'strip_scripts' ); |
|
246 | +add_action('wp_enqueue_scripts', 'strip_scripts'); |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Implement the Custom Header feature. |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | */ |
271 | 271 | require get_template_directory() . '/inc/jetpack.php'; |
272 | 272 | |
273 | -add_action( 'wp_enqueue_scripts', 'enqueue_royal_sliders' ); |
|
273 | +add_action('wp_enqueue_scripts', 'enqueue_royal_sliders'); |
|
274 | 274 | /** |
275 | 275 | * Register RoyalSLider |
276 | 276 | */ |
277 | 277 | function enqueue_royal_sliders() { |
278 | - if ( function_exists( 'register_new_royalslider_files' ) ) { |
|
278 | + if (function_exists('register_new_royalslider_files')) { |
|
279 | 279 | // you could try this: if ( is_single() && is_archive() ) { but you don't really need it. |
280 | - register_new_royalslider_files( 1 ); // 1 is RoyalSlider configuration number |
|
280 | + register_new_royalslider_files(1); // 1 is RoyalSlider configuration number |
|
281 | 281 | // add } if use is_single etc. |
282 | 282 | } |
283 | 283 | } |
@@ -291,24 +291,24 @@ discard block |
||
291 | 291 | * |
292 | 292 | */ |
293 | 293 | function get_first_image() { |
294 | - $post = get_post(); |
|
294 | + $post = get_post(); |
|
295 | 295 | $first_img = ''; |
296 | - preg_match_all( '@src="([^"]+)"@' , do_shortcode( $post->post_content, 'gallery' ), $matches ); |
|
297 | - $first_img = isset( $matches[1][0] ) ? $matches[1][0] : null; |
|
296 | + preg_match_all('@src="([^"]+)"@', do_shortcode($post->post_content, 'gallery'), $matches); |
|
297 | + $first_img = isset($matches[1][0]) ? $matches[1][0] : null; |
|
298 | 298 | |
299 | - if ( empty( $first_img ) ) { |
|
299 | + if (empty($first_img)) { |
|
300 | 300 | return get_template_directory_uri() . '/assets/images/empty.png'; // path to default image. |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Now we have the $first_img but we want the thumbnail of that image. |
304 | - $explode = explode( '.', $first_img ); |
|
305 | - $count = count( $explode ); |
|
304 | + $explode = explode('.', $first_img); |
|
305 | + $count = count($explode); |
|
306 | 306 | $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. |
307 | - $explode[ $count -2 ] = $explode[ $count -2 ] . '' . $size; |
|
308 | - $thumb_img = implode( '.', $explode ); |
|
307 | + $explode[$count - 2] = $explode[$count - 2] . '' . $size; |
|
308 | + $thumb_img = implode('.', $explode); |
|
309 | 309 | return $thumb_img; |
310 | 310 | } |
311 | - add_filter( 'get_first_image', 'thumbnail' ); |
|
311 | + add_filter('get_first_image', 'thumbnail'); |
|
312 | 312 | |
313 | 313 | /** |
314 | 314 | * Register Custom Post Type for comics with REST API support |
@@ -316,24 +316,24 @@ discard block |
||
316 | 316 | function comic_post_type() { |
317 | 317 | |
318 | 318 | $labels = array( |
319 | - 'name' => _x( 'Comics', 'Post Type General Name', 'strip' ), |
|
320 | - 'singular_name' => _x( 'Comic', 'Post Type Singular Name', 'strip' ), |
|
321 | - 'menu_name' => _x( 'Comics', 'admin menu', 'strip' ), |
|
322 | - 'name_admin_bar' => _x( 'Comic', 'add new on admin bar', 'strip' ), |
|
323 | - 'parent_item_colon' => __( 'Parent Comic:', 'strip' ), |
|
324 | - 'all_items' => __( 'All Comics', 'strip' ), |
|
325 | - 'add_new_item' => __( 'Add New Comic', 'strip' ), |
|
326 | - 'add_new' => __( 'Add New Comic', 'strip' ), |
|
327 | - 'new_item' => __( 'New Comic', 'strip' ), |
|
328 | - 'edit_item' => __( 'Edit Comic', 'strip' ), |
|
329 | - 'update_item' => __( 'Update Comic', 'strip' ), |
|
330 | - 'view_item' => __( 'View Comic', 'strip' ), |
|
331 | - 'search_items' => __( 'Search Item', 'strip' ), |
|
332 | - 'not_found' => __( 'No Comics found', 'strip' ), |
|
333 | - 'not_found_in_trash' => __( 'No Comics found in Trash', 'strip' ), |
|
334 | - 'items_list' => __( 'Comics list', 'strip' ), |
|
335 | - 'items_list_navigation' => __( 'Comics list navigation', 'strip' ), |
|
336 | - 'filter_items_list' => __( 'Filter Comics list', 'strip' ), |
|
319 | + 'name' => _x('Comics', 'Post Type General Name', 'strip'), |
|
320 | + 'singular_name' => _x('Comic', 'Post Type Singular Name', 'strip'), |
|
321 | + 'menu_name' => _x('Comics', 'admin menu', 'strip'), |
|
322 | + 'name_admin_bar' => _x('Comic', 'add new on admin bar', 'strip'), |
|
323 | + 'parent_item_colon' => __('Parent Comic:', 'strip'), |
|
324 | + 'all_items' => __('All Comics', 'strip'), |
|
325 | + 'add_new_item' => __('Add New Comic', 'strip'), |
|
326 | + 'add_new' => __('Add New Comic', 'strip'), |
|
327 | + 'new_item' => __('New Comic', 'strip'), |
|
328 | + 'edit_item' => __('Edit Comic', 'strip'), |
|
329 | + 'update_item' => __('Update Comic', 'strip'), |
|
330 | + 'view_item' => __('View Comic', 'strip'), |
|
331 | + 'search_items' => __('Search Item', 'strip'), |
|
332 | + 'not_found' => __('No Comics found', 'strip'), |
|
333 | + 'not_found_in_trash' => __('No Comics found in Trash', 'strip'), |
|
334 | + 'items_list' => __('Comics list', 'strip'), |
|
335 | + 'items_list_navigation' => __('Comics list navigation', 'strip'), |
|
336 | + 'filter_items_list' => __('Filter Comics list', 'strip'), |
|
337 | 337 | ); |
338 | 338 | |
339 | 339 | $supports = array( |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | ); |
352 | 352 | |
353 | 353 | $args = array( |
354 | - 'label' => __( 'Comic', 'strip' ), |
|
355 | - 'description' => __( 'Publish Comics and Webcomics', 'strip' ), |
|
354 | + 'label' => __('Comic', 'strip'), |
|
355 | + 'description' => __('Publish Comics and Webcomics', 'strip'), |
|
356 | 356 | 'labels' => $labels, |
357 | 357 | 'supports' => $supports, |
358 | - 'taxonomies' => array( 'story', 'story_term', 'draft' ), |
|
358 | + 'taxonomies' => array('story', 'story_term', 'draft'), |
|
359 | 359 | 'hierarchical' => true, |
360 | 360 | 'public' => true, |
361 | 361 | 'show_in_rest' => true, |
@@ -371,40 +371,40 @@ discard block |
||
371 | 371 | 'has_archive' => true, |
372 | 372 | 'feeds' => true, |
373 | 373 | 'exclude_from_search' => false, |
374 | - 'rewrite' => array( 'slug' => 'stories', 'with_front' => true ), |
|
374 | + 'rewrite' => array('slug' => 'stories', 'with_front' => true), |
|
375 | 375 | 'publicly_queryable' => true, |
376 | 376 | 'capability_type' => 'post', |
377 | 377 | ); |
378 | - register_post_type( 'comic', $args ); |
|
378 | + register_post_type('comic', $args); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | // Hook into the 'init' action. |
382 | -add_action( 'init', 'comic_post_type', 0 ); // End of register_cpt_comic(). |
|
382 | +add_action('init', 'comic_post_type', 0); // End of register_cpt_comic(). |
|
383 | 383 | |
384 | 384 | /** |
385 | 385 | * Register Custom Taxonomy 'story' with REST API support |
386 | 386 | */ |
387 | 387 | function comic_story_taxonomy() { |
388 | 388 | $labels = array( |
389 | - 'name' => _x( 'Comic Story', 'Taxonomy General Name', 'strip' ), |
|
390 | - 'singular_name' => _x( 'Comic Story', 'Taxonomy Singular Name', 'strip' ), |
|
391 | - 'menu_name' => __( 'Comic Stories', 'strip' ), |
|
392 | - 'all_items' => __( 'All Comic Stories', 'strip' ), |
|
393 | - 'parent_item' => __( 'Parent Story', 'strip' ), |
|
394 | - 'parent_item_colon' => __( 'Parent Story:', 'strip' ), |
|
395 | - 'new_item_name' => __( 'New Comic Story', 'strip' ), |
|
396 | - 'add_new_item' => __( 'Add New Story', 'strip' ), |
|
397 | - 'edit_item' => __( 'Edit Story', 'strip' ), |
|
398 | - 'update_item' => __( 'Update Story', 'strip' ), |
|
399 | - 'view_item' => __( 'View Item', 'strip' ), |
|
400 | - 'separate_items_with_commas' => __( 'Separate stories with commas', 'strip' ), |
|
401 | - 'add_or_remove_items' => __( 'Add or Remove Stories', 'strip' ), |
|
402 | - 'choose_from_most_used' => __( 'Choose from the most used stories', 'strip' ), |
|
403 | - 'popular_items' => __( 'Popular comic stories', 'strip' ), |
|
404 | - 'search_items' => __( 'Search Stories', 'strip' ), |
|
405 | - 'not_found' => __( 'No comic Stories found', 'strip' ), |
|
406 | - 'items_list' => __( 'Comic Stories list', 'strip' ), |
|
407 | - 'items_list_navigation' => __( 'Comic Stories list navigation', 'strip' ), |
|
389 | + 'name' => _x('Comic Story', 'Taxonomy General Name', 'strip'), |
|
390 | + 'singular_name' => _x('Comic Story', 'Taxonomy Singular Name', 'strip'), |
|
391 | + 'menu_name' => __('Comic Stories', 'strip'), |
|
392 | + 'all_items' => __('All Comic Stories', 'strip'), |
|
393 | + 'parent_item' => __('Parent Story', 'strip'), |
|
394 | + 'parent_item_colon' => __('Parent Story:', 'strip'), |
|
395 | + 'new_item_name' => __('New Comic Story', 'strip'), |
|
396 | + 'add_new_item' => __('Add New Story', 'strip'), |
|
397 | + 'edit_item' => __('Edit Story', 'strip'), |
|
398 | + 'update_item' => __('Update Story', 'strip'), |
|
399 | + 'view_item' => __('View Item', 'strip'), |
|
400 | + 'separate_items_with_commas' => __('Separate stories with commas', 'strip'), |
|
401 | + 'add_or_remove_items' => __('Add or Remove Stories', 'strip'), |
|
402 | + 'choose_from_most_used' => __('Choose from the most used stories', 'strip'), |
|
403 | + 'popular_items' => __('Popular comic stories', 'strip'), |
|
404 | + 'search_items' => __('Search Stories', 'strip'), |
|
405 | + 'not_found' => __('No comic Stories found', 'strip'), |
|
406 | + 'items_list' => __('Comic Stories list', 'strip'), |
|
407 | + 'items_list_navigation' => __('Comic Stories list navigation', 'strip'), |
|
408 | 408 | ); |
409 | 409 | $args = array( |
410 | 410 | 'labels' => $labels, |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | 'show_in_nav_menus' => true, |
417 | 417 | 'show_tagcloud' => true, |
418 | 418 | 'query_var' => true, |
419 | - 'rewrite' => array( 'slug' => 'story' ), |
|
419 | + 'rewrite' => array('slug' => 'story'), |
|
420 | 420 | 'show_in_rest' => true, |
421 | 421 | 'rest_base' => 'genre', |
422 | 422 | 'rest_controller_class' => 'WP_REST_Terms_Controller', |
423 | 423 | ); |
424 | - register_taxonomy( 'story', array( 'comic' ), $args ); |
|
425 | - register_taxonomy_for_object_type( 'story', 'comic' ); |
|
424 | + register_taxonomy('story', array('comic'), $args); |
|
425 | + register_taxonomy_for_object_type('story', 'comic'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | // Hook into the 'init' action. |
429 | -add_action( 'init', 'comic_story_taxonomy', 0 ); |
|
429 | +add_action('init', 'comic_story_taxonomy', 0); |
|
430 | 430 | |
431 | 431 | /** |
432 | 432 | * Function strip rewrite rules. |
@@ -435,31 +435,31 @@ discard block |
||
435 | 435 | flush_rewrite_rules(); |
436 | 436 | } |
437 | 437 | /* Flush rewrite rules for custom post types. */ |
438 | -add_action( 'after_switch_theme', 'strip_rewrite_rules' ); |
|
438 | +add_action('after_switch_theme', 'strip_rewrite_rules'); |
|
439 | 439 | |
440 | 440 | // Add Print taxonomy, NOT hierarchical (like tags) |
441 | 441 | // Register Custom Taxonomy. |
442 | 442 | $labels = array( |
443 | - 'name' => _x( 'Prints', 'Taxonomy General Name', 'strip' ), |
|
444 | - 'singular_name' => _x( 'Print', 'Taxonomy Singular Name', 'strip' ), |
|
445 | - 'menu_name' => __( 'Print', 'strip' ), |
|
446 | - 'all_items' => __( 'All Prints', 'strip' ), |
|
447 | - 'parent_item' => __( 'Parent Print', 'strip' ), |
|
448 | - 'parent_item_colon' => __( 'Parent Print:', 'strip' ), |
|
449 | - 'new_item_name' => __( 'New Print Name', 'strip' ), |
|
450 | - 'add_new_item' => __( 'Add New Print', 'strip' ), |
|
451 | - 'edit_item' => __( 'Edit Print', 'strip' ), |
|
452 | - 'update_item' => __( 'Update Print', 'strip' ), |
|
453 | - 'view_item' => __( 'View Print', 'strip' ), |
|
454 | - 'separate_items_with_commas' => __( 'Separate prints with commas', 'strip' ), |
|
455 | - 'add_or_remove_items' => __( 'Add or remove prints', 'strip' ), |
|
456 | - 'choose_from_most_used' => __( 'Choose from the most used', 'strip' ), |
|
457 | - 'popular_items' => __( 'Popular Prints', 'strip' ), |
|
458 | - 'search_items' => __( 'Search Prints', 'strip' ), |
|
459 | - 'not_found' => __( 'Not Found', 'strip' ), |
|
460 | - 'no_terms' => __( 'No prints', 'strip' ), |
|
461 | - 'items_list' => __( 'Prints list', 'strip' ), |
|
462 | - 'items_list_navigation' => __( 'Prints list navigation', 'strip' ), |
|
443 | + 'name' => _x('Prints', 'Taxonomy General Name', 'strip'), |
|
444 | + 'singular_name' => _x('Print', 'Taxonomy Singular Name', 'strip'), |
|
445 | + 'menu_name' => __('Print', 'strip'), |
|
446 | + 'all_items' => __('All Prints', 'strip'), |
|
447 | + 'parent_item' => __('Parent Print', 'strip'), |
|
448 | + 'parent_item_colon' => __('Parent Print:', 'strip'), |
|
449 | + 'new_item_name' => __('New Print Name', 'strip'), |
|
450 | + 'add_new_item' => __('Add New Print', 'strip'), |
|
451 | + 'edit_item' => __('Edit Print', 'strip'), |
|
452 | + 'update_item' => __('Update Print', 'strip'), |
|
453 | + 'view_item' => __('View Print', 'strip'), |
|
454 | + 'separate_items_with_commas' => __('Separate prints with commas', 'strip'), |
|
455 | + 'add_or_remove_items' => __('Add or remove prints', 'strip'), |
|
456 | + 'choose_from_most_used' => __('Choose from the most used', 'strip'), |
|
457 | + 'popular_items' => __('Popular Prints', 'strip'), |
|
458 | + 'search_items' => __('Search Prints', 'strip'), |
|
459 | + 'not_found' => __('Not Found', 'strip'), |
|
460 | + 'no_terms' => __('No prints', 'strip'), |
|
461 | + 'items_list' => __('Prints list', 'strip'), |
|
462 | + 'items_list_navigation' => __('Prints list navigation', 'strip'), |
|
463 | 463 | ); |
464 | 464 | |
465 | 465 | $args = array( |
@@ -471,21 +471,21 @@ discard block |
||
471 | 471 | 'show_in_nav_menus' => true, |
472 | 472 | 'show_tagcloud' => true, |
473 | 473 | ); |
474 | - register_taxonomy( 'print', array( 'comic' ), $args ); |
|
474 | + register_taxonomy('print', array('comic'), $args); |
|
475 | 475 | |
476 | 476 | /* |
477 | 477 | * WooCommerce Hooks |
478 | 478 | * Layout |
479 | 479 | */ |
480 | - remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); |
|
481 | - remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); |
|
482 | - remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); |
|
480 | + remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0); |
|
481 | + remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); |
|
482 | + remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); |
|
483 | 483 | // remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); // removes woo pagination. |
484 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
485 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); |
|
484 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); |
|
485 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30); |
|
486 | 486 | |
487 | - add_action( 'woocommerce_before_main_content', 'strip_wrapper_start', 10 ); |
|
488 | - add_action( 'woocommerce_after_main_content', 'strip_wrapper_end', 10 ); |
|
487 | + add_action('woocommerce_before_main_content', 'strip_wrapper_start', 10); |
|
488 | + add_action('woocommerce_after_main_content', 'strip_wrapper_end', 10); |
|
489 | 489 | |
490 | 490 | /** |
491 | 491 | * WooCommerce wrapper |
@@ -501,13 +501,13 @@ discard block |
||
501 | 501 | echo '</section>'; |
502 | 502 | } |
503 | 503 | |
504 | - add_action( 'after_setup_theme', 'woocommerce_support' ); |
|
504 | + add_action('after_setup_theme', 'woocommerce_support'); |
|
505 | 505 | /** |
506 | 506 | * Add WooCommerce support |
507 | 507 | * https://docs.woothemes.com/document/third-party-custom-theme-compatibility/* |
508 | 508 | */ |
509 | 509 | function woocommerce_support() { |
510 | - add_theme_support( 'woocommerce' ); |
|
510 | + add_theme_support('woocommerce'); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -515,13 +515,13 @@ discard block |
||
515 | 515 | */ |
516 | 516 | function wp_enqueue_woocommerce_style() { |
517 | 517 | |
518 | - wp_register_style( 'strip-woocommerce', get_template_directory_uri() . '/assets/css/woocommerce-min.css' ); |
|
519 | - if ( class_exists( 'woocommerce' ) ) { |
|
520 | - wp_enqueue_style( 'strip-woocommerce' ); |
|
518 | + wp_register_style('strip-woocommerce', get_template_directory_uri() . '/assets/css/woocommerce-min.css'); |
|
519 | + if (class_exists('woocommerce')) { |
|
520 | + wp_enqueue_style('strip-woocommerce'); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | - add_action( 'wp_enqueue_scripts', 'wp_enqueue_woocommerce_style' ); |
|
524 | + add_action('wp_enqueue_scripts', 'wp_enqueue_woocommerce_style'); |
|
525 | 525 | |
526 | 526 | /** |
527 | 527 | * Optimize WooCommerce Scripts |
@@ -532,53 +532,53 @@ discard block |
||
532 | 532 | * @link https://gist.github.com/DevinWalker/7621777 |
533 | 533 | * @link http://dessky.com/blog/disable-woocommerce-scripts-and-styles/ |
534 | 534 | */ |
535 | - add_action( 'wp_enqueue_scripts', 'strip_manage_woocommerce_styles', 99 ); |
|
535 | + add_action('wp_enqueue_scripts', 'strip_manage_woocommerce_styles', 99); |
|
536 | 536 | |
537 | 537 | /** |
538 | 538 | * Remove some WooCommerce queries. |
539 | 539 | */ |
540 | 540 | function strip_manage_woocommerce_styles() { |
541 | 541 | // remove generator meta tag. |
542 | - remove_action( 'wp_head', array( 'woocommerce', 'generator' ) ); |
|
542 | + remove_action('wp_head', array('woocommerce', 'generator')); |
|
543 | 543 | // first check that woo exists to prevent fatal errors. |
544 | - if ( function_exists( 'strip_is_woocommerce_activated' ) ) { |
|
544 | + if (function_exists('strip_is_woocommerce_activated')) { |
|
545 | 545 | // dequeue scripts and styles, unless we're in the store. |
546 | - if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { |
|
547 | - wp_dequeue_style( 'woocommerce_frontend_styles' ); |
|
548 | - wp_dequeue_style( 'woocommerce-general' ); |
|
549 | - wp_dequeue_style( 'woocommerce-layout' ); |
|
550 | - wp_dequeue_style( 'woocommerce-smallscreen' ); |
|
551 | - wp_dequeue_style( 'woocommerce_fancybox_styles' ); |
|
552 | - wp_dequeue_style( 'woocommerce_chosen_styles' ); |
|
553 | - wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); |
|
554 | - wp_dequeue_style( 'select2' ); |
|
555 | - wp_dequeue_style( 'strip-woocommerce' ); // the theme's CSS overwrite. |
|
556 | - wp_dequeue_script( 'wc-add-payment-method' ); |
|
557 | - wp_dequeue_script( 'wc-lost-password' ); |
|
558 | - wp_dequeue_script( 'wc_price_slider' ); |
|
559 | - wp_dequeue_script( 'wc-single-product' ); |
|
560 | - wp_dequeue_script( 'wc-add-to-cart' ); |
|
561 | - wp_dequeue_script( 'wc-cart-fragments' ); |
|
562 | - wp_dequeue_script( 'wc-credit-card-form' ); |
|
563 | - wp_dequeue_script( 'wc-checkout' ); |
|
564 | - wp_dequeue_script( 'wc-add-to-cart-variation' ); |
|
565 | - wp_dequeue_script( 'wc-single-product' ); |
|
566 | - wp_dequeue_script( 'wc-cart' ); |
|
567 | - wp_dequeue_script( 'wc-chosen' ); |
|
568 | - wp_dequeue_script( 'woocommerce' ); |
|
569 | - wp_dequeue_script( 'jquery-cookie' ); |
|
570 | - wp_dequeue_script( 'prettyPhoto' ); |
|
571 | - wp_dequeue_script( 'prettyPhoto-init' ); |
|
572 | - wp_dequeue_script( 'jquery-blockui' ); |
|
573 | - wp_dequeue_script( 'jquery-placeholder' ); |
|
574 | - wp_dequeue_script( 'jquery-payment' ); |
|
575 | - wp_dequeue_script( 'fancybox' ); |
|
576 | - wp_dequeue_script( 'jqueryui' ); |
|
546 | + if ( ! is_woocommerce() && ! is_cart() && ! is_checkout()) { |
|
547 | + wp_dequeue_style('woocommerce_frontend_styles'); |
|
548 | + wp_dequeue_style('woocommerce-general'); |
|
549 | + wp_dequeue_style('woocommerce-layout'); |
|
550 | + wp_dequeue_style('woocommerce-smallscreen'); |
|
551 | + wp_dequeue_style('woocommerce_fancybox_styles'); |
|
552 | + wp_dequeue_style('woocommerce_chosen_styles'); |
|
553 | + wp_dequeue_style('woocommerce_prettyPhoto_css'); |
|
554 | + wp_dequeue_style('select2'); |
|
555 | + wp_dequeue_style('strip-woocommerce'); // the theme's CSS overwrite. |
|
556 | + wp_dequeue_script('wc-add-payment-method'); |
|
557 | + wp_dequeue_script('wc-lost-password'); |
|
558 | + wp_dequeue_script('wc_price_slider'); |
|
559 | + wp_dequeue_script('wc-single-product'); |
|
560 | + wp_dequeue_script('wc-add-to-cart'); |
|
561 | + wp_dequeue_script('wc-cart-fragments'); |
|
562 | + wp_dequeue_script('wc-credit-card-form'); |
|
563 | + wp_dequeue_script('wc-checkout'); |
|
564 | + wp_dequeue_script('wc-add-to-cart-variation'); |
|
565 | + wp_dequeue_script('wc-single-product'); |
|
566 | + wp_dequeue_script('wc-cart'); |
|
567 | + wp_dequeue_script('wc-chosen'); |
|
568 | + wp_dequeue_script('woocommerce'); |
|
569 | + wp_dequeue_script('jquery-cookie'); |
|
570 | + wp_dequeue_script('prettyPhoto'); |
|
571 | + wp_dequeue_script('prettyPhoto-init'); |
|
572 | + wp_dequeue_script('jquery-blockui'); |
|
573 | + wp_dequeue_script('jquery-placeholder'); |
|
574 | + wp_dequeue_script('jquery-payment'); |
|
575 | + wp_dequeue_script('fancybox'); |
|
576 | + wp_dequeue_script('jqueryui'); |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
581 | - add_action( 'pre_get_posts', 'strip_set_posts_per_page' ); |
|
581 | + add_action('pre_get_posts', 'strip_set_posts_per_page'); |
|
582 | 582 | /** |
583 | 583 | * Set posts, WooCommerce products & comics number per archive page |
584 | 584 | * Fixes 404 error on pagination due to CTP conflicting with WordPress posts_per_page default |
@@ -587,12 +587,12 @@ discard block |
||
587 | 587 | * @param WP_Query $query strip_set_posts_per_page. |
588 | 588 | * @return $query |
589 | 589 | */ |
590 | - function strip_set_posts_per_page( $query ) { |
|
591 | - if ( is_post_type_archive( 'product' ) ) { |
|
592 | - $query->set( 'posts_per_page', 4 ); |
|
590 | + function strip_set_posts_per_page($query) { |
|
591 | + if (is_post_type_archive('product')) { |
|
592 | + $query->set('posts_per_page', 4); |
|
593 | 593 | return $query; |
594 | - } elseif ( is_tax( 'story' ) ) { |
|
595 | - $query->set( 'posts_per_page', 6 ); |
|
594 | + } elseif (is_tax('story')) { |
|
595 | + $query->set('posts_per_page', 6); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
@@ -616,35 +616,35 @@ discard block |
||
616 | 616 | * @param string $post_id set_default_object_terms. |
617 | 617 | * @param string $post set_default_object_terms. |
618 | 618 | */ |
619 | - function set_default_object_terms( $post_id, $post ) { |
|
620 | - if ( 'publish' === $post->post_status && 'comic' === $post->post_type ) { |
|
619 | + function set_default_object_terms($post_id, $post) { |
|
620 | + if ('publish' === $post->post_status && 'comic' === $post->post_type) { |
|
621 | 621 | $defaults = array( |
622 | - 'story' => array( 'draft' ), |
|
622 | + 'story' => array('draft'), |
|
623 | 623 | ); |
624 | - $taxonomies = get_object_taxonomies( $post->post_type ); |
|
625 | - foreach ( (array) $taxonomies as $taxonomy ) { |
|
626 | - $terms = get_the_terms( $post_id, $taxonomy ); |
|
627 | - if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) { |
|
628 | - wp_set_object_terms( $post_id, $defaults[ $taxonomy ], $taxonomy ); |
|
624 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
625 | + foreach ((array) $taxonomies as $taxonomy) { |
|
626 | + $terms = get_the_terms($post_id, $taxonomy); |
|
627 | + if (empty($terms) && array_key_exists($taxonomy, $defaults)) { |
|
628 | + wp_set_object_terms($post_id, $defaults[$taxonomy], $taxonomy); |
|
629 | 629 | } |
630 | 630 | } |
631 | 631 | } |
632 | 632 | } |
633 | - add_action( 'save_post', 'set_default_object_terms', 0, 2 ); |
|
633 | + add_action('save_post', 'set_default_object_terms', 0, 2); |
|
634 | 634 | |
635 | 635 | /** |
636 | 636 | * Remove jquery migrate $scripts for enhanced performance. |
637 | 637 | * |
638 | 638 | * @param strings $scripts remove_jquery_migrate. |
639 | 639 | */ |
640 | - function remove_jquery_migrate( $scripts ) { |
|
641 | - if ( is_admin() ) { |
|
640 | + function remove_jquery_migrate($scripts) { |
|
641 | + if (is_admin()) { |
|
642 | 642 | return; |
643 | 643 | } |
644 | - $scripts->remove( 'jquery' ); |
|
645 | - $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' ); |
|
644 | + $scripts->remove('jquery'); |
|
645 | + $scripts->add('jquery', false, array('jquery-core'), '1.10.2'); |
|
646 | 646 | } |
647 | - add_action( 'wp_default_scripts', 'remove_jquery_migrate' ); |
|
647 | + add_action('wp_default_scripts', 'remove_jquery_migrate'); |
|
648 | 648 | |
649 | 649 | /** |
650 | 650 | * Remove login errors notices (security) |
@@ -652,4 +652,4 @@ discard block |
||
652 | 652 | function no_wordpress_errors() { |
653 | 653 | return 'Something is wrong!'; |
654 | 654 | } |
655 | - add_filter( 'login_errors', 'no_wordpress_errors' ); |
|
655 | + add_filter('login_errors', 'no_wordpress_errors'); |