1 | <?php |
||||
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 ); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
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' ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post of get_the_post_thumbnail_url() does only seem to accept WP_Post|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
![]() |
|||||
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 ) { |
||||
52 | $url_option = get_the_permalink() . '#destination-' . $i; |
||||
0 ignored issues
–
show
Are you sure
get_the_permalink() of type false|string can be used in concatenation ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
53 | $destination_name = get_the_title($single_destination); |
||||
54 | $schema_day = array( |
||||
55 | "@type" => "PostalAddress", |
||||
56 | "addressLocality" => $destination_name, |
||||
57 | ); |
||||
58 | $destination_list_schema[] = $schema_day; |
||||
59 | } |
||||
60 | } |
||||
61 | $meta = array( |
||||
62 | array( |
||||
63 | "@context" => "http://schema.org", |
||||
64 | "@type" => array("Trip", "ProfessionalService", "Offer"), |
||||
65 | "offers" => array( |
||||
66 | "@type" => "Offer", |
||||
67 | "price" => $price, |
||||
68 | "availabilityStarts" => $start_validity, |
||||
69 | "availabilityEnds" => $end_validity, |
||||
70 | ), |
||||
71 | "address" => $destination_list_schema, |
||||
72 | "telephone" => "0216713090", |
||||
73 | "priceRange" => $price, |
||||
74 | "description" => $special_content, |
||||
75 | "image" => $thumb_url, |
||||
76 | "name" => $special_title, |
||||
77 | "provider" => "Southern Destinations", |
||||
78 | "url" => $primary_url, |
||||
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 ); ?> |
||||
0 ignored issues
–
show
It seems like
$output can also be of type false ; however, parameter $data of wp_kses_post() 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
![]() |
|||||
85 | </script> |
||||
86 | <?php |
||||
87 | } |
||||
88 | } |
||||
89 | } |
||||
90 | |||||
91 | new LSX_TO_Specials_Schema(); |
||||
92 |