Issues (1110)

classes/class-specials-schema.php (26 issues)

1
<?php
0 ignored issues
show
Class file names should be based on the class name with "class-" prepended. Expected class-lsx-to-specials-schema.php, but found class-specials-schema.php.
Loading history...
2
/**
3
 * LSX_TO_Specials_Schema
4
 *
5
 * @package   LSX_TO_Specials_Schema
6
 * @author    LightSpeed
7
 * @license   GPL-3.0+
8
 * @link
9
 * @copyright 2018 LightSpeedDevelopment
10
 */
11
12
/**
13
 * Main plugin class.
14
 *
15
 * @package LSX_Specials_Schema
16
 * @author  LightSpeed
17
 */
18
19
class LSX_TO_Specials_Schema extends LSX_TO_Specials {
20
21
	/**
22
	 * Constructor
23
	 */
24
	public function __construct() {
25
		$this->set_vars();
26
		add_action( 'wp_head', array( $this, 'specials_single_schema' ), 1499 );
27
	}
28
29
	/**
30
	 * Creates the schema for the specials post type
31
	 *
32
	 * @since 1.0.0
33
	 * @return    object    A single instance of this class.
34
	 */
35
	public function specials_single_schema() {
36
		if ( is_singular( 'special' ) ) {
37
38
		$destination_list_special = get_post_meta( get_the_ID(), 'destination_to_special', false );
39
		$destination_list_schema = array();
40
		$url_option = get_the_permalink();
41
		$special_title = get_the_title();
42
		$primary_url = get_the_permalink();
43
		$special_content = wp_strip_all_tags( get_the_content() );
44
		$thumb_url = get_the_post_thumbnail_url( get_the_ID(), 'full' );
45
		$price = get_post_meta( get_the_ID(), 'price', false );
46
		$start_validity = get_post_meta( get_the_ID(), 'booking_validity_start', false );
47
		$end_validity = get_post_meta( get_the_ID(), 'booking_validity_end', false );
48
	
49
50
		if ( ! empty( $destination_list_special ) ) {
51
			foreach( $destination_list_special as $single_destination ) {
0 ignored issues
show
Space after opening control structure is required
Loading history...
No space before opening parenthesis is prohibited
Loading history...
52
				$url_option   = get_the_permalink() . '#destination-' . $i;
53
				$destination_name = get_the_title($single_destination);
54
				$schema_day       = array(
55
				"@type" => "PostalAddress",
0 ignored issues
show
Array item not aligned correctly; expected 20 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 11 space(s) between ""@type"" and double arrow, but found 1.
Loading history...
56
				"addressLocality" => $destination_name,
0 ignored issues
show
Array item not aligned correctly; expected 20 spaces but found 16
Loading history...
57
			);
0 ignored issues
show
Array closer not aligned correctly; expected 16 space(s) but found 12
Loading history...
58
				$destination_list_schema[] = $schema_day;
59
				}
60
			}
61
			$meta = array(
62
				array(
63
					"@context" => "http://schema.org",
0 ignored issues
show
Array double arrow not aligned correctly; expected 4 space(s) between ""@context"" and double arrow, but found 1.
Loading history...
64
					"@type" => array("Trip", "ProfessionalService", "Offer"),
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between ""@type"" and double arrow, but found 1.
Loading history...
Missing space after array opener.
Loading history...
Missing space before array closer.
Loading history...
65
					"offers" => array(
0 ignored issues
show
Array double arrow not aligned correctly; expected 6 space(s) between ""offers"" and double arrow, but found 1.
Loading history...
66
					"@type" => "Offer",
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 20
Loading history...
Array double arrow not aligned correctly; expected 14 space(s) between ""@type"" and double arrow, but found 1.
Loading history...
67
					"price" => $price,
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 20
Loading history...
Array double arrow not aligned correctly; expected 14 space(s) between ""price"" and double arrow, but found 1.
Loading history...
68
					"availabilityStarts" => $start_validity,
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 20
Loading history...
69
					"availabilityEnds" => $end_validity,
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 20
Loading history...
Array double arrow not aligned correctly; expected 3 space(s) between ""availabilityEnds"" and double arrow, but found 1.
Loading history...
70
					),
71
					"address" => $destination_list_schema,
0 ignored issues
show
Array double arrow not aligned correctly; expected 5 space(s) between ""address"" and double arrow, but found 1.
Loading history...
72
					"telephone" => "0216713090",
0 ignored issues
show
Array double arrow not aligned correctly; expected 3 space(s) between ""telephone"" and double arrow, but found 1.
Loading history...
73
					"priceRange" => $price,
0 ignored issues
show
Array double arrow not aligned correctly; expected 2 space(s) between ""priceRange"" and double arrow, but found 1.
Loading history...
74
					"description" => $special_content,
75
					"image" => $thumb_url,
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between ""image"" and double arrow, but found 1.
Loading history...
76
					"name" => $special_title,
0 ignored issues
show
Array double arrow not aligned correctly; expected 8 space(s) between ""name"" and double arrow, but found 1.
Loading history...
77
					"provider" => "Southern Destinations",
0 ignored issues
show
Array double arrow not aligned correctly; expected 4 space(s) between ""provider"" and double arrow, but found 1.
Loading history...
78
					"url" => $primary_url,
0 ignored issues
show
Array double arrow not aligned correctly; expected 9 space(s) between ""url"" and double arrow, but found 1.
Loading history...
79
				),
80
			);
81
			$output = wp_json_encode( $meta, JSON_UNESCAPED_SLASHES  );
82
			?>
83
			<script type="application/ld+json">
84
				<?php echo wp_kses_post( $output ); ?>
85
			</script>
86
			<?php
87
		}
88
	}
89
}
90
91
new LSX_TO_Specials_Schema();
92