LSX_Activities_Frontend   F
last analyzed

Complexity

Total Complexity 82

Size/Duplication

Total Lines 366
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 191
c 1
b 0
f 0
dl 0
loc 366
rs 2
wmc 82

15 Methods

Rating   Name   Duplication   Size   Complexity  
A get_videos_link() 0 13 5
A init() 0 3 2
C price_filter() 0 41 14
B get_gallery_link() 0 18 10
A __construct() 0 20 2
A get_related_accommodation_link() 0 17 6
A entry_class() 0 12 5
A page_links() 0 15 2
A get_map_link() 0 3 3
A get_related_posts_link() 0 17 5
A archive_entry_top() 0 16 6
A get_related_tours_link() 0 17 6
B archive_entry_bottom() 0 27 8
A single_content_bottom() 0 28 6
A single_fast_facts() 0 17 2

How to fix   Complexity   

Complex Class

Complex classes like LSX_Activities_Frontend often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use LSX_Activities_Frontend, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * LSX_Activities_Frontend
4
 *
5
 * @package   LSX_Activities_Frontend
6
 * @author    LightSpeed
7
 * @license   GPL-2.0+
8
 * @link
9
 * @copyright 2018 LightSpeedDevelopment
10
 */
11
12
/**
13
 * Main plugin class.
14
 *
15
 * @package LSX_Activities_Frontend
16
 * @author  LightSpeed
17
 */
18
class LSX_Activities_Frontend extends LSX_Activities {
19
20
	/**
21
	 * Holds the $page_links array while its being built on the single activity page.
22
	 *
23
	 * @var array
24
	 */
25
	public $page_links = false;
26
27
	/**
28
	 * Constructor
29
	 */
30
	public function __construct() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
31
		$this->set_vars();
32
33
		add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) );
34
		add_action( 'init',array( $this, 'init' ) );
35
36
		if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
37
			require_once( LSX_ACTIVITIES_PATH . 'classes/class-template-redirects.php' );
0 ignored issues
show
Coding Style introduced by
"require_once" is a statement not a function; no parentheses are required
Loading history...
38
		}
39
40
		$this->redirects = new LSX_TO_Template_Redirects( LSX_ACTIVITIES_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...
41
42
		add_action( 'lsx_to_activity_content', array( $this->redirects, 'content_part' ), 10 , 2 );
0 ignored issues
show
Coding Style introduced by
Space found before comma in argument list
Loading history...
43
44
		add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) );
45
46
		add_action( 'lsx_entry_top',      array( $this, 'archive_entry_top' ), 15 );
0 ignored issues
show
Coding Style introduced by
Expected 1 space after comma in argument list; 6 found
Loading history...
47
		add_action( 'lsx_entry_bottom',   array( $this, 'archive_entry_bottom' ) );
0 ignored issues
show
Coding Style introduced by
Expected 1 space after comma in argument list; 3 found
Loading history...
48
		add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) );
49
		add_action( 'lsx_to_fast_facts', array( $this, 'single_fast_facts' ) );
50
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
51
52
	/**
53
	 * Runs on init after all files have been parsed.
54
	 */
55
	public function init() {
56
		if ( ! class_exists( 'LSX_Currencies' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
57
			add_filter( 'lsx_to_custom_field_query',array( $this, 'price_filter' ),5,10 );
58
		}
59
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
60
61
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$classes" missing
Loading history...
62
	 * A filter to set the content area to a small column on single
63
	 */
64
	public function entry_class( $classes ) {
65
		global $lsx_to_archive;
66
67
		if ( 1 !== $lsx_to_archive ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
68
			$lsx_to_archive = false;
69
		}
70
71
		if ( is_main_query() && is_singular( 'activity' ) && false === $lsx_to_archive ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
72
			$classes[] = 'col-xs-12 col-sm-12 col-md-6';
73
		}
74
75
		return $classes;
76
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
77
78
	/**
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...
79
	 * Adds in additional info for the price custom field
80
	 */
81
	public function price_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) {
82
		if ( get_post_type() === 'activity' && 'price' === $meta_key ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
83
			$price_type = get_post_meta( get_the_ID(),'price_type',true );
0 ignored issues
show
Bug introduced by
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

83
			$price_type = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(),'price_type',true );
Loading history...
Coding Style introduced by
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...
84
			$value = preg_replace( '/[^0-9,.]/', '', $value );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
85
			$value = ltrim( $value, '.' );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
86
			$value = str_replace( ',','',$value );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
87
			$value = number_format( (int) $value,2 );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
88
			$tour_operator = tour_operator();
89
			$currency = '';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 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...
90
91
			if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
92
				if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
93
					$currency = $tour_operator->options['general']['currency'];
94
					$currency = '<span class="currency-icon ' . mb_strtolower( $currency ) . '">' . $currency . '</span>';
95
				}
96
			}
97
98
			switch ( $price_type ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
99
				case 'per_person':
100
				case 'per_person_per_night':
101
				case 'per_person_sharing':
102
				case 'per_person_sharing_per_night':
103
					$value = $currency . $value . ' ' . ucwords( str_replace( '_',' ',$price_type ) ) . '';
104
					$value = str_replace( 'Per Person', 'P/P', $value );
105
				break;
106
107
				case 'total_percentage':
108
					$value .= '% ' . __( 'Off','to-specials' ) . '';
109
					$before = str_replace( 'from price', '', $before );
110
				break;
111
112
				case 'none':
113
				default:
114
					$value = $currency . $value;
115
				break;
116
			}
117
118
			$html = $before . $value . $after;
119
		}
120
121
		return $html;
122
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
123
124
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$page_links" missing
Loading history...
125
	 * Adds our navigation links to the activity single post
126
	 *
127
	 * @param $page_links array
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
128
	 * @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...
129
	 */
130
	public function page_links( $page_links ) {
131
		if ( is_singular( 'activity' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
132
			$this->page_links = $page_links;
133
134
			$this->get_map_link();
135
			$this->get_related_tours_link();
136
			$this->get_related_accommodation_link();
137
			$this->get_gallery_link();
138
			$this->get_videos_link();
139
			$this->get_related_posts_link();
140
141
			$page_links = $this->page_links;
142
		}
143
144
		return $page_links;
145
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
146
147
	/**
148
	 * Tests for the Related Tours and returns a link for the section
149
	 */
150
	public function get_related_tours_link() {
151
		$connected_tours = get_post_meta( get_the_ID(), 'tour_to_activity', false );
0 ignored issues
show
Bug introduced by
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

151
		$connected_tours = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'tour_to_activity', false );
Loading history...
152
153
		if ( post_type_exists( 'tour' ) && is_array( $connected_tours ) && ! empty( $connected_tours ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
154
			$connected_tours = new \WP_Query( array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
155
				'post_type' => 'tour',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
156
				'post__in' => $connected_tours,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'post__in'" and double arrow, but found 1.
Loading history...
157
				'post_status' => 'publish',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1.
Loading history...
158
				'nopagin' => true,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
159
				'posts_per_page' => '-1',
160
				'fields' => 'ids',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 9 space(s) between "'fields'" and double arrow, but found 1.
Loading history...
161
			) );
0 ignored issues
show
Coding Style introduced by
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...
162
163
			$connected_tours = $connected_tours->posts;
164
165
			if ( is_array( $connected_tours ) && ! empty( $connected_tours ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
166
				$this->page_links['tours'] = esc_html__( 'Tours', 'lsx-activities' );
167
			}
168
		}
169
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
170
171
	/**
172
	 * Tests for the Related Accommodation and returns a link for the section
173
	 */
174
	public function get_related_accommodation_link() {
175
		$connected_accommodation = get_post_meta( get_the_ID(), 'accommodation_to_activity', false );
0 ignored issues
show
Bug introduced by
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

175
		$connected_accommodation = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'accommodation_to_activity', false );
Loading history...
176
177
		if ( post_type_exists( 'accommodation' ) && is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
178
			$connected_accommodation = new \WP_Query( array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
179
				'post_type' => 'accommodation',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
180
				'post__in' => $connected_accommodation,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'post__in'" and double arrow, but found 1.
Loading history...
181
				'post_status' => 'publish',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1.
Loading history...
182
				'nopagin' => true,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
183
				'posts_per_page' => '-1',
184
				'fields' => 'ids',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 9 space(s) between "'fields'" and double arrow, but found 1.
Loading history...
185
			) );
0 ignored issues
show
Coding Style introduced by
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...
186
187
			$connected_accommodation = $connected_accommodation->posts;
188
189
			if ( is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
190
				$this->page_links['accommodation'] = esc_html__( 'Accommodation', 'lsx-activities' );
191
			}
192
		}
193
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
194
195
	/**
196
	 * Tests for the Google Map and returns a link for the section
197
	 */
198
	public function get_map_link() {
199
		if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
200
			$this->page_links['activity-map'] = esc_html__( 'Map', 'lsx-activities' );
201
		}
202
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
203
204
	/**
205
	 * Tests for the Gallery and returns a link for the section
206
	 */
207
	public function get_gallery_link() {
208
		$gallery_ids = get_post_meta( get_the_ID(), 'gallery', false );
0 ignored issues
show
Bug introduced by
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

208
		$gallery_ids = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'gallery', false );
Loading history...
Coding Style introduced by
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...
209
		$envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true );
210
211
		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
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
212
			if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
213
				// Envira Gallery
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
214
				$this->page_links['gallery'] = esc_html__( 'Gallery', 'lsx-activities' );
215
				return;
216
			} else {
217
				if ( function_exists( 'envira_dynamic' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
218
					// Envira Gallery - Dynamic
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
219
					$this->page_links['gallery'] = esc_html__( 'Gallery', 'lsx-activities' );
220
					return;
221
				} else {
222
					// WordPress Gallery
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
223
					$this->page_links['gallery'] = esc_html__( 'Gallery', 'lsx-activities' );
224
					return;
225
				}
226
			}
227
		}
228
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
229
230
	/**
231
	 * Tests for the Videos and returns a link for the section
232
	 */
233
	public function get_videos_link() {
234
		$videos_id = false;
235
236
		if ( class_exists( 'Envira_Videos' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
237
			$videos_id = get_post_meta( get_the_ID(), 'envira_video', true );
0 ignored issues
show
Bug introduced by
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
			$videos_id = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'envira_video', true );
Loading history...
238
		}
239
240
		if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
241
			$videos_id = get_post_meta( get_the_ID(), 'videos', true );
242
		}
243
244
		if ( ! empty( $videos_id ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
245
			$this->page_links['videos'] = esc_html__( 'Videos', 'lsx-activities' );
246
		}
247
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
248
249
	/**
250
	 * Tests for the Related Posts and returns a link for the section
251
	 */
252
	public function get_related_posts_link() {
253
		$connected_posts = get_post_meta( get_the_ID(), 'post_to_activity', false );
0 ignored issues
show
Bug introduced by
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

253
		$connected_posts = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'post_to_activity', false );
Loading history...
254
255
		if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
256
			$connected_posts = new \WP_Query( array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
257
				'post_type' => 'post',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
258
				'post__in' => $connected_posts,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'post__in'" and double arrow, but found 1.
Loading history...
259
				'post_status' => 'publish',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1.
Loading history...
260
				'nopagin' => true,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
261
				'posts_per_page' => '-1',
262
				'fields' => 'ids',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 9 space(s) between "'fields'" and double arrow, but found 1.
Loading history...
263
			) );
0 ignored issues
show
Coding Style introduced by
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...
264
265
			$connected_posts = $connected_posts->posts;
266
267
			if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
268
				$this->page_links['posts'] = esc_html__( 'Posts', 'lsx-activities' );
269
			}
270
		}
271
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
272
273
	/**
274
	 * Adds the template tags to the top of the archive activity
275
	 */
276
	public function archive_entry_top() {
277
		global $lsx_to_archive;
278
279
		if ( 'activity' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
280
			if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
281
				<div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-grid-mode">
282
					<?php
283
						$meta_class = 'lsx-to-meta-data lsx-to-meta-data-';
284
285
						lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'lsx-activities' ) . ':</span> ', '</span>' );
286
						lsx_to_accommodation_activity_friendly( '<span class="' . $meta_class . 'friendly"><span class="lsx-to-meta-data-key">' . __( 'Friendly', 'lsx-activities' ) . ':</span> ', '</span>' );
287
						lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Location', 'lsx-activities' ) . ':</span> ','</span>' );
288
						lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'lsx-activities' ) . ':</span> ', '</span>' );
289
						lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'lsx-activities' ) . ':</span> ', '</span>' );
290
					?>
291
				</div>
292
			<?php }
0 ignored issues
show
Coding Style introduced by
Opening PHP tag must be on a line by itself
Loading history...
293
		}
294
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
295
296
	/**
297
	 * Adds the template tags to the bottom of the archive activity
298
	 */
299
	public function archive_entry_bottom() {
300
		global $lsx_to_archive;
301
302
		if ( 'activity' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
303
				</div>
304
305
				<?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
306
					<div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-list-mode">
307
						<?php
308
							$meta_class = 'lsx-to-meta-data lsx-to-meta-data-';
309
310
							lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'lsx-activities' ) . ':</span> ', '</span>' );
311
							lsx_to_accommodation_activity_friendly( '<span class="' . $meta_class . 'friendly"><span class="lsx-to-meta-data-key">' . __( 'Friendly', 'lsx-activities' ) . ':</span> ', '</span>' );
312
							lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Location', 'lsx-activities' ) . ':</span> ','</span>' );
313
							lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'lsx-activities' ) . ':</span> ', '</span>' );
314
							lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'lsx-activities' ) . ':</span> ', '</span>' );
315
						?>
316
					</div>
317
				<?php } ?>
318
			</div>
319
320
			<?php $has_single = ! lsx_to_is_single_disabled(); ?>
321
322
			<?php if ( $has_single && 'grid' === tour_operator()->archive_layout ) : ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
323
				<a href="<?php the_permalink(); ?>" class="moretag"><?php esc_html_e( 'View more', 'lsx-activities' ); ?></a>
324
			<?php endif; ?>
325
		<?php }
0 ignored issues
show
Coding Style introduced by
Opening PHP tag must be on a line by itself
Loading history...
326
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
327
328
	/**
329
	 * Adds the template tags fast facts
330
	 */
331
	public function single_fast_facts() {
332
		if ( is_singular( 'activity' ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
333
			<section id="fast-facts">
334
				<div class="lsx-to-section-inner">
335
					<h3 class="lsx-to-section-title"><?php esc_html_e( 'Activity Summary', 'lsx-activities' ); ?></h3>
336
337
					<div class="lsx-to-single-meta-data">
338
						<?php
339
							$meta_class = 'lsx-to-meta-data lsx-to-meta-data-';
340
341
							// lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'lsx-activities' ) . ':</span> ', '</span>' );
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% 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...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
342
							lsx_to_accommodation_activity_friendly( '<span class="' . $meta_class . 'friendly"><span class="lsx-to-meta-data-key">' . __( 'Friendly', 'lsx-activities' ) . ':</span> ', '</span>' );
343
							lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Location', 'lsx-activities' ) . ':</span> ', '</span>' );
344
							lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'lsx-activities' ) . ':</span> ', '</span>' );
345
							lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'lsx-activities' ) . ':</span> ', '</span>' );
346
						?>
347
					</div>
348
				</div>
349
			</section>
350
		<?php }
0 ignored issues
show
Coding Style introduced by
Opening PHP tag must be on a line by itself
Loading history...
351
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
352
353
	/**
354
	 * Adds the template tags to the bottom of the single activity
355
	 */
356
	public function single_content_bottom() {
357
		if ( is_singular( 'activity' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
358
			if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) : ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
359
				<section id="activity-map" class="lsx-to-section lsx-to-collapse-section">
360
					<h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title hidden-lg" data-toggle="collapse" data-target="#collapse-activity-map"><?php esc_html_e( 'Map', 'lsx-activities' ); ?></h2>
361
362
					<div id="collapse-activity-map" class="collapse in">
363
						<div class="collapse-inner">
364
							<?php lsx_to_map(); ?>
365
						</div>
366
					</div>
367
				</section>
368
				<?php
369
			endif;
370
371
			lsx_to_activity_tours();
372
373
			lsx_to_activity_accommodation();
374
375
			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', 'lsx-activities' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' );
376
377
			if ( function_exists( 'lsx_to_videos' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
378
				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', 'lsx-activities' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' );
379
			} elseif ( class_exists( 'Envira_Videos' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
380
				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', 'lsx-activities' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' );
381
			}
382
383
			lsx_to_activity_posts();
384
		}
385
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
386
387
}
388
389
new LSX_Activities_Frontend();
390