@@ -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, 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. |
|
66 | + add_theme_support('post-thumbnails'); |
|
67 | + add_image_size('strip-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 | 71 | |
72 | 72 | /** |
73 | 73 | * Remove paragraph tags around images. |
@@ -76,35 +76,35 @@ discard block |
||
76 | 76 | * @link https://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/ |
77 | 77 | * @see http://codex.wordpress.org/Function_Reference/wpautop gets the same result but removes line blocks: remove_filter( 'the_content', 'wpautop' ); |
78 | 78 | */ |
79 | - function filter_ptags_on_images( $hinh ) { |
|
80 | - return preg_replace( '/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $hinh ); |
|
79 | + function filter_ptags_on_images($hinh) { |
|
80 | + return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $hinh); |
|
81 | 81 | } |
82 | - add_filter( 'the_content', 'filter_ptags_on_images' ); |
|
82 | + add_filter('the_content', 'filter_ptags_on_images'); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * This theme uses wp_nav_menu() in one location. |
86 | 86 | */ |
87 | 87 | register_nav_menus(array( |
88 | - 'primary' => __( 'Primary Menu', 'strip' ), |
|
88 | + 'primary' => __('Primary Menu', 'strip'), |
|
89 | 89 | )); |
90 | 90 | |
91 | 91 | /* |
92 | 92 | * Switch default core markup for search form, comment form, and comments |
93 | 93 | * to output valid HTML5. |
94 | 94 | */ |
95 | - add_theme_support( 'html5', array( |
|
95 | + add_theme_support('html5', array( |
|
96 | 96 | 'search-form', |
97 | 97 | 'comment-form', |
98 | 98 | 'comment-list', |
99 | 99 | 'gallery', |
100 | 100 | 'caption', |
101 | 101 | 'widgets', |
102 | - ) ); |
|
102 | + )); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Enable support for Post Formats |
106 | 106 | */ |
107 | - add_theme_support( 'post-formats', array( |
|
107 | + add_theme_support('post-formats', array( |
|
108 | 108 | 'image', |
109 | 109 | 'video', |
110 | 110 | 'quote', |
@@ -112,35 +112,35 @@ discard block |
||
112 | 112 | 'gallery', |
113 | 113 | 'audio', |
114 | 114 | 'chat', |
115 | - ) ); |
|
115 | + )); |
|
116 | 116 | |
117 | 117 | // Setup the WordPress core custom background feature. |
118 | 118 | add_theme_support('custom-background', apply_filters('strip_custom_background_args', array( |
119 | 119 | 'default-color' => 'ffffff', |
120 | 120 | 'default-image' => '', |
121 | - ) ) ); |
|
121 | + ))); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | 125 | * This theme styles the visual editor to resemble the theme style, |
126 | 126 | * specifically font, colors, icons, and column width. |
127 | 127 | */ |
128 | - add_editor_style( array( '/assets/css/editor-style.css', '/assets/fonts/fenix.css' ) ); |
|
128 | + add_editor_style(array('/assets/css/editor-style.css', '/assets/fonts/fenix.css')); |
|
129 | 129 | |
130 | 130 | // Indicate widget sidebars can use selective refresh in the Customizer. |
131 | 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' ); |
|
132 | + add_theme_support('customize-selective-refresh-widgets'); |
|
133 | 133 | endif; // strip_setup. |
134 | -add_action( 'after_setup_theme', 'strip_setup' ); |
|
134 | +add_action('after_setup_theme', 'strip_setup'); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Register widgetized area and update sidebar with default widgets |
138 | 138 | */ |
139 | 139 | function strip_widgets_init() { |
140 | 140 | register_sidebar(array( |
141 | - 'name' => __( 'Main Sidebar', 'strip' ), |
|
141 | + 'name' => __('Main Sidebar', 'strip'), |
|
142 | 142 | 'id' => 'sidebar', |
143 | - 'description' => __( 'The main body widget area', 'strip' ), |
|
143 | + 'description' => __('The main body widget area', 'strip'), |
|
144 | 144 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
145 | 145 | 'after_widget' => '</aside>', |
146 | 146 | 'before_title' => '<h2 class="widget-title">', |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | )); |
149 | 149 | |
150 | 150 | // First footer widget area, located in the footer. Empty by default. |
151 | - register_sidebar( array( |
|
152 | - 'name' => __( 'First Footer Widget', 'strip' ), |
|
151 | + register_sidebar(array( |
|
152 | + 'name' => __('First Footer Widget', 'strip'), |
|
153 | 153 | 'id' => 'first-footer-widget', |
154 | - 'description' => __( 'The first footer widget', 'strip' ), |
|
154 | + 'description' => __('The first footer widget', 'strip'), |
|
155 | 155 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
156 | 156 | 'after_widget' => '</aside>', |
157 | 157 | 'before_title' => '<h3 class="widget-title">', |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | |
161 | 161 | // Second Footer Widget Area, located in the footer. Empty by default. |
162 | 162 | register_sidebar(array( |
163 | - 'name' => __( 'Second Footer Widget', 'strip' ), |
|
163 | + 'name' => __('Second Footer Widget', 'strip'), |
|
164 | 164 | 'id' => 'second-footer-widget', |
165 | - 'description' => __( 'The second footer widget', 'strip' ), |
|
165 | + 'description' => __('The second footer widget', 'strip'), |
|
166 | 166 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
167 | 167 | 'after_widget' => '</aside>', |
168 | 168 | 'before_title' => '<h3 class="widget-title">', |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | |
172 | 172 | // Third Footer Widget Area, located in the footer. Empty by default. |
173 | 173 | register_sidebar(array( |
174 | - 'name' => __( 'Third Footer Widget', 'strip' ), |
|
174 | + 'name' => __('Third Footer Widget', 'strip'), |
|
175 | 175 | 'id' => 'third-footer-widget', |
176 | - 'description' => __( 'The third footer widget', 'strip' ), |
|
176 | + 'description' => __('The third footer widget', 'strip'), |
|
177 | 177 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
178 | 178 | 'after_widget' => '</aside>', |
179 | 179 | 'before_title' => '<h3 class="widget-title">', |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | |
183 | 183 | // Fourth Footer Widget Area, located in the footer. Empty by default. |
184 | 184 | register_sidebar(array( |
185 | - 'name' => __( 'Fourth Footer Widget', 'strip' ), |
|
185 | + 'name' => __('Fourth Footer Widget', 'strip'), |
|
186 | 186 | 'id' => 'fourth-footer-widget', |
187 | - 'description' => __( 'The fourth footer widget', 'strip' ), |
|
187 | + 'description' => __('The fourth footer widget', 'strip'), |
|
188 | 188 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
189 | 189 | 'after_widget' => '</aside>', |
190 | 190 | 'before_title' => '<h3 class="widget-title">', |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | )); |
193 | 193 | |
194 | 194 | } |
195 | -add_action( 'widgets_init', 'strip_widgets_init' ); |
|
195 | +add_action('widgets_init', 'strip_widgets_init'); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Handles JavaScript detection. |
@@ -204,47 +204,47 @@ discard block |
||
204 | 204 | function strip_javascript_detection() { |
205 | 205 | echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n"; |
206 | 206 | } |
207 | -add_action( 'wp_head', 'strip_javascript_detection', 0 ); |
|
207 | +add_action('wp_head', 'strip_javascript_detection', 0); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * Enqueue_styles for custom fonts. |
211 | 211 | */ |
212 | 212 | function strip_scripts() { |
213 | 213 | // add custom font here if any. |
214 | - wp_enqueue_style( 'fenix', get_template_directory_uri() . '/assets/fonts/fenix.css', array(), null ); |
|
214 | + wp_enqueue_style('fenix', get_template_directory_uri() . '/assets/fonts/fenix.css', array(), null); |
|
215 | 215 | |
216 | - wp_enqueue_style( 'inconsolata', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null ); |
|
216 | + wp_enqueue_style('inconsolata', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null); |
|
217 | 217 | |
218 | 218 | // Theme stylesheet. |
219 | - wp_enqueue_style( 'strip-style', get_stylesheet_uri() ); |
|
219 | + wp_enqueue_style('strip-style', get_stylesheet_uri()); |
|
220 | 220 | |
221 | 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' ); |
|
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 | 224 | |
225 | - if ( has_nav_menu( 'primary' ) ) { |
|
226 | - wp_enqueue_script( 'strip-navigation', get_template_directory_uri() . '/assets/js/min/navigation-min.js', array(), '1.0', true ); |
|
225 | + if (has_nav_menu('primary')) { |
|
226 | + wp_enqueue_script('strip-navigation', get_template_directory_uri() . '/assets/js/min/navigation-min.js', array(), '1.0', true); |
|
227 | 227 | } |
228 | 228 | |
229 | 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' ); |
|
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 | 232 | |
233 | - 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 | + 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); |
|
234 | 234 | |
235 | - if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
|
236 | - wp_enqueue_script( 'comment-reply' ); |
|
235 | + if (is_singular() && comments_open() && get_option('thread_comments')) { |
|
236 | + wp_enqueue_script('comment-reply'); |
|
237 | 237 | |
238 | 238 | // toggle comments js. |
239 | - wp_enqueue_script( 'strip-toggle-comments', get_template_directory_uri() . '/assets/js/min/toggle-comments-min.js', array( 'jquery' ), '1.2', true ); |
|
239 | + wp_enqueue_script('strip-toggle-comments', get_template_directory_uri() . '/assets/js/min/toggle-comments-min.js', array('jquery'), '1.2', true); |
|
240 | 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' ), '20160412', true ); |
|
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'), '20160412', true); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | -add_action( 'wp_enqueue_scripts', 'strip_scripts' ); |
|
247 | +add_action('wp_enqueue_scripts', 'strip_scripts'); |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Implement the Custom Header feature. |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | */ |
272 | 272 | require get_template_directory() . '/inc/jetpack.php'; |
273 | 273 | |
274 | -add_action( 'wp_enqueue_scripts', 'enqueue_royal_sliders' ); |
|
274 | +add_action('wp_enqueue_scripts', 'enqueue_royal_sliders'); |
|
275 | 275 | /** |
276 | 276 | * Register RoyalSLider |
277 | 277 | */ |
278 | 278 | function enqueue_royal_sliders() { |
279 | - if ( function_exists( 'register_new_royalslider_files' ) ) { |
|
279 | + if (function_exists('register_new_royalslider_files')) { |
|
280 | 280 | // you could try this: if ( is_single() && is_archive() ) { but you don't really need it. |
281 | - register_new_royalslider_files( 1 ); // 1 is RoyalSlider configuration number |
|
281 | + register_new_royalslider_files(1); // 1 is RoyalSlider configuration number |
|
282 | 282 | // add } if use is_single etc. |
283 | 283 | } |
284 | 284 | } |
@@ -291,24 +291,24 @@ discard block |
||
291 | 291 | * @link https://gist.github.com/SilentComics/0a7ea47942eb759dbb48eac2b7be1bbc/ |
292 | 292 | */ |
293 | 293 | function get_first_image() { |
294 | - $post = get_post(); |
|
294 | + $post = get_post(); |
|
295 | 295 | $first_img = ''; |
296 | - preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', do_shortcode( $post->post_content, 'gallery' ), $matches ); |
|
297 | - $first_img = isset( $matches[1][0] ) ? $matches[1][0] : null; |
|
296 | + preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', 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 |
@@ -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( |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | ); |
351 | 351 | |
352 | 352 | $args = array( |
353 | - 'label' => __( 'Comic', 'strip' ), |
|
354 | - 'description' => __( 'Publish Comics and Webcomics', 'strip' ), |
|
353 | + 'label' => __('Comic', 'strip'), |
|
354 | + 'description' => __('Publish Comics and Webcomics', 'strip'), |
|
355 | 355 | 'labels' => $labels, |
356 | 356 | 'supports' => $supports, |
357 | - 'taxonomies' => array( 'story', 'story_term', 'draft' ), |
|
357 | + 'taxonomies' => array('story', 'story_term', 'draft'), |
|
358 | 358 | 'hierarchical' => true, |
359 | 359 | 'public' => true, |
360 | 360 | 'show_ui' => true, |
@@ -367,40 +367,40 @@ discard block |
||
367 | 367 | 'has_archive' => true, |
368 | 368 | 'feeds' => true, |
369 | 369 | 'exclude_from_search' => false, |
370 | - 'rewrite' => array( 'slug' => 'stories', 'with_front' => true ), |
|
370 | + 'rewrite' => array('slug' => 'stories', 'with_front' => true), |
|
371 | 371 | 'publicly_queryable' => true, |
372 | 372 | 'capability_type' => 'post', |
373 | 373 | ); |
374 | - register_post_type( 'comic', $args ); |
|
374 | + register_post_type('comic', $args); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // Hook into the 'init' action. |
378 | -add_action( 'init', 'comic_post_type', 0 ); // End of register_cpt_comic(). |
|
378 | +add_action('init', 'comic_post_type', 0); // End of register_cpt_comic(). |
|
379 | 379 | |
380 | 380 | /** |
381 | 381 | * Register Custom Taxonomy 'story' |
382 | 382 | */ |
383 | 383 | function comic_story_taxonomy() { |
384 | 384 | $labels = array( |
385 | - 'name' => _x( 'Comic Story', 'Taxonomy General Name', 'strip' ), |
|
386 | - 'singular_name' => _x( 'Comic Story', 'Taxonomy Singular Name', 'strip' ), |
|
387 | - 'menu_name' => __( 'Comic Stories', 'strip' ), |
|
388 | - 'all_items' => __( 'All Comic Stories', 'strip' ), |
|
389 | - 'parent_item' => __( 'Parent Story', 'strip' ), |
|
390 | - 'parent_item_colon' => __( 'Parent Story:', 'strip' ), |
|
391 | - 'new_item_name' => __( 'New Comic Story', 'strip' ), |
|
392 | - 'add_new_item' => __( 'Add New Story', 'strip' ), |
|
393 | - 'edit_item' => __( 'Edit Story', 'strip' ), |
|
394 | - 'update_item' => __( 'Update Story', 'strip' ), |
|
395 | - 'view_item' => __( 'View Item', 'strip' ), |
|
396 | - 'separate_items_with_commas' => __( 'Separate stories with commas', 'strip' ), |
|
397 | - 'add_or_remove_items' => __( 'Add or Remove Stories', 'strip' ), |
|
398 | - 'choose_from_most_used' => __( 'Choose from the most used stories', 'strip' ), |
|
399 | - 'popular_items' => __( 'Popular comic stories', 'strip' ), |
|
400 | - 'search_items' => __( 'Search Stories', 'strip' ), |
|
401 | - 'not_found' => __( 'No comic Stories found', 'strip' ), |
|
402 | - 'items_list' => __( 'Comic Stories list', 'strip' ), |
|
403 | - 'items_list_navigation' => __( 'Comic Stories list navigation', 'strip' ), |
|
385 | + 'name' => _x('Comic Story', 'Taxonomy General Name', 'strip'), |
|
386 | + 'singular_name' => _x('Comic Story', 'Taxonomy Singular Name', 'strip'), |
|
387 | + 'menu_name' => __('Comic Stories', 'strip'), |
|
388 | + 'all_items' => __('All Comic Stories', 'strip'), |
|
389 | + 'parent_item' => __('Parent Story', 'strip'), |
|
390 | + 'parent_item_colon' => __('Parent Story:', 'strip'), |
|
391 | + 'new_item_name' => __('New Comic Story', 'strip'), |
|
392 | + 'add_new_item' => __('Add New Story', 'strip'), |
|
393 | + 'edit_item' => __('Edit Story', 'strip'), |
|
394 | + 'update_item' => __('Update Story', 'strip'), |
|
395 | + 'view_item' => __('View Item', 'strip'), |
|
396 | + 'separate_items_with_commas' => __('Separate stories with commas', 'strip'), |
|
397 | + 'add_or_remove_items' => __('Add or Remove Stories', 'strip'), |
|
398 | + 'choose_from_most_used' => __('Choose from the most used stories', 'strip'), |
|
399 | + 'popular_items' => __('Popular comic stories', 'strip'), |
|
400 | + 'search_items' => __('Search Stories', 'strip'), |
|
401 | + 'not_found' => __('No comic Stories found', 'strip'), |
|
402 | + 'items_list' => __('Comic Stories list', 'strip'), |
|
403 | + 'items_list_navigation' => __('Comic Stories list navigation', 'strip'), |
|
404 | 404 | ); |
405 | 405 | $args = array( |
406 | 406 | 'labels' => $labels, |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | 'show_in_nav_menus' => true, |
413 | 413 | 'show_tagcloud' => true, |
414 | 414 | 'query_var' => true, |
415 | - 'rewrite' => array( 'slug' => 'story' ), |
|
415 | + 'rewrite' => array('slug' => 'story'), |
|
416 | 416 | ); |
417 | - register_taxonomy( 'story', array( 'comic' ), $args ); |
|
418 | - register_taxonomy_for_object_type( 'story', 'comic' ); |
|
417 | + register_taxonomy('story', array('comic'), $args); |
|
418 | + register_taxonomy_for_object_type('story', 'comic'); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | // Hook into the 'init' action. |
422 | -add_action( 'init', 'comic_story_taxonomy', 0 ); |
|
422 | +add_action('init', 'comic_story_taxonomy', 0); |
|
423 | 423 | |
424 | 424 | /** |
425 | 425 | * Function strip rewrite rules. |
@@ -428,31 +428,31 @@ discard block |
||
428 | 428 | flush_rewrite_rules(); |
429 | 429 | } |
430 | 430 | /* Flush rewrite rules for custom post types. */ |
431 | -add_action( 'after_switch_theme', 'strip_rewrite_rules' ); |
|
431 | +add_action('after_switch_theme', 'strip_rewrite_rules'); |
|
432 | 432 | |
433 | 433 | // Add Print taxonomy, NOT hierarchical (like tags) |
434 | 434 | // Register Custom Taxonomy. |
435 | 435 | $labels = array( |
436 | - 'name' => _x( 'Prints', 'Taxonomy General Name', 'strip' ), |
|
437 | - 'singular_name' => _x( 'Print', 'Taxonomy Singular Name', 'strip' ), |
|
438 | - 'menu_name' => __( 'Print', 'strip' ), |
|
439 | - 'all_items' => __( 'All Prints', 'strip' ), |
|
440 | - 'parent_item' => __( 'Parent Print', 'strip' ), |
|
441 | - 'parent_item_colon' => __( 'Parent Print:', 'strip' ), |
|
442 | - 'new_item_name' => __( 'New Print Name', 'strip' ), |
|
443 | - 'add_new_item' => __( 'Add New Print', 'strip' ), |
|
444 | - 'edit_item' => __( 'Edit Print', 'strip' ), |
|
445 | - 'update_item' => __( 'Update Pring', 'strip' ), |
|
446 | - 'view_item' => __( 'View Print', 'strip' ), |
|
447 | - 'separate_items_with_commas' => __( 'Separate prints with commas', 'strip' ), |
|
448 | - 'add_or_remove_items' => __( 'Add or remove prints', 'strip' ), |
|
449 | - 'choose_from_most_used' => __( 'Choose from the most used', 'strip' ), |
|
450 | - 'popular_items' => __( 'Popular Prints', 'strip' ), |
|
451 | - 'search_items' => __( 'Search Prints', 'strip' ), |
|
452 | - 'not_found' => __( 'Not Found', 'strip' ), |
|
453 | - 'no_terms' => __( 'No prints', 'strip' ), |
|
454 | - 'items_list' => __( 'Prints list', 'strip' ), |
|
455 | - 'items_list_navigation' => __( 'Prints list navigation', 'strip' ), |
|
436 | + 'name' => _x('Prints', 'Taxonomy General Name', 'strip'), |
|
437 | + 'singular_name' => _x('Print', 'Taxonomy Singular Name', 'strip'), |
|
438 | + 'menu_name' => __('Print', 'strip'), |
|
439 | + 'all_items' => __('All Prints', 'strip'), |
|
440 | + 'parent_item' => __('Parent Print', 'strip'), |
|
441 | + 'parent_item_colon' => __('Parent Print:', 'strip'), |
|
442 | + 'new_item_name' => __('New Print Name', 'strip'), |
|
443 | + 'add_new_item' => __('Add New Print', 'strip'), |
|
444 | + 'edit_item' => __('Edit Print', 'strip'), |
|
445 | + 'update_item' => __('Update Pring', 'strip'), |
|
446 | + 'view_item' => __('View Print', 'strip'), |
|
447 | + 'separate_items_with_commas' => __('Separate prints with commas', 'strip'), |
|
448 | + 'add_or_remove_items' => __('Add or remove prints', 'strip'), |
|
449 | + 'choose_from_most_used' => __('Choose from the most used', 'strip'), |
|
450 | + 'popular_items' => __('Popular Prints', 'strip'), |
|
451 | + 'search_items' => __('Search Prints', 'strip'), |
|
452 | + 'not_found' => __('Not Found', 'strip'), |
|
453 | + 'no_terms' => __('No prints', 'strip'), |
|
454 | + 'items_list' => __('Prints list', 'strip'), |
|
455 | + 'items_list_navigation' => __('Prints list navigation', 'strip'), |
|
456 | 456 | ); |
457 | 457 | |
458 | 458 | $args = array( |
@@ -464,21 +464,21 @@ discard block |
||
464 | 464 | 'show_in_nav_menus' => true, |
465 | 465 | 'show_tagcloud' => true, |
466 | 466 | ); |
467 | - register_taxonomy( 'print', array( 'comic' ), $args ); |
|
467 | + register_taxonomy('print', array('comic'), $args); |
|
468 | 468 | |
469 | 469 | /* |
470 | 470 | * WooCommerce Hooks |
471 | 471 | * Layout |
472 | 472 | */ |
473 | - remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); |
|
474 | - remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); |
|
475 | - remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); |
|
473 | + remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0); |
|
474 | + remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); |
|
475 | + remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); |
|
476 | 476 | // remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); // removes woo pagination. |
477 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
478 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); |
|
477 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); |
|
478 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30); |
|
479 | 479 | |
480 | - add_action( 'woocommerce_before_main_content', 'strip_wrapper_start', 10 ); |
|
481 | - add_action( 'woocommerce_after_main_content', 'strip_wrapper_end', 10 ); |
|
480 | + add_action('woocommerce_before_main_content', 'strip_wrapper_start', 10); |
|
481 | + add_action('woocommerce_after_main_content', 'strip_wrapper_end', 10); |
|
482 | 482 | |
483 | 483 | /** |
484 | 484 | * WooCommerce wrapper |
@@ -494,13 +494,13 @@ discard block |
||
494 | 494 | echo '</section>'; |
495 | 495 | } |
496 | 496 | |
497 | - add_action( 'after_setup_theme', 'woocommerce_support' ); |
|
497 | + add_action('after_setup_theme', 'woocommerce_support'); |
|
498 | 498 | /** |
499 | 499 | * Add WooCommerce support |
500 | 500 | * https://docs.woothemes.com/document/third-party-custom-theme-compatibility/* |
501 | 501 | */ |
502 | 502 | function woocommerce_support() { |
503 | - add_theme_support( 'woocommerce' ); |
|
503 | + add_theme_support('woocommerce'); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | */ |
509 | 509 | function wp_enqueue_woocommerce_style() { |
510 | 510 | |
511 | - wp_register_style( 'strip-woocommerce', get_template_directory_uri() . '/assets/css/woocommerce-min.css' ); |
|
512 | - if ( class_exists( 'woocommerce' ) ) { |
|
513 | - wp_enqueue_style( 'strip-woocommerce' ); |
|
511 | + wp_register_style('strip-woocommerce', get_template_directory_uri() . '/assets/css/woocommerce-min.css'); |
|
512 | + if (class_exists('woocommerce')) { |
|
513 | + wp_enqueue_style('strip-woocommerce'); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
517 | - add_action( 'wp_enqueue_scripts', 'wp_enqueue_woocommerce_style' ); |
|
517 | + add_action('wp_enqueue_scripts', 'wp_enqueue_woocommerce_style'); |
|
518 | 518 | |
519 | 519 | /** |
520 | 520 | * Optimize WooCommerce Scripts |
@@ -525,53 +525,53 @@ discard block |
||
525 | 525 | * @link https://gist.github.com/DevinWalker/7621777 |
526 | 526 | * @link http://dessky.com/blog/disable-woocommerce-scripts-and-styles/ |
527 | 527 | */ |
528 | - add_action( 'wp_enqueue_scripts', 'strip_manage_woocommerce_styles', 99 ); |
|
528 | + add_action('wp_enqueue_scripts', 'strip_manage_woocommerce_styles', 99); |
|
529 | 529 | |
530 | 530 | /** |
531 | 531 | * Remove some WooCommerce queries. |
532 | 532 | */ |
533 | 533 | function strip_manage_woocommerce_styles() { |
534 | 534 | // remove generator meta tag. |
535 | - remove_action( 'wp_head', array( 'woocommerce', 'generator' ) ); |
|
535 | + remove_action('wp_head', array('woocommerce', 'generator')); |
|
536 | 536 | // first check that woo exists to prevent fatal errors. |
537 | - if ( function_exists( 'strip_is_woocommerce_activated' ) ) { |
|
537 | + if (function_exists('strip_is_woocommerce_activated')) { |
|
538 | 538 | // dequeue scripts and styles, unless we're in the store. |
539 | - if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { |
|
540 | - wp_dequeue_style( 'woocommerce_frontend_styles' ); |
|
541 | - wp_dequeue_style( 'woocommerce-general' ); |
|
542 | - wp_dequeue_style( 'woocommerce-layout' ); |
|
543 | - wp_dequeue_style( 'woocommerce-smallscreen' ); |
|
544 | - wp_dequeue_style( 'woocommerce_fancybox_styles' ); |
|
545 | - wp_dequeue_style( 'woocommerce_chosen_styles' ); |
|
546 | - wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); |
|
547 | - wp_dequeue_style( 'select2' ); |
|
548 | - wp_dequeue_style( 'strip-woocommerce' ); // the theme's CSS overwrite. |
|
549 | - wp_dequeue_script( 'wc-add-payment-method' ); |
|
550 | - wp_dequeue_script( 'wc-lost-password' ); |
|
551 | - wp_dequeue_script( 'wc_price_slider' ); |
|
552 | - wp_dequeue_script( 'wc-single-product' ); |
|
553 | - wp_dequeue_script( 'wc-add-to-cart' ); |
|
554 | - wp_dequeue_script( 'wc-cart-fragments' ); |
|
555 | - wp_dequeue_script( 'wc-credit-card-form' ); |
|
556 | - wp_dequeue_script( 'wc-checkout' ); |
|
557 | - wp_dequeue_script( 'wc-add-to-cart-variation' ); |
|
558 | - wp_dequeue_script( 'wc-single-product' ); |
|
559 | - wp_dequeue_script( 'wc-cart' ); |
|
560 | - wp_dequeue_script( 'wc-chosen' ); |
|
561 | - wp_dequeue_script( 'woocommerce' ); |
|
562 | - wp_dequeue_script( 'jquery-cookie' ); |
|
563 | - wp_dequeue_script( 'prettyPhoto' ); |
|
564 | - wp_dequeue_script( 'prettyPhoto-init' ); |
|
565 | - wp_dequeue_script( 'jquery-blockui' ); |
|
566 | - wp_dequeue_script( 'jquery-placeholder' ); |
|
567 | - wp_dequeue_script( 'jquery-payment' ); |
|
568 | - wp_dequeue_script( 'fancybox' ); |
|
569 | - wp_dequeue_script( 'jqueryui' ); |
|
539 | + if ( ! is_woocommerce() && ! is_cart() && ! is_checkout()) { |
|
540 | + wp_dequeue_style('woocommerce_frontend_styles'); |
|
541 | + wp_dequeue_style('woocommerce-general'); |
|
542 | + wp_dequeue_style('woocommerce-layout'); |
|
543 | + wp_dequeue_style('woocommerce-smallscreen'); |
|
544 | + wp_dequeue_style('woocommerce_fancybox_styles'); |
|
545 | + wp_dequeue_style('woocommerce_chosen_styles'); |
|
546 | + wp_dequeue_style('woocommerce_prettyPhoto_css'); |
|
547 | + wp_dequeue_style('select2'); |
|
548 | + wp_dequeue_style('strip-woocommerce'); // the theme's CSS overwrite. |
|
549 | + wp_dequeue_script('wc-add-payment-method'); |
|
550 | + wp_dequeue_script('wc-lost-password'); |
|
551 | + wp_dequeue_script('wc_price_slider'); |
|
552 | + wp_dequeue_script('wc-single-product'); |
|
553 | + wp_dequeue_script('wc-add-to-cart'); |
|
554 | + wp_dequeue_script('wc-cart-fragments'); |
|
555 | + wp_dequeue_script('wc-credit-card-form'); |
|
556 | + wp_dequeue_script('wc-checkout'); |
|
557 | + wp_dequeue_script('wc-add-to-cart-variation'); |
|
558 | + wp_dequeue_script('wc-single-product'); |
|
559 | + wp_dequeue_script('wc-cart'); |
|
560 | + wp_dequeue_script('wc-chosen'); |
|
561 | + wp_dequeue_script('woocommerce'); |
|
562 | + wp_dequeue_script('jquery-cookie'); |
|
563 | + wp_dequeue_script('prettyPhoto'); |
|
564 | + wp_dequeue_script('prettyPhoto-init'); |
|
565 | + wp_dequeue_script('jquery-blockui'); |
|
566 | + wp_dequeue_script('jquery-placeholder'); |
|
567 | + wp_dequeue_script('jquery-payment'); |
|
568 | + wp_dequeue_script('fancybox'); |
|
569 | + wp_dequeue_script('jqueryui'); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
574 | - add_action( 'pre_get_posts', 'strip_set_posts_per_page' ); |
|
574 | + add_action('pre_get_posts', 'strip_set_posts_per_page'); |
|
575 | 575 | /** |
576 | 576 | * Set posts, WooCommerce products & comics number per archive page |
577 | 577 | * Fixes 404 error on pagination due to CTP conflicting with WordPress posts_per_page default |
@@ -580,12 +580,12 @@ discard block |
||
580 | 580 | * @param WP_Query $query strip_set_posts_per_page. |
581 | 581 | * @return $query |
582 | 582 | */ |
583 | - function strip_set_posts_per_page( $query ) { |
|
584 | - if ( is_post_type_archive( 'product' ) ) { |
|
585 | - $query->set( 'posts_per_page', 4 ); |
|
583 | + function strip_set_posts_per_page($query) { |
|
584 | + if (is_post_type_archive('product')) { |
|
585 | + $query->set('posts_per_page', 4); |
|
586 | 586 | return $query; |
587 | - } elseif ( is_tax( 'story' ) ) { |
|
588 | - $query->set( 'posts_per_page', 6 ); |
|
587 | + } elseif (is_tax('story')) { |
|
588 | + $query->set('posts_per_page', 6); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
@@ -594,13 +594,13 @@ discard block |
||
594 | 594 | * |
595 | 595 | * @param string $query strip_add_comics_to_blog. |
596 | 596 | */ |
597 | - function strip_add_comics_to_blog( $query ) { |
|
598 | - if ( is_home() && $query->is_main_query() ) { |
|
599 | - $query->set( 'post_type', array( 'post', 'comic' ) ); |
|
597 | + function strip_add_comics_to_blog($query) { |
|
598 | + if (is_home() && $query->is_main_query()) { |
|
599 | + $query->set('post_type', array('post', 'comic')); |
|
600 | 600 | return $query; |
601 | 601 | } |
602 | 602 | } |
603 | - add_action( 'pre_get_posts', 'strip_add_comics_to_blog' ); |
|
603 | + add_action('pre_get_posts', 'strip_add_comics_to_blog'); |
|
604 | 604 | |
605 | 605 | /** |
606 | 606 | * Set an automatic default custom taxonomy for comic posts. |
@@ -610,35 +610,35 @@ discard block |
||
610 | 610 | * @param string $post_id set_default_object_terms. |
611 | 611 | * @param string $post set_default_object_terms. |
612 | 612 | */ |
613 | - function set_default_object_terms( $post_id, $post ) { |
|
614 | - if ( 'publish' === $post->post_status && 'comic' === $post->post_type ) { |
|
613 | + function set_default_object_terms($post_id, $post) { |
|
614 | + if ('publish' === $post->post_status && 'comic' === $post->post_type) { |
|
615 | 615 | $defaults = array( |
616 | - 'story' => array( 'draft' ), |
|
616 | + 'story' => array('draft'), |
|
617 | 617 | ); |
618 | - $taxonomies = get_object_taxonomies( $post->post_type ); |
|
619 | - foreach ( (array) $taxonomies as $taxonomy ) { |
|
620 | - $terms = get_the_terms( $post_id, $taxonomy ); |
|
621 | - if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) { |
|
622 | - wp_set_object_terms( $post_id, $defaults[ $taxonomy ], $taxonomy ); |
|
618 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
619 | + foreach ((array) $taxonomies as $taxonomy) { |
|
620 | + $terms = get_the_terms($post_id, $taxonomy); |
|
621 | + if (empty($terms) && array_key_exists($taxonomy, $defaults)) { |
|
622 | + wp_set_object_terms($post_id, $defaults[$taxonomy], $taxonomy); |
|
623 | 623 | } |
624 | 624 | } |
625 | 625 | } |
626 | 626 | } |
627 | - add_action( 'save_post', 'set_default_object_terms', 0, 2 ); |
|
627 | + add_action('save_post', 'set_default_object_terms', 0, 2); |
|
628 | 628 | |
629 | 629 | /** |
630 | 630 | * Remove jquery migrate $scripts for enhanced performance. |
631 | 631 | * |
632 | 632 | * @param strings $scripts remove_jquery_migrate. |
633 | 633 | */ |
634 | - function remove_jquery_migrate( $scripts ) { |
|
635 | - if ( is_admin() ) { |
|
634 | + function remove_jquery_migrate($scripts) { |
|
635 | + if (is_admin()) { |
|
636 | 636 | return; |
637 | 637 | } |
638 | - $scripts->remove( 'jquery' ); |
|
639 | - $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' ); |
|
638 | + $scripts->remove('jquery'); |
|
639 | + $scripts->add('jquery', false, array('jquery-core'), '1.10.2'); |
|
640 | 640 | } |
641 | - add_action( 'wp_default_scripts', 'remove_jquery_migrate' ); |
|
641 | + add_action('wp_default_scripts', 'remove_jquery_migrate'); |
|
642 | 642 | |
643 | 643 | /** |
644 | 644 | * Remove login errors notices (security) |
@@ -646,4 +646,4 @@ discard block |
||
646 | 646 | function no_wordpress_errors() { |
647 | 647 | return 'Something is wrong!'; |
648 | 648 | } |
649 | - add_filter( 'login_errors', 'no_wordpress_errors' ); |
|
649 | + add_filter('login_errors', 'no_wordpress_errors'); |