Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ugoku committed Dec 6, 2024
1 parent ff5ee9b commit 8560245
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion editor/form-arrangement.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
});

document.getElementById('arrangement_submit').addEventListener('click', function(){
let shortcode = '[recras-package id="' + document.getElementById('arrangement_id').value + '" show="' + document.getElementById('show_what').value + '"';
let shortcode = '[<?= \Recras\Arrangement::SHORTCODE; ?> id="' + document.getElementById('arrangement_id').value + '" show="' + document.getElementById('show_what').value + '"';
if (document.getElementById('show_what').value === 'programme') {
if (document.getElementById('starttime').value !== '00:00') {
shortcode += ' starttime="' + document.getElementById('starttime').value + '"';
Expand Down
2 changes: 1 addition & 1 deletion editor/form-booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
} else {
packageIDsMultiple = [...selectedPackages].map(el => el.value);
}
let shortcode = '[<?= \Recras\Plugin::SHORTCODE_ONLINE_BOOKING; ?>';
let shortcode = '[<?= \Recras\OnlineBooking::SHORTCODE; ?>';
if (packageIDsMultiple.length > 0 && useNewLibrary) {
shortcode += ' package_list="' + packageIDsMultiple.join(',') + '"';
} else if (arrangementID) {
Expand Down
2 changes: 1 addition & 1 deletion editor/form-bookprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function bpIdChange () {
document.getElementById('bp_submit').addEventListener('click', function() {
const elPackage = document.getElementById('first_widget_value_package');

let shortcode = '[<?= \Recras\Plugin::SHORTCODE_BOOK_PROCESS; ?> id="' + document.getElementById('bookprocess_id').value + '"';
let shortcode = '[<?= \Recras\Bookprocess::SHORTCODE; ?> id="' + document.getElementById('bookprocess_id').value + '"';

let initialValue;
if (elPackage && elPackage.value) {
Expand Down
2 changes: 1 addition & 1 deletion editor/form-contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
});

document.getElementById('contact_submit').addEventListener('click', function(){
let shortcode = '[<?= \Recras\Plugin::SHORTCODE_CONTACT_FORM; ?> id="' + document.getElementById('contactform_id').value + '"';
let shortcode = '[<?= \Recras\ContactForm::SHORTCODE; ?> id="' + document.getElementById('contactform_id').value + '"';

const options = ['showtitle', 'showlabels', 'showplaceholders'];
for (let opt of options) {
Expand Down
2 changes: 1 addition & 1 deletion editor/form-package-availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<script>
document.getElementById('arrangement_submit').addEventListener('click', function(){
let shortcode = '[recras-availability id="' + document.getElementById('arrangement_id').value + '"';
let shortcode = '[<?= \Recras\Availability::SHORTCODE; ?> id="' + document.getElementById('arrangement_id').value + '"';
if (!document.getElementById('auto_resize').checked) {
shortcode += ' autoresize=0';
}
Expand Down
2 changes: 1 addition & 1 deletion editor/form-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<script>
document.getElementById('product_submit').addEventListener('click', function(){
const shortcode = '[recras-product id="' +
const shortcode = '[<?= \Recras\Products::SHORTCODE; ?> id="' +
document.getElementById('product_id').value + '" show="' +
document.getElementById('show_what').value + '"]';

Expand Down
2 changes: 1 addition & 1 deletion editor/form-voucher-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<script>
document.getElementById('voucher_submit').addEventListener('click', function(){
let shortcode = '[<?= \Recras\Plugin::SHORTCODE_VOUCHER_INFO; ?>';
let shortcode = '[<?= \Recras\Vouchers::SHORTCODE_INFO; ?>';
shortcode += ' id="' + document.getElementById('template_id').value + '"';
shortcode += ' show="' + document.getElementById('show_what').value + '"';
shortcode += ']';
Expand Down
2 changes: 1 addition & 1 deletion editor/form-voucher-sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<script>
document.getElementById('voucher_submit').addEventListener('click', function(){
const templateID = document.getElementById('template_id').value;
let shortcode = '[<?= \Recras\Plugin::SHORTCODE_VOUCHER_SALES; ?>';
let shortcode = '[<?= \Recras\Vouchers::SHORTCODE_SALES; ?>';

if (templateID !== '0') {
shortcode += ' id="' + templateID + '"';
Expand Down
1 change: 1 addition & 0 deletions src/Arrangement.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class Arrangement
{
public const SHORTCODE = 'recras-package';
private const SHOW_DEFAULT = 'title';

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

class Availability
{
public const SHORTCODE = 'recras-availability';

/**
* Add the [recras-availability] shortcode
*
Expand Down
1 change: 1 addition & 0 deletions src/Bookprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class Bookprocess
{
public const SHORTCODE = 'recras-bookprocess';
/**
* Clear book process cache (transients)
*/
Expand Down
1 change: 1 addition & 0 deletions src/ContactForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ContactForm
{
public const PATTERN_DATE = '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])';
public const PATTERN_TIME = '(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9])';
public const SHORTCODE = 'recras-contact';

public static function getDefaultCountry(): ?string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Elementor/Bookprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected function render(): void
return;
}

$shortcode = '[' . \Recras\Plugin::SHORTCODE_BOOK_PROCESS;
$shortcode = '[' . \Recras\Bookprocess::SHORTCODE;
$shortcode .= ' id="' . $settings['bp_id'] . '"';
$shortcode .= ' initial_widget_value="' . $settings['initial_widget_value'] . '"';
$shortcode .= ' hide_first_widget="' . $settings['hide_first_widget'] . '"';
Expand Down
2 changes: 2 additions & 0 deletions src/OnlineBooking.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

class OnlineBooking
{
public const SHORTCODE = 'recras-booking';

/**
* Add the [recras-booking] shortcode
*
Expand Down
22 changes: 8 additions & 14 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ class Plugin
private const LIBRARY_VERSION = '2.0.6';
public const TEXT_DOMAIN = 'recras';

public const SHORTCODE_BOOK_PROCESS = 'recras-bookprocess';
public const SHORTCODE_CONTACT_FORM = 'recras-contact';
public const SHORTCODE_ONLINE_BOOKING = 'recras-booking';
public const SHORTCODE_VOUCHER_SALES = 'recras-vouchers';
public const SHORTCODE_VOUCHER_INFO = 'recras-voucher-info';

public string $baseUrl;
public Transient $transients;

Expand Down Expand Up @@ -129,14 +123,14 @@ public function addMenuItems(): void
*/
public function addShortcodes(): void
{
add_shortcode('recras-availability', [Availability::class, 'renderAvailability']);
add_shortcode($this::SHORTCODE_ONLINE_BOOKING, [OnlineBooking::class, 'renderOnlineBooking']);
add_shortcode($this::SHORTCODE_BOOK_PROCESS, [Bookprocess::class, 'renderBookprocess']);
add_shortcode($this::SHORTCODE_CONTACT_FORM, [ContactForm::class, 'renderContactForm']);
add_shortcode('recras-package', [Arrangement::class, 'renderPackage']);
add_shortcode('recras-product', [Products::class, 'renderProduct']);
add_shortcode($this::SHORTCODE_VOUCHER_SALES, [Vouchers::class, 'renderVoucherSales']);
add_shortcode($this::SHORTCODE_VOUCHER_INFO, [Vouchers::class, 'renderVoucherInfo']);
add_shortcode(Availability::SHORTCODE, [Availability::class, 'renderAvailability']);
add_shortcode(OnlineBooking::SHORTCODE, [OnlineBooking::class, 'renderOnlineBooking']);
add_shortcode(Bookprocess::SHORTCODE, [Bookprocess::class, 'renderBookprocess']);
add_shortcode(ContactForm::SHORTCODE, [ContactForm::class, 'renderContactForm']);
add_shortcode(Arrangement::SHORTCODE, [Arrangement::class, 'renderPackage']);
add_shortcode(Products::SHORTCODE, [Products::class, 'renderProduct']);
add_shortcode(Vouchers::SHORTCODE_SALES, [Vouchers::class, 'renderVoucherSales']);
add_shortcode(Vouchers::SHORTCODE_INFO, [Vouchers::class, 'renderVoucherInfo']);
}


Expand Down
1 change: 1 addition & 0 deletions src/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class Products
{
public const SHORTCODE = 'recras-product';
private const SHOW_DEFAULT = 'title';

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Vouchers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

class Vouchers
{
public const SHORTCODE_SALES = 'recras-vouchers';
public const SHORTCODE_INFO = 'recras-voucher-info';
private const SHOW_DEFAULT = 'name';

/**
Expand Down

0 comments on commit 8560245

Please sign in to comment.