@@ -8,31 +8,31 @@ |
||
8 | 8 | |
9 | 9 | global $lsx_to_archive, $post; |
10 | 10 | |
11 | -if ( 1 !== $lsx_to_archive ) { |
|
11 | +if (1 !== $lsx_to_archive) { |
|
12 | 12 | $lsx_to_archive = false; |
13 | 13 | } |
14 | 14 | ?> |
15 | 15 | |
16 | 16 | <?php lsx_entry_before(); ?> |
17 | 17 | |
18 | -<article id="special-<?php echo esc_attr( $post->post_name ); ?>" <?php post_class( 'lsx-to-archive-container' ); ?>> |
|
18 | +<article id="special-<?php echo esc_attr($post->post_name); ?>" <?php post_class('lsx-to-archive-container'); ?>> |
|
19 | 19 | <?php lsx_entry_top(); ?> |
20 | 20 | |
21 | - <?php if ( is_single() && false === $lsx_to_archive ) { ?> |
|
21 | + <?php if (is_single() && false === $lsx_to_archive) { ?> |
|
22 | 22 | |
23 | - <div <?php lsx_to_entry_class( 'entry-content' ); ?>> |
|
23 | + <div <?php lsx_to_entry_class('entry-content'); ?>> |
|
24 | 24 | <div class="lsx-to-summary"> |
25 | 25 | <h2 class="lsx-to-summary-title"><?php the_title(); ?></h2> |
26 | 26 | </div> |
27 | 27 | |
28 | - <?php lsx_to_price( '<p class="lsx-to-meta-data lsx-to-meta-data-big lsx-to-meta-data-price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'tour-operator' ) . ':</span> ', '</p>' ); ?> |
|
28 | + <?php lsx_to_price('<p class="lsx-to-meta-data lsx-to-meta-data-big lsx-to-meta-data-price"><span class="lsx-to-meta-data-key">' . esc_html__('From price', 'tour-operator') . ':</span> ', '</p>'); ?> |
|
29 | 29 | <?php the_content(); ?> |
30 | 30 | <?php lsx_to_sharing(); ?> |
31 | 31 | </div> |
32 | 32 | |
33 | - <?php } elseif ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_text'] ) ) { ?> |
|
33 | + <?php } elseif (is_search() || empty(tour_operator()->options[get_post_type()]['disable_entry_text'])) { ?> |
|
34 | 34 | |
35 | - <div <?php lsx_to_entry_class( 'entry-content' ); ?>><?php |
|
35 | + <div <?php lsx_to_entry_class('entry-content'); ?>><?php |
|
36 | 36 | lsx_to_entry_content_top(); |
37 | 37 | the_excerpt(); |
38 | 38 | lsx_to_entry_content_bottom(); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | global $lsx_to_archive, $post; |
10 | 10 | |
11 | 11 | if ( 1 !== $lsx_to_archive ) { |
12 | - $lsx_to_archive = false; |
|
12 | + $lsx_to_archive = false; |
|
13 | 13 | } |
14 | 14 | ?> |
15 | 15 | |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | <?php } elseif ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_text'] ) ) { ?> |
34 | 34 | |
35 | 35 | <div <?php lsx_to_entry_class( 'entry-content' ); ?>><?php |
36 | - lsx_to_entry_content_top(); |
|
37 | - the_excerpt(); |
|
38 | - lsx_to_entry_content_bottom(); |
|
39 | - ?></div> |
|
36 | + lsx_to_entry_content_top(); |
|
37 | + the_excerpt(); |
|
38 | + lsx_to_entry_content_bottom(); |
|
39 | + ?></div> |
|
40 | 40 | |
41 | 41 | <?php } ?> |
42 | 42 |
@@ -13,16 +13,16 @@ |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // If this file is called directly, abort. |
16 | -if ( ! defined( 'WPINC' ) ) { |
|
16 | +if ( ! defined('WPINC')) { |
|
17 | 17 | die; |
18 | 18 | } |
19 | 19 | |
20 | -define('LSX_TO_SPECIALS_PATH', plugin_dir_path( __FILE__ ) ); |
|
21 | -define('LSX_TO_SPECIALS_CORE', __FILE__ ); |
|
22 | -define('LSX_TO_SPECIALS_URL', plugin_dir_url( __FILE__ ) ); |
|
23 | -define('LSX_TO_SPECIALS_VER', '1.3.1' ); |
|
20 | +define('LSX_TO_SPECIALS_PATH', plugin_dir_path(__FILE__)); |
|
21 | +define('LSX_TO_SPECIALS_CORE', __FILE__); |
|
22 | +define('LSX_TO_SPECIALS_URL', plugin_dir_url(__FILE__)); |
|
23 | +define('LSX_TO_SPECIALS_VER', '1.3.1'); |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /* ======================= Below is the Plugin Class init ========================= */ |
27 | 27 | |
28 | -require_once( LSX_TO_SPECIALS_PATH . '/classes/class-to-specials.php' ); |
|
28 | +require_once(LSX_TO_SPECIALS_PATH . '/classes/class-to-specials.php'); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | // If this file is called directly, abort. |
16 | 16 | if ( ! defined( 'WPINC' ) ) { |
17 | - die; |
|
17 | + die; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | define('LSX_TO_SPECIALS_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | * @param array $post_types an array of the post types to redirect. |
32 | 32 | * @param array $taxonomies an array of the taxonomies to redirect. |
33 | 33 | */ |
34 | - public function __construct($plugin_path=false,$post_types=false,$taxonomies=false) { |
|
35 | - if(false !== $plugin_path){ |
|
34 | + public function __construct($plugin_path = false, $post_types = false, $taxonomies = false) { |
|
35 | + if (false !== $plugin_path) { |
|
36 | 36 | $this->plugin_path = $plugin_path; |
37 | 37 | |
38 | - add_filter( 'lsx_to_widget_path', array( $this, 'widget_path'), 10, 2 ); |
|
39 | - add_filter( 'lsx_to_content_path', array( $this, 'content_path'), 10, 3 ); |
|
38 | + add_filter('lsx_to_widget_path', array($this, 'widget_path'), 10, 2); |
|
39 | + add_filter('lsx_to_content_path', array($this, 'content_path'), 10, 3); |
|
40 | 40 | |
41 | - if(false !== $post_types){ |
|
41 | + if (false !== $post_types) { |
|
42 | 42 | $this->post_types = $post_types; |
43 | - add_filter( 'template_include', array( $this, 'post_type_archive_template_include'), 99 ); |
|
44 | - add_filter( 'template_include', array( $this, 'post_type_single_template_include'), 99 ); |
|
45 | - add_filter( 'template_include', array( $this, 'search_template_include'), 99 ); |
|
43 | + add_filter('template_include', array($this, 'post_type_archive_template_include'), 99); |
|
44 | + add_filter('template_include', array($this, 'post_type_single_template_include'), 99); |
|
45 | + add_filter('template_include', array($this, 'search_template_include'), 99); |
|
46 | 46 | } |
47 | - if(false !== $taxonomies){ |
|
47 | + if (false !== $taxonomies) { |
|
48 | 48 | $this->taxonomies = $taxonomies; |
49 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include'), 99 ); |
|
49 | + add_filter('template_include', array($this, 'taxonomy_template_include'), 99); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * @param $template |
58 | 58 | * @return $template |
59 | 59 | */ |
60 | - public function post_type_archive_template_include( $template ) { |
|
60 | + public function post_type_archive_template_include($template) { |
|
61 | 61 | |
62 | - if ( is_main_query() && is_post_type_archive($this->post_types)) { |
|
62 | + if (is_main_query() && is_post_type_archive($this->post_types)) { |
|
63 | 63 | $current_post_type = get_post_type(); |
64 | - if ( '' == locate_template( array( 'archive-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/archive-'.$current_post_type.'.php' )) { |
|
65 | - $template = $this->plugin_path.'templates/archive-'.$current_post_type.'.php'; |
|
64 | + if ('' == locate_template(array('archive-' . $current_post_type . '.php')) && file_exists($this->plugin_path . 'templates/archive-' . $current_post_type . '.php')) { |
|
65 | + $template = $this->plugin_path . 'templates/archive-' . $current_post_type . '.php'; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | return $template; |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | * @return $template |
77 | 77 | */ |
78 | 78 | public function post_type_single_template_include($template) { |
79 | - if ( is_main_query() && is_singular($this->post_types) ) { |
|
79 | + if (is_main_query() && is_singular($this->post_types)) { |
|
80 | 80 | $current_post_type = get_post_type(); |
81 | 81 | |
82 | - if ( '' == locate_template( array( 'single-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/single-'.$current_post_type.'.php') ) { |
|
83 | - $template = $this->plugin_path.'templates/single-'.$current_post_type.'.php'; |
|
82 | + if ('' == locate_template(array('single-' . $current_post_type . '.php')) && file_exists($this->plugin_path . 'templates/single-' . $current_post_type . '.php')) { |
|
83 | + $template = $this->plugin_path . 'templates/single-' . $current_post_type . '.php'; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | return $template; |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function taxonomy_template_include($template) { |
97 | 97 | |
98 | - if ( is_main_query() && is_tax($this->taxonomies) ) { |
|
98 | + if (is_main_query() && is_tax($this->taxonomies)) { |
|
99 | 99 | $current_taxonomy = get_query_var('taxonomy'); |
100 | 100 | |
101 | - if ( '' == locate_template( array( 'taxonomy-'.$current_taxonomy.'.php' ) ) && file_exists( $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php') ) { |
|
102 | - $template = $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php'; |
|
101 | + if ('' == locate_template(array('taxonomy-' . $current_taxonomy . '.php')) && file_exists($this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php')) { |
|
102 | + $template = $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | return $template; |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return $template |
114 | 114 | */ |
115 | - public function search_template_include( $template ) { |
|
115 | + public function search_template_include($template) { |
|
116 | 116 | |
117 | - if ( is_main_query() && is_search() ) { |
|
118 | - if ( file_exists( $this->plugin_path.'templates/search.php' )) { |
|
119 | - $template = $this->plugin_path.'templates/search.php'; |
|
117 | + if (is_main_query() && is_search()) { |
|
118 | + if (file_exists($this->plugin_path . 'templates/search.php')) { |
|
119 | + $template = $this->plugin_path . 'templates/search.php'; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $template; |
@@ -132,26 +132,26 @@ discard block |
||
132 | 132 | public function content_part($slug, $name = null) { |
133 | 133 | $template = array(); |
134 | 134 | $name = (string) $name; |
135 | - if ( '' !== $name ){ |
|
135 | + if ('' !== $name) { |
|
136 | 136 | $template = "{$slug}-{$name}.php"; |
137 | - }else{ |
|
137 | + } else { |
|
138 | 138 | $template = "{$slug}.php"; |
139 | 139 | } |
140 | 140 | $original_name = $template; |
141 | - $path = apply_filters('lsx_to_content_path','',get_post_type()); |
|
141 | + $path = apply_filters('lsx_to_content_path', '', get_post_type()); |
|
142 | 142 | |
143 | - if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
|
144 | - $template = $path.'templates/'.$template; |
|
145 | - }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | - $template = get_stylesheet_directory().'/'.$template; |
|
147 | - }else{ |
|
143 | + if ('' == locate_template(array($template)) && file_exists($path . 'templates/' . $template)) { |
|
144 | + $template = $path . 'templates/' . $template; |
|
145 | + }elseif (file_exists(get_stylesheet_directory() . '/' . $template)) { |
|
146 | + $template = get_stylesheet_directory() . '/' . $template; |
|
147 | + } else { |
|
148 | 148 | $template = false; |
149 | 149 | } |
150 | 150 | |
151 | - if(false !== $template){ |
|
152 | - load_template( $template, false ); |
|
153 | - }else { |
|
154 | - echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
|
151 | + if (false !== $template) { |
|
152 | + load_template($template, false); |
|
153 | + } else { |
|
154 | + echo wp_kses_post('<p>No ' . $original_name . ' can be found.</p>'); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return $path |
165 | 165 | */ |
166 | - public function widget_path($path,$slug) { |
|
167 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
168 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
166 | + public function widget_path($path, $slug) { |
|
167 | + if ((false !== $this->post_types && in_array($slug, $this->post_types)) |
|
168 | + || (false !== $this->taxonomies && in_array($slug, $this->taxonomies)) || 'post' === $slug) { |
|
169 | 169 | $path = $this->plugin_path; |
170 | 170 | } |
171 | 171 | return $path; |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return $path |
181 | 181 | */ |
182 | - public function content_path($path,$slug) { |
|
183 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
184 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
182 | + public function content_path($path, $slug) { |
|
183 | + if ((false !== $this->post_types && in_array($slug, $this->post_types)) |
|
184 | + || (false !== $this->taxonomies && in_array($slug, $this->taxonomies)) || 'post' === $slug) { |
|
185 | 185 | $path = $this->plugin_path; |
186 | 186 | } |
187 | 187 | return $path; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $name = (string) $name; |
135 | 135 | if ( '' !== $name ){ |
136 | 136 | $template = "{$slug}-{$name}.php"; |
137 | - }else{ |
|
137 | + } else{ |
|
138 | 138 | $template = "{$slug}.php"; |
139 | 139 | } |
140 | 140 | $original_name = $template; |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | |
143 | 143 | if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
144 | 144 | $template = $path.'templates/'.$template; |
145 | - }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
145 | + } elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | 146 | $template = get_stylesheet_directory().'/'.$template; |
147 | - }else{ |
|
147 | + } else{ |
|
148 | 148 | $template = false; |
149 | 149 | } |
150 | 150 | |
151 | 151 | if(false !== $template){ |
152 | 152 | load_template( $template, false ); |
153 | - }else { |
|
153 | + } else { |
|
154 | 154 | echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
155 | 155 | } |
156 | 156 | } |
@@ -10,180 +10,180 @@ |
||
10 | 10 | |
11 | 11 | class LSX_TO_Template_Redirects { |
12 | 12 | |
13 | - /** |
|
14 | - * Plugin Path |
|
15 | - */ |
|
16 | - public $plugin_path = false; |
|
13 | + /** |
|
14 | + * Plugin Path |
|
15 | + */ |
|
16 | + public $plugin_path = false; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Post Types |
|
20 | - */ |
|
21 | - public $post_types = false; |
|
18 | + /** |
|
19 | + * Post Types |
|
20 | + */ |
|
21 | + public $post_types = false; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Taxonomies |
|
25 | - */ |
|
26 | - public $taxonomies = false; |
|
23 | + /** |
|
24 | + * Taxonomies |
|
25 | + */ |
|
26 | + public $taxonomies = false; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Initialize the plugin by setting localization, filters, and administration functions. |
|
30 | - * |
|
31 | - * @param array $post_types an array of the post types to redirect. |
|
32 | - * @param array $taxonomies an array of the taxonomies to redirect. |
|
33 | - */ |
|
34 | - public function __construct($plugin_path=false,$post_types=false,$taxonomies=false) { |
|
35 | - if(false !== $plugin_path){ |
|
36 | - $this->plugin_path = $plugin_path; |
|
28 | + /** |
|
29 | + * Initialize the plugin by setting localization, filters, and administration functions. |
|
30 | + * |
|
31 | + * @param array $post_types an array of the post types to redirect. |
|
32 | + * @param array $taxonomies an array of the taxonomies to redirect. |
|
33 | + */ |
|
34 | + public function __construct($plugin_path=false,$post_types=false,$taxonomies=false) { |
|
35 | + if(false !== $plugin_path){ |
|
36 | + $this->plugin_path = $plugin_path; |
|
37 | 37 | |
38 | - add_filter( 'lsx_to_widget_path', array( $this, 'widget_path'), 10, 2 ); |
|
39 | - add_filter( 'lsx_to_content_path', array( $this, 'content_path'), 10, 3 ); |
|
38 | + add_filter( 'lsx_to_widget_path', array( $this, 'widget_path'), 10, 2 ); |
|
39 | + add_filter( 'lsx_to_content_path', array( $this, 'content_path'), 10, 3 ); |
|
40 | 40 | |
41 | - if(false !== $post_types){ |
|
42 | - $this->post_types = $post_types; |
|
43 | - add_filter( 'template_include', array( $this, 'post_type_archive_template_include'), 99 ); |
|
44 | - add_filter( 'template_include', array( $this, 'post_type_single_template_include'), 99 ); |
|
45 | - add_filter( 'template_include', array( $this, 'search_template_include'), 99 ); |
|
46 | - } |
|
47 | - if(false !== $taxonomies){ |
|
48 | - $this->taxonomies = $taxonomies; |
|
49 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include'), 99 ); |
|
50 | - } |
|
51 | - } |
|
52 | - } |
|
41 | + if(false !== $post_types){ |
|
42 | + $this->post_types = $post_types; |
|
43 | + add_filter( 'template_include', array( $this, 'post_type_archive_template_include'), 99 ); |
|
44 | + add_filter( 'template_include', array( $this, 'post_type_single_template_include'), 99 ); |
|
45 | + add_filter( 'template_include', array( $this, 'search_template_include'), 99 ); |
|
46 | + } |
|
47 | + if(false !== $taxonomies){ |
|
48 | + $this->taxonomies = $taxonomies; |
|
49 | + add_filter( 'template_include', array( $this, 'taxonomy_template_include'), 99 ); |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Redirect wordpress to the archive template located in the plugin |
|
56 | - * |
|
57 | - * @param $template |
|
58 | - * @return $template |
|
59 | - */ |
|
60 | - public function post_type_archive_template_include( $template ) { |
|
54 | + /** |
|
55 | + * Redirect wordpress to the archive template located in the plugin |
|
56 | + * |
|
57 | + * @param $template |
|
58 | + * @return $template |
|
59 | + */ |
|
60 | + public function post_type_archive_template_include( $template ) { |
|
61 | 61 | |
62 | - if ( is_main_query() && is_post_type_archive($this->post_types)) { |
|
63 | - $current_post_type = get_post_type(); |
|
64 | - if ( '' == locate_template( array( 'archive-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/archive-'.$current_post_type.'.php' )) { |
|
65 | - $template = $this->plugin_path.'templates/archive-'.$current_post_type.'.php'; |
|
66 | - } |
|
67 | - } |
|
68 | - return $template; |
|
69 | - } |
|
62 | + if ( is_main_query() && is_post_type_archive($this->post_types)) { |
|
63 | + $current_post_type = get_post_type(); |
|
64 | + if ( '' == locate_template( array( 'archive-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/archive-'.$current_post_type.'.php' )) { |
|
65 | + $template = $this->plugin_path.'templates/archive-'.$current_post_type.'.php'; |
|
66 | + } |
|
67 | + } |
|
68 | + return $template; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Redirect wordpress to the single template located in the plugin |
|
73 | - * |
|
74 | - * @param $template |
|
75 | - * |
|
76 | - * @return $template |
|
77 | - */ |
|
78 | - public function post_type_single_template_include($template) { |
|
79 | - if ( is_main_query() && is_singular($this->post_types) ) { |
|
80 | - $current_post_type = get_post_type(); |
|
71 | + /** |
|
72 | + * Redirect wordpress to the single template located in the plugin |
|
73 | + * |
|
74 | + * @param $template |
|
75 | + * |
|
76 | + * @return $template |
|
77 | + */ |
|
78 | + public function post_type_single_template_include($template) { |
|
79 | + if ( is_main_query() && is_singular($this->post_types) ) { |
|
80 | + $current_post_type = get_post_type(); |
|
81 | 81 | |
82 | - if ( '' == locate_template( array( 'single-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/single-'.$current_post_type.'.php') ) { |
|
83 | - $template = $this->plugin_path.'templates/single-'.$current_post_type.'.php'; |
|
84 | - } |
|
85 | - } |
|
86 | - return $template; |
|
87 | - } |
|
82 | + if ( '' == locate_template( array( 'single-'.$current_post_type.'.php' ) ) && file_exists( $this->plugin_path.'templates/single-'.$current_post_type.'.php') ) { |
|
83 | + $template = $this->plugin_path.'templates/single-'.$current_post_type.'.php'; |
|
84 | + } |
|
85 | + } |
|
86 | + return $template; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Redirect wordpress to the taxonomy located in the plugin |
|
91 | - * |
|
92 | - * @param $template |
|
93 | - * |
|
94 | - * @return $template |
|
95 | - */ |
|
96 | - public function taxonomy_template_include($template) { |
|
89 | + /** |
|
90 | + * Redirect wordpress to the taxonomy located in the plugin |
|
91 | + * |
|
92 | + * @param $template |
|
93 | + * |
|
94 | + * @return $template |
|
95 | + */ |
|
96 | + public function taxonomy_template_include($template) { |
|
97 | 97 | |
98 | - if ( is_main_query() && is_tax($this->taxonomies) ) { |
|
99 | - $current_taxonomy = get_query_var('taxonomy'); |
|
98 | + if ( is_main_query() && is_tax($this->taxonomies) ) { |
|
99 | + $current_taxonomy = get_query_var('taxonomy'); |
|
100 | 100 | |
101 | - if ( '' == locate_template( array( 'taxonomy-'.$current_taxonomy.'.php' ) ) && file_exists( $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php') ) { |
|
102 | - $template = $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php'; |
|
103 | - } |
|
104 | - } |
|
105 | - return $template; |
|
106 | - } |
|
101 | + if ( '' == locate_template( array( 'taxonomy-'.$current_taxonomy.'.php' ) ) && file_exists( $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php') ) { |
|
102 | + $template = $this->plugin_path.'templates/taxonomy-'.$current_taxonomy.'.php'; |
|
103 | + } |
|
104 | + } |
|
105 | + return $template; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Redirect wordpress to the search template located in the plugin |
|
110 | - * |
|
111 | - * @param $template |
|
112 | - * |
|
113 | - * @return $template |
|
114 | - */ |
|
115 | - public function search_template_include( $template ) { |
|
108 | + /** |
|
109 | + * Redirect wordpress to the search template located in the plugin |
|
110 | + * |
|
111 | + * @param $template |
|
112 | + * |
|
113 | + * @return $template |
|
114 | + */ |
|
115 | + public function search_template_include( $template ) { |
|
116 | 116 | |
117 | - if ( is_main_query() && is_search() ) { |
|
118 | - if ( file_exists( $this->plugin_path.'templates/search.php' )) { |
|
119 | - $template = $this->plugin_path.'templates/search.php'; |
|
120 | - } |
|
121 | - } |
|
122 | - return $template; |
|
123 | - } |
|
117 | + if ( is_main_query() && is_search() ) { |
|
118 | + if ( file_exists( $this->plugin_path.'templates/search.php' )) { |
|
119 | + $template = $this->plugin_path.'templates/search.php'; |
|
120 | + } |
|
121 | + } |
|
122 | + return $template; |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Redirect wordpress to the single template located in the plugin |
|
127 | - * |
|
128 | - * @param $template |
|
129 | - * |
|
130 | - * @return $template |
|
131 | - */ |
|
132 | - public function content_part($slug, $name = null) { |
|
133 | - $template = array(); |
|
134 | - $name = (string) $name; |
|
135 | - if ( '' !== $name ){ |
|
136 | - $template = "{$slug}-{$name}.php"; |
|
137 | - }else{ |
|
138 | - $template = "{$slug}.php"; |
|
139 | - } |
|
140 | - $original_name = $template; |
|
141 | - $path = apply_filters('lsx_to_content_path','',get_post_type()); |
|
125 | + /** |
|
126 | + * Redirect wordpress to the single template located in the plugin |
|
127 | + * |
|
128 | + * @param $template |
|
129 | + * |
|
130 | + * @return $template |
|
131 | + */ |
|
132 | + public function content_part($slug, $name = null) { |
|
133 | + $template = array(); |
|
134 | + $name = (string) $name; |
|
135 | + if ( '' !== $name ){ |
|
136 | + $template = "{$slug}-{$name}.php"; |
|
137 | + }else{ |
|
138 | + $template = "{$slug}.php"; |
|
139 | + } |
|
140 | + $original_name = $template; |
|
141 | + $path = apply_filters('lsx_to_content_path','',get_post_type()); |
|
142 | 142 | |
143 | - if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
|
144 | - $template = $path.'templates/'.$template; |
|
145 | - }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | - $template = get_stylesheet_directory().'/'.$template; |
|
147 | - }else{ |
|
148 | - $template = false; |
|
149 | - } |
|
143 | + if ( '' == locate_template( array( $template ) ) && file_exists( $path.'templates/'.$template) ) { |
|
144 | + $template = $path.'templates/'.$template; |
|
145 | + }elseif(file_exists( get_stylesheet_directory().'/'.$template)){ |
|
146 | + $template = get_stylesheet_directory().'/'.$template; |
|
147 | + }else{ |
|
148 | + $template = false; |
|
149 | + } |
|
150 | 150 | |
151 | - if(false !== $template){ |
|
152 | - load_template( $template, false ); |
|
153 | - }else { |
|
154 | - echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
|
155 | - } |
|
156 | - } |
|
151 | + if(false !== $template){ |
|
152 | + load_template( $template, false ); |
|
153 | + }else { |
|
154 | + echo wp_kses_post('<p>No '.$original_name.' can be found.</p>'); |
|
155 | + } |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Redirect wordpress to the widget template located in the plugin |
|
160 | - * |
|
161 | - * @param $path |
|
162 | - * @param $post_type |
|
163 | - * |
|
164 | - * @return $path |
|
165 | - */ |
|
166 | - public function widget_path($path,$slug) { |
|
167 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
168 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
169 | - $path = $this->plugin_path; |
|
170 | - } |
|
171 | - return $path; |
|
172 | - } |
|
158 | + /** |
|
159 | + * Redirect wordpress to the widget template located in the plugin |
|
160 | + * |
|
161 | + * @param $path |
|
162 | + * @param $post_type |
|
163 | + * |
|
164 | + * @return $path |
|
165 | + */ |
|
166 | + public function widget_path($path,$slug) { |
|
167 | + if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
168 | + || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
169 | + $path = $this->plugin_path; |
|
170 | + } |
|
171 | + return $path; |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * Redirect wordpress to the single template located in the plugin |
|
176 | - * |
|
177 | - * @param $path |
|
178 | - * @param $post_type |
|
179 | - * |
|
180 | - * @return $path |
|
181 | - */ |
|
182 | - public function content_path($path,$slug) { |
|
183 | - if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
184 | - || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
185 | - $path = $this->plugin_path; |
|
186 | - } |
|
187 | - return $path; |
|
188 | - } |
|
174 | + /** |
|
175 | + * Redirect wordpress to the single template located in the plugin |
|
176 | + * |
|
177 | + * @param $path |
|
178 | + * @param $post_type |
|
179 | + * |
|
180 | + * @return $path |
|
181 | + */ |
|
182 | + public function content_path($path,$slug) { |
|
183 | + if((false !== $this->post_types && in_array($slug,$this->post_types)) |
|
184 | + || (false !== $this->taxonomies && in_array($slug,$this->taxonomies)) || 'post' === $slug){ |
|
185 | + $path = $this->plugin_path; |
|
186 | + } |
|
187 | + return $path; |
|
188 | + } |
|
189 | 189 | } |
190 | 190 | \ No newline at end of file |
@@ -31,48 +31,48 @@ discard block |
||
31 | 31 | public function __construct() { |
32 | 32 | $this->set_vars(); |
33 | 33 | |
34 | - add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
|
35 | - add_action( 'lsx_to_settings_current_tab', array( $this, 'set_settings_current_tab' ) ); |
|
36 | - add_action( 'init', array( $this, 'init' ) ); |
|
34 | + add_filter('lsx_to_entry_class', array($this, 'entry_class')); |
|
35 | + add_action('lsx_to_settings_current_tab', array($this, 'set_settings_current_tab')); |
|
36 | + add_action('init', array($this, 'init')); |
|
37 | 37 | |
38 | - if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
|
39 | - require_once( LSX_TO_SPECIALS_PATH . 'classes/class-template-redirects.php' ); |
|
38 | + if ( ! class_exists('LSX_TO_Template_Redirects')) { |
|
39 | + require_once(LSX_TO_SPECIALS_PATH . 'classes/class-template-redirects.php'); |
|
40 | 40 | } |
41 | 41 | |
42 | - $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_SPECIALS_PATH, array_keys( $this->post_types ), array_keys( $this->taxonomies ) ); |
|
42 | + $this->redirects = new LSX_TO_Template_Redirects(LSX_TO_SPECIALS_PATH, array_keys($this->post_types), array_keys($this->taxonomies)); |
|
43 | 43 | |
44 | - add_action( 'lsx_special_content', array( $this->redirects, 'content_part' ), 10 , 2 ); |
|
44 | + add_action('lsx_special_content', array($this->redirects, 'content_part'), 10, 2); |
|
45 | 45 | |
46 | - add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
|
46 | + add_filter('lsx_to_page_navigation', array($this, 'page_links')); |
|
47 | 47 | |
48 | - add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
|
49 | - add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
|
50 | - add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
|
51 | - add_action( 'lsx_to_fast_facts', array( $this, 'single_fast_facts' ) ); |
|
48 | + add_action('lsx_entry_top', array($this, 'archive_entry_top'), 15); |
|
49 | + add_action('lsx_entry_bottom', array($this, 'archive_entry_bottom')); |
|
50 | + add_action('lsx_content_bottom', array($this, 'single_content_bottom')); |
|
51 | + add_action('lsx_to_fast_facts', array($this, 'single_fast_facts')); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Runs on init after all files have been parsed. |
56 | 56 | */ |
57 | 57 | public function init() { |
58 | - if ( ! class_exists( 'LSX_Currencies' ) ) { |
|
59 | - add_filter( 'lsx_to_custom_field_query', array( $this, 'price_filter' ), 5, 10 ); |
|
58 | + if ( ! class_exists('LSX_Currencies')) { |
|
59 | + add_filter('lsx_to_custom_field_query', array($this, 'price_filter'), 5, 10); |
|
60 | 60 | } |
61 | 61 | |
62 | - add_filter( 'lsx_to_custom_field_query', array( $this, 'terms_conditions_filter' ), 5, 10 ); |
|
62 | + add_filter('lsx_to_custom_field_query', array($this, 'terms_conditions_filter'), 5, 10); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * A filter to set the content area to a small column on single |
67 | 67 | */ |
68 | - public function entry_class( $classes ) { |
|
68 | + public function entry_class($classes) { |
|
69 | 69 | global $lsx_to_archive; |
70 | 70 | |
71 | - if ( 1 !== $lsx_to_archive ) { |
|
71 | + if (1 !== $lsx_to_archive) { |
|
72 | 72 | $lsx_to_archive = false; |
73 | 73 | } |
74 | 74 | |
75 | - if ( is_main_query() && is_singular( 'special' ) && false === $lsx_to_archive ) { |
|
75 | + if (is_main_query() && is_singular('special') && false === $lsx_to_archive) { |
|
76 | 76 | $classes[] = 'col-xs-12 col-sm-12 col-md-6'; |
77 | 77 | } |
78 | 78 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * Sets the current tab selected. |
84 | 84 | */ |
85 | - public function set_settings_current_tab( $settings_tab ) { |
|
86 | - if ( is_tax( array_keys( $this->taxonomies ) ) ) { |
|
87 | - $taxonomy = get_query_var( 'taxonomy' ); |
|
85 | + public function set_settings_current_tab($settings_tab) { |
|
86 | + if (is_tax(array_keys($this->taxonomies))) { |
|
87 | + $taxonomy = get_query_var('taxonomy'); |
|
88 | 88 | |
89 | - if ( 'special-type' === $taxonomy ) { |
|
89 | + if ('special-type' === $taxonomy) { |
|
90 | 90 | $settings_tab = 'special'; |
91 | 91 | } |
92 | 92 | } |
@@ -97,35 +97,35 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * Adds in additional info for the price custom field |
99 | 99 | */ |
100 | - public function price_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { |
|
101 | - if ( get_post_type() === 'special' && 'price' === $meta_key ) { |
|
102 | - $price_type = get_post_meta( get_the_ID(), 'price_type', true ); |
|
103 | - $value = preg_replace( '/[^0-9,.]/', '', $value ); |
|
104 | - $value = ltrim( $value, '.' ); |
|
105 | - $value = str_replace( ', ', '', $value ); |
|
106 | - $value = number_format( (int) $value, 2 ); |
|
100 | + public function price_filter($html = '', $meta_key = false, $value = false, $before = '', $after = '') { |
|
101 | + if (get_post_type() === 'special' && 'price' === $meta_key) { |
|
102 | + $price_type = get_post_meta(get_the_ID(), 'price_type', true); |
|
103 | + $value = preg_replace('/[^0-9,.]/', '', $value); |
|
104 | + $value = ltrim($value, '.'); |
|
105 | + $value = str_replace(', ', '', $value); |
|
106 | + $value = number_format((int) $value, 2); |
|
107 | 107 | $tour_operator = tour_operator(); |
108 | 108 | $currency = ''; |
109 | 109 | |
110 | - if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
|
111 | - if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
|
110 | + if (is_object($tour_operator) && isset($tour_operator->options['general']) && is_array($tour_operator->options['general'])) { |
|
111 | + if (isset($tour_operator->options['general']['currency']) && ! empty($tour_operator->options['general']['currency'])) { |
|
112 | 112 | $currency = $tour_operator->options['general']['currency']; |
113 | - $currency = '<span class="currency-icon ' . mb_strtolower( $currency ) . '">' . $currency . '</span>'; |
|
113 | + $currency = '<span class="currency-icon ' . mb_strtolower($currency) . '">' . $currency . '</span>'; |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - switch ( $price_type ) { |
|
117 | + switch ($price_type) { |
|
118 | 118 | case 'per_person': |
119 | 119 | case 'per_person_per_night': |
120 | 120 | case 'per_person_sharing': |
121 | 121 | case 'per_person_sharing_per_night': |
122 | - $value = $currency . $value . ' ' . ucwords( str_replace( '_', ' ', $price_type ) ) . ''; |
|
123 | - $value = str_replace( 'Per Person', 'P/P', $value ); |
|
122 | + $value = $currency . $value . ' ' . ucwords(str_replace('_', ' ', $price_type)) . ''; |
|
123 | + $value = str_replace('Per Person', 'P/P', $value); |
|
124 | 124 | break; |
125 | 125 | |
126 | 126 | case 'total_percentage': |
127 | - $value .= '% ' . __( 'Off', 'to-specials' ) . ''; |
|
128 | - $before = str_replace( 'from price', '', $before ); |
|
127 | + $value .= '% ' . __('Off', 'to-specials') . ''; |
|
128 | + $before = str_replace('from price', '', $before); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case 'none': |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | /** |
144 | 144 | * Filters text area type filters |
145 | 145 | */ |
146 | - public function terms_conditions_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { |
|
147 | - if ( get_post_type() === 'special' && 'terms_conditions' === $meta_key ) { |
|
148 | - $html = $before . '<div class="entry-content">' . apply_filters( 'the_content', wpautop( $value ) ) . '</div>' . $after; |
|
146 | + public function terms_conditions_filter($html = '', $meta_key = false, $value = false, $before = '', $after = '') { |
|
147 | + if (get_post_type() === 'special' && 'terms_conditions' === $meta_key) { |
|
148 | + $html = $before . '<div class="entry-content">' . apply_filters('the_content', wpautop($value)) . '</div>' . $after; |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param $page_links array |
159 | 159 | * @return $page_links array |
160 | 160 | */ |
161 | - public function page_links( $page_links ) { |
|
162 | - if ( is_singular( 'special' ) ) { |
|
161 | + public function page_links($page_links) { |
|
162 | + if (is_singular('special')) { |
|
163 | 163 | $this->page_links = $page_links; |
164 | 164 | |
165 | 165 | $this->get_map_link(); |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | * Tests for the Google Map and returns a link for the section |
180 | 180 | */ |
181 | 181 | public function get_map_link() { |
182 | - if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) { |
|
183 | - $this->page_links['special-map'] = esc_html__( 'Map', 'to-specials' ); |
|
182 | + if (function_exists('lsx_to_has_map') && lsx_to_has_map()) { |
|
183 | + $this->page_links['special-map'] = esc_html__('Map', 'to-specials'); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -188,22 +188,22 @@ discard block |
||
188 | 188 | * Tests for the Gallery and returns a link for the section |
189 | 189 | */ |
190 | 190 | public function get_gallery_link() { |
191 | - $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
|
192 | - $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
|
191 | + $gallery_ids = get_post_meta(get_the_ID(), 'gallery', false); |
|
192 | + $envira_gallery = get_post_meta(get_the_ID(), 'envira_gallery', true); |
|
193 | 193 | |
194 | - if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
|
195 | - if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
|
194 | + if (( ! empty($gallery_ids) && is_array($gallery_ids)) || (function_exists('envira_gallery') && ! empty($envira_gallery) && false === lsx_to_enable_envira_banner())) { |
|
195 | + if (function_exists('envira_gallery') && ! empty($envira_gallery) && false === lsx_to_enable_envira_banner()) { |
|
196 | 196 | // Envira Gallery |
197 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
197 | + $this->page_links['gallery'] = esc_html__('Gallery', 'to-specials'); |
|
198 | 198 | return; |
199 | 199 | } else { |
200 | - if ( function_exists( 'envira_dynamic' ) ) { |
|
200 | + if (function_exists('envira_dynamic')) { |
|
201 | 201 | // Envira Gallery - Dynamic |
202 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
202 | + $this->page_links['gallery'] = esc_html__('Gallery', 'to-specials'); |
|
203 | 203 | return; |
204 | 204 | } else { |
205 | 205 | // WordPress Gallery |
206 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
206 | + $this->page_links['gallery'] = esc_html__('Gallery', 'to-specials'); |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | } |
@@ -216,16 +216,16 @@ discard block |
||
216 | 216 | public function get_videos_link() { |
217 | 217 | $videos_id = false; |
218 | 218 | |
219 | - if ( class_exists( 'Envira_Videos' ) ) { |
|
220 | - $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
|
219 | + if (class_exists('Envira_Videos')) { |
|
220 | + $videos_id = get_post_meta(get_the_ID(), 'envira_video', true); |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
|
224 | - $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
|
223 | + if (empty($videos_id) && function_exists('lsx_to_videos')) { |
|
224 | + $videos_id = get_post_meta(get_the_ID(), 'videos', true); |
|
225 | 225 | } |
226 | 226 | |
227 | - if ( ! empty( $videos_id ) ) { |
|
228 | - $this->page_links['videos'] = esc_html__( 'Videos', 'to-specials' ); |
|
227 | + if ( ! empty($videos_id)) { |
|
228 | + $this->page_links['videos'] = esc_html__('Videos', 'to-specials'); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -233,22 +233,22 @@ discard block |
||
233 | 233 | * Tests for the Related Posts and returns a link for the section |
234 | 234 | */ |
235 | 235 | public function get_related_posts_link() { |
236 | - $connected_posts = get_post_meta( get_the_ID(), 'post_to_special', false ); |
|
236 | + $connected_posts = get_post_meta(get_the_ID(), 'post_to_special', false); |
|
237 | 237 | |
238 | - if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) { |
|
239 | - $connected_posts = new \WP_Query( array( |
|
238 | + if (is_array($connected_posts) && ! empty($connected_posts)) { |
|
239 | + $connected_posts = new \WP_Query(array( |
|
240 | 240 | 'post_type' => 'post', |
241 | 241 | 'post__in' => $connected_posts, |
242 | 242 | 'post_status' => 'publish', |
243 | 243 | 'nopagin' => true, |
244 | 244 | 'posts_per_page' => '-1', |
245 | 245 | 'fields' => 'ids', |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | |
248 | 248 | $connected_posts = $connected_posts->posts; |
249 | 249 | |
250 | - if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) { |
|
251 | - $this->page_links['posts'] = esc_html__( 'Posts', 'to-specials' ); |
|
250 | + if (is_array($connected_posts) && ! empty($connected_posts)) { |
|
251 | + $this->page_links['posts'] = esc_html__('Posts', 'to-specials'); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * Tests for the Term and Conditions and returns a link for the section |
258 | 258 | */ |
259 | 259 | public function get_terms_and_conditions_link() { |
260 | - $terms_conditions = get_post_meta( get_the_ID(), 'terms_conditions', true ); |
|
260 | + $terms_conditions = get_post_meta(get_the_ID(), 'terms_conditions', true); |
|
261 | 261 | |
262 | - if ( ! empty( $terms_conditions ) ) { |
|
263 | - $this->page_links['terms-and-conditions'] = esc_html__( 'Terms and Conditions', 'to-specials' ); |
|
262 | + if ( ! empty($terms_conditions)) { |
|
263 | + $this->page_links['terms-and-conditions'] = esc_html__('Terms and Conditions', 'to-specials'); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
@@ -270,23 +270,23 @@ discard block |
||
270 | 270 | public function archive_entry_top() { |
271 | 271 | global $lsx_to_archive; |
272 | 272 | |
273 | - if ( 'special' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
|
274 | - if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
|
273 | + if ('special' === get_post_type() && (is_archive() || $lsx_to_archive)) { |
|
274 | + if (is_search() || empty(tour_operator()->options[get_post_type()]['disable_entry_metadata'])) { ?> |
|
275 | 275 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-grid-mode"> |
276 | 276 | <?php |
277 | 277 | $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
278 | 278 | |
279 | - lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
280 | - lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
281 | - lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
282 | - the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
283 | - the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
284 | - lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
285 | - lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
286 | - lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
287 | - |
|
288 | - if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
289 | - lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
279 | + lsx_to_price('<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__('From price', 'to-specials') . ':</span> ', '</span>'); |
|
280 | + lsx_to_connected_tours('<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __('Tours', 'to-specials') . ':</span> ', '</span>'); |
|
281 | + lsx_to_connected_accommodation('<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __('Accommodation', 'to-specials') . ':</span> ', '</span>'); |
|
282 | + the_terms(get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __('Travel Style', 'to-specials') . ':</span> ', ', ', '</span>'); |
|
283 | + the_terms(get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __('Type', 'to-specials') . ':</span> ', ', ', '</span>'); |
|
284 | + lsx_to_connected_destinations('<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __('Destinations', 'to-specials') . ':</span> ', '</span>'); |
|
285 | + lsx_to_specials_validity('<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __('Booking Validity', 'to-specials') . ':</span> ', '</span>'); |
|
286 | + lsx_to_travel_dates('<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __('Travel Dates', 'to-specials') . ':</span> ', '</span>'); |
|
287 | + |
|
288 | + if (function_exists('lsx_to_connected_activities')) { |
|
289 | + lsx_to_connected_activities('<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __('Activites', 'to-specials') . ':</span> ', '</span>'); |
|
290 | 290 | } |
291 | 291 | ?> |
292 | 292 | </div> |
@@ -300,25 +300,25 @@ discard block |
||
300 | 300 | public function archive_entry_bottom() { |
301 | 301 | global $lsx_to_archive; |
302 | 302 | |
303 | - if ( 'special' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { ?> |
|
303 | + if ('special' === get_post_type() && (is_archive() || $lsx_to_archive)) { ?> |
|
304 | 304 | </div> |
305 | 305 | |
306 | - <?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
|
306 | + <?php if (is_search() || empty(tour_operator()->options[get_post_type()]['disable_entry_metadata'])) { ?> |
|
307 | 307 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-list-mode"> |
308 | 308 | <?php |
309 | 309 | $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
310 | 310 | |
311 | - lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
312 | - lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
313 | - lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
314 | - the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
315 | - the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
316 | - lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
317 | - lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
318 | - lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
319 | - |
|
320 | - if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
321 | - lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
311 | + lsx_to_price('<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__('From price', 'to-specials') . ':</span> ', '</span>'); |
|
312 | + lsx_to_connected_tours('<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __('Tours', 'to-specials') . ':</span> ', '</span>'); |
|
313 | + lsx_to_connected_accommodation('<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __('Accommodation', 'to-specials') . ':</span> ', '</span>'); |
|
314 | + the_terms(get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __('Travel Style', 'to-specials') . ':</span> ', ', ', '</span>'); |
|
315 | + the_terms(get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __('Type', 'to-specials') . ':</span> ', ', ', '</span>'); |
|
316 | + lsx_to_connected_destinations('<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __('Destinations', 'to-specials') . ':</span> ', '</span>'); |
|
317 | + lsx_to_specials_validity('<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __('Booking Validity', 'to-specials') . ':</span> ', '</span>'); |
|
318 | + lsx_to_travel_dates('<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __('Travel Dates', 'to-specials') . ':</span> ', '</span>'); |
|
319 | + |
|
320 | + if (function_exists('lsx_to_connected_activities')) { |
|
321 | + lsx_to_connected_activities('<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __('Activites', 'to-specials') . ':</span> ', '</span>'); |
|
322 | 322 | } |
323 | 323 | ?> |
324 | 324 | </div> |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | |
328 | 328 | <?php $has_single = ! lsx_to_is_single_disabled(); ?> |
329 | 329 | |
330 | - <?php if ( $has_single && 'grid' === tour_operator()->archive_layout ) : ?> |
|
331 | - <a href="<?php the_permalink(); ?>" class="moretag"><?php esc_html_e( 'View more', 'to-specials' ); ?></a> |
|
330 | + <?php if ($has_single && 'grid' === tour_operator()->archive_layout) : ?> |
|
331 | + <a href="<?php the_permalink(); ?>" class="moretag"><?php esc_html_e('View more', 'to-specials'); ?></a> |
|
332 | 332 | <?php endif; ?> |
333 | 333 | <?php } |
334 | 334 | } |
@@ -337,26 +337,26 @@ discard block |
||
337 | 337 | * Adds the template tags fast facts |
338 | 338 | */ |
339 | 339 | public function single_fast_facts() { |
340 | - if ( is_singular( 'special' ) ) { ?> |
|
340 | + if (is_singular('special')) { ?> |
|
341 | 341 | <section id="fast-facts"> |
342 | 342 | <div class="lsx-to-section-inner"> |
343 | - <h3 class="lsx-to-section-title"><?php esc_html_e( 'Special Summary', 'to-specials' ); ?></h3> |
|
343 | + <h3 class="lsx-to-section-title"><?php esc_html_e('Special Summary', 'to-specials'); ?></h3> |
|
344 | 344 | |
345 | 345 | <div class="lsx-to-single-meta-data"> |
346 | 346 | <?php |
347 | 347 | $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
348 | 348 | |
349 | 349 | // lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
350 | - lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . esc_html__( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
351 | - lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . esc_html__( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
352 | - the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . esc_html__( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
353 | - the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . esc_html__( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
354 | - lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . esc_html__( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
355 | - lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
356 | - lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
357 | - |
|
358 | - if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
359 | - lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . esc_html__( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
350 | + lsx_to_specials_validity('<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . esc_html__('Booking Validity', 'to-specials') . ':</span> ', '</span>'); |
|
351 | + lsx_to_travel_dates('<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . esc_html__('Travel Dates', 'to-specials') . ':</span> ', '</span>'); |
|
352 | + the_terms(get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . esc_html__('Travel Style', 'to-specials') . ':</span> ', ', ', '</span>'); |
|
353 | + the_terms(get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . esc_html__('Type', 'to-specials') . ':</span> ', ', ', '</span>'); |
|
354 | + lsx_to_connected_tours('<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . esc_html__('Tours', 'to-specials') . ':</span> ', '</span>'); |
|
355 | + lsx_to_connected_accommodation('<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . esc_html__('Accommodation', 'to-specials') . ':</span> ', '</span>'); |
|
356 | + lsx_to_connected_destinations('<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . esc_html__('Destinations', 'to-specials') . ':</span> ', '</span>'); |
|
357 | + |
|
358 | + if (function_exists('lsx_to_connected_activities')) { |
|
359 | + lsx_to_connected_activities('<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . esc_html__('Activites', 'to-specials') . ':</span> ', '</span>'); |
|
360 | 360 | } |
361 | 361 | ?> |
362 | 362 | </div> |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | * Adds the template tags to the bottom of the single special |
370 | 370 | */ |
371 | 371 | public function single_content_bottom() { |
372 | - if ( is_singular( 'special' ) ) { |
|
373 | - if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) : ?> |
|
372 | + if (is_singular('special')) { |
|
373 | + if (function_exists('lsx_to_has_map') && lsx_to_has_map()) : ?> |
|
374 | 374 | <section id="special-map" class="lsx-to-section lsx-to-collapse-section"> |
375 | - <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title hidden-lg" data-toggle="collapse" data-target="#collapse-special-map"><?php esc_html_e( 'Map', 'to-specials' ); ?></h2> |
|
375 | + <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title hidden-lg" data-toggle="collapse" data-target="#collapse-special-map"><?php esc_html_e('Map', 'to-specials'); ?></h2> |
|
376 | 376 | |
377 | 377 | <div id="collapse-special-map" class="collapse in"> |
378 | 378 | <div class="collapse-inner"> |
@@ -383,19 +383,19 @@ discard block |
||
383 | 383 | <?php |
384 | 384 | endif; |
385 | 385 | |
386 | - 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-specials' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
386 | + 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-specials') . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>'); |
|
387 | 387 | |
388 | - if ( function_exists( 'lsx_to_videos' ) ) { |
|
389 | - 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-specials' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
390 | - } elseif ( class_exists( 'Envira_Videos' ) ) { |
|
391 | - 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-specials' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
388 | + if (function_exists('lsx_to_videos')) { |
|
389 | + 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-specials') . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>'); |
|
390 | + } elseif (class_exists('Envira_Videos')) { |
|
391 | + 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-specials') . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>'); |
|
392 | 392 | } |
393 | 393 | |
394 | - $terms_conditions = get_post_meta( get_the_ID(), 'terms_conditions', true ); |
|
394 | + $terms_conditions = get_post_meta(get_the_ID(), 'terms_conditions', true); |
|
395 | 395 | |
396 | - if ( false !== $terms_conditions && '' !== $terms_conditions ) { ?> |
|
396 | + if (false !== $terms_conditions && '' !== $terms_conditions) { ?> |
|
397 | 397 | <section id="terms-and-conditions" class="lsx-to-section lsx-to-collapse-section"> |
398 | - <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-terms-and-conditions"><?php esc_html_e( 'Terms and Conditions', 'to-specials' ); ?></h2> |
|
398 | + <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-terms-and-conditions"><?php esc_html_e('Terms and Conditions', 'to-specials'); ?></h2> |
|
399 | 399 | |
400 | 400 | <div id="collapse-terms-and-conditions" class="collapse in"> |
401 | 401 | <div class="collapse-inner"> |
@@ -18,309 +18,309 @@ discard block |
||
18 | 18 | |
19 | 19 | class LSX_TO_Specials_Frontend extends LSX_TO_Specials { |
20 | 20 | |
21 | - /** |
|
22 | - * Holds the $page_links array while its being built on the single special page. |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - public $page_links = false; |
|
27 | - |
|
28 | - /** |
|
29 | - * Constructor |
|
30 | - */ |
|
31 | - public function __construct() { |
|
32 | - $this->set_vars(); |
|
33 | - |
|
34 | - add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
|
35 | - add_action( 'lsx_to_settings_current_tab', array( $this, 'set_settings_current_tab' ) ); |
|
36 | - add_action( 'init', array( $this, 'init' ) ); |
|
37 | - |
|
38 | - if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
|
39 | - require_once( LSX_TO_SPECIALS_PATH . 'classes/class-template-redirects.php' ); |
|
40 | - } |
|
41 | - |
|
42 | - $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_SPECIALS_PATH, array_keys( $this->post_types ), array_keys( $this->taxonomies ) ); |
|
43 | - |
|
44 | - add_action( 'lsx_special_content', array( $this->redirects, 'content_part' ), 10 , 2 ); |
|
45 | - |
|
46 | - add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
|
47 | - |
|
48 | - add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
|
49 | - add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
|
50 | - add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
|
51 | - add_action( 'lsx_to_fast_facts', array( $this, 'single_fast_facts' ) ); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Runs on init after all files have been parsed. |
|
56 | - */ |
|
57 | - public function init() { |
|
58 | - if ( ! class_exists( 'LSX_Currencies' ) ) { |
|
59 | - add_filter( 'lsx_to_custom_field_query', array( $this, 'price_filter' ), 5, 10 ); |
|
60 | - } |
|
61 | - |
|
62 | - add_filter( 'lsx_to_custom_field_query', array( $this, 'terms_conditions_filter' ), 5, 10 ); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * A filter to set the content area to a small column on single |
|
67 | - */ |
|
68 | - public function entry_class( $classes ) { |
|
69 | - global $lsx_to_archive; |
|
70 | - |
|
71 | - if ( 1 !== $lsx_to_archive ) { |
|
72 | - $lsx_to_archive = false; |
|
73 | - } |
|
74 | - |
|
75 | - if ( is_main_query() && is_singular( 'special' ) && false === $lsx_to_archive ) { |
|
76 | - $classes[] = 'col-xs-12 col-sm-12 col-md-6'; |
|
77 | - } |
|
78 | - |
|
79 | - return $classes; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Sets the current tab selected. |
|
84 | - */ |
|
85 | - public function set_settings_current_tab( $settings_tab ) { |
|
86 | - if ( is_tax( array_keys( $this->taxonomies ) ) ) { |
|
87 | - $taxonomy = get_query_var( 'taxonomy' ); |
|
88 | - |
|
89 | - if ( 'special-type' === $taxonomy ) { |
|
90 | - $settings_tab = 'special'; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - return $settings_tab; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Adds in additional info for the price custom field |
|
99 | - */ |
|
100 | - public function price_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { |
|
101 | - if ( get_post_type() === 'special' && 'price' === $meta_key ) { |
|
102 | - $price_type = get_post_meta( get_the_ID(), 'price_type', true ); |
|
103 | - $value = preg_replace( '/[^0-9,.]/', '', $value ); |
|
104 | - $value = ltrim( $value, '.' ); |
|
105 | - $value = str_replace( ', ', '', $value ); |
|
106 | - $value = number_format( (int) $value, 2 ); |
|
107 | - $tour_operator = tour_operator(); |
|
108 | - $currency = ''; |
|
109 | - |
|
110 | - if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
|
111 | - if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
|
112 | - $currency = $tour_operator->options['general']['currency']; |
|
113 | - $currency = '<span class="currency-icon ' . mb_strtolower( $currency ) . '">' . $currency . '</span>'; |
|
114 | - } |
|
115 | - } |
|
116 | - |
|
117 | - switch ( $price_type ) { |
|
118 | - case 'per_person': |
|
119 | - case 'per_person_per_night': |
|
120 | - case 'per_person_sharing': |
|
121 | - case 'per_person_sharing_per_night': |
|
122 | - $value = $currency . $value . ' ' . ucwords( str_replace( '_', ' ', $price_type ) ) . ''; |
|
123 | - $value = str_replace( 'Per Person', 'P/P', $value ); |
|
124 | - break; |
|
125 | - |
|
126 | - case 'total_percentage': |
|
127 | - $value .= '% ' . __( 'Off', 'to-specials' ) . ''; |
|
128 | - $before = str_replace( 'from price', '', $before ); |
|
129 | - break; |
|
130 | - |
|
131 | - case 'none': |
|
132 | - default: |
|
133 | - $value = $currency . $value; |
|
134 | - break; |
|
135 | - } |
|
136 | - |
|
137 | - $html = $before . $value . $after; |
|
138 | - } |
|
139 | - |
|
140 | - return $html; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Filters text area type filters |
|
145 | - */ |
|
146 | - public function terms_conditions_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { |
|
147 | - if ( get_post_type() === 'special' && 'terms_conditions' === $meta_key ) { |
|
148 | - $html = $before . '<div class="entry-content">' . apply_filters( 'the_content', wpautop( $value ) ) . '</div>' . $after; |
|
149 | - |
|
150 | - } |
|
151 | - |
|
152 | - return $html; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Adds our navigation links to the special single post |
|
157 | - * |
|
158 | - * @param $page_links array |
|
159 | - * @return $page_links array |
|
160 | - */ |
|
161 | - public function page_links( $page_links ) { |
|
162 | - if ( is_singular( 'special' ) ) { |
|
163 | - $this->page_links = $page_links; |
|
164 | - |
|
165 | - $this->get_map_link(); |
|
166 | - $this->get_gallery_link(); |
|
167 | - $this->get_videos_link(); |
|
168 | - $this->get_terms_and_conditions_link(); |
|
169 | - |
|
170 | - $this->get_related_posts_link(); |
|
171 | - |
|
172 | - $page_links = $this->page_links; |
|
173 | - } |
|
174 | - |
|
175 | - return $page_links; |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Tests for the Google Map and returns a link for the section |
|
180 | - */ |
|
181 | - public function get_map_link() { |
|
182 | - if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) { |
|
183 | - $this->page_links['special-map'] = esc_html__( 'Map', 'to-specials' ); |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Tests for the Gallery and returns a link for the section |
|
189 | - */ |
|
190 | - public function get_gallery_link() { |
|
191 | - $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
|
192 | - $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
|
193 | - |
|
194 | - if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
|
195 | - if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
|
196 | - // Envira Gallery |
|
197 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
198 | - return; |
|
199 | - } else { |
|
200 | - if ( function_exists( 'envira_dynamic' ) ) { |
|
201 | - // Envira Gallery - Dynamic |
|
202 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
203 | - return; |
|
204 | - } else { |
|
205 | - // WordPress Gallery |
|
206 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
207 | - return; |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Tests for the Videos and returns a link for the section |
|
215 | - */ |
|
216 | - public function get_videos_link() { |
|
217 | - $videos_id = false; |
|
218 | - |
|
219 | - if ( class_exists( 'Envira_Videos' ) ) { |
|
220 | - $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
|
221 | - } |
|
222 | - |
|
223 | - if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
|
224 | - $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
|
225 | - } |
|
226 | - |
|
227 | - if ( ! empty( $videos_id ) ) { |
|
228 | - $this->page_links['videos'] = esc_html__( 'Videos', 'to-specials' ); |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Tests for the Related Posts and returns a link for the section |
|
234 | - */ |
|
235 | - public function get_related_posts_link() { |
|
236 | - $connected_posts = get_post_meta( get_the_ID(), 'post_to_special', false ); |
|
237 | - |
|
238 | - if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) { |
|
239 | - $connected_posts = new \WP_Query( array( |
|
240 | - 'post_type' => 'post', |
|
241 | - 'post__in' => $connected_posts, |
|
242 | - 'post_status' => 'publish', |
|
243 | - 'nopagin' => true, |
|
244 | - 'posts_per_page' => '-1', |
|
245 | - 'fields' => 'ids', |
|
246 | - ) ); |
|
247 | - |
|
248 | - $connected_posts = $connected_posts->posts; |
|
249 | - |
|
250 | - if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) { |
|
251 | - $this->page_links['posts'] = esc_html__( 'Posts', 'to-specials' ); |
|
252 | - } |
|
253 | - } |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Tests for the Term and Conditions and returns a link for the section |
|
258 | - */ |
|
259 | - public function get_terms_and_conditions_link() { |
|
260 | - $terms_conditions = get_post_meta( get_the_ID(), 'terms_conditions', true ); |
|
261 | - |
|
262 | - if ( ! empty( $terms_conditions ) ) { |
|
263 | - $this->page_links['terms-and-conditions'] = esc_html__( 'Terms and Conditions', 'to-specials' ); |
|
264 | - } |
|
265 | - } |
|
266 | - |
|
267 | - /** |
|
268 | - * Adds the template tags to the top of the archive special |
|
269 | - */ |
|
270 | - public function archive_entry_top() { |
|
271 | - global $lsx_to_archive; |
|
272 | - |
|
273 | - if ( 'special' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
|
274 | - if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
|
21 | + /** |
|
22 | + * Holds the $page_links array while its being built on the single special page. |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + public $page_links = false; |
|
27 | + |
|
28 | + /** |
|
29 | + * Constructor |
|
30 | + */ |
|
31 | + public function __construct() { |
|
32 | + $this->set_vars(); |
|
33 | + |
|
34 | + add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
|
35 | + add_action( 'lsx_to_settings_current_tab', array( $this, 'set_settings_current_tab' ) ); |
|
36 | + add_action( 'init', array( $this, 'init' ) ); |
|
37 | + |
|
38 | + if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
|
39 | + require_once( LSX_TO_SPECIALS_PATH . 'classes/class-template-redirects.php' ); |
|
40 | + } |
|
41 | + |
|
42 | + $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_SPECIALS_PATH, array_keys( $this->post_types ), array_keys( $this->taxonomies ) ); |
|
43 | + |
|
44 | + add_action( 'lsx_special_content', array( $this->redirects, 'content_part' ), 10 , 2 ); |
|
45 | + |
|
46 | + add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
|
47 | + |
|
48 | + add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
|
49 | + add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
|
50 | + add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
|
51 | + add_action( 'lsx_to_fast_facts', array( $this, 'single_fast_facts' ) ); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Runs on init after all files have been parsed. |
|
56 | + */ |
|
57 | + public function init() { |
|
58 | + if ( ! class_exists( 'LSX_Currencies' ) ) { |
|
59 | + add_filter( 'lsx_to_custom_field_query', array( $this, 'price_filter' ), 5, 10 ); |
|
60 | + } |
|
61 | + |
|
62 | + add_filter( 'lsx_to_custom_field_query', array( $this, 'terms_conditions_filter' ), 5, 10 ); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * A filter to set the content area to a small column on single |
|
67 | + */ |
|
68 | + public function entry_class( $classes ) { |
|
69 | + global $lsx_to_archive; |
|
70 | + |
|
71 | + if ( 1 !== $lsx_to_archive ) { |
|
72 | + $lsx_to_archive = false; |
|
73 | + } |
|
74 | + |
|
75 | + if ( is_main_query() && is_singular( 'special' ) && false === $lsx_to_archive ) { |
|
76 | + $classes[] = 'col-xs-12 col-sm-12 col-md-6'; |
|
77 | + } |
|
78 | + |
|
79 | + return $classes; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Sets the current tab selected. |
|
84 | + */ |
|
85 | + public function set_settings_current_tab( $settings_tab ) { |
|
86 | + if ( is_tax( array_keys( $this->taxonomies ) ) ) { |
|
87 | + $taxonomy = get_query_var( 'taxonomy' ); |
|
88 | + |
|
89 | + if ( 'special-type' === $taxonomy ) { |
|
90 | + $settings_tab = 'special'; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + return $settings_tab; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Adds in additional info for the price custom field |
|
99 | + */ |
|
100 | + public function price_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { |
|
101 | + if ( get_post_type() === 'special' && 'price' === $meta_key ) { |
|
102 | + $price_type = get_post_meta( get_the_ID(), 'price_type', true ); |
|
103 | + $value = preg_replace( '/[^0-9,.]/', '', $value ); |
|
104 | + $value = ltrim( $value, '.' ); |
|
105 | + $value = str_replace( ', ', '', $value ); |
|
106 | + $value = number_format( (int) $value, 2 ); |
|
107 | + $tour_operator = tour_operator(); |
|
108 | + $currency = ''; |
|
109 | + |
|
110 | + if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
|
111 | + if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
|
112 | + $currency = $tour_operator->options['general']['currency']; |
|
113 | + $currency = '<span class="currency-icon ' . mb_strtolower( $currency ) . '">' . $currency . '</span>'; |
|
114 | + } |
|
115 | + } |
|
116 | + |
|
117 | + switch ( $price_type ) { |
|
118 | + case 'per_person': |
|
119 | + case 'per_person_per_night': |
|
120 | + case 'per_person_sharing': |
|
121 | + case 'per_person_sharing_per_night': |
|
122 | + $value = $currency . $value . ' ' . ucwords( str_replace( '_', ' ', $price_type ) ) . ''; |
|
123 | + $value = str_replace( 'Per Person', 'P/P', $value ); |
|
124 | + break; |
|
125 | + |
|
126 | + case 'total_percentage': |
|
127 | + $value .= '% ' . __( 'Off', 'to-specials' ) . ''; |
|
128 | + $before = str_replace( 'from price', '', $before ); |
|
129 | + break; |
|
130 | + |
|
131 | + case 'none': |
|
132 | + default: |
|
133 | + $value = $currency . $value; |
|
134 | + break; |
|
135 | + } |
|
136 | + |
|
137 | + $html = $before . $value . $after; |
|
138 | + } |
|
139 | + |
|
140 | + return $html; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Filters text area type filters |
|
145 | + */ |
|
146 | + public function terms_conditions_filter( $html = '', $meta_key = false, $value = false, $before = '', $after = '' ) { |
|
147 | + if ( get_post_type() === 'special' && 'terms_conditions' === $meta_key ) { |
|
148 | + $html = $before . '<div class="entry-content">' . apply_filters( 'the_content', wpautop( $value ) ) . '</div>' . $after; |
|
149 | + |
|
150 | + } |
|
151 | + |
|
152 | + return $html; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Adds our navigation links to the special single post |
|
157 | + * |
|
158 | + * @param $page_links array |
|
159 | + * @return $page_links array |
|
160 | + */ |
|
161 | + public function page_links( $page_links ) { |
|
162 | + if ( is_singular( 'special' ) ) { |
|
163 | + $this->page_links = $page_links; |
|
164 | + |
|
165 | + $this->get_map_link(); |
|
166 | + $this->get_gallery_link(); |
|
167 | + $this->get_videos_link(); |
|
168 | + $this->get_terms_and_conditions_link(); |
|
169 | + |
|
170 | + $this->get_related_posts_link(); |
|
171 | + |
|
172 | + $page_links = $this->page_links; |
|
173 | + } |
|
174 | + |
|
175 | + return $page_links; |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Tests for the Google Map and returns a link for the section |
|
180 | + */ |
|
181 | + public function get_map_link() { |
|
182 | + if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) { |
|
183 | + $this->page_links['special-map'] = esc_html__( 'Map', 'to-specials' ); |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Tests for the Gallery and returns a link for the section |
|
189 | + */ |
|
190 | + public function get_gallery_link() { |
|
191 | + $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
|
192 | + $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
|
193 | + |
|
194 | + if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
|
195 | + if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
|
196 | + // Envira Gallery |
|
197 | + $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
198 | + return; |
|
199 | + } else { |
|
200 | + if ( function_exists( 'envira_dynamic' ) ) { |
|
201 | + // Envira Gallery - Dynamic |
|
202 | + $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
203 | + return; |
|
204 | + } else { |
|
205 | + // WordPress Gallery |
|
206 | + $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-specials' ); |
|
207 | + return; |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Tests for the Videos and returns a link for the section |
|
215 | + */ |
|
216 | + public function get_videos_link() { |
|
217 | + $videos_id = false; |
|
218 | + |
|
219 | + if ( class_exists( 'Envira_Videos' ) ) { |
|
220 | + $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
|
221 | + } |
|
222 | + |
|
223 | + if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
|
224 | + $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
|
225 | + } |
|
226 | + |
|
227 | + if ( ! empty( $videos_id ) ) { |
|
228 | + $this->page_links['videos'] = esc_html__( 'Videos', 'to-specials' ); |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Tests for the Related Posts and returns a link for the section |
|
234 | + */ |
|
235 | + public function get_related_posts_link() { |
|
236 | + $connected_posts = get_post_meta( get_the_ID(), 'post_to_special', false ); |
|
237 | + |
|
238 | + if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) { |
|
239 | + $connected_posts = new \WP_Query( array( |
|
240 | + 'post_type' => 'post', |
|
241 | + 'post__in' => $connected_posts, |
|
242 | + 'post_status' => 'publish', |
|
243 | + 'nopagin' => true, |
|
244 | + 'posts_per_page' => '-1', |
|
245 | + 'fields' => 'ids', |
|
246 | + ) ); |
|
247 | + |
|
248 | + $connected_posts = $connected_posts->posts; |
|
249 | + |
|
250 | + if ( is_array( $connected_posts ) && ! empty( $connected_posts ) ) { |
|
251 | + $this->page_links['posts'] = esc_html__( 'Posts', 'to-specials' ); |
|
252 | + } |
|
253 | + } |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Tests for the Term and Conditions and returns a link for the section |
|
258 | + */ |
|
259 | + public function get_terms_and_conditions_link() { |
|
260 | + $terms_conditions = get_post_meta( get_the_ID(), 'terms_conditions', true ); |
|
261 | + |
|
262 | + if ( ! empty( $terms_conditions ) ) { |
|
263 | + $this->page_links['terms-and-conditions'] = esc_html__( 'Terms and Conditions', 'to-specials' ); |
|
264 | + } |
|
265 | + } |
|
266 | + |
|
267 | + /** |
|
268 | + * Adds the template tags to the top of the archive special |
|
269 | + */ |
|
270 | + public function archive_entry_top() { |
|
271 | + global $lsx_to_archive; |
|
272 | + |
|
273 | + if ( 'special' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
|
274 | + if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
|
275 | 275 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-grid-mode"> |
276 | 276 | <?php |
277 | - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
278 | - |
|
279 | - lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
280 | - lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
281 | - lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
282 | - the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
283 | - the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
284 | - lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
285 | - lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
286 | - lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
287 | - |
|
288 | - if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
289 | - lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
290 | - } |
|
291 | - ?> |
|
277 | + $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
278 | + |
|
279 | + lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
280 | + lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
281 | + lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
282 | + the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
283 | + the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
284 | + lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
285 | + lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
286 | + lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
287 | + |
|
288 | + if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
289 | + lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
290 | + } |
|
291 | + ?> |
|
292 | 292 | </div> |
293 | 293 | <?php } |
294 | - } |
|
295 | - } |
|
294 | + } |
|
295 | + } |
|
296 | 296 | |
297 | - /** |
|
298 | - * Adds the template tags to the bottom of the archive special |
|
299 | - */ |
|
300 | - public function archive_entry_bottom() { |
|
301 | - global $lsx_to_archive; |
|
297 | + /** |
|
298 | + * Adds the template tags to the bottom of the archive special |
|
299 | + */ |
|
300 | + public function archive_entry_bottom() { |
|
301 | + global $lsx_to_archive; |
|
302 | 302 | |
303 | - if ( 'special' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { ?> |
|
303 | + if ( 'special' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { ?> |
|
304 | 304 | </div> |
305 | 305 | |
306 | 306 | <?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
307 | 307 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-list-mode"> |
308 | 308 | <?php |
309 | - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
310 | - |
|
311 | - lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
312 | - lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
313 | - lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
314 | - the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
315 | - the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
316 | - lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
317 | - lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
318 | - lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
319 | - |
|
320 | - if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
321 | - lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
322 | - } |
|
323 | - ?> |
|
309 | + $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
310 | + |
|
311 | + lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
312 | + lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . __( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
313 | + lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . __( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
314 | + the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . __( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
315 | + the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . __( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
316 | + lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . __( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
317 | + lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . __( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
318 | + lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . __( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
319 | + |
|
320 | + if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
321 | + lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . __( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
322 | + } |
|
323 | + ?> |
|
324 | 324 | </div> |
325 | 325 | <?php } ?> |
326 | 326 | </div> |
@@ -331,46 +331,46 @@ discard block |
||
331 | 331 | <a href="<?php the_permalink(); ?>" class="moretag"><?php esc_html_e( 'View more', 'to-specials' ); ?></a> |
332 | 332 | <?php endif; ?> |
333 | 333 | <?php } |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | - /** |
|
337 | - * Adds the template tags fast facts |
|
338 | - */ |
|
339 | - public function single_fast_facts() { |
|
340 | - if ( is_singular( 'special' ) ) { ?> |
|
336 | + /** |
|
337 | + * Adds the template tags fast facts |
|
338 | + */ |
|
339 | + public function single_fast_facts() { |
|
340 | + if ( is_singular( 'special' ) ) { ?> |
|
341 | 341 | <section id="fast-facts"> |
342 | 342 | <div class="lsx-to-section-inner"> |
343 | 343 | <h3 class="lsx-to-section-title"><?php esc_html_e( 'Special Summary', 'to-specials' ); ?></h3> |
344 | 344 | |
345 | 345 | <div class="lsx-to-single-meta-data"> |
346 | 346 | <?php |
347 | - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
348 | - |
|
349 | - // lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
350 | - lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . esc_html__( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
351 | - lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . esc_html__( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
352 | - the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . esc_html__( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
353 | - the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . esc_html__( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
354 | - lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . esc_html__( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
355 | - lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
356 | - lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
357 | - |
|
358 | - if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
359 | - lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . esc_html__( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
360 | - } |
|
361 | - ?> |
|
347 | + $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
348 | + |
|
349 | + // lsx_to_price( '<span class="' . $meta_class . 'price"><span class="lsx-to-meta-data-key">' . esc_html__( 'From price', 'to-specials' ) . ':</span> ', '</span>' ); |
|
350 | + lsx_to_specials_validity( '<span class="' . $meta_class . 'valid-from"><span class="lsx-to-meta-data-key">' . esc_html__( 'Booking Validity', 'to-specials' ) . ':</span> ', '</span>' ); |
|
351 | + lsx_to_travel_dates( '<span class="' . $meta_class . 'travel-dates"><span class="lsx-to-meta-data-key">' . esc_html__( 'Travel Dates', 'to-specials' ) . ':</span> ', '</span>' ); |
|
352 | + the_terms( get_the_ID(), 'travel-style', '<span class="' . $meta_class . 'style"><span class="lsx-to-meta-data-key">' . esc_html__( 'Travel Style', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
353 | + the_terms( get_the_ID(), 'special-type', '<span class="' . $meta_class . 'type"><span class="lsx-to-meta-data-key">' . esc_html__( 'Type', 'to-specials' ) . ':</span> ', ', ', '</span>' ); |
|
354 | + lsx_to_connected_tours( '<span class="' . $meta_class . 'tours"><span class="lsx-to-meta-data-key">' . esc_html__( 'Tours', 'to-specials' ) . ':</span> ', '</span>' ); |
|
355 | + lsx_to_connected_accommodation( '<span class="' . $meta_class . 'accommodations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Accommodation', 'to-specials' ) . ':</span> ', '</span>' ); |
|
356 | + lsx_to_connected_destinations( '<span class="' . $meta_class . 'destinations"><span class="lsx-to-meta-data-key">' . esc_html__( 'Destinations', 'to-specials' ) . ':</span> ', '</span>' ); |
|
357 | + |
|
358 | + if ( function_exists( 'lsx_to_connected_activities' ) ) { |
|
359 | + lsx_to_connected_activities( '<span class="' . $meta_class . 'activities"><span class="lsx-to-meta-data-key">' . esc_html__( 'Activites', 'to-specials' ) . ':</span> ', '</span>' ); |
|
360 | + } |
|
361 | + ?> |
|
362 | 362 | </div> |
363 | 363 | </div> |
364 | 364 | </section> |
365 | 365 | <?php } |
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * Adds the template tags to the bottom of the single special |
|
370 | - */ |
|
371 | - public function single_content_bottom() { |
|
372 | - if ( is_singular( 'special' ) ) { |
|
373 | - if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) : ?> |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * Adds the template tags to the bottom of the single special |
|
370 | + */ |
|
371 | + public function single_content_bottom() { |
|
372 | + if ( is_singular( 'special' ) ) { |
|
373 | + if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) : ?> |
|
374 | 374 | <section id="special-map" class="lsx-to-section lsx-to-collapse-section"> |
375 | 375 | <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title hidden-lg" data-toggle="collapse" data-target="#collapse-special-map"><?php esc_html_e( 'Map', 'to-specials' ); ?></h2> |
376 | 376 | |
@@ -381,19 +381,19 @@ discard block |
||
381 | 381 | </div> |
382 | 382 | </section> |
383 | 383 | <?php |
384 | - endif; |
|
384 | + endif; |
|
385 | 385 | |
386 | - 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-specials' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
386 | + 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-specials' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
387 | 387 | |
388 | - if ( function_exists( 'lsx_to_videos' ) ) { |
|
389 | - 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-specials' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
390 | - } elseif ( class_exists( 'Envira_Videos' ) ) { |
|
391 | - 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-specials' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
392 | - } |
|
388 | + if ( function_exists( 'lsx_to_videos' ) ) { |
|
389 | + 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-specials' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
390 | + } elseif ( class_exists( 'Envira_Videos' ) ) { |
|
391 | + 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-specials' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
392 | + } |
|
393 | 393 | |
394 | - $terms_conditions = get_post_meta( get_the_ID(), 'terms_conditions', true ); |
|
394 | + $terms_conditions = get_post_meta( get_the_ID(), 'terms_conditions', true ); |
|
395 | 395 | |
396 | - if ( false !== $terms_conditions && '' !== $terms_conditions ) { ?> |
|
396 | + if ( false !== $terms_conditions && '' !== $terms_conditions ) { ?> |
|
397 | 397 | <section id="terms-and-conditions" class="lsx-to-section lsx-to-collapse-section"> |
398 | 398 | <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-terms-and-conditions"><?php esc_html_e( 'Terms and Conditions', 'to-specials' ); ?></h2> |
399 | 399 | |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | </section> |
410 | 410 | <?php } |
411 | 411 | |
412 | - lsx_to_special_posts(); |
|
413 | - } |
|
414 | - } |
|
412 | + lsx_to_special_posts(); |
|
413 | + } |
|
414 | + } |
|
415 | 415 | |
416 | 416 | } |
417 | 417 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | $this->set_vars(); |
26 | - add_action( 'wp_head', array( $this, 'specials_single_schema' ), 1499 ); |
|
26 | + add_action('wp_head', array($this, 'specials_single_schema'), 1499); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -33,23 +33,23 @@ discard block |
||
33 | 33 | * @return object A single instance of this class. |
34 | 34 | */ |
35 | 35 | public function specials_single_schema() { |
36 | - if ( is_singular( 'special' ) ) { |
|
36 | + if (is_singular('special')) { |
|
37 | 37 | |
38 | - $destination_list_special = get_post_meta( get_the_ID(), 'destination_to_special', false ); |
|
38 | + $destination_list_special = get_post_meta(get_the_ID(), 'destination_to_special', false); |
|
39 | 39 | $destination_list_schema = array(); |
40 | 40 | $url_option = get_the_permalink(); |
41 | 41 | $special_title = get_the_title(); |
42 | 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 ); |
|
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 | 48 | |
49 | 49 | |
50 | - if ( ! empty( $destination_list_special ) ) { |
|
51 | - foreach( $destination_list_special as $single_destination ) { |
|
52 | - $url_option = get_the_permalink() . '#destination-' . $i; |
|
50 | + if ( ! empty($destination_list_special)) { |
|
51 | + foreach ($destination_list_special as $single_destination) { |
|
52 | + $url_option = get_the_permalink() . '#destination-' . $i; |
|
53 | 53 | $destination_name = get_the_title($single_destination); |
54 | 54 | $schema_day = array( |
55 | 55 | "@type" => "PostalAddress", |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | "url" => $primary_url, |
79 | 79 | ), |
80 | 80 | ); |
81 | - $output = wp_json_encode( $meta, JSON_UNESCAPED_SLASHES ); |
|
81 | + $output = wp_json_encode($meta, JSON_UNESCAPED_SLASHES); |
|
82 | 82 | ?> |
83 | 83 | <script type="application/ld+json"> |
84 | - <?php echo wp_kses_post( $output ); ?> |
|
84 | + <?php echo wp_kses_post($output); ?> |
|
85 | 85 | </script> |
86 | 86 | <?php |
87 | 87 | } |
@@ -18,74 +18,74 @@ |
||
18 | 18 | |
19 | 19 | class LSX_TO_Specials_Schema extends LSX_TO_Specials { |
20 | 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 | - } |
|
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 | 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' ) ) { |
|
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 | 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 ); |
|
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 | 48 | |
49 | 49 | |
50 | - if ( ! empty( $destination_list_special ) ) { |
|
51 | - foreach( $destination_list_special as $single_destination ) { |
|
52 | - $url_option = get_the_permalink() . '#destination-' . $i; |
|
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 | - ?> |
|
50 | + if ( ! empty( $destination_list_special ) ) { |
|
51 | + foreach( $destination_list_special as $single_destination ) { |
|
52 | + $url_option = get_the_permalink() . '#destination-' . $i; |
|
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 | 83 | <script type="application/ld+json"> |
84 | 84 | <?php echo wp_kses_post( $output ); ?> |
85 | 85 | </script> |
86 | 86 | <?php |
87 | - } |
|
88 | - } |
|
87 | + } |
|
88 | + } |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | new LSX_TO_Specials_Schema(); |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | public function __construct() { |
25 | 25 | $this->set_vars(); |
26 | 26 | |
27 | - add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
28 | - add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
29 | - add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 ); |
|
27 | + add_filter('lsx_get_post-types_configs', array($this, 'post_type_config'), 10, 1); |
|
28 | + add_filter('lsx_get_metaboxes_configs', array($this, 'meta_box_config'), 10, 1); |
|
29 | + add_filter('lsx_get_taxonomies_configs', array($this, 'taxonomy_config'), 10, 1); |
|
30 | 30 | |
31 | - add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
32 | - add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
33 | - add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
31 | + add_filter('lsx_to_destination_custom_fields', array($this, 'custom_fields')); |
|
32 | + add_filter('lsx_to_tour_custom_fields', array($this, 'custom_fields')); |
|
33 | + add_filter('lsx_to_accommodation_custom_fields', array($this, 'custom_fields')); |
|
34 | 34 | |
35 | - add_filter( 'lsx_to_team_custom_fields', array( $this, 'custom_fields' ) ); |
|
36 | - add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
37 | - add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) ); |
|
35 | + add_filter('lsx_to_team_custom_fields', array($this, 'custom_fields')); |
|
36 | + add_filter('lsx_to_review_custom_fields', array($this, 'custom_fields')); |
|
37 | + add_filter('lsx_to_activity_custom_fields', array($this, 'custom_fields')); |
|
38 | 38 | |
39 | - add_action( 'lsx_to_framework_special_tab_general_settings_bottom', array( $this, 'general_settings' ), 10, 1 ); |
|
39 | + add_action('lsx_to_framework_special_tab_general_settings_bottom', array($this, 'general_settings'), 10, 1); |
|
40 | 40 | } |
41 | 41 | /** |
42 | 42 | * Register the specials post type config |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @param $objects |
45 | 45 | * @return array |
46 | 46 | */ |
47 | - public function post_type_config( $objects ) { |
|
47 | + public function post_type_config($objects) { |
|
48 | 48 | |
49 | - foreach ( $this->post_types as $key => $label ) { |
|
50 | - if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
51 | - $objects[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
49 | + foreach ($this->post_types as $key => $label) { |
|
50 | + if (file_exists(LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php')) { |
|
51 | + $objects[$key] = include LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @param $meta_boxes |
62 | 62 | * @return array |
63 | 63 | */ |
64 | - public function meta_box_config( $meta_boxes ) { |
|
65 | - foreach ( $this->post_types as $key => $label ) { |
|
66 | - if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
67 | - $meta_boxes[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
64 | + public function meta_box_config($meta_boxes) { |
|
65 | + foreach ($this->post_types as $key => $label) { |
|
66 | + if (file_exists(LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php')) { |
|
67 | + $meta_boxes[$key] = include LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | return $meta_boxes; |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return null |
78 | 78 | */ |
79 | - public function taxonomy_config( $taxonomies ) { |
|
79 | + public function taxonomy_config($taxonomies) { |
|
80 | 80 | |
81 | - if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php' ) ) { |
|
81 | + if (file_exists(LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php')) { |
|
82 | 82 | $taxonomies['special-type'] = include LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php'; |
83 | 83 | } |
84 | 84 | return $taxonomies; |
@@ -93,21 +93,21 @@ discard block |
||
93 | 93 | public function register_taxonomies() { |
94 | 94 | |
95 | 95 | $labels = array( |
96 | - 'name' => _x( 'Special Type', 'to-specials' ), |
|
97 | - 'singular_name' => _x( 'Special Type', 'to-specials' ), |
|
98 | - 'search_items' => __( 'Search Special Types' , 'to-specials' ), |
|
99 | - 'all_items' => __( 'Special Types' , 'to-specials' ), |
|
100 | - 'parent_item' => __( 'Parent Special Type' , 'to-specials' ), |
|
101 | - 'parent_item_colon' => __( 'Parent Special Type:' , 'to-specials' ), |
|
102 | - 'edit_item' => __( 'Edit Special Type' , 'to-specials' ), |
|
103 | - 'update_item' => __( 'Update Special Type' , 'to-specials' ), |
|
104 | - 'add_new_item' => __( 'Add New Special Type' , 'to-specials' ), |
|
105 | - 'new_item_name' => __( 'New Special Type' , 'to-specials' ), |
|
106 | - 'menu_name' => __( 'Special Types' , 'to-specials' ), |
|
96 | + 'name' => _x('Special Type', 'to-specials'), |
|
97 | + 'singular_name' => _x('Special Type', 'to-specials'), |
|
98 | + 'search_items' => __('Search Special Types', 'to-specials'), |
|
99 | + 'all_items' => __('Special Types', 'to-specials'), |
|
100 | + 'parent_item' => __('Parent Special Type', 'to-specials'), |
|
101 | + 'parent_item_colon' => __('Parent Special Type:', 'to-specials'), |
|
102 | + 'edit_item' => __('Edit Special Type', 'to-specials'), |
|
103 | + 'update_item' => __('Update Special Type', 'to-specials'), |
|
104 | + 'add_new_item' => __('Add New Special Type', 'to-specials'), |
|
105 | + 'new_item_name' => __('New Special Type', 'to-specials'), |
|
106 | + 'menu_name' => __('Special Types', 'to-specials'), |
|
107 | 107 | ); |
108 | 108 | |
109 | 109 | // Now register the taxonomy |
110 | - register_taxonomy('special-type',$this->plugin_slug, array( |
|
110 | + register_taxonomy('special-type', $this->plugin_slug, array( |
|
111 | 111 | 'hierarchical' => true, |
112 | 112 | 'labels' => $labels, |
113 | 113 | 'show_ui' => true, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | 'exclude_from_search' => true, |
117 | 117 | 'show_admin_column' => true, |
118 | 118 | 'query_var' => true, |
119 | - 'rewrite' => array( 'special-type' ), |
|
119 | + 'rewrite' => array('special-type'), |
|
120 | 120 | )); |
121 | 121 | |
122 | 122 | } |
@@ -124,23 +124,23 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * Adds in the fields to the Tour Operators Post Types. |
126 | 126 | */ |
127 | - public function custom_fields( $fields ) { |
|
127 | + public function custom_fields($fields) { |
|
128 | 128 | global $post, $typenow, $current_screen; |
129 | 129 | |
130 | 130 | $post_type = false; |
131 | - if ( $post && $post->post_type ) { |
|
131 | + if ($post && $post->post_type) { |
|
132 | 132 | $post_type = $post->post_type; |
133 | - } elseif ( $typenow ) { |
|
133 | + } elseif ($typenow) { |
|
134 | 134 | $post_type = $typenow; |
135 | - } elseif ( $current_screen && $current_screen->post_type ) { |
|
135 | + } elseif ($current_screen && $current_screen->post_type) { |
|
136 | 136 | $post_type = $current_screen->post_type; |
137 | - } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
138 | - $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
139 | - } elseif ( isset( $_REQUEST['post'] ) ) { |
|
140 | - $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
137 | + } elseif (isset($_REQUEST['post_type'])) { |
|
138 | + $post_type = sanitize_key($_REQUEST['post_type']); |
|
139 | + } elseif (isset($_REQUEST['post'])) { |
|
140 | + $post_type = get_post_type(sanitize_key($_REQUEST['post'])); |
|
141 | 141 | } |
142 | 142 | |
143 | - if ( false !== $post_type ) { |
|
143 | + if (false !== $post_type) { |
|
144 | 144 | $fields[] = array( |
145 | 145 | 'id' => 'specials_title', |
146 | 146 | 'name' => 'Specials', |
@@ -174,22 +174,22 @@ discard block |
||
174 | 174 | ?> |
175 | 175 | <tr class="form-field-wrap"> |
176 | 176 | <th scope="row"> |
177 | - <label for="enable_widget_excerpt"> <?php esc_html_e( 'Disable Widget Excerpt', 'tour-operator' ); ?></label> |
|
177 | + <label for="enable_widget_excerpt"> <?php esc_html_e('Disable Widget Excerpt', 'tour-operator'); ?></label> |
|
178 | 178 | </th> |
179 | 179 | <td> |
180 | 180 | <input type="checkbox" {{#if enable_widget_excerpt}} checked="checked" {{/if}} name="enable_widget_excerpt" /> |
181 | - <small><?php esc_html_e( 'This enables the excerpt text on the widget.', 'tour-operator' ); ?></small> |
|
181 | + <small><?php esc_html_e('This enables the excerpt text on the widget.', 'tour-operator'); ?></small> |
|
182 | 182 | </td> |
183 | 183 | </tr> |
184 | 184 | <tr class="form-field-wrap"> |
185 | 185 | <th scope="row"> |
186 | - <label for="expiration_status"> <?php esc_html_e( 'Expiration Status', 'tour-operator' ); ?></label> |
|
186 | + <label for="expiration_status"> <?php esc_html_e('Expiration Status', 'tour-operator'); ?></label> |
|
187 | 187 | </th> |
188 | 188 | <td> |
189 | 189 | <select value="{{expiration_status}}" name="expiration_status"> |
190 | - <option value="draft" {{#is expiration_status value=""}}selected="selected"{{/is}} {{#is expiration_status value="draft"}} selected="selected"{{/is}}><?php esc_html_e( 'Draft', 'tour-operator' ); ?></option> |
|
191 | - <option value="delete" {{#is expiration_status value="delete"}} selected="selected"{{/is}}><?php esc_html_e( 'Delete', 'tour-operator' ); ?></option> |
|
192 | - <option value="private" {{#is expiration_status value="private"}} selected="selected"{{/is}}><?php esc_html_e( 'Private', 'tour-operator' ); ?></option> |
|
190 | + <option value="draft" {{#is expiration_status value=""}}selected="selected"{{/is}} {{#is expiration_status value="draft"}} selected="selected"{{/is}}><?php esc_html_e('Draft', 'tour-operator'); ?></option> |
|
191 | + <option value="delete" {{#is expiration_status value="delete"}} selected="selected"{{/is}}><?php esc_html_e('Delete', 'tour-operator'); ?></option> |
|
192 | + <option value="private" {{#is expiration_status value="private"}} selected="selected"{{/is}}><?php esc_html_e('Private', 'tour-operator'); ?></option> |
|
193 | 193 | </select> |
194 | 194 | </td> |
195 | 195 | </tr> |
@@ -18,160 +18,160 @@ discard block |
||
18 | 18 | |
19 | 19 | class LSX_TO_Specials_Admin extends LSX_TO_Specials { |
20 | 20 | |
21 | - /** |
|
22 | - * Constructor |
|
23 | - */ |
|
24 | - public function __construct() { |
|
25 | - $this->set_vars(); |
|
26 | - |
|
27 | - add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
28 | - add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
29 | - add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 ); |
|
30 | - |
|
31 | - add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
32 | - add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
33 | - add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
34 | - |
|
35 | - add_filter( 'lsx_to_team_custom_fields', array( $this, 'custom_fields' ) ); |
|
36 | - add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
37 | - add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) ); |
|
38 | - |
|
39 | - add_action( 'lsx_to_framework_special_tab_general_settings_bottom', array( $this, 'general_settings' ), 10, 1 ); |
|
40 | - } |
|
41 | - /** |
|
42 | - * Register the specials post type config |
|
43 | - * |
|
44 | - * @param $objects |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function post_type_config( $objects ) { |
|
48 | - |
|
49 | - foreach ( $this->post_types as $key => $label ) { |
|
50 | - if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
51 | - $objects[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - return $objects; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Register the activity metabox config |
|
60 | - * |
|
61 | - * @param $meta_boxes |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function meta_box_config( $meta_boxes ) { |
|
65 | - foreach ( $this->post_types as $key => $label ) { |
|
66 | - if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
67 | - $meta_boxes[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
68 | - } |
|
69 | - } |
|
70 | - return $meta_boxes; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Register the Role taxonomy |
|
75 | - * |
|
76 | - * |
|
77 | - * @return null |
|
78 | - */ |
|
79 | - public function taxonomy_config( $taxonomies ) { |
|
80 | - |
|
81 | - if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php' ) ) { |
|
82 | - $taxonomies['special-type'] = include LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php'; |
|
83 | - } |
|
84 | - return $taxonomies; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Register the global post types. |
|
89 | - * |
|
90 | - * |
|
91 | - * @return null |
|
92 | - */ |
|
93 | - public function register_taxonomies() { |
|
94 | - |
|
95 | - $labels = array( |
|
96 | - 'name' => _x( 'Special Type', 'to-specials' ), |
|
97 | - 'singular_name' => _x( 'Special Type', 'to-specials' ), |
|
98 | - 'search_items' => __( 'Search Special Types' , 'to-specials' ), |
|
99 | - 'all_items' => __( 'Special Types' , 'to-specials' ), |
|
100 | - 'parent_item' => __( 'Parent Special Type' , 'to-specials' ), |
|
101 | - 'parent_item_colon' => __( 'Parent Special Type:' , 'to-specials' ), |
|
102 | - 'edit_item' => __( 'Edit Special Type' , 'to-specials' ), |
|
103 | - 'update_item' => __( 'Update Special Type' , 'to-specials' ), |
|
104 | - 'add_new_item' => __( 'Add New Special Type' , 'to-specials' ), |
|
105 | - 'new_item_name' => __( 'New Special Type' , 'to-specials' ), |
|
106 | - 'menu_name' => __( 'Special Types' , 'to-specials' ), |
|
107 | - ); |
|
108 | - |
|
109 | - // Now register the taxonomy |
|
110 | - register_taxonomy('special-type',$this->plugin_slug, array( |
|
111 | - 'hierarchical' => true, |
|
112 | - 'labels' => $labels, |
|
113 | - 'show_ui' => true, |
|
114 | - 'public' => true, |
|
115 | - 'show_tagcloud' => false, |
|
116 | - 'exclude_from_search' => true, |
|
117 | - 'show_admin_column' => true, |
|
118 | - 'query_var' => true, |
|
119 | - 'rewrite' => array( 'special-type' ), |
|
120 | - )); |
|
121 | - |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Adds in the fields to the Tour Operators Post Types. |
|
126 | - */ |
|
127 | - public function custom_fields( $fields ) { |
|
128 | - global $post, $typenow, $current_screen; |
|
129 | - |
|
130 | - $post_type = false; |
|
131 | - if ( $post && $post->post_type ) { |
|
132 | - $post_type = $post->post_type; |
|
133 | - } elseif ( $typenow ) { |
|
134 | - $post_type = $typenow; |
|
135 | - } elseif ( $current_screen && $current_screen->post_type ) { |
|
136 | - $post_type = $current_screen->post_type; |
|
137 | - } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
138 | - $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
139 | - } elseif ( isset( $_REQUEST['post'] ) ) { |
|
140 | - $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
141 | - } |
|
142 | - |
|
143 | - if ( false !== $post_type ) { |
|
144 | - $fields[] = array( |
|
145 | - 'id' => 'specials_title', |
|
146 | - 'name' => 'Specials', |
|
147 | - 'type' => 'title', |
|
148 | - 'cols' => 12, |
|
149 | - ); |
|
150 | - $fields[] = array( |
|
151 | - 'id' => 'special_to_' . $post_type, |
|
152 | - 'name' => 'Specials related with this ' . $post_type, |
|
153 | - 'type' => 'post_select', |
|
154 | - 'use_ajax' => false, |
|
155 | - 'query' => array( |
|
156 | - 'post_type' => 'special', |
|
157 | - 'nopagin' => true, |
|
158 | - 'posts_per_page' => '-1', |
|
159 | - 'orderby' => 'title', |
|
160 | - 'order' => 'ASC', |
|
161 | - ), |
|
162 | - 'repeatable' => true, |
|
163 | - 'allow_none' => true, |
|
164 | - 'cols' => 12, |
|
165 | - ); |
|
166 | - } |
|
167 | - return $fields; |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Adds the special specific options |
|
172 | - */ |
|
173 | - public function general_settings() { |
|
174 | - ?> |
|
21 | + /** |
|
22 | + * Constructor |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | + $this->set_vars(); |
|
26 | + |
|
27 | + add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
28 | + add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
29 | + add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 ); |
|
30 | + |
|
31 | + add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
32 | + add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
33 | + add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
34 | + |
|
35 | + add_filter( 'lsx_to_team_custom_fields', array( $this, 'custom_fields' ) ); |
|
36 | + add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
37 | + add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) ); |
|
38 | + |
|
39 | + add_action( 'lsx_to_framework_special_tab_general_settings_bottom', array( $this, 'general_settings' ), 10, 1 ); |
|
40 | + } |
|
41 | + /** |
|
42 | + * Register the specials post type config |
|
43 | + * |
|
44 | + * @param $objects |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function post_type_config( $objects ) { |
|
48 | + |
|
49 | + foreach ( $this->post_types as $key => $label ) { |
|
50 | + if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
51 | + $objects[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + return $objects; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Register the activity metabox config |
|
60 | + * |
|
61 | + * @param $meta_boxes |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function meta_box_config( $meta_boxes ) { |
|
65 | + foreach ( $this->post_types as $key => $label ) { |
|
66 | + if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
67 | + $meta_boxes[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
68 | + } |
|
69 | + } |
|
70 | + return $meta_boxes; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Register the Role taxonomy |
|
75 | + * |
|
76 | + * |
|
77 | + * @return null |
|
78 | + */ |
|
79 | + public function taxonomy_config( $taxonomies ) { |
|
80 | + |
|
81 | + if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php' ) ) { |
|
82 | + $taxonomies['special-type'] = include LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php'; |
|
83 | + } |
|
84 | + return $taxonomies; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Register the global post types. |
|
89 | + * |
|
90 | + * |
|
91 | + * @return null |
|
92 | + */ |
|
93 | + public function register_taxonomies() { |
|
94 | + |
|
95 | + $labels = array( |
|
96 | + 'name' => _x( 'Special Type', 'to-specials' ), |
|
97 | + 'singular_name' => _x( 'Special Type', 'to-specials' ), |
|
98 | + 'search_items' => __( 'Search Special Types' , 'to-specials' ), |
|
99 | + 'all_items' => __( 'Special Types' , 'to-specials' ), |
|
100 | + 'parent_item' => __( 'Parent Special Type' , 'to-specials' ), |
|
101 | + 'parent_item_colon' => __( 'Parent Special Type:' , 'to-specials' ), |
|
102 | + 'edit_item' => __( 'Edit Special Type' , 'to-specials' ), |
|
103 | + 'update_item' => __( 'Update Special Type' , 'to-specials' ), |
|
104 | + 'add_new_item' => __( 'Add New Special Type' , 'to-specials' ), |
|
105 | + 'new_item_name' => __( 'New Special Type' , 'to-specials' ), |
|
106 | + 'menu_name' => __( 'Special Types' , 'to-specials' ), |
|
107 | + ); |
|
108 | + |
|
109 | + // Now register the taxonomy |
|
110 | + register_taxonomy('special-type',$this->plugin_slug, array( |
|
111 | + 'hierarchical' => true, |
|
112 | + 'labels' => $labels, |
|
113 | + 'show_ui' => true, |
|
114 | + 'public' => true, |
|
115 | + 'show_tagcloud' => false, |
|
116 | + 'exclude_from_search' => true, |
|
117 | + 'show_admin_column' => true, |
|
118 | + 'query_var' => true, |
|
119 | + 'rewrite' => array( 'special-type' ), |
|
120 | + )); |
|
121 | + |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Adds in the fields to the Tour Operators Post Types. |
|
126 | + */ |
|
127 | + public function custom_fields( $fields ) { |
|
128 | + global $post, $typenow, $current_screen; |
|
129 | + |
|
130 | + $post_type = false; |
|
131 | + if ( $post && $post->post_type ) { |
|
132 | + $post_type = $post->post_type; |
|
133 | + } elseif ( $typenow ) { |
|
134 | + $post_type = $typenow; |
|
135 | + } elseif ( $current_screen && $current_screen->post_type ) { |
|
136 | + $post_type = $current_screen->post_type; |
|
137 | + } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
138 | + $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
139 | + } elseif ( isset( $_REQUEST['post'] ) ) { |
|
140 | + $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
141 | + } |
|
142 | + |
|
143 | + if ( false !== $post_type ) { |
|
144 | + $fields[] = array( |
|
145 | + 'id' => 'specials_title', |
|
146 | + 'name' => 'Specials', |
|
147 | + 'type' => 'title', |
|
148 | + 'cols' => 12, |
|
149 | + ); |
|
150 | + $fields[] = array( |
|
151 | + 'id' => 'special_to_' . $post_type, |
|
152 | + 'name' => 'Specials related with this ' . $post_type, |
|
153 | + 'type' => 'post_select', |
|
154 | + 'use_ajax' => false, |
|
155 | + 'query' => array( |
|
156 | + 'post_type' => 'special', |
|
157 | + 'nopagin' => true, |
|
158 | + 'posts_per_page' => '-1', |
|
159 | + 'orderby' => 'title', |
|
160 | + 'order' => 'ASC', |
|
161 | + ), |
|
162 | + 'repeatable' => true, |
|
163 | + 'allow_none' => true, |
|
164 | + 'cols' => 12, |
|
165 | + ); |
|
166 | + } |
|
167 | + return $fields; |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Adds the special specific options |
|
172 | + */ |
|
173 | + public function general_settings() { |
|
174 | + ?> |
|
175 | 175 | <tr class="form-field-wrap"> |
176 | 176 | <th scope="row"> |
177 | 177 | <label for="enable_widget_excerpt"> <?php esc_html_e( 'Disable Widget Excerpt', 'tour-operator' ); ?></label> |
@@ -195,6 +195,6 @@ discard block |
||
195 | 195 | </tr> |
196 | 196 | |
197 | 197 | <?php |
198 | - } |
|
198 | + } |
|
199 | 199 | } |
200 | 200 | new LSX_TO_Specials_Admin(); |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @param \WPSEO_Schema_Context $context A value object with context variables. |
19 | 19 | */ |
20 | - public function __construct( WPSEO_Schema_Context $context ) { |
|
20 | + public function __construct(WPSEO_Schema_Context $context) { |
|
21 | 21 | $this->post_type = 'special'; |
22 | - parent::__construct( $context ); |
|
22 | + parent::__construct($context); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,36 +28,36 @@ discard block |
||
28 | 28 | * @return array $data Review data. |
29 | 29 | */ |
30 | 30 | public function generate() { |
31 | - $tour_list = get_post_meta( get_the_ID(), 'tour_to_special', false ); |
|
32 | - $accom_list = get_post_meta( get_the_ID(), 'accommodation_to_special', false ); |
|
31 | + $tour_list = get_post_meta(get_the_ID(), 'tour_to_special', false); |
|
32 | + $accom_list = get_post_meta(get_the_ID(), 'accommodation_to_special', false); |
|
33 | 33 | $data = array( |
34 | 34 | '@type' => array( |
35 | 35 | 'Offer', |
36 | 36 | ), |
37 | 37 | '@id' => $this->context->canonical . '#special', |
38 | 38 | 'name' => $this->post->post_title, |
39 | - 'description' => wp_strip_all_tags( $this->post->post_content ), |
|
39 | + 'description' => wp_strip_all_tags($this->post->post_content), |
|
40 | 40 | 'url' => $this->post_url, |
41 | 41 | 'mainEntityOfPage' => array( |
42 | 42 | '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
43 | 43 | ), |
44 | 44 | ); |
45 | 45 | |
46 | - if ( $this->context->site_represents_reference ) { |
|
46 | + if ($this->context->site_represents_reference) { |
|
47 | 47 | $data['offeredBy'] = $this->context->site_represents_reference; |
48 | 48 | } |
49 | 49 | |
50 | - $data = $this->add_custom_field( $data, 'availabilityStarts', 'booking_validity_start' ); |
|
51 | - $data = $this->add_custom_field( $data, 'availabilityEnds', 'booking_validity_end' ); |
|
52 | - $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
|
53 | - $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
|
54 | - $data = $this->get_price( $data ); |
|
50 | + $data = $this->add_custom_field($data, 'availabilityStarts', 'booking_validity_start'); |
|
51 | + $data = $this->add_custom_field($data, 'availabilityEnds', 'booking_validity_end'); |
|
52 | + $data = $this->add_custom_field($data, 'priceValidUntil', 'booking_validity_end'); |
|
53 | + $data = $this->add_custom_field($data, 'priceValidUntil', 'booking_validity_end'); |
|
54 | + $data = $this->get_price($data); |
|
55 | 55 | |
56 | - $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $tour_list, 'Product' ); |
|
57 | - $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $accom_list, 'Product' ); |
|
56 | + $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed($tour_list, 'Product'); |
|
57 | + $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed($accom_list, 'Product'); |
|
58 | 58 | |
59 | - $data = $this->add_articles( $data ); |
|
60 | - $data = \lsx\legacy\Schema_Utils::add_image( $data, $this->context ); |
|
59 | + $data = $this->add_articles($data); |
|
60 | + $data = \lsx\legacy\Schema_Utils::add_image($data, $this->context); |
|
61 | 61 | |
62 | 62 | return $data; |
63 | 63 | } |
@@ -68,24 +68,24 @@ discard block |
||
68 | 68 | * @param array $data An array of offers already added. |
69 | 69 | * @return array $data |
70 | 70 | */ |
71 | - public function get_price( $data ) { |
|
72 | - $price = get_post_meta( $this->context->id, 'price', true ); |
|
71 | + public function get_price($data) { |
|
72 | + $price = get_post_meta($this->context->id, 'price', true); |
|
73 | 73 | $currency = 'USD'; |
74 | 74 | $tour_operator = tour_operator(); |
75 | - if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
|
76 | - if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
|
75 | + if (is_object($tour_operator) && isset($tour_operator->options['general']) && is_array($tour_operator->options['general'])) { |
|
76 | + if (isset($tour_operator->options['general']['currency']) && ! empty($tour_operator->options['general']['currency'])) { |
|
77 | 77 | $currency = $tour_operator->options['general']['currency']; |
78 | 78 | } |
79 | 79 | } |
80 | - if ( false !== $price && '' !== $price ) { |
|
80 | + if (false !== $price && '' !== $price) { |
|
81 | 81 | $data['price'] = $price; |
82 | 82 | $data['priceCurrency'] = $currency; |
83 | - $data['category'] = __( 'Special', 'tour-operator-specials' ); |
|
83 | + $data['category'] = __('Special', 'tour-operator-specials'); |
|
84 | 84 | $data['availability'] = 'https://schema.org/LimitedAvailability'; |
85 | 85 | |
86 | - $price_type = get_post_meta( $this->context->id, 'price_type', true ); |
|
87 | - if ( false !== $price_type && '' !== $price_type && 'none' !== $price_type ) { |
|
88 | - $data['PriceSpecification'] = lsx_to_get_price_type_label( $price_type ); |
|
86 | + $price_type = get_post_meta($this->context->id, 'price_type', true); |
|
87 | + if (false !== $price_type && '' !== $price_type && 'none' !== $price_type) { |
|
88 | + $data['PriceSpecification'] = lsx_to_get_price_type_label($price_type); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | return $data; |
@@ -12,82 +12,82 @@ |
||
12 | 12 | */ |
13 | 13 | class LSX_TO_Specials_Schema extends LSX_TO_Schema_Graph_Piece { |
14 | 14 | |
15 | - /** |
|
16 | - * Constructor. |
|
17 | - * |
|
18 | - * @param \WPSEO_Schema_Context $context A value object with context variables. |
|
19 | - */ |
|
20 | - public function __construct( WPSEO_Schema_Context $context ) { |
|
21 | - $this->post_type = 'special'; |
|
22 | - parent::__construct( $context ); |
|
23 | - } |
|
15 | + /** |
|
16 | + * Constructor. |
|
17 | + * |
|
18 | + * @param \WPSEO_Schema_Context $context A value object with context variables. |
|
19 | + */ |
|
20 | + public function __construct( WPSEO_Schema_Context $context ) { |
|
21 | + $this->post_type = 'special'; |
|
22 | + parent::__construct( $context ); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Returns Review data. |
|
27 | - * |
|
28 | - * @return array $data Review data. |
|
29 | - */ |
|
30 | - public function generate() { |
|
31 | - $tour_list = get_post_meta( get_the_ID(), 'tour_to_special', false ); |
|
32 | - $accom_list = get_post_meta( get_the_ID(), 'accommodation_to_special', false ); |
|
33 | - $data = array( |
|
34 | - '@type' => array( |
|
35 | - 'Offer', |
|
36 | - ), |
|
37 | - '@id' => $this->context->canonical . '#special', |
|
38 | - 'name' => $this->post->post_title, |
|
39 | - 'description' => wp_strip_all_tags( $this->post->post_content ), |
|
40 | - 'url' => $this->post_url, |
|
41 | - 'mainEntityOfPage' => array( |
|
42 | - '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
|
43 | - ), |
|
44 | - ); |
|
25 | + /** |
|
26 | + * Returns Review data. |
|
27 | + * |
|
28 | + * @return array $data Review data. |
|
29 | + */ |
|
30 | + public function generate() { |
|
31 | + $tour_list = get_post_meta( get_the_ID(), 'tour_to_special', false ); |
|
32 | + $accom_list = get_post_meta( get_the_ID(), 'accommodation_to_special', false ); |
|
33 | + $data = array( |
|
34 | + '@type' => array( |
|
35 | + 'Offer', |
|
36 | + ), |
|
37 | + '@id' => $this->context->canonical . '#special', |
|
38 | + 'name' => $this->post->post_title, |
|
39 | + 'description' => wp_strip_all_tags( $this->post->post_content ), |
|
40 | + 'url' => $this->post_url, |
|
41 | + 'mainEntityOfPage' => array( |
|
42 | + '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
|
43 | + ), |
|
44 | + ); |
|
45 | 45 | |
46 | - if ( $this->context->site_represents_reference ) { |
|
47 | - $data['offeredBy'] = $this->context->site_represents_reference; |
|
48 | - } |
|
46 | + if ( $this->context->site_represents_reference ) { |
|
47 | + $data['offeredBy'] = $this->context->site_represents_reference; |
|
48 | + } |
|
49 | 49 | |
50 | - $data = $this->add_custom_field( $data, 'availabilityStarts', 'booking_validity_start' ); |
|
51 | - $data = $this->add_custom_field( $data, 'availabilityEnds', 'booking_validity_end' ); |
|
52 | - $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
|
53 | - $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
|
54 | - $data = $this->get_price( $data ); |
|
50 | + $data = $this->add_custom_field( $data, 'availabilityStarts', 'booking_validity_start' ); |
|
51 | + $data = $this->add_custom_field( $data, 'availabilityEnds', 'booking_validity_end' ); |
|
52 | + $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
|
53 | + $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
|
54 | + $data = $this->get_price( $data ); |
|
55 | 55 | |
56 | - $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $tour_list, 'Product' ); |
|
57 | - $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $accom_list, 'Product' ); |
|
56 | + $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $tour_list, 'Product' ); |
|
57 | + $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $accom_list, 'Product' ); |
|
58 | 58 | |
59 | - $data = $this->add_articles( $data ); |
|
60 | - $data = \lsx\legacy\Schema_Utils::add_image( $data, $this->context ); |
|
59 | + $data = $this->add_articles( $data ); |
|
60 | + $data = \lsx\legacy\Schema_Utils::add_image( $data, $this->context ); |
|
61 | 61 | |
62 | - return $data; |
|
63 | - } |
|
62 | + return $data; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Gets the single special post and adds it as a special "Offer". |
|
67 | - * |
|
68 | - * @param array $data An array of offers already added. |
|
69 | - * @return array $data |
|
70 | - */ |
|
71 | - public function get_price( $data ) { |
|
72 | - $price = get_post_meta( $this->context->id, 'price', true ); |
|
73 | - $currency = 'USD'; |
|
74 | - $tour_operator = tour_operator(); |
|
75 | - if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
|
76 | - if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
|
77 | - $currency = $tour_operator->options['general']['currency']; |
|
78 | - } |
|
79 | - } |
|
80 | - if ( false !== $price && '' !== $price ) { |
|
81 | - $data['price'] = $price; |
|
82 | - $data['priceCurrency'] = $currency; |
|
83 | - $data['category'] = __( 'Special', 'tour-operator-specials' ); |
|
84 | - $data['availability'] = 'https://schema.org/LimitedAvailability'; |
|
65 | + /** |
|
66 | + * Gets the single special post and adds it as a special "Offer". |
|
67 | + * |
|
68 | + * @param array $data An array of offers already added. |
|
69 | + * @return array $data |
|
70 | + */ |
|
71 | + public function get_price( $data ) { |
|
72 | + $price = get_post_meta( $this->context->id, 'price', true ); |
|
73 | + $currency = 'USD'; |
|
74 | + $tour_operator = tour_operator(); |
|
75 | + if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
|
76 | + if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
|
77 | + $currency = $tour_operator->options['general']['currency']; |
|
78 | + } |
|
79 | + } |
|
80 | + if ( false !== $price && '' !== $price ) { |
|
81 | + $data['price'] = $price; |
|
82 | + $data['priceCurrency'] = $currency; |
|
83 | + $data['category'] = __( 'Special', 'tour-operator-specials' ); |
|
84 | + $data['availability'] = 'https://schema.org/LimitedAvailability'; |
|
85 | 85 | |
86 | - $price_type = get_post_meta( $this->context->id, 'price_type', true ); |
|
87 | - if ( false !== $price_type && '' !== $price_type && 'none' !== $price_type ) { |
|
88 | - $data['PriceSpecification'] = lsx_to_get_price_type_label( $price_type ); |
|
89 | - } |
|
90 | - } |
|
91 | - return $data; |
|
92 | - } |
|
86 | + $price_type = get_post_meta( $this->context->id, 'price_type', true ); |
|
87 | + if ( false !== $price_type && '' !== $price_type && 'none' !== $price_type ) { |
|
88 | + $data['PriceSpecification'] = lsx_to_get_price_type_label( $price_type ); |
|
89 | + } |
|
90 | + } |
|
91 | + return $data; |
|
92 | + } |
|
93 | 93 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @link |
9 | 9 | * @copyright 2018 LightSpeedDevelopment |
10 | 10 | */ |
11 | -if (!class_exists( 'LSX_TO_Specials' ) ) { |
|
11 | +if ( ! class_exists('LSX_TO_Specials')) { |
|
12 | 12 | /** |
13 | 13 | * Main plugin class. |
14 | 14 | * |
@@ -56,19 +56,19 @@ discard block |
||
56 | 56 | $this->lsx_to_search_integration(); |
57 | 57 | |
58 | 58 | // Make TO last plugin to load |
59 | - add_action( 'activated_plugin', array( $this, 'activated_plugin' ) ); |
|
59 | + add_action('activated_plugin', array($this, 'activated_plugin')); |
|
60 | 60 | |
61 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
61 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
62 | 62 | |
63 | - if ( false !== $this->post_types ) { |
|
64 | - add_filter( 'lsx_to_framework_post_types', array( $this, 'post_types_filter' ) ); |
|
65 | - add_filter( 'lsx_to_post_types', array( $this, 'post_types_filter' ) ); |
|
66 | - add_filter( 'lsx_to_post_types_singular', array( $this, 'post_types_singular_filter' ) ); |
|
67 | - add_filter( 'lsx_to_settings_path', array( $this, 'plugin_path' ), 10, 2 ); |
|
63 | + if (false !== $this->post_types) { |
|
64 | + add_filter('lsx_to_framework_post_types', array($this, 'post_types_filter')); |
|
65 | + add_filter('lsx_to_post_types', array($this, 'post_types_filter')); |
|
66 | + add_filter('lsx_to_post_types_singular', array($this, 'post_types_singular_filter')); |
|
67 | + add_filter('lsx_to_settings_path', array($this, 'plugin_path'), 10, 2); |
|
68 | 68 | } |
69 | - if ( false !== $this->taxonomies ) { |
|
70 | - add_filter( 'lsx_to_framework_taxonomies', array( $this, 'taxonomies_filter' ) ); |
|
71 | - add_filter( 'lsx_to_framework_taxonomies_plural', array( $this, 'taxonomies_plural_filter' ) ); |
|
69 | + if (false !== $this->taxonomies) { |
|
70 | + add_filter('lsx_to_framework_taxonomies', array($this, 'taxonomies_filter')); |
|
71 | + add_filter('lsx_to_framework_taxonomies_plural', array($this, 'taxonomies_plural_filter')); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | require_once LSX_TO_SPECIALS_PATH . '/classes/class-to-specials-admin.php'; |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | require_once LSX_TO_SPECIALS_PATH . '/includes/template-tags.php'; |
77 | 77 | |
78 | 78 | // flush_rewrite_rules. |
79 | - register_activation_hook( LSX_TO_SPECIALS_CORE, array( $this, 'register_activation_hook' ) ); |
|
80 | - add_action( 'admin_init', array( $this, 'register_activation_hook_check' ) ); |
|
81 | - add_filter( 'wpseo_schema_graph_pieces', array( $this, 'add_graph_pieces' ), 11, 2 ); |
|
79 | + register_activation_hook(LSX_TO_SPECIALS_CORE, array($this, 'register_activation_hook')); |
|
80 | + add_action('admin_init', array($this, 'register_activation_hook_check')); |
|
81 | + add_filter('wpseo_schema_graph_pieces', array($this, 'add_graph_pieces'), 11, 2); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Include the post type for the search integration |
86 | 86 | */ |
87 | 87 | public function lsx_to_search_integration() { |
88 | - add_filter( 'lsx_to_search_post_types', array( $this, 'post_types_filter' ) ); |
|
89 | - add_filter( 'lsx_to_search_taxonomies', array( $this, 'taxonomies_filter' ) ); |
|
88 | + add_filter('lsx_to_search_post_types', array($this, 'post_types_filter')); |
|
89 | + add_filter('lsx_to_search_taxonomies', array($this, 'taxonomies_filter')); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Load the plugin text domain for translation. |
94 | 94 | */ |
95 | 95 | public function load_plugin_textdomain() { |
96 | - load_plugin_textdomain( 'to-specials', FALSE, basename( LSX_TO_SPECIALS_PATH ) . '/languages'); |
|
96 | + load_plugin_textdomain('to-specials', FALSE, basename(LSX_TO_SPECIALS_PATH) . '/languages'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -101,25 +101,25 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function set_vars() { |
103 | 103 | $this->post_types = array( |
104 | - 'special' => __( 'Specials', 'to-specials' ), |
|
104 | + 'special' => __('Specials', 'to-specials'), |
|
105 | 105 | ); |
106 | 106 | $this->post_types_singular = array( |
107 | - 'special' => __( 'Special', 'to-specials' ), |
|
107 | + 'special' => __('Special', 'to-specials'), |
|
108 | 108 | ); |
109 | - $this->post_type_slugs = array_keys( $this->post_types ); |
|
109 | + $this->post_type_slugs = array_keys($this->post_types); |
|
110 | 110 | $this->taxonomies = array( |
111 | - 'special-type' => __( 'Special Type', 'to-specials' ), |
|
111 | + 'special-type' => __('Special Type', 'to-specials'), |
|
112 | 112 | ); |
113 | 113 | $this->taxonomies_plural = array( |
114 | - 'special-type' => __( 'Special Types', 'to-specials' ), |
|
114 | + 'special-type' => __('Special Types', 'to-specials'), |
|
115 | 115 | ); |
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Adds our post types to an array via a filter |
120 | 120 | */ |
121 | - public function plugin_path( $path, $post_type ) { |
|
122 | - if ( false !== $this->post_types && array_key_exists( $post_type, $this->post_types ) ) { |
|
121 | + public function plugin_path($path, $post_type) { |
|
122 | + if (false !== $this->post_types && array_key_exists($post_type, $this->post_types)) { |
|
123 | 123 | $path = LSX_TO_SPECIALS_PATH; |
124 | 124 | } |
125 | 125 | return $path; |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * Adds our post types to an array via a filter |
130 | 130 | */ |
131 | - public function post_types_slugs_filter( $post_types ) { |
|
132 | - if ( is_array( $post_types ) ) { |
|
133 | - $post_types = array_merge( $post_types, $this->post_type_slugs ); |
|
131 | + public function post_types_slugs_filter($post_types) { |
|
132 | + if (is_array($post_types)) { |
|
133 | + $post_types = array_merge($post_types, $this->post_type_slugs); |
|
134 | 134 | } else { |
135 | 135 | $post_types = $this->post_type_slugs; |
136 | 136 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Adds our post types to an array via a filter |
142 | 142 | */ |
143 | - public function post_types_filter( $post_types ) { |
|
144 | - if ( is_array( $post_types ) && is_array( $this->post_types ) ) { |
|
145 | - $post_types = array_merge( $post_types, $this->post_types ); |
|
146 | - } elseif ( is_array( $this->post_types ) ) { |
|
143 | + public function post_types_filter($post_types) { |
|
144 | + if (is_array($post_types) && is_array($this->post_types)) { |
|
145 | + $post_types = array_merge($post_types, $this->post_types); |
|
146 | + } elseif (is_array($this->post_types)) { |
|
147 | 147 | $post_types = $this->post_types; |
148 | 148 | } |
149 | 149 | return $post_types; |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * Adds our post types to an array via a filter |
154 | 154 | */ |
155 | - public function post_types_singular_filter( $post_types_singular ){ |
|
156 | - if ( is_array( $post_types_singular ) && is_array( $this->post_types_singular ) ) { |
|
157 | - $post_types_singular = array_merge( $post_types_singular, $this->post_types_singular ); |
|
158 | - } elseif ( is_array( $this->post_types_singular ) ) { |
|
155 | + public function post_types_singular_filter($post_types_singular) { |
|
156 | + if (is_array($post_types_singular) && is_array($this->post_types_singular)) { |
|
157 | + $post_types_singular = array_merge($post_types_singular, $this->post_types_singular); |
|
158 | + } elseif (is_array($this->post_types_singular)) { |
|
159 | 159 | $post_types_singular = $this->post_types_singular; |
160 | 160 | } |
161 | 161 | return $post_types_singular; |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * Adds our taxonomies to an array via a filter |
166 | 166 | */ |
167 | - public function taxonomies_filter( $taxonomies ) { |
|
168 | - if ( is_array( $taxonomies ) && is_array( $this->taxonomies ) ) { |
|
169 | - $taxonomies = array_merge( $taxonomies, $this->taxonomies ); |
|
170 | - } elseif ( is_array( $this->taxonomies ) ) { |
|
167 | + public function taxonomies_filter($taxonomies) { |
|
168 | + if (is_array($taxonomies) && is_array($this->taxonomies)) { |
|
169 | + $taxonomies = array_merge($taxonomies, $this->taxonomies); |
|
170 | + } elseif (is_array($this->taxonomies)) { |
|
171 | 171 | $taxonomies = $this->taxonomies; |
172 | 172 | } |
173 | 173 | return $taxonomies; |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * Adds our taxonomies_plural to an array via a filter |
178 | 178 | */ |
179 | - public function taxonomies_plural_filter( $taxonomies_plural ) { |
|
180 | - if ( is_array( $taxonomies_plural ) && is_array( $this->taxonomies_plural ) ) { |
|
181 | - $taxonomies_plural = array_merge( $taxonomies_plural, $this->taxonomies_plural ); |
|
182 | - } elseif ( is_array( $this->taxonomies_plural ) ) { |
|
179 | + public function taxonomies_plural_filter($taxonomies_plural) { |
|
180 | + if (is_array($taxonomies_plural) && is_array($this->taxonomies_plural)) { |
|
181 | + $taxonomies_plural = array_merge($taxonomies_plural, $this->taxonomies_plural); |
|
182 | + } elseif (is_array($this->taxonomies_plural)) { |
|
183 | 183 | $taxonomies_plural = $this->taxonomies_plural; |
184 | 184 | } |
185 | 185 | return $taxonomies_plural; |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | * Make TO last plugin to load. |
190 | 190 | */ |
191 | 191 | public function activated_plugin() { |
192 | - if ( $plugins = get_option( 'active_plugins' ) ) { |
|
193 | - $search = preg_grep( '/.*\/tour-operator\.php/', $plugins ); |
|
194 | - $key = array_search( $search, $plugins ); |
|
195 | - |
|
196 | - if ( is_array( $search ) && count( $search ) ) { |
|
197 | - foreach ( $search as $key => $path ) { |
|
198 | - array_splice( $plugins, $key, 1 ); |
|
199 | - array_push( $plugins, $path ); |
|
200 | - update_option( 'active_plugins', $plugins ); |
|
192 | + if ($plugins = get_option('active_plugins')) { |
|
193 | + $search = preg_grep('/.*\/tour-operator\.php/', $plugins); |
|
194 | + $key = array_search($search, $plugins); |
|
195 | + |
|
196 | + if (is_array($search) && count($search)) { |
|
197 | + foreach ($search as $key => $path) { |
|
198 | + array_splice($plugins, $key, 1); |
|
199 | + array_push($plugins, $path); |
|
200 | + update_option('active_plugins', $plugins); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * On plugin activation |
208 | 208 | */ |
209 | 209 | public function register_activation_hook() { |
210 | - if ( ! is_network_admin() && ! isset( $_GET['activate-multi'] ) ) { |
|
211 | - set_transient( '_tour_operators_specials_flush_rewrite_rules', 1, 30 ); |
|
210 | + if ( ! is_network_admin() && ! isset($_GET['activate-multi'])) { |
|
211 | + set_transient('_tour_operators_specials_flush_rewrite_rules', 1, 30); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | * On plugin activation (check) |
217 | 217 | */ |
218 | 218 | public function register_activation_hook_check() { |
219 | - if ( ! get_transient( '_tour_operators_specials_flush_rewrite_rules' ) ) { |
|
219 | + if ( ! get_transient('_tour_operators_specials_flush_rewrite_rules')) { |
|
220 | 220 | return; |
221 | 221 | } |
222 | - delete_transient( '_tour_operators_specials_flush_rewrite_rules' ); |
|
222 | + delete_transient('_tour_operators_specials_flush_rewrite_rules'); |
|
223 | 223 | flush_rewrite_rules(); |
224 | 224 | } |
225 | 225 | /** |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return array $pieces Graph pieces to output. |
232 | 232 | */ |
233 | - public function add_graph_pieces( $pieces, $context ) { |
|
234 | - if ( class_exists( 'LSX_TO_Schema_Graph_Piece' ) ) { |
|
233 | + public function add_graph_pieces($pieces, $context) { |
|
234 | + if (class_exists('LSX_TO_Schema_Graph_Piece')) { |
|
235 | 235 | require_once LSX_TO_SPECIALS_PATH . 'classes/class-to-specials-schema.php'; |
236 | - $pieces[] = new LSX_TO_Specials_Schema( $context ); |
|
236 | + $pieces[] = new LSX_TO_Specials_Schema($context); |
|
237 | 237 | } |
238 | 238 | return $pieces; |
239 | 239 | } |
@@ -9,234 +9,234 @@ |
||
9 | 9 | * @copyright 2018 LightSpeedDevelopment |
10 | 10 | */ |
11 | 11 | if (!class_exists( 'LSX_TO_Specials' ) ) { |
12 | - /** |
|
13 | - * Main plugin class. |
|
14 | - * |
|
15 | - * @package LSX_Specials |
|
16 | - * @author LightSpeed |
|
17 | - */ |
|
18 | - class LSX_TO_Specials { |
|
19 | - |
|
20 | - /** |
|
21 | - * The plugins id |
|
22 | - */ |
|
23 | - public $plugin_slug = 'to-specials'; |
|
24 | - |
|
25 | - /** |
|
26 | - * The post types the plugin registers |
|
27 | - */ |
|
28 | - public $post_types = false; |
|
29 | - |
|
30 | - /** |
|
31 | - * The singular post types the plugin registers |
|
32 | - */ |
|
33 | - public $post_types_singular = false; |
|
34 | - |
|
35 | - /** |
|
36 | - * An array of the post types slugs plugin registers |
|
37 | - */ |
|
38 | - public $post_type_slugs = false; |
|
39 | - |
|
40 | - /** |
|
41 | - * The taxonomies the plugin registers |
|
42 | - */ |
|
43 | - public $taxonomies = false; |
|
44 | - |
|
45 | - /** |
|
46 | - * The taxonomies the plugin registers (plural) |
|
47 | - */ |
|
48 | - public $taxonomies_plural = false; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor |
|
52 | - */ |
|
53 | - public function __construct() { |
|
54 | - //Set the variables |
|
55 | - $this->set_vars(); |
|
56 | - $this->lsx_to_search_integration(); |
|
57 | - |
|
58 | - // Make TO last plugin to load |
|
59 | - add_action( 'activated_plugin', array( $this, 'activated_plugin' ) ); |
|
60 | - |
|
61 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
62 | - |
|
63 | - if ( false !== $this->post_types ) { |
|
64 | - add_filter( 'lsx_to_framework_post_types', array( $this, 'post_types_filter' ) ); |
|
65 | - add_filter( 'lsx_to_post_types', array( $this, 'post_types_filter' ) ); |
|
66 | - add_filter( 'lsx_to_post_types_singular', array( $this, 'post_types_singular_filter' ) ); |
|
67 | - add_filter( 'lsx_to_settings_path', array( $this, 'plugin_path' ), 10, 2 ); |
|
68 | - } |
|
69 | - if ( false !== $this->taxonomies ) { |
|
70 | - add_filter( 'lsx_to_framework_taxonomies', array( $this, 'taxonomies_filter' ) ); |
|
71 | - add_filter( 'lsx_to_framework_taxonomies_plural', array( $this, 'taxonomies_plural_filter' ) ); |
|
72 | - } |
|
73 | - |
|
74 | - require_once LSX_TO_SPECIALS_PATH . '/classes/class-to-specials-admin.php'; |
|
75 | - require_once LSX_TO_SPECIALS_PATH . '/classes/class-to-specials-frontend.php'; |
|
76 | - require_once LSX_TO_SPECIALS_PATH . '/includes/template-tags.php'; |
|
77 | - |
|
78 | - // flush_rewrite_rules. |
|
79 | - register_activation_hook( LSX_TO_SPECIALS_CORE, array( $this, 'register_activation_hook' ) ); |
|
80 | - add_action( 'admin_init', array( $this, 'register_activation_hook_check' ) ); |
|
81 | - add_filter( 'wpseo_schema_graph_pieces', array( $this, 'add_graph_pieces' ), 11, 2 ); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Include the post type for the search integration |
|
86 | - */ |
|
87 | - public function lsx_to_search_integration() { |
|
88 | - add_filter( 'lsx_to_search_post_types', array( $this, 'post_types_filter' ) ); |
|
89 | - add_filter( 'lsx_to_search_taxonomies', array( $this, 'taxonomies_filter' ) ); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Load the plugin text domain for translation. |
|
94 | - */ |
|
95 | - public function load_plugin_textdomain() { |
|
96 | - load_plugin_textdomain( 'to-specials', FALSE, basename( LSX_TO_SPECIALS_PATH ) . '/languages'); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Sets the plugins variables |
|
101 | - */ |
|
102 | - public function set_vars() { |
|
103 | - $this->post_types = array( |
|
104 | - 'special' => __( 'Specials', 'to-specials' ), |
|
105 | - ); |
|
106 | - $this->post_types_singular = array( |
|
107 | - 'special' => __( 'Special', 'to-specials' ), |
|
108 | - ); |
|
109 | - $this->post_type_slugs = array_keys( $this->post_types ); |
|
110 | - $this->taxonomies = array( |
|
111 | - 'special-type' => __( 'Special Type', 'to-specials' ), |
|
112 | - ); |
|
113 | - $this->taxonomies_plural = array( |
|
114 | - 'special-type' => __( 'Special Types', 'to-specials' ), |
|
115 | - ); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Adds our post types to an array via a filter |
|
120 | - */ |
|
121 | - public function plugin_path( $path, $post_type ) { |
|
122 | - if ( false !== $this->post_types && array_key_exists( $post_type, $this->post_types ) ) { |
|
123 | - $path = LSX_TO_SPECIALS_PATH; |
|
124 | - } |
|
125 | - return $path; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Adds our post types to an array via a filter |
|
130 | - */ |
|
131 | - public function post_types_slugs_filter( $post_types ) { |
|
132 | - if ( is_array( $post_types ) ) { |
|
133 | - $post_types = array_merge( $post_types, $this->post_type_slugs ); |
|
134 | - } else { |
|
135 | - $post_types = $this->post_type_slugs; |
|
136 | - } |
|
137 | - return $post_types; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Adds our post types to an array via a filter |
|
142 | - */ |
|
143 | - public function post_types_filter( $post_types ) { |
|
144 | - if ( is_array( $post_types ) && is_array( $this->post_types ) ) { |
|
145 | - $post_types = array_merge( $post_types, $this->post_types ); |
|
146 | - } elseif ( is_array( $this->post_types ) ) { |
|
147 | - $post_types = $this->post_types; |
|
148 | - } |
|
149 | - return $post_types; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Adds our post types to an array via a filter |
|
154 | - */ |
|
155 | - public function post_types_singular_filter( $post_types_singular ){ |
|
156 | - if ( is_array( $post_types_singular ) && is_array( $this->post_types_singular ) ) { |
|
157 | - $post_types_singular = array_merge( $post_types_singular, $this->post_types_singular ); |
|
158 | - } elseif ( is_array( $this->post_types_singular ) ) { |
|
159 | - $post_types_singular = $this->post_types_singular; |
|
160 | - } |
|
161 | - return $post_types_singular; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Adds our taxonomies to an array via a filter |
|
166 | - */ |
|
167 | - public function taxonomies_filter( $taxonomies ) { |
|
168 | - if ( is_array( $taxonomies ) && is_array( $this->taxonomies ) ) { |
|
169 | - $taxonomies = array_merge( $taxonomies, $this->taxonomies ); |
|
170 | - } elseif ( is_array( $this->taxonomies ) ) { |
|
171 | - $taxonomies = $this->taxonomies; |
|
172 | - } |
|
173 | - return $taxonomies; |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Adds our taxonomies_plural to an array via a filter |
|
178 | - */ |
|
179 | - public function taxonomies_plural_filter( $taxonomies_plural ) { |
|
180 | - if ( is_array( $taxonomies_plural ) && is_array( $this->taxonomies_plural ) ) { |
|
181 | - $taxonomies_plural = array_merge( $taxonomies_plural, $this->taxonomies_plural ); |
|
182 | - } elseif ( is_array( $this->taxonomies_plural ) ) { |
|
183 | - $taxonomies_plural = $this->taxonomies_plural; |
|
184 | - } |
|
185 | - return $taxonomies_plural; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Make TO last plugin to load. |
|
190 | - */ |
|
191 | - public function activated_plugin() { |
|
192 | - if ( $plugins = get_option( 'active_plugins' ) ) { |
|
193 | - $search = preg_grep( '/.*\/tour-operator\.php/', $plugins ); |
|
194 | - $key = array_search( $search, $plugins ); |
|
195 | - |
|
196 | - if ( is_array( $search ) && count( $search ) ) { |
|
197 | - foreach ( $search as $key => $path ) { |
|
198 | - array_splice( $plugins, $key, 1 ); |
|
199 | - array_push( $plugins, $path ); |
|
200 | - update_option( 'active_plugins', $plugins ); |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * On plugin activation |
|
208 | - */ |
|
209 | - public function register_activation_hook() { |
|
210 | - if ( ! is_network_admin() && ! isset( $_GET['activate-multi'] ) ) { |
|
211 | - set_transient( '_tour_operators_specials_flush_rewrite_rules', 1, 30 ); |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * On plugin activation (check) |
|
217 | - */ |
|
218 | - public function register_activation_hook_check() { |
|
219 | - if ( ! get_transient( '_tour_operators_specials_flush_rewrite_rules' ) ) { |
|
220 | - return; |
|
221 | - } |
|
222 | - delete_transient( '_tour_operators_specials_flush_rewrite_rules' ); |
|
223 | - flush_rewrite_rules(); |
|
224 | - } |
|
225 | - /** |
|
226 | - * Adds Schema pieces to our output. |
|
227 | - * |
|
228 | - * @param array $pieces Graph pieces to output. |
|
229 | - * @param \WPSEO_Schema_Context $context Object with context variables. |
|
230 | - * |
|
231 | - * @return array $pieces Graph pieces to output. |
|
232 | - */ |
|
233 | - public function add_graph_pieces( $pieces, $context ) { |
|
234 | - if ( class_exists( 'LSX_TO_Schema_Graph_Piece' ) ) { |
|
235 | - require_once LSX_TO_SPECIALS_PATH . 'classes/class-to-specials-schema.php'; |
|
236 | - $pieces[] = new LSX_TO_Specials_Schema( $context ); |
|
237 | - } |
|
238 | - return $pieces; |
|
239 | - } |
|
240 | - } |
|
241 | - new LSX_TO_Specials(); |
|
12 | + /** |
|
13 | + * Main plugin class. |
|
14 | + * |
|
15 | + * @package LSX_Specials |
|
16 | + * @author LightSpeed |
|
17 | + */ |
|
18 | + class LSX_TO_Specials { |
|
19 | + |
|
20 | + /** |
|
21 | + * The plugins id |
|
22 | + */ |
|
23 | + public $plugin_slug = 'to-specials'; |
|
24 | + |
|
25 | + /** |
|
26 | + * The post types the plugin registers |
|
27 | + */ |
|
28 | + public $post_types = false; |
|
29 | + |
|
30 | + /** |
|
31 | + * The singular post types the plugin registers |
|
32 | + */ |
|
33 | + public $post_types_singular = false; |
|
34 | + |
|
35 | + /** |
|
36 | + * An array of the post types slugs plugin registers |
|
37 | + */ |
|
38 | + public $post_type_slugs = false; |
|
39 | + |
|
40 | + /** |
|
41 | + * The taxonomies the plugin registers |
|
42 | + */ |
|
43 | + public $taxonomies = false; |
|
44 | + |
|
45 | + /** |
|
46 | + * The taxonomies the plugin registers (plural) |
|
47 | + */ |
|
48 | + public $taxonomies_plural = false; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor |
|
52 | + */ |
|
53 | + public function __construct() { |
|
54 | + //Set the variables |
|
55 | + $this->set_vars(); |
|
56 | + $this->lsx_to_search_integration(); |
|
57 | + |
|
58 | + // Make TO last plugin to load |
|
59 | + add_action( 'activated_plugin', array( $this, 'activated_plugin' ) ); |
|
60 | + |
|
61 | + add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
62 | + |
|
63 | + if ( false !== $this->post_types ) { |
|
64 | + add_filter( 'lsx_to_framework_post_types', array( $this, 'post_types_filter' ) ); |
|
65 | + add_filter( 'lsx_to_post_types', array( $this, 'post_types_filter' ) ); |
|
66 | + add_filter( 'lsx_to_post_types_singular', array( $this, 'post_types_singular_filter' ) ); |
|
67 | + add_filter( 'lsx_to_settings_path', array( $this, 'plugin_path' ), 10, 2 ); |
|
68 | + } |
|
69 | + if ( false !== $this->taxonomies ) { |
|
70 | + add_filter( 'lsx_to_framework_taxonomies', array( $this, 'taxonomies_filter' ) ); |
|
71 | + add_filter( 'lsx_to_framework_taxonomies_plural', array( $this, 'taxonomies_plural_filter' ) ); |
|
72 | + } |
|
73 | + |
|
74 | + require_once LSX_TO_SPECIALS_PATH . '/classes/class-to-specials-admin.php'; |
|
75 | + require_once LSX_TO_SPECIALS_PATH . '/classes/class-to-specials-frontend.php'; |
|
76 | + require_once LSX_TO_SPECIALS_PATH . '/includes/template-tags.php'; |
|
77 | + |
|
78 | + // flush_rewrite_rules. |
|
79 | + register_activation_hook( LSX_TO_SPECIALS_CORE, array( $this, 'register_activation_hook' ) ); |
|
80 | + add_action( 'admin_init', array( $this, 'register_activation_hook_check' ) ); |
|
81 | + add_filter( 'wpseo_schema_graph_pieces', array( $this, 'add_graph_pieces' ), 11, 2 ); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Include the post type for the search integration |
|
86 | + */ |
|
87 | + public function lsx_to_search_integration() { |
|
88 | + add_filter( 'lsx_to_search_post_types', array( $this, 'post_types_filter' ) ); |
|
89 | + add_filter( 'lsx_to_search_taxonomies', array( $this, 'taxonomies_filter' ) ); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Load the plugin text domain for translation. |
|
94 | + */ |
|
95 | + public function load_plugin_textdomain() { |
|
96 | + load_plugin_textdomain( 'to-specials', FALSE, basename( LSX_TO_SPECIALS_PATH ) . '/languages'); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Sets the plugins variables |
|
101 | + */ |
|
102 | + public function set_vars() { |
|
103 | + $this->post_types = array( |
|
104 | + 'special' => __( 'Specials', 'to-specials' ), |
|
105 | + ); |
|
106 | + $this->post_types_singular = array( |
|
107 | + 'special' => __( 'Special', 'to-specials' ), |
|
108 | + ); |
|
109 | + $this->post_type_slugs = array_keys( $this->post_types ); |
|
110 | + $this->taxonomies = array( |
|
111 | + 'special-type' => __( 'Special Type', 'to-specials' ), |
|
112 | + ); |
|
113 | + $this->taxonomies_plural = array( |
|
114 | + 'special-type' => __( 'Special Types', 'to-specials' ), |
|
115 | + ); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Adds our post types to an array via a filter |
|
120 | + */ |
|
121 | + public function plugin_path( $path, $post_type ) { |
|
122 | + if ( false !== $this->post_types && array_key_exists( $post_type, $this->post_types ) ) { |
|
123 | + $path = LSX_TO_SPECIALS_PATH; |
|
124 | + } |
|
125 | + return $path; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Adds our post types to an array via a filter |
|
130 | + */ |
|
131 | + public function post_types_slugs_filter( $post_types ) { |
|
132 | + if ( is_array( $post_types ) ) { |
|
133 | + $post_types = array_merge( $post_types, $this->post_type_slugs ); |
|
134 | + } else { |
|
135 | + $post_types = $this->post_type_slugs; |
|
136 | + } |
|
137 | + return $post_types; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Adds our post types to an array via a filter |
|
142 | + */ |
|
143 | + public function post_types_filter( $post_types ) { |
|
144 | + if ( is_array( $post_types ) && is_array( $this->post_types ) ) { |
|
145 | + $post_types = array_merge( $post_types, $this->post_types ); |
|
146 | + } elseif ( is_array( $this->post_types ) ) { |
|
147 | + $post_types = $this->post_types; |
|
148 | + } |
|
149 | + return $post_types; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Adds our post types to an array via a filter |
|
154 | + */ |
|
155 | + public function post_types_singular_filter( $post_types_singular ){ |
|
156 | + if ( is_array( $post_types_singular ) && is_array( $this->post_types_singular ) ) { |
|
157 | + $post_types_singular = array_merge( $post_types_singular, $this->post_types_singular ); |
|
158 | + } elseif ( is_array( $this->post_types_singular ) ) { |
|
159 | + $post_types_singular = $this->post_types_singular; |
|
160 | + } |
|
161 | + return $post_types_singular; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Adds our taxonomies to an array via a filter |
|
166 | + */ |
|
167 | + public function taxonomies_filter( $taxonomies ) { |
|
168 | + if ( is_array( $taxonomies ) && is_array( $this->taxonomies ) ) { |
|
169 | + $taxonomies = array_merge( $taxonomies, $this->taxonomies ); |
|
170 | + } elseif ( is_array( $this->taxonomies ) ) { |
|
171 | + $taxonomies = $this->taxonomies; |
|
172 | + } |
|
173 | + return $taxonomies; |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Adds our taxonomies_plural to an array via a filter |
|
178 | + */ |
|
179 | + public function taxonomies_plural_filter( $taxonomies_plural ) { |
|
180 | + if ( is_array( $taxonomies_plural ) && is_array( $this->taxonomies_plural ) ) { |
|
181 | + $taxonomies_plural = array_merge( $taxonomies_plural, $this->taxonomies_plural ); |
|
182 | + } elseif ( is_array( $this->taxonomies_plural ) ) { |
|
183 | + $taxonomies_plural = $this->taxonomies_plural; |
|
184 | + } |
|
185 | + return $taxonomies_plural; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Make TO last plugin to load. |
|
190 | + */ |
|
191 | + public function activated_plugin() { |
|
192 | + if ( $plugins = get_option( 'active_plugins' ) ) { |
|
193 | + $search = preg_grep( '/.*\/tour-operator\.php/', $plugins ); |
|
194 | + $key = array_search( $search, $plugins ); |
|
195 | + |
|
196 | + if ( is_array( $search ) && count( $search ) ) { |
|
197 | + foreach ( $search as $key => $path ) { |
|
198 | + array_splice( $plugins, $key, 1 ); |
|
199 | + array_push( $plugins, $path ); |
|
200 | + update_option( 'active_plugins', $plugins ); |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * On plugin activation |
|
208 | + */ |
|
209 | + public function register_activation_hook() { |
|
210 | + if ( ! is_network_admin() && ! isset( $_GET['activate-multi'] ) ) { |
|
211 | + set_transient( '_tour_operators_specials_flush_rewrite_rules', 1, 30 ); |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * On plugin activation (check) |
|
217 | + */ |
|
218 | + public function register_activation_hook_check() { |
|
219 | + if ( ! get_transient( '_tour_operators_specials_flush_rewrite_rules' ) ) { |
|
220 | + return; |
|
221 | + } |
|
222 | + delete_transient( '_tour_operators_specials_flush_rewrite_rules' ); |
|
223 | + flush_rewrite_rules(); |
|
224 | + } |
|
225 | + /** |
|
226 | + * Adds Schema pieces to our output. |
|
227 | + * |
|
228 | + * @param array $pieces Graph pieces to output. |
|
229 | + * @param \WPSEO_Schema_Context $context Object with context variables. |
|
230 | + * |
|
231 | + * @return array $pieces Graph pieces to output. |
|
232 | + */ |
|
233 | + public function add_graph_pieces( $pieces, $context ) { |
|
234 | + if ( class_exists( 'LSX_TO_Schema_Graph_Piece' ) ) { |
|
235 | + require_once LSX_TO_SPECIALS_PATH . 'classes/class-to-specials-schema.php'; |
|
236 | + $pieces[] = new LSX_TO_Specials_Schema( $context ); |
|
237 | + } |
|
238 | + return $pieces; |
|
239 | + } |
|
240 | + } |
|
241 | + new LSX_TO_Specials(); |
|
242 | 242 | } |