Skip to content

Commit

Permalink
v1.1.6
Browse files Browse the repository at this point in the history
Fixed conflict with appointment widgets
  • Loading branch information
atlantdak authored Jan 19, 2023
1 parent dc14003 commit 333b7bf
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 36 deletions.
7 changes: 4 additions & 3 deletions languages/mphb-elementor.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPLv2 or later.
msgid ""
msgstr ""
"Project-Id-Version: Hotel Booking & Elementor Integration 1.1.5\n"
"Project-Id-Version: Hotel Booking & Elementor Integration 1.1.6\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mphb-elementor\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2022-10-04T06:20:10+00:00\n"
"POT-Creation-Date: 2022-12-21T20:17:28+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.6.0\n"
"X-Domain: mphb-elementor\n"
Expand All @@ -34,7 +34,8 @@ msgstr ""
msgid "https://motopress.com/"
msgstr ""

#: plugin.php:67
#: plugin.php:90
#: plugin.php:105
msgid "MotoPress Hotel Booking"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion mphb-elementor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Hotel Booking & Elementor Integration
* Plugin URI: https://motopress.com/products/hotel-booking-elementor-integration/
* Description: Manage hotel booking shortcodes in Elementor builder.
* Version: 1.1.5
* Version: 1.1.6
* Author: MotoPress
* Author URI: https://motopress.com/
* License: GPLv2 or later
Expand Down
114 changes: 84 additions & 30 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class MPHBElementor
{
const SLUG = 'mphb-elementor';

const WIDGET_CATEGORY_NAME = 'motopress-hotel-booking';

private static $instance = null;

private function __construct() {
Expand All @@ -33,12 +35,33 @@ private function addActions()
return;
}

add_action('elementor/init', array($this, 'registerCategories'));
if ($this->isActiveLegacyElementor()) {
if (!version_compare(ELEMENTOR_VERSION, '2.2.4', '>=')) {
add_action('elementor/init', array($this, 'registerCategoriesLegacy'), 10);
}

add_action('elementor/elements/categories_registered', array($this, 'registerCategoriesLegacy'), 10);
add_action('elementor/widgets/widgets_registered', array($this, 'registerWidgetsLegacy'), 10);
} else {
add_filter('elementor/elements/categories_registered', array($this, 'registerCategories'), 10, 1);
add_filter('elementor/widgets/register', array($this, 'registerWidgets'), 10, 1);
}

add_action('elementor/init', array($this, 'addAvailableRoomsData'));
add_action('elementor/widgets/widgets_registered', array($this, 'registerWidgets'));
add_action('elementor/preview/enqueue_styles', array($this, 'enqueuePreviewStyles'));
}

/**
* @return bool
*/
protected function isActiveLegacyElementor() {
if (version_compare(ELEMENTOR_VERSION, '3.5.0', '>=' )) {
return false;
}

return true;
}

public function loadTextdomain()
{
global $wp_version;
Expand All @@ -55,47 +78,78 @@ public function loadTextdomain()
load_plugin_textdomain(self::SLUG, false, self::SLUG . '/languages');
}

/**
* Note that the categories are displayed in the widgets panel, only if they
* have widgets assigned to them.
*/
public function registerCategoriesLegacy()
{
\Elementor\Plugin::instance()->elements_manager->add_category(
self::WIDGET_CATEGORY_NAME,
array(
'title' => __('MotoPress Hotel Booking', 'mphb-elementor'),
'icon' => 'fa fa-plug'
)
);
}

/**
* Note that the categories are displayed in the widgets panel, only if they
* have widgets assigned to them.
*/
public function registerCategories()
{
\Elementor\Plugin::instance()->elements_manager->add_category(
'motopress-hotel-booking',
public function registerCategories( $elementsManager )
{
$elementsManager->add_category(
self::WIDGET_CATEGORY_NAME,
array(
'title' => __('MotoPress Hotel Booking', 'mphb-elementor'),
'icon' => 'fa fa-plug'
)
);
}

protected function widgets()
{
require __DIR__ . '/widgets/abstract-widget.php';
require __DIR__ . '/widgets/abstract-gallery-widget.php';
require __DIR__ . '/widgets/abstract-calendar-widget.php';
require __DIR__ . '/widgets/search-form-widget.php';
require __DIR__ . '/widgets/search-results-widget.php';
require __DIR__ . '/widgets/rooms-widget.php';
require __DIR__ . '/widgets/room-widget.php';
require __DIR__ . '/widgets/services-widget.php';
require __DIR__ . '/widgets/rates-widget.php';
require __DIR__ . '/widgets/availability-widget.php';
require __DIR__ . '/widgets/booking-confirmation-widget.php';
require __DIR__ . '/widgets/checkout-widget.php';
require __DIR__ . '/widgets/availability-calendar-widget.php';

return array(
new \mphbe\widgets\SearchFormWidget(),
new \mphbe\widgets\SearchResultsWidget(),
new \mphbe\widgets\RoomsWidget(),
new \mphbe\widgets\RoomWidget(),
new \mphbe\widgets\ServicesWidget(),
new \mphbe\widgets\RatesWidget(),
new \mphbe\widgets\AvailabilityWidget(),
new \mphbe\widgets\BookingConfirmationWidget(),
new \mphbe\widgets\CheckoutWidget(),
new \mphbe\widgets\AvailabilityCalendarWidget(),
);
}

public function registerWidgetsLegacy()
{
foreach ( $this->widgets() as $widget ) {
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( $widget );
}
}

public function registerWidgets($widgetsManager)
{
require __DIR__ . '/widgets/abstract-widget.php';
require __DIR__ . '/widgets/abstract-gallery-widget.php';
require __DIR__ . '/widgets/abstract-calendar-widget.php';
require __DIR__ . '/widgets/search-form-widget.php';
require __DIR__ . '/widgets/search-results-widget.php';
require __DIR__ . '/widgets/rooms-widget.php';
require __DIR__ . '/widgets/room-widget.php';
require __DIR__ . '/widgets/services-widget.php';
require __DIR__ . '/widgets/rates-widget.php';
require __DIR__ . '/widgets/availability-widget.php';
require __DIR__ . '/widgets/booking-confirmation-widget.php';
require __DIR__ . '/widgets/checkout-widget.php';
require __DIR__ . '/widgets/availability-calendar-widget.php';

$widgetsManager->register_widget_type(new \mphbe\widgets\SearchFormWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\SearchResultsWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\RoomsWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\RoomWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\ServicesWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\RatesWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\AvailabilityWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\BookingConfirmationWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\CheckoutWidget());
$widgetsManager->register_widget_type(new \mphbe\widgets\AvailabilityCalendarWidget());
foreach ( $this->widgets() as $widget ) {
$widgetsManager->register( $widget );
}
}

public function enqueuePreviewStyles()
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: MotoPress
Donate link: https://motopress.com/
Tags: hotel, booking, reservation, elementor, hotel booking, booking form
Requires at least: 4.6
Tested up to: 6.0
Tested up to: 6.1
Requires PHP: 5.6
Stable tag: 1.1.5
Stable tag: 1.1.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -51,6 +51,9 @@ Hotel Booking & Elementor Integration plugin is distributed under the terms of t

== Changelog ==

= 1.1.6, Dec 23 2022 =
* Fixed an issue with displaying widget categories in Elementor.

= 1.1.5, Oct 7 2022 =
* Added support for displaying prices in the availability calendars.

Expand Down

0 comments on commit 333b7bf

Please sign in to comment.