@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | |
16 | 16 | get_header( spurs_template_base() ); |
17 | 17 | |
18 | -if (!is_front_page() && function_exists('yoast_breadcrumb')) { |
|
19 | - yoast_breadcrumb('<div id="breadcrumbs">', '</div>'); |
|
18 | +if ( ! is_front_page() && function_exists( 'yoast_breadcrumb' ) ) { |
|
19 | + yoast_breadcrumb( '<div id="breadcrumbs">', '</div>' ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | ?> |
23 | 23 | |
24 | 24 | <div id="primary" class="<?php spurs_content_classes(); ?>"> |
25 | 25 | |
26 | - <?php if ( ( is_page_template( 'page-templates/sidebar-left.php' ) || is_page_template( 'page-templates/sidebar-right.php' ) || is_page_template( 'page-templates/both-sidebars.php' ) ) && ( is_active_sidebar( 'sidebar-left' ) || is_active_sidebar( 'sidebar-right' ) ) ) { |
|
26 | + <?php if ( ( is_page_template( 'page-templates/sidebar-left.php' ) || is_page_template( 'page-templates/sidebar-right.php' ) || is_page_template( 'page-templates/both-sidebars.php' ) ) && ( is_active_sidebar( 'sidebar-left' ) || is_active_sidebar( 'sidebar-right' ) ) ) { |
|
27 | 27 | echo '<div class="container"><div class=row>'; |
28 | 28 | } ?> |
29 | 29 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | <?php |
37 | 37 | |
38 | - if( 'pagination' === get_theme_mod( 'spurs_pagination' ) ){ |
|
38 | + if ( 'pagination' === get_theme_mod( 'spurs_pagination' ) ) { |
|
39 | 39 | spurs_pagination(); |
40 | 40 | } else { |
41 | 41 | spurs_load_more(); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | <?php spurs_right_sidebar(); ?> |
47 | 47 | |
48 | - <?php if ( ( is_page_template( 'page-templates/sidebar-left.php' ) || is_page_template( 'page-templates/sidebar-right.php' ) ) && ( is_active_sidebar( 'sidebar-left' ) || is_active_sidebar( 'sidebar-right' ) ) ) { |
|
48 | + <?php if ( ( is_page_template( 'page-templates/sidebar-left.php' ) || is_page_template( 'page-templates/sidebar-right.php' ) ) && ( is_active_sidebar( 'sidebar-left' ) || is_active_sidebar( 'sidebar-right' ) ) ) { |
|
49 | 49 | echo '</div></div>'; |
50 | 50 | } ?> |
51 | 51 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | <?php |
37 | 37 | |
38 | - if( 'pagination' === get_theme_mod( 'spurs_pagination' ) ){ |
|
38 | + if( 'pagination' === get_theme_mod( 'spurs_pagination' ) ) { |
|
39 | 39 | spurs_pagination(); |
40 | 40 | } else { |
41 | 41 | spurs_load_more(); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | add_action( 'wp_enqueue_scripts', 'spurs_scripts' ); |
36 | 36 | |
37 | -add_action('admin_head', 'spurs_admin_inline_styles'); |
|
37 | +add_action( 'admin_head', 'spurs_admin_inline_styles' ); |
|
38 | 38 | function spurs_admin_inline_styles() { |
39 | 39 | echo '<style> |
40 | 40 | .wp-block{max-width: 1070px} |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! class_exists('Spurs_CPT_Creator') ) { |
|
4 | - class Spurs_CPT_Creator{ |
|
3 | +if ( ! class_exists( 'Spurs_CPT_Creator' ) ) { |
|
4 | + class Spurs_CPT_Creator { |
|
5 | 5 | |
6 | 6 | public function register_cpt( $post_type, $names, $icon ) { |
7 | 7 | |
8 | - $args = [ |
|
8 | + $args = [ |
|
9 | 9 | 'labels' => [ |
10 | 10 | 'name' => $names['uc_plural'], |
11 | 11 | 'all_items' => $names['uc_plural'], |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | 'public' => true, |
25 | 25 | 'query_var' => true, |
26 | 26 | 'rewrite' => array( 'slug' => $names['single'], 'with_front' => false ), |
27 | - 'menu_icon' => 'dashicons-'.$icon, |
|
27 | + 'menu_icon' => 'dashicons-' . $icon, |
|
28 | 28 | 'has_archive' => true, |
29 | 29 | 'can_export' => true, |
30 | - 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt' ], |
|
30 | + 'supports' => ['title', 'editor', 'thumbnail', 'excerpt'], |
|
31 | 31 | ]; |
32 | 32 | |
33 | 33 | register_post_type( $post_type, $args ); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! class_exists('Spurs_CPT_Creator') ) { |
4 | - class Spurs_CPT_Creator{ |
|
4 | + class Spurs_CPT_Creator { |
|
5 | 5 | |
6 | 6 | public function register_cpt( $post_type, $names, $icon ) { |
7 | 7 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | global $wp_query; // you can remove this line if everything works for you |
15 | 15 | |
16 | 16 | // don't display the button if there are not enough posts |
17 | - if ( $wp_query->max_num_pages > 1 ) |
|
17 | + if ( $wp_query->max_num_pages > 1 ) |
|
18 | 18 | echo '<div class="spurs_loadmore btn btn-primary btn-lg mx-auto w-25">More posts</div>'; // you can use <a> as well |
19 | 19 | } |
20 | 20 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | global $wp_query; |
25 | 25 | |
26 | 26 | // In most cases it is already included on the page and this line can be removed |
27 | - wp_enqueue_script('jquery'); |
|
27 | + wp_enqueue_script( 'jquery' ); |
|
28 | 28 | |
29 | 29 | // register our main script but do not enqueue it yet |
30 | 30 | //wp_register_script( 'my_loadmore', get_stylesheet_directory_uri() . '/js/myloadmore.js', array('jquery') ); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | wp_localize_script( 'spurs-scripts', 'spurs_loadmore_params', array( |
36 | 36 | 'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX |
37 | 37 | 'posts' => json_encode( $wp_query->query_vars ), // everything about your loop is here |
38 | - 'current_page' => get_query_var( 'paged' ) ? get_query_var('paged') : 1, |
|
38 | + 'current_page' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1, |
|
39 | 39 | 'max_page' => $wp_query->max_num_pages |
40 | 40 | ) ); |
41 | 41 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | add_action( 'wp_enqueue_scripts', 'jd_my_load_more_scripts' ); |
45 | 45 | |
46 | -function spurs_loadmore_ajax_handler(){ |
|
46 | +function spurs_loadmore_ajax_handler() { |
|
47 | 47 | |
48 | 48 | // prepare our arguments for the query |
49 | 49 | $args = json_decode( stripslashes( $_POST['query'] ), true ); |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | // it is always better to use WP_Query but not here |
55 | 55 | query_posts( $args ); |
56 | 56 | |
57 | - if( have_posts() ) : |
|
57 | + if ( have_posts() ) : |
|
58 | 58 | |
59 | 59 | // run the loop |
60 | - while( have_posts() ): the_post(); |
|
60 | + while ( have_posts() ): the_post(); |
|
61 | 61 | |
62 | 62 | // look into your theme code how the posts are inserted, but you can use your own HTML of course |
63 | 63 | // do you remember? - my example is adapted for Twenty Seventeen theme |
64 | - if( true == $search_page ){ |
|
64 | + if ( true == $search_page ) { |
|
65 | 65 | get_template_part( 'templates/loop/content', 'search' ); |
66 | 66 | } else { |
67 | 67 | get_template_part( 'templates/loop/content', get_post_format() ); |
@@ -75,5 +75,5 @@ discard block |
||
75 | 75 | endif; |
76 | 76 | die; // here we exit the script and even no wp_reset_query() required! |
77 | 77 | } |
78 | -add_action('wp_ajax_loadmore', 'spurs_loadmore_ajax_handler'); // wp_ajax_{action} |
|
79 | -add_action('wp_ajax_nopriv_loadmore', 'spurs_loadmore_ajax_handler'); // wp_ajax_nopriv_{action} |
|
80 | 78 | \ No newline at end of file |
79 | +add_action( 'wp_ajax_loadmore', 'spurs_loadmore_ajax_handler' ); // wp_ajax_{action} |
|
80 | +add_action( 'wp_ajax_nopriv_loadmore', 'spurs_loadmore_ajax_handler' ); // wp_ajax_nopriv_{action} |
|
81 | 81 | \ No newline at end of file |
@@ -14,8 +14,10 @@ discard block |
||
14 | 14 | global $wp_query; // you can remove this line if everything works for you |
15 | 15 | |
16 | 16 | // don't display the button if there are not enough posts |
17 | - if ( $wp_query->max_num_pages > 1 ) |
|
18 | - echo '<div class="spurs_loadmore btn btn-primary btn-lg mx-auto w-25">More posts</div>'; // you can use <a> as well |
|
17 | + if ( $wp_query->max_num_pages > 1 ) { |
|
18 | + echo '<div class="spurs_loadmore btn btn-primary btn-lg mx-auto w-25">More posts</div>'; |
|
19 | + } |
|
20 | + // you can use <a> as well |
|
19 | 21 | } |
20 | 22 | } |
21 | 23 | |
@@ -43,7 +45,7 @@ discard block |
||
43 | 45 | } |
44 | 46 | add_action( 'wp_enqueue_scripts', 'jd_my_load_more_scripts' ); |
45 | 47 | |
46 | -function spurs_loadmore_ajax_handler(){ |
|
48 | +function spurs_loadmore_ajax_handler() { |
|
47 | 49 | |
48 | 50 | // prepare our arguments for the query |
49 | 51 | $args = json_decode( stripslashes( $_POST['query'] ), true ); |
@@ -61,7 +63,7 @@ discard block |
||
61 | 63 | |
62 | 64 | // look into your theme code how the posts are inserted, but you can use your own HTML of course |
63 | 65 | // do you remember? - my example is adapted for Twenty Seventeen theme |
64 | - if( true == $search_page ){ |
|
66 | + if( true == $search_page ) { |
|
65 | 67 | get_template_part( 'templates/loop/content', 'search' ); |
66 | 68 | } else { |
67 | 69 | get_template_part( 'templates/loop/content', get_post_format() ); |