Issues (1057)

classes/class-to-reviews-frontend.php (172 issues)

1
<?php
0 ignored issues
show
Class file names should be based on the class name with "class-" prepended. Expected class-lsx-to-reviews-frontend.php, but found class-to-reviews-frontend.php.
Loading history...
2
/**
3
 * LSX_TO_Reviews_Frontend
4
 *
5
 * @package   LSX_TO_Reviews_Frontend
6
 * @author    LightSpeed
7
 * @license   GPL-2.0+
8
 * @link
9
 * @copyright 2016 LightSpeedDevelopment
10
 */
11
12
/**
13
 * Main plugin class.
14
 *
15
 * @package LSX_TO_Reviews_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_Reviews_Frontend extends LSX_TO_Reviews {
20
21
	/**
22
	 * Holds the $page_links array while its being built on the single review page.
23
	 *
24
	 * @var array
25
	 */
26
	public $page_links = false;
27
28
	/**
29
	 * Constructor
30
	 */
31
	public function __construct() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
32
		$this->set_vars();
33
34
		add_action( 'wp_head', array( $this, 'change_single_review_layout' ), 20, 1 );
35
36
		add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) );
37
		add_action( 'init', array( $this, 'init' ) );
38
39
		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...
40
			require_once( LSX_TO_REVIEWS_PATH . 'classes/class-template-redirects.php' );
0 ignored issues
show
"require_once" is a statement not a function; no parentheses are required
Loading history...
41
		}
42
43
		$this->redirects = new LSX_TO_Template_Redirects( LSX_TO_REVIEWS_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...
44
45
		add_action( 'lsx_to_review_content', array( $this->redirects, 'content_part' ), 10 , 2 );
0 ignored issues
show
Space found before comma in argument list
Loading history...
46
47
		add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) );
48
49
		add_action( 'lsx_entry_top',      array( $this, 'archive_entry_top' ), 15 );
0 ignored issues
show
Expected 1 space after comma in argument list; 6 found
Loading history...
50
		add_action( 'lsx_entry_bottom',   array( $this, 'archive_entry_bottom' ) );
0 ignored issues
show
Expected 1 space after comma in argument list; 3 found
Loading history...
51
		add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) );
52
		add_action( 'lsx_to_fast_facts', array( $this, 'single_fast_facts' ) );
53
	}
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...
54
55
	/**
56
	 * Change single review layout.
57
	 */
58
	public function change_single_review_layout() {
59
		global $lsx_to_archive;
60
61
		if ( is_singular( 'review' ) && 1 !== $lsx_to_archive ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
62
			remove_action( 'lsx_entry_bottom', 'lsx_to_single_entry_bottom' );
63
			add_action( 'lsx_entry_top', array( $this, '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
	 * Change single review layout.
69
	 */
70
	public function lsx_to_single_entry_bottom() {
71
		if ( is_singular( 'review' ) ) { ?>
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
			<div class="col-xs-12 col-sm-4 col-md-3">
73
				<figure class="lsx-to-review-thumb">
74
					<?php lsx_thumbnail( 'lsx-thumbnail-square' ); ?>
75
				</figure>
76
77
				<?php $reviewer_name = get_post_meta( get_the_ID(), 'reviewer_name', 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

77
				<?php $reviewer_name = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'reviewer_name', true ); ?>
Loading history...
78
				<h3 class="lsx-to-summary-title text-center"><?php echo esc_html( $reviewer_name ); ?></h3>
0 ignored issues
show
It seems like $reviewer_name can also be of type false; however, parameter $text of esc_html() does only seem to accept string, 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

78
				<h3 class="lsx-to-summary-title text-center"><?php echo esc_html( /** @scrutinizer ignore-type */ $reviewer_name ); ?></h3>
Loading history...
79
			</div>
80
		<?php }
0 ignored issues
show
Opening PHP tag must be on a line by itself
Loading history...
81
	}
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...
82
83
	/**
84
	 * Runs on init after all files have been parsed.
85
	 */
86
	public function init() {
87
		add_filter( 'lsx_to_custom_field_query',array( $this, 'rating' ),5,10 );
88
	}
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...
89
90
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$classes" missing
Loading history...
91
	 * A filter to set the content area to a small column on single
92
	 */
93
	public function entry_class( $classes ) {
94
		global $lsx_to_archive;
95
96
		if ( 1 !== $lsx_to_archive ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
97
			$lsx_to_archive = false;
98
		}
99
100
		if ( is_main_query() && is_singular( 'review' ) && false === $lsx_to_archive ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
101
			//if ( lsx_to_has_enquiry_contact() ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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 "// if ( lsx_to_has_enquiry_contact() ) {" but found "//if ( lsx_to_has_enquiry_contact() ) {"
Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
102
				$classes[] = 'col-xs-12 col-sm-8 col-md-9';
103
			//} else {
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% 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 "// } else " but found "// else {"
Loading history...
104
				//$classes[] = 'col-sm-12';
0 ignored issues
show
No space found before comment text; expected "// $classes[] = 'col-sm-12';" but found "//$classes[] = 'col-sm-12';"
Loading history...
105
			//}
0 ignored issues
show
No space found before comment text; expected "// }" but found "//}"
Loading history...
106
		}
107
108
		return $classes;
109
	}
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...
110
111
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$html" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$meta_key" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$value" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$before" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$after" missing
Loading history...
112
	 * Filter and make the star ratings
113
	 */
114
	public function rating( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) {
115
		if ( get_post_type() === 'review' && 'rating' === $meta_key ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
116
			$ratings_array = array();
117
			$counter       = 5;
118
			$html          = '';
119
			if ( 0 !== (int) $value ) {
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
				while ( $counter > 0 ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
121
					if ( $value > 0 ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
122
						$ratings_array[] = '<i class="fa fa-star"></i>';
123
					} else {
124
						$ratings_array[] = '<i class="fa fa-star-o"></i>';
125
					}
126
127
					$counter--;
128
					$value--;
129
				}
130
131
				$html = $before . implode( '', $ratings_array ) . $after;
132
			}
133
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
134
		return $html;
135
	}
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...
136
137
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$page_links" missing
Loading history...
138
	 * Adds our navigation links to the review single post
139
	 *
140
	 * @param $page_links array
0 ignored issues
show
Missing parameter name
Loading history...
141
	 * @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...
142
	 */
143
	public function page_links( $page_links ) {
144
		if ( is_singular( 'review' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
145
			$this->page_links = $page_links;
146
147
			$this->get_related_accommodation_link();
148
			$this->get_related_tours_link();
149
			$this->get_related_destinations_link();
150
			$this->get_gallery_link();
151
			$this->get_videos_link();
152
			$this->get_related_posts_link();
153
154
			$page_links = $this->page_links;
155
		}
156
157
		return $page_links;
158
	}
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...
159
160
	/**
161
	 * Tests for the Related Accommodation and returns a link for the section
162
	 */
163
	public function get_related_accommodation_link() {
164
		$connected_accommodation = get_post_meta( get_the_ID(), 'accommodation_to_review', 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

164
		$connected_accommodation = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'accommodation_to_review', false );
Loading history...
165
166
		if ( post_type_exists( 'accommodation' ) && is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
167
			$connected_accommodation = new \WP_Query( array(
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
168
				'post_type' => 'accommodation',
0 ignored issues
show
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
169
				'post__in' => $connected_accommodation,
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between "'post__in'" and double arrow, but found 1.
Loading history...
170
				'post_status' => 'publish',
0 ignored issues
show
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1.
Loading history...
171
				'nopagin' => true,
0 ignored issues
show
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
172
				'posts_per_page' => '-1',
173
				'fields' => 'ids',
0 ignored issues
show
Array double arrow not aligned correctly; expected 9 space(s) between "'fields'" and double arrow, but found 1.
Loading history...
174
			) );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
175
176
			$connected_accommodation = $connected_accommodation->posts;
177
178
			if ( is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
179
				$this->page_links['accommodation'] = esc_html__( 'Accommodation', 'to-reviews' );
180
			}
181
		}
182
	}
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...
183
184
	/**
185
	 * Tests for the Related Tours and returns a link for the section
186
	 */
187
	public function get_related_tours_link() {
188
		$connected_tours = get_post_meta( get_the_ID(), 'tour_to_review', 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

188
		$connected_tours = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'tour_to_review', false );
Loading history...
189
190
		if ( post_type_exists( 'tour' ) && is_array( $connected_tours ) && ! empty( $connected_tours ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
191
			$connected_tours = new \WP_Query( array(
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
192
				'post_type' => 'tour',
0 ignored issues
show
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
193
				'post__in' => $connected_tours,
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between "'post__in'" and double arrow, but found 1.
Loading history...
194
				'post_status' => 'publish',
0 ignored issues
show
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1.
Loading history...
195
				'nopagin' => true,
0 ignored issues
show
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
196
				'posts_per_page' => '-1',
197
				'fields' => 'ids',
0 ignored issues
show
Array double arrow not aligned correctly; expected 9 space(s) between "'fields'" and double arrow, but found 1.
Loading history...
198
			) );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
199
200
			$connected_tours = $connected_tours->posts;
201
202
			if ( is_array( $connected_tours ) && ! empty( $connected_tours ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
203
				$this->page_links['tours'] = esc_html__( 'Tours', 'to-reviews' );
204
			}
205
		}
206
	}
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...
207
208
	/**
209
	 * Tests for the Related Destinations and returns a link for the section
210
	 */
211
	public function get_related_destinations_link() {
212
		$connected_destination  = '';
213
		$connected_destinations = get_post_meta( get_the_ID(), 'destination_to_review', 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

213
		$connected_destinations = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'destination_to_review', false );
Loading history...
214
215
		if ( post_type_exists( 'destination' ) && is_array( $connected_destinations ) && ! empty( $connected_destinations ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
216
			$connected_destination = new \WP_Query( array(
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
217
				'post_type' => 'destination',
0 ignored issues
show
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
218
				'post__in' => $connected_destination,
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between "'post__in'" and double arrow, but found 1.
Loading history...
219
				'post_status' => 'publish',
0 ignored issues
show
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1.
Loading history...
220
				'nopagin' => true,
0 ignored issues
show
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
221
				'posts_per_page' => '-1',
222
				'fields' => 'ids',
0 ignored issues
show
Array double arrow not aligned correctly; expected 9 space(s) between "'fields'" and double arrow, but found 1.
Loading history...
223
			) );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
224
225
			$connected_destination = $connected_destination->posts;
226
227
			if ( is_array( $connected_destination ) && ! empty( $connected_destination ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
228
				$this->page_links['destinations'] = esc_html__( 'Destinations', 'to-reviews' );
229
			}
230
		}
231
	}
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...
232
233
	/**
234
	 * Tests for the Gallery and returns a link for the section
235
	 */
236
	public function get_gallery_link() {
237
		$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

237
		$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...
238
		$envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true );
239
240
		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...
241
			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...
242
				// Envira Gallery
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
243
				$this->page_links['gallery'] = esc_html__( 'Gallery', 'to-reviews' );
244
				return;
245
			} else {
246
				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...
247
					// Envira Gallery - Dynamic
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
248
					$this->page_links['gallery'] = esc_html__( 'Gallery', 'to-reviews' );
249
					return;
250
				} else {
251
					// WordPress Gallery
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
252
					$this->page_links['gallery'] = esc_html__( 'Gallery', 'to-reviews' );
253
					return;
254
				}
255
			}
256
		}
257
	}
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...
258
259
	/**
260
	 * Tests for the Videos and returns a link for the section
261
	 */
262
	public function get_videos_link() {
263
		$videos_id = false;
264
265
		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...
266
			$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

266
			$videos_id = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'envira_video', true );
Loading history...
267
		}
268
269
		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...
270
			$videos_id = get_post_meta( get_the_ID(), 'videos', true );
271
		}
272
273
		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...
274
			$this->page_links['videos'] = esc_html__( 'Videos', 'to-reviews' );
275
		}
276
	}
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...
277
278
	/**
279
	 * Tests for the Related Posts and returns a link for the section
280
	 */
281
	public function get_related_posts_link() {
282
		$connected_posts = get_post_meta( get_the_ID(), 'post_to_review', 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

282
		$connected_posts = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'post_to_review', false );
Loading history...
283
284
		if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
285
			$connected_posts = new \WP_Query( array(
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
286
				'post_type' => 'post',
0 ignored issues
show
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
287
				'post__in' => $connected_posts,
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between "'post__in'" and double arrow, but found 1.
Loading history...
288
				'post_status' => 'publish',
0 ignored issues
show
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1.
Loading history...
289
				'nopagin' => true,
0 ignored issues
show
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
290
				'posts_per_page' => '-1',
291
				'fields' => 'ids',
0 ignored issues
show
Array double arrow not aligned correctly; expected 9 space(s) between "'fields'" and double arrow, but found 1.
Loading history...
292
			) );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
293
294
			$connected_posts = $connected_posts->posts;
295
296
			if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
297
				$this->page_links['posts'] = esc_html__( 'Posts', 'to-reviews' );
298
			}
299
		}
300
	}
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...
301
302
	/**
303
	 * Adds the template tags to the top of the archive review
304
	 */
305
	public function archive_entry_top() {
306
		global $lsx_to_archive;
307
308
		if ( 'review' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
309
			if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
Closing PHP tag must be on a line by itself
Loading history...
310
				<div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-grid-mode">
311
					<?php
312
						$meta_class = 'lsx-to-meta-data lsx-to-meta-data-';
313
314
						lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-reviews' ) . ':</span> ', '</span>' );
315
						lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-reviews' ) . ':</span> ', '</span>' );
316
						lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-reviews' ) . ':</span> ', '</span>' );
317
					?>
318
				</div>
319
			<?php } ?>
320
		<?php }
0 ignored issues
show
Opening PHP tag must be on a line by itself
Loading history...
321
	}
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...
322
323
	/**
324
	 * Adds the template tags to the bottom of the archive review
325
	 */
326
	public function archive_entry_bottom() {
327
		global $lsx_to_archive;
328
329
		if ( 'review' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
Closing PHP tag must be on a line by itself
Loading history...
330
				</div>
331
332
				<?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
333
					<div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-list-mode">
334
						<?php
335
							$meta_class = 'lsx-to-meta-data lsx-to-meta-data-';
336
337
							lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-reviews' ) . ':</span> ', '</span>' );
338
							lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-reviews' ) . ':</span> ', '</span>' );
339
							lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-reviews' ) . ':</span> ', '</span>' );
340
						?>
341
					</div>
342
				<?php } ?>
343
			</div>
344
345
			<?php $has_single = ! lsx_to_is_single_disabled(); ?>
346
347
			<?php if ( $has_single && 'grid' === tour_operator()->archive_layout ) : ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
348
				<a href="<?php the_permalink(); ?>" class="moretag"><?php esc_html_e( 'View more', 'to-reviews' ); ?></a>
349
			<?php endif; ?>
350
		<?php }
0 ignored issues
show
Opening PHP tag must be on a line by itself
Loading history...
351
	}
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...
352
353
	/**
354
	 * Adds the template tags fast facts
355
	 */
356
	public function single_fast_facts() {
357
		if ( is_singular( 'review' ) ) { ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
Closing PHP tag must be on a line by itself
Loading history...
358
			<section id="fast-facts">
359
				<div class="lsx-to-single-meta-data">
360
					<?php
361
						$meta_class = 'lsx-to-meta-data lsx-to-meta-data-';
362
363
						lsx_to_review_rating( '<span class="' . $meta_class . 'rating"><span class="lsx-to-meta-data-key">' . esc_html__( 'Rating', 'to-reviews' ) . ':</span> ', '</span>' );
364
						lsx_to_review_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . esc_html__( 'Date Travelled', 'to-reviews' ) . ':</span> ', '</span>' );
365
						lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Accommodation', 'to-reviews' ) . ':</span> ', '</span>' );
366
						lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . esc_html__( 'Tours', 'to-reviews' ) . ':</span> ', '</span>' );
367
						lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Destinations', 'to-reviews' ) . ':</span> ', '</span>' );
368
					?>
369
				</div>
370
			</section>
371
		<?php }
0 ignored issues
show
Opening PHP tag must be on a line by itself
Loading history...
372
	}
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...
373
374
	/**
375
	 * Adds the template tags to the bottom of the single review
376
	 */
377
	public function single_content_bottom() {
378
		if ( is_singular( 'review' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
379
			lsx_to_review_accommodation();
380
381
			lsx_to_review_tour();
382
383
			lsx_to_review_destination();
384
385
			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>' );
386
387
			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...
388
				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>' );
389
			} 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...
390
				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>' );
391
			}
392
393
			lsx_to_review_posts();
394
		}
395
	}
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...
396
397
}
398
399
new LSX_TO_Reviews_Frontend();
400