@@ -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 | } |
@@ -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(); |
@@ -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(); |
@@ -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 |
@@ -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 | |
@@ -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 | } |
@@ -10,235 +10,235 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | $metabox = array( |
| 13 | - 'title' => esc_html__( 'Tour Operator Plugin', 'to-specials' ), |
|
| 14 | - 'pages' => 'special', |
|
| 15 | - 'fields' => array(), |
|
| 13 | + 'title' => esc_html__( 'Tour Operator Plugin', 'to-specials' ), |
|
| 14 | + 'pages' => 'special', |
|
| 15 | + 'fields' => array(), |
|
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | 18 | $metabox['fields'][] = array( |
| 19 | - 'id' => 'featured', |
|
| 20 | - 'name' => esc_html__( 'Featured', 'to-specials' ), |
|
| 21 | - 'type' => 'checkbox', |
|
| 19 | + 'id' => 'featured', |
|
| 20 | + 'name' => esc_html__( 'Featured', 'to-specials' ), |
|
| 21 | + 'type' => 'checkbox', |
|
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | 24 | $metabox['fields'][] = array( |
| 25 | - 'id' => 'disable_single', |
|
| 26 | - 'name' => esc_html__( 'Disable Single', 'to-specials' ), |
|
| 27 | - 'type' => 'checkbox', |
|
| 25 | + 'id' => 'disable_single', |
|
| 26 | + 'name' => esc_html__( 'Disable Single', 'to-specials' ), |
|
| 27 | + 'type' => 'checkbox', |
|
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | 30 | if ( ! class_exists( 'LSX_Banners' ) ) { |
| 31 | - $metabox['fields'][] = array( |
|
| 32 | - 'id' => 'tagline', |
|
| 33 | - 'name' => esc_html__( 'Tagline', 'to-specials' ), |
|
| 34 | - 'type' => 'text', |
|
| 35 | - ); |
|
| 31 | + $metabox['fields'][] = array( |
|
| 32 | + 'id' => 'tagline', |
|
| 33 | + 'name' => esc_html__( 'Tagline', 'to-specials' ), |
|
| 34 | + 'type' => 'text', |
|
| 35 | + ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $metabox['fields'][] = array( |
| 39 | - 'id' => 'terms_conditions', |
|
| 40 | - 'name' => esc_html__( 'Terms & Conditions','to-specials' ), |
|
| 41 | - 'type' => 'wysiwyg', |
|
| 42 | - 'options' => array( |
|
| 43 | - 'editor_height' => '100', |
|
| 44 | - ), |
|
| 39 | + 'id' => 'terms_conditions', |
|
| 40 | + 'name' => esc_html__( 'Terms & Conditions','to-specials' ), |
|
| 41 | + 'type' => 'wysiwyg', |
|
| 42 | + 'options' => array( |
|
| 43 | + 'editor_height' => '100', |
|
| 44 | + ), |
|
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | 47 | if ( class_exists( 'LSX_TO_Team' ) ) { |
| 48 | - $metabox['fields'][] = array( |
|
| 49 | - 'id' => 'team_to_special', |
|
| 50 | - 'name' => esc_html__( 'Team Member', 'to-specials' ), |
|
| 51 | - 'type' => 'post_select', |
|
| 52 | - 'use_ajax' => false, |
|
| 53 | - 'allow_none' => true, |
|
| 54 | - 'query' => array( |
|
| 55 | - 'post_type' => 'team', |
|
| 56 | - 'nopagin' => true, |
|
| 57 | - 'posts_per_page' => 1000, |
|
| 58 | - 'orderby' => 'title', |
|
| 59 | - 'order' => 'ASC', |
|
| 60 | - ), |
|
| 61 | - ); |
|
| 48 | + $metabox['fields'][] = array( |
|
| 49 | + 'id' => 'team_to_special', |
|
| 50 | + 'name' => esc_html__( 'Team Member', 'to-specials' ), |
|
| 51 | + 'type' => 'post_select', |
|
| 52 | + 'use_ajax' => false, |
|
| 53 | + 'allow_none' => true, |
|
| 54 | + 'query' => array( |
|
| 55 | + 'post_type' => 'team', |
|
| 56 | + 'nopagin' => true, |
|
| 57 | + 'posts_per_page' => 1000, |
|
| 58 | + 'orderby' => 'title', |
|
| 59 | + 'order' => 'ASC', |
|
| 60 | + ), |
|
| 61 | + ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $metabox['fields'][] = array( |
| 65 | - 'id' => 'booking_title', |
|
| 66 | - 'name' => esc_html__( 'Booking','to-specials' ), |
|
| 67 | - 'type' => 'title', |
|
| 65 | + 'id' => 'booking_title', |
|
| 66 | + 'name' => esc_html__( 'Booking','to-specials' ), |
|
| 67 | + 'type' => 'title', |
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | $metabox['fields'][] = array( |
| 71 | - 'id' => 'price', |
|
| 72 | - 'name' => esc_html__( 'Price','to-specials' ), |
|
| 73 | - 'type' => 'text', |
|
| 71 | + 'id' => 'price', |
|
| 72 | + 'name' => esc_html__( 'Price','to-specials' ), |
|
| 73 | + 'type' => 'text', |
|
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | $metabox['fields'][] = array( |
| 77 | - 'id' => 'price_type', |
|
| 78 | - 'name' => esc_html__( 'Price Type','to-specials' ), |
|
| 79 | - 'type' => 'select', |
|
| 80 | - 'options' => array( |
|
| 81 | - 'none' => esc_html__( 'Select a type','to-specials' ), |
|
| 82 | - 'per_person' => esc_html__( 'Per Person','to-specials' ), |
|
| 83 | - 'per_person_per_night' => esc_html__( 'Per Person Per Night','to-specials' ), |
|
| 84 | - 'per_person_sharing' => esc_html__( 'Per Person Sharing','to-specials' ), |
|
| 85 | - 'per_person_sharing_per_night' => esc_html__( 'Per Person Sharing Per Night','to-specials' ), |
|
| 86 | - 'total_percentage' => esc_html__( 'Percentage Off Your Price.','to-specials' ), |
|
| 87 | - ), |
|
| 77 | + 'id' => 'price_type', |
|
| 78 | + 'name' => esc_html__( 'Price Type','to-specials' ), |
|
| 79 | + 'type' => 'select', |
|
| 80 | + 'options' => array( |
|
| 81 | + 'none' => esc_html__( 'Select a type','to-specials' ), |
|
| 82 | + 'per_person' => esc_html__( 'Per Person','to-specials' ), |
|
| 83 | + 'per_person_per_night' => esc_html__( 'Per Person Per Night','to-specials' ), |
|
| 84 | + 'per_person_sharing' => esc_html__( 'Per Person Sharing','to-specials' ), |
|
| 85 | + 'per_person_sharing_per_night' => esc_html__( 'Per Person Sharing Per Night','to-specials' ), |
|
| 86 | + 'total_percentage' => esc_html__( 'Percentage Off Your Price.','to-specials' ), |
|
| 87 | + ), |
|
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | $metabox['fields'][] = array( |
| 91 | - 'id' => 'duration', |
|
| 92 | - 'name' => esc_html__( 'Duration','to-specials' ), |
|
| 93 | - 'type' => 'text', |
|
| 91 | + 'id' => 'duration', |
|
| 92 | + 'name' => esc_html__( 'Duration','to-specials' ), |
|
| 93 | + 'type' => 'text', |
|
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | 96 | $metabox['fields'][] = array( |
| 97 | - 'id' => 'booking_validity_start', |
|
| 98 | - 'name' => esc_html__( 'Booking Validity (start)','to-specials' ), |
|
| 99 | - 'type' => 'date', |
|
| 97 | + 'id' => 'booking_validity_start', |
|
| 98 | + 'name' => esc_html__( 'Booking Validity (start)','to-specials' ), |
|
| 99 | + 'type' => 'date', |
|
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | $metabox['fields'][] = array( |
| 103 | - 'id' => 'booking_validity_end', |
|
| 104 | - 'name' => esc_html__( 'Booking Validity (end)','to-specials' ), |
|
| 105 | - 'type' => 'date', |
|
| 103 | + 'id' => 'booking_validity_end', |
|
| 104 | + 'name' => esc_html__( 'Booking Validity (end)','to-specials' ), |
|
| 105 | + 'type' => 'date', |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | $metabox['fields'][] = array( |
| 109 | - 'id' => 'expire_post', |
|
| 110 | - 'name' => esc_html__( 'Expire this special automatically', 'to-specials' ), |
|
| 111 | - 'type' => 'checkbox', |
|
| 109 | + 'id' => 'expire_post', |
|
| 110 | + 'name' => esc_html__( 'Expire this special automatically', 'to-specials' ), |
|
| 111 | + 'type' => 'checkbox', |
|
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | 114 | $metabox['fields'][] = array( |
| 115 | - 'id' => 'travel_dates', |
|
| 116 | - 'name' => '', |
|
| 117 | - 'single_name' => esc_html__( 'Travel Dates','to-specials' ), |
|
| 118 | - 'type' => 'group', |
|
| 119 | - 'repeatable' => true, |
|
| 120 | - 'sortable' => true, |
|
| 121 | - 'fields' => array( |
|
| 122 | - array( |
|
| 123 | - 'id' => 'travel_dates_start', |
|
| 124 | - 'name' => esc_html__( 'Start','to-specials' ), |
|
| 125 | - 'type' => 'date', |
|
| 126 | - ), |
|
| 127 | - array( |
|
| 128 | - 'id' => 'travel_dates_end', |
|
| 129 | - 'name' => esc_html__( 'End','to-specials' ), |
|
| 130 | - 'type' => 'date', |
|
| 131 | - ), |
|
| 132 | - ), |
|
| 115 | + 'id' => 'travel_dates', |
|
| 116 | + 'name' => '', |
|
| 117 | + 'single_name' => esc_html__( 'Travel Dates','to-specials' ), |
|
| 118 | + 'type' => 'group', |
|
| 119 | + 'repeatable' => true, |
|
| 120 | + 'sortable' => true, |
|
| 121 | + 'fields' => array( |
|
| 122 | + array( |
|
| 123 | + 'id' => 'travel_dates_start', |
|
| 124 | + 'name' => esc_html__( 'Start','to-specials' ), |
|
| 125 | + 'type' => 'date', |
|
| 126 | + ), |
|
| 127 | + array( |
|
| 128 | + 'id' => 'travel_dates_end', |
|
| 129 | + 'name' => esc_html__( 'End','to-specials' ), |
|
| 130 | + 'type' => 'date', |
|
| 131 | + ), |
|
| 132 | + ), |
|
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | 135 | if ( class_exists( 'LSX_TO_Maps' ) ) { |
| 136 | - $tour_operator = tour_operator(); |
|
| 137 | - $api_key = false; |
|
| 138 | - |
|
| 139 | - if ( isset( $tour_operator->options['api']['googlemaps_key'] ) ) { |
|
| 140 | - $api_key = $tour_operator->options['api']['googlemaps_key']; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $metabox['fields'][] = array( |
|
| 144 | - 'id' => 'location_title', |
|
| 145 | - 'name' => esc_html__( 'Location', 'to-specials' ), |
|
| 146 | - 'type' => 'title', |
|
| 147 | - ); |
|
| 148 | - |
|
| 149 | - $metabox['fields'][] = array( |
|
| 150 | - 'id' => 'location', |
|
| 151 | - 'name' => esc_html__( 'Location', 'to-specials' ), |
|
| 152 | - 'type' => 'gmap', |
|
| 153 | - 'google_api_key' => $api_key, |
|
| 154 | - ); |
|
| 136 | + $tour_operator = tour_operator(); |
|
| 137 | + $api_key = false; |
|
| 138 | + |
|
| 139 | + if ( isset( $tour_operator->options['api']['googlemaps_key'] ) ) { |
|
| 140 | + $api_key = $tour_operator->options['api']['googlemaps_key']; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $metabox['fields'][] = array( |
|
| 144 | + 'id' => 'location_title', |
|
| 145 | + 'name' => esc_html__( 'Location', 'to-specials' ), |
|
| 146 | + 'type' => 'title', |
|
| 147 | + ); |
|
| 148 | + |
|
| 149 | + $metabox['fields'][] = array( |
|
| 150 | + 'id' => 'location', |
|
| 151 | + 'name' => esc_html__( 'Location', 'to-specials' ), |
|
| 152 | + 'type' => 'gmap', |
|
| 153 | + 'google_api_key' => $api_key, |
|
| 154 | + ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $metabox['fields'][] = array( |
| 158 | - 'id' => 'gallery_title', |
|
| 159 | - 'name' => esc_html__( 'Gallery', 'to-specials' ), |
|
| 160 | - 'type' => 'title', |
|
| 158 | + 'id' => 'gallery_title', |
|
| 159 | + 'name' => esc_html__( 'Gallery', 'to-specials' ), |
|
| 160 | + 'type' => 'title', |
|
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | 163 | $metabox['fields'][] = array( |
| 164 | - 'id' => 'gallery', |
|
| 165 | - 'name' => '', |
|
| 166 | - 'type' => 'image', |
|
| 167 | - 'repeatable' => true, |
|
| 168 | - 'show_size' => false, |
|
| 169 | - 'sortable' => true, |
|
| 170 | - 'string-repeat-field' => esc_html__( 'Add new image', 'tour-operator' ), |
|
| 164 | + 'id' => 'gallery', |
|
| 165 | + 'name' => '', |
|
| 166 | + 'type' => 'image', |
|
| 167 | + 'repeatable' => true, |
|
| 168 | + 'show_size' => false, |
|
| 169 | + 'sortable' => true, |
|
| 170 | + 'string-repeat-field' => esc_html__( 'Add new image', 'tour-operator' ), |
|
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | 173 | if ( class_exists( 'Envira_Gallery' ) ) { |
| 174 | - $metabox['fields'][] = array( |
|
| 175 | - 'id' => 'envira_title', |
|
| 176 | - 'name' => esc_html__( 'Envira Gallery', 'to-specials' ), |
|
| 177 | - 'type' => 'title', |
|
| 178 | - ); |
|
| 179 | - |
|
| 180 | - $metabox['fields'][] = array( |
|
| 181 | - 'id' => 'envira_gallery', |
|
| 182 | - 'name' => esc_html__( 'Envira Gallery', 'to-specials' ), |
|
| 183 | - 'type' => 'post_select', |
|
| 184 | - 'use_ajax' => false, |
|
| 185 | - 'allow_none' => true, |
|
| 186 | - 'query' => array( |
|
| 187 | - 'post_type' => 'envira', |
|
| 188 | - 'nopagin' => true, |
|
| 189 | - 'posts_per_page' => '-1', |
|
| 190 | - 'orderby' => 'title', |
|
| 191 | - 'order' => 'ASC', |
|
| 192 | - ), |
|
| 193 | - ); |
|
| 194 | - |
|
| 195 | - if ( class_exists( 'Envira_Videos' ) ) { |
|
| 196 | - $metabox['fields'][] = array( |
|
| 197 | - 'id' => 'envira_video', |
|
| 198 | - 'name' => esc_html__( 'Envira Video Gallery', 'to-specials' ), |
|
| 199 | - 'type' => 'post_select', |
|
| 200 | - 'use_ajax' => false, |
|
| 201 | - 'allow_none' => true, |
|
| 202 | - 'query' => array( |
|
| 203 | - 'post_type' => 'envira', |
|
| 204 | - 'nopagin' => true, |
|
| 205 | - 'posts_per_page' => '-1', |
|
| 206 | - 'orderby' => 'title', |
|
| 207 | - 'order' => 'ASC', |
|
| 208 | - ), |
|
| 209 | - ); |
|
| 210 | - } |
|
| 174 | + $metabox['fields'][] = array( |
|
| 175 | + 'id' => 'envira_title', |
|
| 176 | + 'name' => esc_html__( 'Envira Gallery', 'to-specials' ), |
|
| 177 | + 'type' => 'title', |
|
| 178 | + ); |
|
| 179 | + |
|
| 180 | + $metabox['fields'][] = array( |
|
| 181 | + 'id' => 'envira_gallery', |
|
| 182 | + 'name' => esc_html__( 'Envira Gallery', 'to-specials' ), |
|
| 183 | + 'type' => 'post_select', |
|
| 184 | + 'use_ajax' => false, |
|
| 185 | + 'allow_none' => true, |
|
| 186 | + 'query' => array( |
|
| 187 | + 'post_type' => 'envira', |
|
| 188 | + 'nopagin' => true, |
|
| 189 | + 'posts_per_page' => '-1', |
|
| 190 | + 'orderby' => 'title', |
|
| 191 | + 'order' => 'ASC', |
|
| 192 | + ), |
|
| 193 | + ); |
|
| 194 | + |
|
| 195 | + if ( class_exists( 'Envira_Videos' ) ) { |
|
| 196 | + $metabox['fields'][] = array( |
|
| 197 | + 'id' => 'envira_video', |
|
| 198 | + 'name' => esc_html__( 'Envira Video Gallery', 'to-specials' ), |
|
| 199 | + 'type' => 'post_select', |
|
| 200 | + 'use_ajax' => false, |
|
| 201 | + 'allow_none' => true, |
|
| 202 | + 'query' => array( |
|
| 203 | + 'post_type' => 'envira', |
|
| 204 | + 'nopagin' => true, |
|
| 205 | + 'posts_per_page' => '-1', |
|
| 206 | + 'orderby' => 'title', |
|
| 207 | + 'order' => 'ASC', |
|
| 208 | + ), |
|
| 209 | + ); |
|
| 210 | + } |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | $post_types = array( |
| 214 | - 'post' => esc_html__( 'Posts', 'to-specials' ), |
|
| 215 | - 'accommodation' => esc_html__( 'Accommodation', 'to-specials' ), |
|
| 216 | - 'destination' => esc_html__( 'Destinations', 'to-specials' ), |
|
| 217 | - 'tour' => esc_html__( 'Tours', 'to-specials' ), |
|
| 214 | + 'post' => esc_html__( 'Posts', 'to-specials' ), |
|
| 215 | + 'accommodation' => esc_html__( 'Accommodation', 'to-specials' ), |
|
| 216 | + 'destination' => esc_html__( 'Destinations', 'to-specials' ), |
|
| 217 | + 'tour' => esc_html__( 'Tours', 'to-specials' ), |
|
| 218 | 218 | ); |
| 219 | 219 | |
| 220 | 220 | foreach ( $post_types as $slug => $label ) { |
| 221 | - $metabox['fields'][] = array( |
|
| 222 | - 'id' => $slug . '_title', |
|
| 223 | - 'name' => $label, |
|
| 224 | - 'type' => 'title', |
|
| 225 | - ); |
|
| 226 | - |
|
| 227 | - $metabox['fields'][] = array( |
|
| 228 | - 'id' => $slug . '_to_special', |
|
| 229 | - 'name' => $label . esc_html__( ' related with this special', 'to-specials' ), |
|
| 230 | - 'type' => 'post_select', |
|
| 231 | - 'use_ajax' => false, |
|
| 232 | - 'repeatable' => true, |
|
| 233 | - 'allow_none' => true, |
|
| 234 | - 'query' => array( |
|
| 235 | - 'post_type' => $slug, |
|
| 236 | - 'nopagin' => true, |
|
| 237 | - 'posts_per_page' => '-1', |
|
| 238 | - 'orderby' => 'title', |
|
| 239 | - 'order' => 'ASC', |
|
| 240 | - ), |
|
| 241 | - ); |
|
| 221 | + $metabox['fields'][] = array( |
|
| 222 | + 'id' => $slug . '_title', |
|
| 223 | + 'name' => $label, |
|
| 224 | + 'type' => 'title', |
|
| 225 | + ); |
|
| 226 | + |
|
| 227 | + $metabox['fields'][] = array( |
|
| 228 | + 'id' => $slug . '_to_special', |
|
| 229 | + 'name' => $label . esc_html__( ' related with this special', 'to-specials' ), |
|
| 230 | + 'type' => 'post_select', |
|
| 231 | + 'use_ajax' => false, |
|
| 232 | + 'repeatable' => true, |
|
| 233 | + 'allow_none' => true, |
|
| 234 | + 'query' => array( |
|
| 235 | + 'post_type' => $slug, |
|
| 236 | + 'nopagin' => true, |
|
| 237 | + 'posts_per_page' => '-1', |
|
| 238 | + 'orderby' => 'title', |
|
| 239 | + 'order' => 'ASC', |
|
| 240 | + ), |
|
| 241 | + ); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $metabox['fields'] = apply_filters( 'lsx_to_special_custom_fields', $metabox['fields'] ); |
@@ -14,19 +14,19 @@ discard block |
||
| 14 | 14 | * @category special |
| 15 | 15 | */ |
| 16 | 16 | if ( ! function_exists( 'lsx_to_special_posts' ) ) { |
| 17 | - function lsx_to_special_posts() { |
|
| 18 | - global $lsx_to_archive; |
|
| 19 | - |
|
| 20 | - $args = array( |
|
| 21 | - 'from' => 'post', |
|
| 22 | - 'to' => 'special', |
|
| 23 | - 'column' => '3', |
|
| 24 | - 'before' => '<section id="posts" 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-posts">' . esc_html__( 'Featured Posts', 'to-specials' ) . '</h2><div id="collapse-posts" class="collapse in"><div class="collapse-inner">', |
|
| 25 | - 'after' => '</div></div></section>', |
|
| 26 | - ); |
|
| 27 | - |
|
| 28 | - lsx_to_connected_panel_query( $args ); |
|
| 29 | - } |
|
| 17 | + function lsx_to_special_posts() { |
|
| 18 | + global $lsx_to_archive; |
|
| 19 | + |
|
| 20 | + $args = array( |
|
| 21 | + 'from' => 'post', |
|
| 22 | + 'to' => 'special', |
|
| 23 | + 'column' => '3', |
|
| 24 | + 'before' => '<section id="posts" 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-posts">' . esc_html__( 'Featured Posts', 'to-specials' ) . '</h2><div id="collapse-posts" class="collapse in"><div class="collapse-inner">', |
|
| 25 | + 'after' => '</div></div></section>', |
|
| 26 | + ); |
|
| 27 | + |
|
| 28 | + lsx_to_connected_panel_query( $args ); |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @category to-specials |
| 38 | 38 | */ |
| 39 | 39 | function lsx_to_special_content( $slug, $name = null ) { |
| 40 | - do_action( 'lsx_special_content', $slug, $name ); |
|
| 40 | + do_action( 'lsx_special_content', $slug, $name ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @category to-specials |
| 54 | 54 | */ |
| 55 | 55 | function lsx_to_specials_terms_conditions( $before = '', $after = '', $echo = true ) { |
| 56 | - lsx_to_custom_field_query( 'terms_conditions', $before, $after, $echo ); |
|
| 56 | + lsx_to_custom_field_query( 'terms_conditions', $before, $after, $echo ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -69,78 +69,78 @@ discard block |
||
| 69 | 69 | * @category to-specials |
| 70 | 70 | */ |
| 71 | 71 | function lsx_to_travel_dates( $before = '', $after = '', $echo = true ) { |
| 72 | - // --- START: [legacy] migrate content from old fields to new repeatable fields (grouped fields) |
|
| 73 | - |
|
| 74 | - $start = get_post_meta( get_the_ID(), 'travel_dates_start', true ); |
|
| 75 | - $end = get_post_meta( get_the_ID(), 'travel_dates_end', true ); |
|
| 76 | - |
|
| 77 | - if ( ! empty( $start ) && ! empty( $end ) ) { |
|
| 78 | - $start = date( 'M j, Y', strtotime( $start ) ); |
|
| 79 | - $end = date( 'M j, Y', strtotime( $end ) ); |
|
| 80 | - |
|
| 81 | - $new_field = array( |
|
| 82 | - 'travel_dates_start' => $start, |
|
| 83 | - 'travel_dates_end' => $end, |
|
| 84 | - ); |
|
| 85 | - |
|
| 86 | - delete_post_meta( get_the_ID(), 'travel_dates' ); |
|
| 87 | - update_post_meta( get_the_ID(), 'travel_dates', $new_field ); |
|
| 88 | - |
|
| 89 | - delete_post_meta( get_the_ID(), 'travel_dates_start' ); |
|
| 90 | - delete_post_meta( get_the_ID(), 'travel_dates_end' ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // --- END: [legacy] migrate content from old fields to new repeatable fields (grouped fields) |
|
| 94 | - |
|
| 95 | - $return = ''; |
|
| 96 | - $multiple = false; |
|
| 97 | - $dates = get_post_meta( get_the_ID(), 'travel_dates', false ); |
|
| 98 | - |
|
| 99 | - if ( is_array( $dates ) && ! empty( $dates ) ) { |
|
| 100 | - foreach ( $dates as $key => $value ) { |
|
| 101 | - $start = false; |
|
| 102 | - $end = false; |
|
| 103 | - |
|
| 104 | - if ( isset( $value['travel_dates_start'] ) ) { |
|
| 105 | - $start = $value['travel_dates_start']; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - if ( isset( $value['travel_dates_end'] ) ) { |
|
| 109 | - $end = $value['travel_dates_end']; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - if ( ! empty( $start ) ) { |
|
| 113 | - $start = date( 'd M Y', strtotime( $start ) ); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if ( ! empty( $end ) ) { |
|
| 117 | - $start .= ' - ' . date( 'd M Y', strtotime( $end ) ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if ( ! empty( $start ) ) { |
|
| 121 | - if ( ! empty( $return ) ) { |
|
| 122 | - $multiple = true; |
|
| 123 | - $return .= '<br>'; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $return .= $start; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - if ( ! empty( $return ) ) { |
|
| 132 | - if ( true === $multiple ) { |
|
| 133 | - $return = '<br>' . $return; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $return = $before . $return . $after; |
|
| 137 | - |
|
| 138 | - if ( $echo ) { |
|
| 139 | - echo wp_kses_post( $return ); |
|
| 140 | - } else { |
|
| 141 | - return $return; |
|
| 142 | - } |
|
| 143 | - } |
|
| 72 | + // --- START: [legacy] migrate content from old fields to new repeatable fields (grouped fields) |
|
| 73 | + |
|
| 74 | + $start = get_post_meta( get_the_ID(), 'travel_dates_start', true ); |
|
| 75 | + $end = get_post_meta( get_the_ID(), 'travel_dates_end', true ); |
|
| 76 | + |
|
| 77 | + if ( ! empty( $start ) && ! empty( $end ) ) { |
|
| 78 | + $start = date( 'M j, Y', strtotime( $start ) ); |
|
| 79 | + $end = date( 'M j, Y', strtotime( $end ) ); |
|
| 80 | + |
|
| 81 | + $new_field = array( |
|
| 82 | + 'travel_dates_start' => $start, |
|
| 83 | + 'travel_dates_end' => $end, |
|
| 84 | + ); |
|
| 85 | + |
|
| 86 | + delete_post_meta( get_the_ID(), 'travel_dates' ); |
|
| 87 | + update_post_meta( get_the_ID(), 'travel_dates', $new_field ); |
|
| 88 | + |
|
| 89 | + delete_post_meta( get_the_ID(), 'travel_dates_start' ); |
|
| 90 | + delete_post_meta( get_the_ID(), 'travel_dates_end' ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // --- END: [legacy] migrate content from old fields to new repeatable fields (grouped fields) |
|
| 94 | + |
|
| 95 | + $return = ''; |
|
| 96 | + $multiple = false; |
|
| 97 | + $dates = get_post_meta( get_the_ID(), 'travel_dates', false ); |
|
| 98 | + |
|
| 99 | + if ( is_array( $dates ) && ! empty( $dates ) ) { |
|
| 100 | + foreach ( $dates as $key => $value ) { |
|
| 101 | + $start = false; |
|
| 102 | + $end = false; |
|
| 103 | + |
|
| 104 | + if ( isset( $value['travel_dates_start'] ) ) { |
|
| 105 | + $start = $value['travel_dates_start']; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + if ( isset( $value['travel_dates_end'] ) ) { |
|
| 109 | + $end = $value['travel_dates_end']; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + if ( ! empty( $start ) ) { |
|
| 113 | + $start = date( 'd M Y', strtotime( $start ) ); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if ( ! empty( $end ) ) { |
|
| 117 | + $start .= ' - ' . date( 'd M Y', strtotime( $end ) ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if ( ! empty( $start ) ) { |
|
| 121 | + if ( ! empty( $return ) ) { |
|
| 122 | + $multiple = true; |
|
| 123 | + $return .= '<br>'; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $return .= $start; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + if ( ! empty( $return ) ) { |
|
| 132 | + if ( true === $multiple ) { |
|
| 133 | + $return = '<br>' . $return; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $return = $before . $return . $after; |
|
| 137 | + |
|
| 138 | + if ( $echo ) { |
|
| 139 | + echo wp_kses_post( $return ); |
|
| 140 | + } else { |
|
| 141 | + return $return; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,29 +156,29 @@ discard block |
||
| 156 | 156 | * @category to-specials |
| 157 | 157 | */ |
| 158 | 158 | function lsx_to_specials_validity( $before = '', $after = '', $echo = true ) { |
| 159 | - // $valid_from = get_the_date( 'M j, Y', get_the_ID() ); |
|
| 160 | - // $valid_to = get_post_meta( get_the_ID(), '_expiration-date', true ); |
|
| 159 | + // $valid_from = get_the_date( 'M j, Y', get_the_ID() ); |
|
| 160 | + // $valid_to = get_post_meta( get_the_ID(), '_expiration-date', true ); |
|
| 161 | 161 | |
| 162 | - $valid_from = get_post_meta( get_the_ID(), 'booking_validity_start', true ); |
|
| 163 | - $valid_to = get_post_meta( get_the_ID(), 'booking_validity_end', true ); |
|
| 162 | + $valid_from = get_post_meta( get_the_ID(), 'booking_validity_start', true ); |
|
| 163 | + $valid_to = get_post_meta( get_the_ID(), 'booking_validity_end', true ); |
|
| 164 | 164 | |
| 165 | - if ( ! empty( $valid_from ) ) { |
|
| 166 | - $valid_from = date( 'd M Y', strtotime( $valid_from ) ); |
|
| 167 | - } |
|
| 165 | + if ( ! empty( $valid_from ) ) { |
|
| 166 | + $valid_from = date( 'd M Y', strtotime( $valid_from ) ); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if ( ! empty( $valid_to ) ) { |
|
| 170 | - $valid_from .= ' - ' . date( 'd M Y', strtotime( $valid_to ) ); |
|
| 171 | - } |
|
| 169 | + if ( ! empty( $valid_to ) ) { |
|
| 170 | + $valid_from .= ' - ' . date( 'd M Y', strtotime( $valid_to ) ); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - if ( ! empty( $valid_from ) ) { |
|
| 174 | - $return = $before . $valid_from . $after; |
|
| 173 | + if ( ! empty( $valid_from ) ) { |
|
| 174 | + $return = $before . $valid_from . $after; |
|
| 175 | 175 | |
| 176 | - if ( $echo ) { |
|
| 177 | - echo wp_kses_post( $return ); |
|
| 178 | - } else { |
|
| 179 | - return $return; |
|
| 180 | - } |
|
| 181 | - } |
|
| 176 | + if ( $echo ) { |
|
| 177 | + echo wp_kses_post( $return ); |
|
| 178 | + } else { |
|
| 179 | + return $return; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -189,19 +189,19 @@ discard block |
||
| 189 | 189 | * @category special |
| 190 | 190 | */ |
| 191 | 191 | function lsx_to_accommodation_specials() { |
| 192 | - global $lsx_archive; |
|
| 193 | - |
|
| 194 | - if ( post_type_exists( 'special' ) && is_singular( 'accommodation' ) ) { |
|
| 195 | - $args = array( |
|
| 196 | - 'from' => 'special', |
|
| 197 | - 'to' => 'accommodation', |
|
| 198 | - 'column' => '3', |
|
| 199 | - 'before' => '<section id="special" 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-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
| 200 | - 'after' => '</div></div></section>', |
|
| 201 | - ); |
|
| 202 | - |
|
| 203 | - lsx_to_connected_panel_query( $args ); |
|
| 204 | - } |
|
| 192 | + global $lsx_archive; |
|
| 193 | + |
|
| 194 | + if ( post_type_exists( 'special' ) && is_singular( 'accommodation' ) ) { |
|
| 195 | + $args = array( |
|
| 196 | + 'from' => 'special', |
|
| 197 | + 'to' => 'accommodation', |
|
| 198 | + 'column' => '3', |
|
| 199 | + 'before' => '<section id="special" 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-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
| 200 | + 'after' => '</div></div></section>', |
|
| 201 | + ); |
|
| 202 | + |
|
| 203 | + lsx_to_connected_panel_query( $args ); |
|
| 204 | + } |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -212,19 +212,19 @@ discard block |
||
| 212 | 212 | * @category special |
| 213 | 213 | */ |
| 214 | 214 | function lsx_to_tour_specials() { |
| 215 | - global $lsx_archive; |
|
| 216 | - |
|
| 217 | - if ( post_type_exists( 'special' ) && is_singular( 'tour' ) ) { |
|
| 218 | - $args = array( |
|
| 219 | - 'from' => 'special', |
|
| 220 | - 'to' => 'tour', |
|
| 221 | - 'column' => '3', |
|
| 222 | - 'before' => '<section id="special" 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-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
| 223 | - 'after' => '</div></div></section>', |
|
| 224 | - ); |
|
| 225 | - |
|
| 226 | - lsx_to_connected_panel_query( $args ); |
|
| 227 | - } |
|
| 215 | + global $lsx_archive; |
|
| 216 | + |
|
| 217 | + if ( post_type_exists( 'special' ) && is_singular( 'tour' ) ) { |
|
| 218 | + $args = array( |
|
| 219 | + 'from' => 'special', |
|
| 220 | + 'to' => 'tour', |
|
| 221 | + 'column' => '3', |
|
| 222 | + 'before' => '<section id="special" 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-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
| 223 | + 'after' => '</div></div></section>', |
|
| 224 | + ); |
|
| 225 | + |
|
| 226 | + lsx_to_connected_panel_query( $args ); |
|
| 227 | + } |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -235,17 +235,17 @@ discard block |
||
| 235 | 235 | * @category special |
| 236 | 236 | */ |
| 237 | 237 | function lsx_to_destination_specials() { |
| 238 | - global $lsx_archive; |
|
| 239 | - |
|
| 240 | - if ( post_type_exists( 'special' ) && is_singular( 'destination' ) ) { |
|
| 241 | - $args = array( |
|
| 242 | - 'from' => 'special', |
|
| 243 | - 'to' => 'destination', |
|
| 244 | - 'column' => '3', |
|
| 245 | - 'before' => '<section id="special" 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-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
| 246 | - 'after' => '</div></div></section>', |
|
| 247 | - ); |
|
| 248 | - |
|
| 249 | - lsx_to_connected_panel_query( $args ); |
|
| 250 | - } |
|
| 238 | + global $lsx_archive; |
|
| 239 | + |
|
| 240 | + if ( post_type_exists( 'special' ) && is_singular( 'destination' ) ) { |
|
| 241 | + $args = array( |
|
| 242 | + 'from' => 'special', |
|
| 243 | + 'to' => 'destination', |
|
| 244 | + 'column' => '3', |
|
| 245 | + 'before' => '<section id="special" 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-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
| 246 | + 'after' => '</div></div></section>', |
|
| 247 | + ); |
|
| 248 | + |
|
| 249 | + lsx_to_connected_panel_query( $args ); |
|
| 250 | + } |
|
| 251 | 251 | } |
@@ -10,31 +10,31 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | $taxonomy = array( |
| 13 | - 'object_types' => 'special', |
|
| 14 | - 'menu_position' => 73, |
|
| 15 | - 'args' => array( |
|
| 16 | - 'hierarchical' => true, |
|
| 17 | - 'labels' => array( |
|
| 18 | - 'name' => esc_html__( 'Special Type', 'to-special' ), |
|
| 19 | - 'singular_name' => esc_html__( 'Special Type', 'to-special' ), |
|
| 20 | - 'search_items' => esc_html__( 'Search Types', 'to-special' ), |
|
| 21 | - 'all_items' => esc_html__( 'Special Types', 'to-special' ), |
|
| 22 | - 'parent_item' => esc_html__( 'Parent', 'to-special' ), |
|
| 23 | - 'parent_item_colon' => esc_html__( 'Parent:', 'to-special' ), |
|
| 24 | - 'edit_item' => esc_html__( 'Edit Special Type', 'to-special' ), |
|
| 25 | - 'update_item' => esc_html__( 'Update Special Type', 'to-special' ), |
|
| 26 | - 'add_new_item' => esc_html__( 'Add New Special Type', 'to-special' ), |
|
| 27 | - 'new_item_name' => esc_html__( 'New Role', 'to-special' ), |
|
| 28 | - 'menu_name' => esc_html__( 'Roles', 'to-special' ), |
|
| 29 | - ), |
|
| 30 | - 'show_ui' => true, |
|
| 31 | - 'public' => true, |
|
| 32 | - 'show_tagcloud' => false, |
|
| 33 | - 'exclude_from_search' => true, |
|
| 34 | - 'show_admin_column' => true, |
|
| 35 | - 'query_var' => true, |
|
| 36 | - 'rewrite' => array( 'special-type' ), |
|
| 37 | - ), |
|
| 13 | + 'object_types' => 'special', |
|
| 14 | + 'menu_position' => 73, |
|
| 15 | + 'args' => array( |
|
| 16 | + 'hierarchical' => true, |
|
| 17 | + 'labels' => array( |
|
| 18 | + 'name' => esc_html__( 'Special Type', 'to-special' ), |
|
| 19 | + 'singular_name' => esc_html__( 'Special Type', 'to-special' ), |
|
| 20 | + 'search_items' => esc_html__( 'Search Types', 'to-special' ), |
|
| 21 | + 'all_items' => esc_html__( 'Special Types', 'to-special' ), |
|
| 22 | + 'parent_item' => esc_html__( 'Parent', 'to-special' ), |
|
| 23 | + 'parent_item_colon' => esc_html__( 'Parent:', 'to-special' ), |
|
| 24 | + 'edit_item' => esc_html__( 'Edit Special Type', 'to-special' ), |
|
| 25 | + 'update_item' => esc_html__( 'Update Special Type', 'to-special' ), |
|
| 26 | + 'add_new_item' => esc_html__( 'Add New Special Type', 'to-special' ), |
|
| 27 | + 'new_item_name' => esc_html__( 'New Role', 'to-special' ), |
|
| 28 | + 'menu_name' => esc_html__( 'Roles', 'to-special' ), |
|
| 29 | + ), |
|
| 30 | + 'show_ui' => true, |
|
| 31 | + 'public' => true, |
|
| 32 | + 'show_tagcloud' => false, |
|
| 33 | + 'exclude_from_search' => true, |
|
| 34 | + 'show_admin_column' => true, |
|
| 35 | + 'query_var' => true, |
|
| 36 | + 'rewrite' => array( 'special-type' ), |
|
| 37 | + ), |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | return $taxonomy; |