Issues (617)

classes/class-lsx-to-vehicles-frontend.php (65 issues)

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
There must be no blank lines after the class comment
Loading history...
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
Expected 2 blank lines before function; 1 found
Loading history...
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.

Loading history...
No space found before comment text; expected "// add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) );" but found "//add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) );"
Loading history...
44
		//add_action( 'init', array( $this, 'init' ) );
0 ignored issues
show
No space found before comment text; expected "// add_action( 'init', array( $this, 'init' ) );" but found "//add_action( 'init', array( $this, 'init' ) );"
Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
45
46
		if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
47
			require_once( LSX_TO_VEHICLES_PATH . 'classes/class-lsx-to-template-redirects.php' );
0 ignored issues
show
"require_once" is a statement not a function; no parentheses are required
Loading history...
48
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
49
		$this->redirects = new LSX_TO_Template_Redirects( LSX_TO_VEHICLES_PATH, array_keys( $this->post_types ) );
0 ignored issues
show
Bug Best Practice introduced by
The property redirects does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
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.

Loading history...
No space found before comment text; expected "// add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 );" but found "//add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 );"
Loading history...
55
		//add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) );
0 ignored issues
show
No space found before comment text; expected "// add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) );" but found "//add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) );"
Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
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
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
60
61
	function wp_head() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style Documentation introduced by
Missing doc comment for function wp_head()
Loading history...
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 private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
62
		if ( is_singular( 'vehicle' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
63
			remove_action( 'lsx_entry_bottom', 'lsx_to_single_entry_bottom' );
64
		}
65
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
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
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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.

Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
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.

Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
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.

Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
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
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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.

Loading history...
85
		}
86
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
87
88
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$page_links" missing
Loading history...
89
	 * Adds our navigation links to the team single post
90
	 *
91
	 * @param $page_links array
0 ignored issues
show
Missing parameter name
Loading history...
92
	 * @return $page_links array
0 ignored issues
show
Documentation Bug introduced by
The doc comment $page_links at position 0 could not be parsed: Unknown type name '$page_links' at position 0 in $page_links.
Loading history...
93
	 */
94
	public function page_links( $page_links ) {
95
		if ( is_singular( 'vehicle' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
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 ignore-type  annotation

110
		$gallery_ids = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'gallery', false );
Loading history...
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.

Loading history...
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
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
114
			if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
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
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
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 ignore-type  annotation

139
			$videos_id = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'envira_video', true );
Loading history...
140
		}
141
142
		if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
143
			$videos_id = get_post_meta( get_the_ID(), 'videos', true );
144
		}
145
146
		if ( ! empty( $videos_id ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
147
			$this->page_links['videos'] = esc_html__( 'Videos', 'to-vehicles' );
148
		}
149
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
150
151
}
152
new LSX_TO_Vehicles_Frontend();
153