1 | <?php |
||||
2 | /** |
||||
3 | * LSX_TO_Vehicles_Frontend |
||||
4 | * |
||||
5 | * @package LSX_TO_Vehicles_Frontend |
||||
6 | * @author LightSpeed |
||||
7 | * @license GPL-3.0+ |
||||
8 | * @link |
||||
9 | * @copyright 2016 LightSpeedDevelopment |
||||
10 | */ |
||||
11 | |||||
12 | /** |
||||
13 | * Main plugin class. |
||||
14 | * |
||||
15 | * @package LSX_TO_Vehicles_Frontend |
||||
16 | * @author LightSpeed |
||||
17 | */ |
||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||
18 | |||||
19 | class LSX_TO_Vehicles_Frontend extends LSX_TO_Vehicles { |
||||
20 | |||||
21 | /** |
||||
22 | * Holds the $page_links array while its being built on the single team page. |
||||
23 | * |
||||
24 | * @var array |
||||
25 | */ |
||||
26 | public $page_links = false; |
||||
27 | |||||
28 | /** |
||||
29 | * Holds the array of options. |
||||
30 | * |
||||
31 | * @var array |
||||
32 | */ |
||||
33 | public $options = false; |
||||
34 | |||||
35 | /** |
||||
36 | * Constructor |
||||
37 | */ |
||||
38 | public function __construct() { |
||||
0 ignored issues
–
show
|
|||||
39 | $this->set_vars(); |
||||
40 | |||||
41 | add_action( 'wp_head', array( $this, 'wp_head' ), 20, 1 ); |
||||
42 | |||||
43 | //add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||
44 | //add_action( 'init', array( $this, 'init' ) ); |
||||
0 ignored issues
–
show
|
|||||
45 | |||||
46 | if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
||||
0 ignored issues
–
show
|
|||||
47 | require_once( LSX_TO_VEHICLES_PATH . 'classes/class-lsx-to-template-redirects.php' ); |
||||
0 ignored issues
–
show
|
|||||
48 | } |
||||
0 ignored issues
–
show
|
|||||
49 | $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_VEHICLES_PATH, array_keys( $this->post_types ) ); |
||||
0 ignored issues
–
show
|
|||||
50 | add_action( 'lsx_vehicle_content', array( $this->redirects, 'content_part' ), 10, 2 ); |
||||
51 | |||||
52 | add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
||||
53 | |||||
54 | //add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
61% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||
55 | //add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
||||
0 ignored issues
–
show
|
|||||
56 | add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
||||
57 | |||||
58 | add_action( 'lsx_banner_allowed_post_types', array( $this, 'theme_allowed_post_type_banners' ) ); |
||||
59 | } |
||||
0 ignored issues
–
show
|
|||||
60 | |||||
61 | function wp_head() { |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
It is recommend to declare an explicit visibility for
wp_head .
Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed. If you are not sure which visibility to choose, it is a good idea to start with
the most restrictive visibility, and then raise visibility as needed, i.e.
start with ![]() |
|||||
62 | if ( is_singular( 'vehicle' ) ) { |
||||
0 ignored issues
–
show
|
|||||
63 | remove_action( 'lsx_entry_bottom', 'lsx_to_single_entry_bottom' ); |
||||
64 | } |
||||
65 | } |
||||
0 ignored issues
–
show
|
|||||
66 | |||||
67 | /** |
||||
68 | * Adds the template tags to the bottom of the single review |
||||
69 | */ |
||||
70 | public function single_content_bottom() { |
||||
71 | if ( is_singular( 'vehicle' ) ) { |
||||
0 ignored issues
–
show
|
|||||
72 | // lsx_to_review_accommodation(); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||
73 | |||||
74 | // lsx_to_review_tour(); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||
75 | |||||
76 | // lsx_to_review_destination(); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||
77 | |||||
78 | lsx_to_gallery( '<section id="gallery" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-gallery">' . esc_html__( 'Gallery', 'to-reviews' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||||
79 | |||||
80 | if ( function_exists( 'lsx_to_videos' ) ) { |
||||
0 ignored issues
–
show
|
|||||
81 | lsx_to_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-reviews' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||||
82 | } elseif ( class_exists( 'Envira_Videos' ) ) { |
||||
0 ignored issues
–
show
|
|||||
83 | lsx_to_envira_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-reviews' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||||
84 | } //lsx_to_review_posts(); |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||
85 | } |
||||
86 | } |
||||
0 ignored issues
–
show
|
|||||
87 | |||||
88 | /** |
||||
0 ignored issues
–
show
|
|||||
89 | * Adds our navigation links to the team single post |
||||
90 | * |
||||
91 | * @param $page_links array |
||||
0 ignored issues
–
show
|
|||||
92 | * @return $page_links array |
||||
0 ignored issues
–
show
|
|||||
93 | */ |
||||
94 | public function page_links( $page_links ) { |
||||
95 | if ( is_singular( 'vehicle' ) ) { |
||||
0 ignored issues
–
show
|
|||||
96 | $this->page_links = $page_links; |
||||
97 | $this->get_gallery_link(); |
||||
98 | $this->get_videos_link(); |
||||
99 | |||||
100 | $page_links = $this->page_links; |
||||
101 | } |
||||
102 | |||||
103 | return $page_links; |
||||
104 | } |
||||
0 ignored issues
–
show
|
|||||
105 | |||||
106 | /** |
||||
107 | * Tests for the Gallery and returns a link for the section |
||||
108 | */ |
||||
109 | public function get_gallery_link() { |
||||
110 | $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||
111 | $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
||||
112 | |||||
113 | if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
||||
0 ignored issues
–
show
|
|||||
114 | if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
||||
0 ignored issues
–
show
|
|||||
115 | // Envira Gallery. |
||||
116 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-vehicles' ); |
||||
117 | return; |
||||
118 | } else { |
||||
119 | if ( function_exists( 'envira_dynamic' ) ) { |
||||
0 ignored issues
–
show
|
|||||
120 | // Envira Gallery - Dynamic. |
||||
121 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-vehicles' ); |
||||
122 | return; |
||||
123 | } else { |
||||
124 | // WordPress Gallery. |
||||
125 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-vehicles' ); |
||||
126 | return; |
||||
127 | } |
||||
128 | } |
||||
129 | } |
||||
130 | } |
||||
0 ignored issues
–
show
|
|||||
131 | |||||
132 | /** |
||||
133 | * Tests for the Videos and returns a link for the section |
||||
134 | */ |
||||
135 | public function get_videos_link() { |
||||
136 | $videos_id = false; |
||||
137 | |||||
138 | if ( class_exists( 'Envira_Videos' ) ) { |
||||
0 ignored issues
–
show
|
|||||
139 | $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
140 | } |
||||
141 | |||||
142 | if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
||||
0 ignored issues
–
show
|
|||||
143 | $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
||||
144 | } |
||||
145 | |||||
146 | if ( ! empty( $videos_id ) ) { |
||||
0 ignored issues
–
show
|
|||||
147 | $this->page_links['videos'] = esc_html__( 'Videos', 'to-vehicles' ); |
||||
148 | } |
||||
149 | } |
||||
0 ignored issues
–
show
|
|||||
150 | |||||
151 | } |
||||
152 | new LSX_TO_Vehicles_Frontend(); |
||||
153 |