Changeset 3019330
- Timestamp:
- 01/09/2024 02:10:38 PM (2 years ago)
- Location:
- mphb-styles/trunk
- Files:
-
- 6 edited
-
includes/template-editor/includes/blocks/attribute.php (modified) (1 diff)
-
includes/template-editor/includes/post-types/template.php (modified) (1 diff)
-
includes/template-editor/includes/templates.php (modified) (5 diffs)
-
languages/mphb-styles.pot (modified) (23 diffs)
-
mphb-styles.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mphb-styles/trunk/includes/template-editor/includes/blocks/attribute.php
r2918603 r3019330 8 8 9 9 public $slug = 'attribute'; 10 public $customAttributes = []; 10 11 private $showLabel = true; 11 12 -
mphb-styles/trunk/includes/template-editor/includes/post-types/template.php
r2918603 r3019330 16 16 register_post_type($this->postType, array( 17 17 'labels' => array( 18 'name' => __('Templates (beta)', 'mphb-styles'),18 'name' => __('Templates', 'mphb-styles'), 19 19 'singular_name' => __('Template', 'mphb-styles'), 20 'add_new' => __('Add New Template', 'mphb-styles'), 20 21 'add_new_item' => __('Add New Template', 'mphb-styles'), 21 22 'edit_item' => __('Edit Template', 'mphb-styles'), -
mphb-styles/trunk/includes/template-editor/includes/templates.php
r2918603 r3019330 9 9 private $accommodationPostType; 10 10 private $selectedTemplateID; 11 private $autopPriority = false; 11 12 12 13 public function __construct() { … … 16 17 add_action('init', array($this, 'addTemplates')); 17 18 add_filter('single_template', array($this, 'maybeReplaceAccommodationTemplate'), 20); 19 add_filter('single_template', array($this, 'maybeReplaceTemplateTemplate'), 20); 18 20 } 19 21 … … 51 53 public function filterAccommodationTypeTemplatesDropdown($templates) { 52 54 return $templates + $this->customTemplates; 55 } 56 57 public function maybeReplaceTemplateTemplate($template) { 58 global $post; 59 60 if(!$post || $post->post_type != 'mphb_template') { 61 return $template; 62 } 63 64 $phpTemplate = get_post_meta($post->ID, '_wp_page_template', true); 65 $hasPHPTemplate = isset($this->templates[$phpTemplate]); 66 67 if(!$hasPHPTemplate) { 68 return $template; 69 } 70 71 // try to apply template for selected Template(Full Width or Canvas) 72 $file = locate_template(MPHB()->getTemplatePath() . 'templates/single/' . $phpTemplate . '.php'); 73 74 if(empty($file)) { 75 $file = MPHB_TEMPLATES_PATH . 'includes/templates/single/' . $phpTemplate . '.php'; 76 } 77 78 if(file_exists($file)) { 79 return $file; 80 } 81 82 return $template; 53 83 } 54 84 … … 102 132 103 133 // try to make sure that our filter is almost certainly the first (-1 priority), content will be replaced in replaceAccommodationContent 104 add_filter('the_content', array($this, 'replaceAccommodationContent'), -1);134 add_filter('the_content', array($this, 'replaceAccommodationContent'), -1); 105 135 106 136 // next actions 107 remove_action('loop_start', array($this, 'applyTemplate'), 0);108 add_action('loop_end', array($this, 'stopReplaceAccommodationContent'));109 }137 remove_action('loop_start', array($this, 'applyTemplate'), 0); 138 add_action('loop_end', array($this, 'stopReplaceAccommodationContent')); 139 } 110 140 } 111 141 112 142 public function replaceAccommodationContent($content) { 113 if(is_main_query()) { 114 // remove the filter to ensure that the filter only runs once 115 remove_filter('the_content', array($this, 'replaceAccommodationContent'), -1); 116 // replace accommodation content with selected Template content 143 // remove the filter to ensure that the filter only runs once 144 remove_filter('the_content', array($this, 'replaceAccommodationContent'), -1); 145 146 // replace accommodation content with selected Template content 147 if ($this->shouldReplaceWithElementor()) { 148 $content = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display($this->selectedTemplateID, true); 149 $this->removeAutopFilter(); 150 } else { 117 151 $content = get_post($this->selectedTemplateID)->post_content; 118 152 } … … 121 155 } 122 156 123 public function stopReplaceAccommodationContent($query) { 124 if ($query->is_main_query()) { 125 // remove filter if some reason the_content don't used by theme's loop 126 remove_filter('the_content', array($this, 'replaceAccommodationContent')); 127 remove_action('loop_end', array($this, 'stopReplaceAccommodationContent')); 157 public function stopReplaceAccommodationContent() { 158 // remove filter if some reason the_content don't used by theme's loop 159 remove_filter('the_content', array($this, 'replaceAccommodationContent')); 160 remove_action('loop_end', array($this, 'stopReplaceAccommodationContent')); 161 } 162 163 private function shouldReplaceWithElementor() { 164 $should_replace = false; 165 166 if (class_exists('\Elementor\Plugin')) { 167 $should_replace = \Elementor\Plugin::instance()->documents->get($this->selectedTemplateID)->is_built_with_elementor(); 168 } 169 170 return $should_replace; 171 } 172 173 public function removeAutopFilter() { 174 $this->autopPriority = has_filter('the_content', 'wpautop'); 175 176 if (false !== $this->autopPriority) { 177 remove_filter('the_content', 'wpautop'); 178 add_filter('the_content', array($this, 'restoreAutopFilter'), $this->autopPriority + 1); 128 179 } 129 180 } 181 182 public function restoreAutopFilter($content) { 183 remove_filter('the_content', array($this, 'restoreAutopFilter'), $this->autopPriority + 1); 184 add_filter('the_content', 'wpautop', $this->autopPriority, $this->autopPriority); 185 186 return $content; 187 } 188 130 189 } 131 190 -
mphb-styles/trunk/languages/mphb-styles.pot
r2918603 r3019330 1 # Copyright (C) 202 2MotoPress1 # Copyright (C) 2024 MotoPress 2 2 # This file is distributed under the GPLv2 or later. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Hotel Booking Styles & Templates 1. 0.2\n"5 "Project-Id-Version: Hotel Booking Styles & Templates 1.1.2\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mphb-styles\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 202 2-11-15T13:29:53+02:00\n"12 "POT-Creation-Date: 2024-01-08T14:29:32+03:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 "X-Generator: WP-CLI 2. 7.1\n"14 "X-Generator: WP-CLI 2.9.0\n" 15 15 "X-Domain: mphb-styles\n" 16 16 … … 20 20 21 21 #. Description of the plugin 22 msgid " Extra CSS styles to customize the MotoPress Hotel Booking plugin forms and widgets."22 msgid "A set of tools to easily customize and style the booking forms, widgets, and accommodation type pages for the MotoPress Hotel Booking plugin." 23 23 msgstr "" 24 24 … … 39 39 #: includes/template-editor/build/featured-image/index.js:1 40 40 #: includes/template-editor/build/gallery/index.js:1 41 #: includes/template-editor/src/featured-image/index.js:19 42 #: includes/template-editor/src/gallery/index.js:25 43 #: includes/template-editor/src/gallery/index.js:74 44 #: includes/template-editor/src/gallery/index.js:87 41 45 msgid "Default" 42 46 msgstr "" … … 179 183 msgstr "" 180 184 181 #: includes/template-editor/includes/blocks/attribute.php:13 7182 msgid "Please choose a ttribute from available"185 #: includes/template-editor/includes/blocks/attribute.php:138 186 msgid "Please choose an attribute from available ones." 183 187 msgstr "" 184 188 185 189 #: includes/template-editor/includes/post-types/template.php:18 186 msgid "Templates (beta)" 190 #: includes/template-editor/includes/post-types/template.php:57 191 #: includes/template-editor/includes/post-types/template.php:58 192 msgid "Templates" 187 193 msgstr "" 188 194 189 195 #: includes/template-editor/includes/post-types/template.php:19 190 196 #: includes/template-editor/build/template/index.js:1 197 #: includes/template-editor/src/template/index.js:62 191 198 msgid "Template" 192 199 msgstr "" 193 200 194 201 #: includes/template-editor/includes/post-types/template.php:20 202 #: includes/template-editor/includes/post-types/template.php:21 195 203 msgid "Add New Template" 196 204 msgstr "" 197 205 198 #: includes/template-editor/includes/post-types/template.php:2 1206 #: includes/template-editor/includes/post-types/template.php:22 199 207 msgid "Edit Template" 200 208 msgstr "" 201 209 202 #: includes/template-editor/includes/post-types/template.php:2 2210 #: includes/template-editor/includes/post-types/template.php:23 203 211 msgid "New Template" 204 212 msgstr "" 205 213 206 #: includes/template-editor/includes/post-types/template.php:2 3214 #: includes/template-editor/includes/post-types/template.php:24 207 215 msgid "View Template" 208 216 msgstr "" 209 217 210 #: includes/template-editor/includes/post-types/template.php:2 4218 #: includes/template-editor/includes/post-types/template.php:25 211 219 msgid "Search Templates" 212 220 msgstr "" 213 221 214 #: includes/template-editor/includes/post-types/template.php:49 215 #: includes/template-editor/includes/post-types/template.php:50 216 msgid "Templates" 217 msgstr "" 218 219 #: includes/template-editor/includes/post-types/template.php:68 220 msgid "Description" 221 msgstr "" 222 223 #: includes/template-editor/includes/templates.php:24 222 #: includes/template-editor/includes/post-types/template.php:76 223 msgid "Сhange the look of your accommodation type pages by creating custom templates. You can apply your templates to the chosen properties via Accommodation Type > Template selector." 224 msgstr "" 225 226 #: includes/template-editor/includes/templates.php:26 224 227 msgid "Hotel Booking Full Width" 225 228 msgstr "" 226 229 227 #: includes/template-editor/includes/templates.php:2 5230 #: includes/template-editor/includes/templates.php:27 228 231 msgid "Hotel Booking Canvas" 229 232 msgstr "" … … 236 239 #: includes/template-editor/build/price/index.js:1 237 240 #: includes/template-editor/build/title/index.js:1 241 #: includes/template-editor/src/controls/accommodation-select.js:24 238 242 msgid "Accommodation Type" 239 243 msgstr "" … … 246 250 #: includes/template-editor/build/price/index.js:1 247 251 #: includes/template-editor/build/title/index.js:1 252 #: includes/template-editor/src/controls/accommodation-select.js:28 248 253 msgid "Leave blank to use current." 249 254 msgstr "" 250 255 251 256 #: includes/template-editor/build/attribute/index.js:1 257 #: includes/template-editor/src/attribute/index.js:15 252 258 msgid "Adults" 253 259 msgstr "" 254 260 255 261 #: includes/template-editor/build/attribute/index.js:1 262 #: includes/template-editor/src/attribute/index.js:19 256 263 msgid "Children" 257 264 msgstr "" 258 265 259 266 #: includes/template-editor/build/attribute/index.js:1 267 #: includes/template-editor/src/attribute/index.js:23 260 268 msgid "Total Capacity" 261 269 msgstr "" … … 263 271 #: includes/template-editor/build/attribute/index.js:1 264 272 #: includes/template-editor/build/attributes/index.js:1 273 #: includes/template-editor/src/attribute/index.js:27 274 #: includes/template-editor/src/attributes/index.js:21 265 275 msgid "Amenities" 266 276 msgstr "" … … 268 278 #: includes/template-editor/build/attribute/index.js:1 269 279 #: includes/template-editor/build/attributes/index.js:1 280 #: includes/template-editor/src/attribute/index.js:31 281 #: includes/template-editor/src/attributes/index.js:25 270 282 msgid "View" 271 283 msgstr "" … … 273 285 #: includes/template-editor/build/attribute/index.js:1 274 286 #: includes/template-editor/build/attributes/index.js:1 287 #: includes/template-editor/src/attribute/index.js:35 288 #: includes/template-editor/src/attributes/index.js:29 275 289 msgid "Size" 276 290 msgstr "" … … 278 292 #: includes/template-editor/build/attribute/index.js:1 279 293 #: includes/template-editor/build/attributes/index.js:1 294 #: includes/template-editor/src/attribute/index.js:39 295 #: includes/template-editor/src/attributes/index.js:33 280 296 msgid "Bed Types" 281 297 msgstr "" … … 283 299 #: includes/template-editor/build/attribute/index.js:1 284 300 #: includes/template-editor/build/attributes/index.js:1 301 #: includes/template-editor/src/attribute/index.js:43 302 #: includes/template-editor/src/attributes/index.js:37 285 303 msgid "Categories" 286 304 msgstr "" … … 294 312 #: includes/template-editor/build/title/index.js:1 295 313 #: includes/template-editor/build/wrapper/index.js:1 314 #: includes/template-editor/src/attribute/index.js:70 315 #: includes/template-editor/src/attributes/index.js:64 316 #: includes/template-editor/src/content/index.js:26 317 #: includes/template-editor/src/featured-image/index.js:49 318 #: includes/template-editor/src/gallery/index.js:42 319 #: includes/template-editor/src/price/index.js:26 320 #: includes/template-editor/src/title/index.js:25 321 #: includes/template-editor/src/wrapper/index.js:21 296 322 msgid "Settings" 297 323 msgstr "" 298 324 299 325 #: includes/template-editor/build/attribute/index.js:1 326 #: includes/template-editor/src/attribute/index.js:79 300 327 msgid "Attribute" 301 328 msgstr "" 302 329 303 330 #: includes/template-editor/build/attribute/index.js:1 331 #: includes/template-editor/src/attribute/index.js:87 304 332 msgid "Show label" 305 333 msgstr "" 306 334 307 335 #: includes/template-editor/build/attribute/index.js:1 336 #: includes/template-editor/src/attribute/index.js:60 308 337 msgid "Accommodation Type Attribute" 309 338 msgstr "" 310 339 311 340 #: includes/template-editor/build/attributes/index.js:1 341 #: includes/template-editor/src/attributes/index.js:17 312 342 msgid "Capacity" 313 343 msgstr "" 314 344 315 345 #: includes/template-editor/build/attributes/index.js:1 346 #: includes/template-editor/src/attributes/index.js:54 316 347 msgid "Accommodation Type Attributes" 317 348 msgstr "" 318 349 319 350 #: includes/template-editor/build/content/index.js:1 351 #: includes/template-editor/src/content/index.js:16 320 352 msgid "Accommodation Type Content" 321 353 msgstr "" … … 323 355 #: includes/template-editor/build/featured-image/index.js:1 324 356 #: includes/template-editor/build/title/index.js:1 357 #: includes/template-editor/src/featured-image/index.js:57 358 #: includes/template-editor/src/title/index.js:33 325 359 msgid "Link to post" 326 360 msgstr "" … … 328 362 #: includes/template-editor/build/featured-image/index.js:1 329 363 #: includes/template-editor/build/gallery/index.js:1 364 #: includes/template-editor/src/featured-image/index.js:62 365 #: includes/template-editor/src/gallery/index.js:50 330 366 msgid "Image size" 331 367 msgstr "" 332 368 333 369 #: includes/template-editor/build/featured-image/index.js:1 370 #: includes/template-editor/src/featured-image/index.js:40 334 371 msgid "Accommodation Type Image" 335 372 msgstr "" 336 373 337 374 #: includes/template-editor/build/gallery/index.js:1 375 #: includes/template-editor/src/gallery/index.js:58 338 376 msgid "Display as slider" 339 377 msgstr "" 340 378 341 379 #: includes/template-editor/build/gallery/index.js:1 342 msgid "This option is applied on frontend only." 343 msgstr "" 344 345 #: includes/template-editor/build/gallery/index.js:1 380 #: includes/template-editor/src/gallery/index.js:61 381 msgid "Check it out on the frontend once applied." 382 msgstr "" 383 384 #: includes/template-editor/build/gallery/index.js:1 385 #: includes/template-editor/src/gallery/index.js:64 346 386 msgid "Columns" 347 387 msgstr "" 348 388 349 389 #: includes/template-editor/build/gallery/index.js:1 390 #: includes/template-editor/src/gallery/index.js:71 350 391 msgid "Link to" 351 392 msgstr "" 352 393 353 394 #: includes/template-editor/build/gallery/index.js:1 395 #: includes/template-editor/src/gallery/index.js:75 354 396 msgid "None" 355 397 msgstr "" 356 398 357 399 #: includes/template-editor/build/gallery/index.js:1 400 #: includes/template-editor/src/gallery/index.js:76 358 401 msgid "File" 359 402 msgstr "" 360 403 361 404 #: includes/template-editor/build/gallery/index.js:1 405 #: includes/template-editor/src/gallery/index.js:83 362 406 msgid "Open in lightbox" 363 407 msgstr "" 364 408 365 409 #: includes/template-editor/build/gallery/index.js:1 410 #: includes/template-editor/src/gallery/index.js:88 366 411 msgid "Yes" 367 412 msgstr "" 368 413 369 414 #: includes/template-editor/build/gallery/index.js:1 415 #: includes/template-editor/src/gallery/index.js:89 370 416 msgid "No" 371 417 msgstr "" 372 418 373 419 #: includes/template-editor/build/gallery/index.js:1 420 #: includes/template-editor/src/gallery/index.js:33 374 421 msgid "Accommodation Type Gallery" 375 422 msgstr "" 376 423 377 424 #: includes/template-editor/build/price/index.js:1 425 #: includes/template-editor/src/price/index.js:16 378 426 msgid "Accommodation Type Price" 379 427 msgstr "" 380 428 381 429 #: includes/template-editor/build/template/index.js:1 430 #: includes/template-editor/src/template/index.js:27 431 #: includes/template-editor/src/template/index.js:53 382 432 msgid "Choose template" 383 433 msgstr "" 384 434 385 435 #: includes/template-editor/build/template/index.js:1 436 #: includes/template-editor/src/template/index.js:93 386 437 msgid "No templates found" 387 438 msgstr "" 388 439 389 440 #: includes/template-editor/build/template/index.js:1 441 #: includes/template-editor/src/template/index.js:80 442 #: includes/template-editor/src/template/index.js:99 390 443 msgid "Create template" 391 444 msgstr "" 392 445 393 446 #: includes/template-editor/build/template/index.js:1 447 #: includes/template-editor/src/template/index.js:73 394 448 msgid "Insert" 395 449 msgstr "" 396 450 397 451 #: includes/template-editor/build/title/index.js:1 452 #: includes/template-editor/src/title/index.js:16 398 453 msgid "Accommodation Type Title" 399 454 msgstr "" 400 455 401 456 #: includes/template-editor/build/wrapper/index.js:1 402 msgid "Wrapper width(in pixels)" 457 #: includes/template-editor/src/wrapper/index.js:24 458 msgid "Width" 403 459 msgstr "" 404 460 405 461 #: includes/template-editor/build/attribute/block.json 462 #: includes/template-editor/src/attribute/block.json 406 463 msgctxt "block title" 407 464 msgid "Accommodation Type Attribute" … … 409 466 410 467 #: includes/template-editor/build/attributes/block.json 468 #: includes/template-editor/src/attributes/block.json 411 469 msgctxt "block title" 412 470 msgid "Accommodation Type Attributes" … … 414 472 415 473 #: includes/template-editor/build/content/block.json 474 #: includes/template-editor/src/content/block.json 416 475 msgctxt "block title" 417 476 msgid "Accommodation Type Content" … … 419 478 420 479 #: includes/template-editor/build/featured-image/block.json 480 #: includes/template-editor/src/featured-image/block.json 421 481 msgctxt "block title" 422 482 msgid "Accommodation Type Image" … … 424 484 425 485 #: includes/template-editor/build/gallery/block.json 486 #: includes/template-editor/src/gallery/block.json 426 487 msgctxt "block title" 427 488 msgid "Accommodation Type Gallery" … … 429 490 430 491 #: includes/template-editor/build/price/block.json 492 #: includes/template-editor/src/price/block.json 431 493 msgctxt "block title" 432 494 msgid "Accommodation Type Price" … … 434 496 435 497 #: includes/template-editor/build/template/block.json 498 #: includes/template-editor/src/template/block.json 436 499 msgctxt "block title" 437 500 msgid "Accommodation Type Template" … … 439 502 440 503 #: includes/template-editor/build/title/block.json 504 #: includes/template-editor/src/title/block.json 441 505 msgctxt "block title" 442 506 msgid "Accommodation Type Title" … … 444 508 445 509 #: includes/template-editor/build/wrapper/block.json 510 #: includes/template-editor/src/wrapper/block.json 446 511 msgctxt "block title" 447 512 msgid "Hotel Booking Wrapper" -
mphb-styles/trunk/mphb-styles.php
r2918603 r3019330 4 4 * Plugin Name: Hotel Booking Styles & Templates 5 5 * Description: A set of tools to easily customize and style the booking forms, widgets, and accommodation type pages for the MotoPress Hotel Booking plugin. 6 * Version: 1.1. 16 * Version: 1.1.2 7 7 * Author: MotoPress 8 8 * Author URI: https://motopress.com/ … … 18 18 19 19 if (!defined('MPHB\Styles\VERSION')) { 20 define('MPHB\Styles\VERSION', '1.1. 1');20 define('MPHB\Styles\VERSION', '1.1.2'); 21 21 define('MPHB\Styles\PLUGIN_URL', plugin_dir_url(__FILE__)); // With trailing slash 22 22 -
mphb-styles/trunk/readme.txt
r2918603 r3019330 4 4 Tags: motopress hotel booking, hotel booking styles, free hotel booking plugin, booking form 5 5 Requires at least: 5.4 6 Tested up to: 6. 26 Tested up to: 6.4 7 7 Requires PHP: 5.6 8 Stable tag: 1.1. 18 Stable tag: 1.1.2 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 72 72 == Changelog == 73 73 74 = 1.1.2, Jan 08 2024 = 75 * Improved template replacement for Accommodation Type templates created via Elementor. 76 74 77 = 1.1.1, May 29 2023 = 75 78 * Fixed an issue with the slider columns setting in the Accommodation Type Gallery block.
Note: See TracChangeset
for help on using the changeset viewer.