Plugin Directory

Changeset 3019330


Ignore:
Timestamp:
01/09/2024 02:10:38 PM (2 years ago)
Author:
endzevich
Message:

Version: 1.1.2

Location:
mphb-styles/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • mphb-styles/trunk/includes/template-editor/includes/blocks/attribute.php

    r2918603 r3019330  
    88
    99    public $slug = 'attribute';
     10    public $customAttributes = [];
    1011    private $showLabel = true;
    1112
  • mphb-styles/trunk/includes/template-editor/includes/post-types/template.php

    r2918603 r3019330  
    1616        register_post_type($this->postType, array(
    1717            'labels'      => array(
    18                 'name' => __('Templates (beta)', 'mphb-styles'),
     18                'name' => __('Templates', 'mphb-styles'),
    1919                'singular_name' => __('Template', 'mphb-styles'),
     20                'add_new' => __('Add New Template', 'mphb-styles'),
    2021                'add_new_item' => __('Add New Template', 'mphb-styles'),
    2122                'edit_item' => __('Edit Template', 'mphb-styles'),
  • mphb-styles/trunk/includes/template-editor/includes/templates.php

    r2918603 r3019330  
    99    private $accommodationPostType;
    1010    private $selectedTemplateID;
     11    private $autopPriority = false;
    1112
    1213    public function __construct() {
     
    1617        add_action('init', array($this, 'addTemplates'));
    1718        add_filter('single_template', array($this, 'maybeReplaceAccommodationTemplate'), 20);
     19        add_filter('single_template', array($this, 'maybeReplaceTemplateTemplate'), 20);
    1820    }
    1921
     
    5153    public function filterAccommodationTypeTemplatesDropdown($templates) {
    5254        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;
    5383    }
    5484
     
    102132
    103133            // 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);
    105135
    106136            // 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        }
    110140    }
    111141
    112142    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 {
    117151            $content = get_post($this->selectedTemplateID)->post_content;
    118152        }
     
    121155    }
    122156
    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);
    128179        }
    129180    }
     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
    130189}
    131190
  • mphb-styles/trunk/languages/mphb-styles.pot

    r2918603 r3019330  
    1 # Copyright (C) 2022 MotoPress
     1# Copyright (C) 2024 MotoPress
    22# This file is distributed under the GPLv2 or later.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Hotel Booking Styles & Templates 1.0.2\n"
     5"Project-Id-Version: Hotel Booking Styles & Templates 1.1.2\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mphb-styles\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2022-11-15T13:29:53+02:00\n"
     12"POT-Creation-Date: 2024-01-08T14:29:32+03:00\n"
    1313"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"
    1515"X-Domain: mphb-styles\n"
    1616
     
    2020
    2121#. Description of the plugin
    22 msgid "Extra CSS styles to customize the MotoPress Hotel Booking plugin forms and widgets."
     22msgid "A set of tools to easily customize and style the booking forms, widgets, and accommodation type pages for the MotoPress Hotel Booking plugin."
    2323msgstr ""
    2424
     
    3939#: includes/template-editor/build/featured-image/index.js:1
    4040#: 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
    4145msgid "Default"
    4246msgstr ""
     
    179183msgstr ""
    180184
    181 #: includes/template-editor/includes/blocks/attribute.php:137
    182 msgid "Please choose attribute from available"
     185#: includes/template-editor/includes/blocks/attribute.php:138
     186msgid "Please choose an attribute from available ones."
    183187msgstr ""
    184188
    185189#: 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
     192msgid "Templates"
    187193msgstr ""
    188194
    189195#: includes/template-editor/includes/post-types/template.php:19
    190196#: includes/template-editor/build/template/index.js:1
     197#: includes/template-editor/src/template/index.js:62
    191198msgid "Template"
    192199msgstr ""
    193200
    194201#: includes/template-editor/includes/post-types/template.php:20
     202#: includes/template-editor/includes/post-types/template.php:21
    195203msgid "Add New Template"
    196204msgstr ""
    197205
    198 #: includes/template-editor/includes/post-types/template.php:21
     206#: includes/template-editor/includes/post-types/template.php:22
    199207msgid "Edit Template"
    200208msgstr ""
    201209
    202 #: includes/template-editor/includes/post-types/template.php:22
     210#: includes/template-editor/includes/post-types/template.php:23
    203211msgid "New Template"
    204212msgstr ""
    205213
    206 #: includes/template-editor/includes/post-types/template.php:23
     214#: includes/template-editor/includes/post-types/template.php:24
    207215msgid "View Template"
    208216msgstr ""
    209217
    210 #: includes/template-editor/includes/post-types/template.php:24
     218#: includes/template-editor/includes/post-types/template.php:25
    211219msgid "Search Templates"
    212220msgstr ""
    213221
    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
     223msgid "С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."
     224msgstr ""
     225
     226#: includes/template-editor/includes/templates.php:26
    224227msgid "Hotel Booking Full Width"
    225228msgstr ""
    226229
    227 #: includes/template-editor/includes/templates.php:25
     230#: includes/template-editor/includes/templates.php:27
    228231msgid "Hotel Booking Canvas"
    229232msgstr ""
     
    236239#: includes/template-editor/build/price/index.js:1
    237240#: includes/template-editor/build/title/index.js:1
     241#: includes/template-editor/src/controls/accommodation-select.js:24
    238242msgid "Accommodation Type"
    239243msgstr ""
     
    246250#: includes/template-editor/build/price/index.js:1
    247251#: includes/template-editor/build/title/index.js:1
     252#: includes/template-editor/src/controls/accommodation-select.js:28
    248253msgid "Leave blank to use current."
    249254msgstr ""
    250255
    251256#: includes/template-editor/build/attribute/index.js:1
     257#: includes/template-editor/src/attribute/index.js:15
    252258msgid "Adults"
    253259msgstr ""
    254260
    255261#: includes/template-editor/build/attribute/index.js:1
     262#: includes/template-editor/src/attribute/index.js:19
    256263msgid "Children"
    257264msgstr ""
    258265
    259266#: includes/template-editor/build/attribute/index.js:1
     267#: includes/template-editor/src/attribute/index.js:23
    260268msgid "Total Capacity"
    261269msgstr ""
     
    263271#: includes/template-editor/build/attribute/index.js:1
    264272#: 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
    265275msgid "Amenities"
    266276msgstr ""
     
    268278#: includes/template-editor/build/attribute/index.js:1
    269279#: 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
    270282msgid "View"
    271283msgstr ""
     
    273285#: includes/template-editor/build/attribute/index.js:1
    274286#: 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
    275289msgid "Size"
    276290msgstr ""
     
    278292#: includes/template-editor/build/attribute/index.js:1
    279293#: 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
    280296msgid "Bed Types"
    281297msgstr ""
     
    283299#: includes/template-editor/build/attribute/index.js:1
    284300#: 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
    285303msgid "Categories"
    286304msgstr ""
     
    294312#: includes/template-editor/build/title/index.js:1
    295313#: 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
    296322msgid "Settings"
    297323msgstr ""
    298324
    299325#: includes/template-editor/build/attribute/index.js:1
     326#: includes/template-editor/src/attribute/index.js:79
    300327msgid "Attribute"
    301328msgstr ""
    302329
    303330#: includes/template-editor/build/attribute/index.js:1
     331#: includes/template-editor/src/attribute/index.js:87
    304332msgid "Show label"
    305333msgstr ""
    306334
    307335#: includes/template-editor/build/attribute/index.js:1
     336#: includes/template-editor/src/attribute/index.js:60
    308337msgid "Accommodation Type Attribute"
    309338msgstr ""
    310339
    311340#: includes/template-editor/build/attributes/index.js:1
     341#: includes/template-editor/src/attributes/index.js:17
    312342msgid "Capacity"
    313343msgstr ""
    314344
    315345#: includes/template-editor/build/attributes/index.js:1
     346#: includes/template-editor/src/attributes/index.js:54
    316347msgid "Accommodation Type Attributes"
    317348msgstr ""
    318349
    319350#: includes/template-editor/build/content/index.js:1
     351#: includes/template-editor/src/content/index.js:16
    320352msgid "Accommodation Type Content"
    321353msgstr ""
     
    323355#: includes/template-editor/build/featured-image/index.js:1
    324356#: 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
    325359msgid "Link to post"
    326360msgstr ""
     
    328362#: includes/template-editor/build/featured-image/index.js:1
    329363#: 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
    330366msgid "Image size"
    331367msgstr ""
    332368
    333369#: includes/template-editor/build/featured-image/index.js:1
     370#: includes/template-editor/src/featured-image/index.js:40
    334371msgid "Accommodation Type Image"
    335372msgstr ""
    336373
    337374#: includes/template-editor/build/gallery/index.js:1
     375#: includes/template-editor/src/gallery/index.js:58
    338376msgid "Display as slider"
    339377msgstr ""
    340378
    341379#: 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
     381msgid "Check it out on the frontend once applied."
     382msgstr ""
     383
     384#: includes/template-editor/build/gallery/index.js:1
     385#: includes/template-editor/src/gallery/index.js:64
    346386msgid "Columns"
    347387msgstr ""
    348388
    349389#: includes/template-editor/build/gallery/index.js:1
     390#: includes/template-editor/src/gallery/index.js:71
    350391msgid "Link to"
    351392msgstr ""
    352393
    353394#: includes/template-editor/build/gallery/index.js:1
     395#: includes/template-editor/src/gallery/index.js:75
    354396msgid "None"
    355397msgstr ""
    356398
    357399#: includes/template-editor/build/gallery/index.js:1
     400#: includes/template-editor/src/gallery/index.js:76
    358401msgid "File"
    359402msgstr ""
    360403
    361404#: includes/template-editor/build/gallery/index.js:1
     405#: includes/template-editor/src/gallery/index.js:83
    362406msgid "Open in lightbox"
    363407msgstr ""
    364408
    365409#: includes/template-editor/build/gallery/index.js:1
     410#: includes/template-editor/src/gallery/index.js:88
    366411msgid "Yes"
    367412msgstr ""
    368413
    369414#: includes/template-editor/build/gallery/index.js:1
     415#: includes/template-editor/src/gallery/index.js:89
    370416msgid "No"
    371417msgstr ""
    372418
    373419#: includes/template-editor/build/gallery/index.js:1
     420#: includes/template-editor/src/gallery/index.js:33
    374421msgid "Accommodation Type Gallery"
    375422msgstr ""
    376423
    377424#: includes/template-editor/build/price/index.js:1
     425#: includes/template-editor/src/price/index.js:16
    378426msgid "Accommodation Type Price"
    379427msgstr ""
    380428
    381429#: 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
    382432msgid "Choose template"
    383433msgstr ""
    384434
    385435#: includes/template-editor/build/template/index.js:1
     436#: includes/template-editor/src/template/index.js:93
    386437msgid "No templates found"
    387438msgstr ""
    388439
    389440#: 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
    390443msgid "Create template"
    391444msgstr ""
    392445
    393446#: includes/template-editor/build/template/index.js:1
     447#: includes/template-editor/src/template/index.js:73
    394448msgid "Insert"
    395449msgstr ""
    396450
    397451#: includes/template-editor/build/title/index.js:1
     452#: includes/template-editor/src/title/index.js:16
    398453msgid "Accommodation Type Title"
    399454msgstr ""
    400455
    401456#: includes/template-editor/build/wrapper/index.js:1
    402 msgid "Wrapper width(in pixels)"
     457#: includes/template-editor/src/wrapper/index.js:24
     458msgid "Width"
    403459msgstr ""
    404460
    405461#: includes/template-editor/build/attribute/block.json
     462#: includes/template-editor/src/attribute/block.json
    406463msgctxt "block title"
    407464msgid "Accommodation Type Attribute"
     
    409466
    410467#: includes/template-editor/build/attributes/block.json
     468#: includes/template-editor/src/attributes/block.json
    411469msgctxt "block title"
    412470msgid "Accommodation Type Attributes"
     
    414472
    415473#: includes/template-editor/build/content/block.json
     474#: includes/template-editor/src/content/block.json
    416475msgctxt "block title"
    417476msgid "Accommodation Type Content"
     
    419478
    420479#: includes/template-editor/build/featured-image/block.json
     480#: includes/template-editor/src/featured-image/block.json
    421481msgctxt "block title"
    422482msgid "Accommodation Type Image"
     
    424484
    425485#: includes/template-editor/build/gallery/block.json
     486#: includes/template-editor/src/gallery/block.json
    426487msgctxt "block title"
    427488msgid "Accommodation Type Gallery"
     
    429490
    430491#: includes/template-editor/build/price/block.json
     492#: includes/template-editor/src/price/block.json
    431493msgctxt "block title"
    432494msgid "Accommodation Type Price"
     
    434496
    435497#: includes/template-editor/build/template/block.json
     498#: includes/template-editor/src/template/block.json
    436499msgctxt "block title"
    437500msgid "Accommodation Type Template"
     
    439502
    440503#: includes/template-editor/build/title/block.json
     504#: includes/template-editor/src/title/block.json
    441505msgctxt "block title"
    442506msgid "Accommodation Type Title"
     
    444508
    445509#: includes/template-editor/build/wrapper/block.json
     510#: includes/template-editor/src/wrapper/block.json
    446511msgctxt "block title"
    447512msgid "Hotel Booking Wrapper"
  • mphb-styles/trunk/mphb-styles.php

    r2918603 r3019330  
    44 * Plugin Name: Hotel Booking Styles & Templates
    55 * 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.1
     6 * Version: 1.1.2
    77 * Author: MotoPress
    88 * Author URI: https://motopress.com/
     
    1818
    1919if (!defined('MPHB\Styles\VERSION')) {
    20     define('MPHB\Styles\VERSION', '1.1.1');
     20    define('MPHB\Styles\VERSION', '1.1.2');
    2121    define('MPHB\Styles\PLUGIN_URL', plugin_dir_url(__FILE__)); // With trailing slash
    2222
  • mphb-styles/trunk/readme.txt

    r2918603 r3019330  
    44Tags: motopress hotel booking, hotel booking styles, free hotel booking plugin, booking form
    55Requires at least: 5.4
    6 Tested up to: 6.2
     6Tested up to: 6.4
    77Requires PHP: 5.6
    8 Stable tag: 1.1.1
     8Stable tag: 1.1.2
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7272== Changelog ==
    7373
     74= 1.1.2, Jan 08 2024 =
     75* Improved template replacement for Accommodation Type templates created via Elementor.
     76
    7477= 1.1.1, May 29 2023 =
    7578* Fixed an issue with the slider columns setting in the Accommodation Type Gallery block.
Note: See TracChangeset for help on using the changeset viewer.