Changeset 3221428
- Timestamp:
- 01/13/2025 09:06:21 AM (13 months ago)
- Location:
- recras
- Files:
-
- 20 edited
- 1 copied
-
tags/6.3.0 (copied) (copied from recras/trunk)
-
tags/6.3.0/changelog.md (modified) (1 diff)
-
tags/6.3.0/editor/plugin.js (modified) (2 diffs)
-
tags/6.3.0/readme.txt (modified) (2 diffs)
-
tags/6.3.0/recras-wordpress-plugin.php (modified) (1 diff)
-
tags/6.3.0/src/Gutenberg.php (modified) (1 diff)
-
tags/6.3.0/src/OnlineBooking.php (modified) (1 diff)
-
tags/6.3.0/src/Plugin.php (modified) (7 diffs)
-
tags/6.3.0/src/Settings.php (modified) (1 diff)
-
tags/6.3.0/src/Transient.php (modified) (1 diff)
-
tags/6.3.0/src/Vouchers.php (modified) (1 diff)
-
trunk/changelog.md (modified) (1 diff)
-
trunk/editor/plugin.js (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/recras-wordpress-plugin.php (modified) (1 diff)
-
trunk/src/Gutenberg.php (modified) (1 diff)
-
trunk/src/OnlineBooking.php (modified) (1 diff)
-
trunk/src/Plugin.php (modified) (7 diffs)
-
trunk/src/Settings.php (modified) (1 diff)
-
trunk/src/Transient.php (modified) (1 diff)
-
trunk/src/Vouchers.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
recras/tags/6.3.0/changelog.md
r3217607 r3221428 1 1 # Changelog 2 3 ## 6.3.0 (2025-01-13) 4 * The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance 5 * Plugin now requires WP 6.5 or higher 2 6 3 7 ## 6.2.3 (2025-01-06) -
recras/tags/6.3.0/editor/plugin.js
r2612483 r3221428 16 16 }); 17 17 18 editor.addButton('recras-booking', { 19 title: recras_l10n.online_booking, 20 image: url + '/online-booking.svg', 21 onclick: function() { 22 tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking'); 23 } 24 }); 18 if (recras_l10n.showOnlineBooking === 'yes') { 19 editor.addButton('recras-booking', { 20 title: recras_l10n.online_booking, 21 image: url + '/online-booking.svg', 22 onclick: function() { 23 tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking'); 24 } 25 }); 26 } 25 27 26 28 editor.addButton('recras-bookprocess', { … … 48 50 }); 49 51 50 editor.addButton('recras-voucher-sales', { 51 title: recras_l10n.voucherSales, 52 image: url + '/vouchers.svg', 53 onclick: function() { 54 tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales'); 55 } 56 }); 52 if (recras_l10n.showVoucherSales === 'yes') { 53 editor.addButton('recras-voucher-sales', { 54 title: recras_l10n.voucherSales, 55 image: url + '/vouchers.svg', 56 onclick: function () { 57 tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales'); 58 } 59 }); 60 } 57 61 58 62 editor.addButton('recras-voucher-info', { -
recras/tags/6.3.0/readme.txt
r3217607 r3221428 3 3 Tags: recras, recreation, reservation, booking, voucher 4 4 Tested up to: 6.7 5 Stable tag: 6. 2.35 Stable tag: 6.3.0 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 77 77 78 78 == Changelog == 79 80 = 6.3.0 = 81 * The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance 82 * Plugin now requires WP 6.5 or higher 79 83 80 84 = 6.2.3 = -
recras/tags/6.3.0/recras-wordpress-plugin.php
r3217607 r3221428 3 3 Plugin Name: Recras WordPress Plugin 4 4 Plugin URI: https://www.recras.nl/ 5 Version: 6. 2.35 Version: 6.3.0 6 6 Description: Easily integrate your Recras data into your own site 7 Requires at least: 6. 47 Requires at least: 6.5 8 8 Requires PHP: 7.4.0 9 9 Author: Recras -
recras/tags/6.3.0/src/Gutenberg.php
r2915644 r3221428 69 69 ], 70 70 ]; 71 72 if (!Settings::allowOnlinePackageBooking()) { 73 unset($gutenbergBlocks['onlinebooking']); 74 } 75 if (!Settings::allowOldVoucherSales()) { 76 unset($gutenbergBlocks['voucher-sales']); 77 } 78 71 79 foreach ($gutenbergBlocks as $key => $block) { 72 80 $handle = 'recras-gutenberg-' . $key; -
recras/tags/6.3.0/src/OnlineBooking.php
r3217607 r3221428 13 13 public static function renderOnlineBooking($attributes): string 14 14 { 15 if (!Settings::allowOnlinePackageBooking()) { 16 error_log('Online booking of packages is integrated on your website, but is disabled in your Recras'); 17 return ''; 18 } 19 15 20 if (is_string($attributes)) { 16 21 $attributes = []; -
recras/tags/6.3.0/src/Plugin.php
r3217607 r3221428 17 17 $this->setBaseUrl(); 18 18 $this->transients = new Transient(); 19 20 // Needs to run before: Gutenberg::addBlocks, self::loadAdminScripts 21 $this->checkOldSettings(); 19 22 20 23 // Init Localisation … … 90 93 'edit_pages', 91 94 Settings::PAGE_CACHE, 92 ['\Recras\Settings', 'clearCache ']95 ['\Recras\Settings', 'clearCachePage'] 93 96 ); 94 97 add_submenu_page( … … 122 125 * Register our shortcodes 123 126 */ 124 p ublicfunction addShortcodes(): void127 private function addShortcodes(): void 125 128 { 126 129 add_shortcode(Availability::SHORTCODE, [Availability::class, 'renderAvailability']); … … 134 137 } 135 138 139 private function checkOldSettings(): void 140 { 141 $subdomain = get_option('recras_subdomain'); 142 if (!$subdomain) { 143 return; 144 } 145 146 $setting = $this->transients->get($subdomain . '_show_old_online_booking'); 147 if ($setting === false) { 148 try { 149 $setting = Http::get($subdomain, 'instellingen/allow_online_package_booking'); 150 } catch (\Exception $e) { 151 return; 152 } 153 if (is_object($setting) && property_exists($setting, 'waarde')) { 154 $this->transients->set($subdomain . '_show_old_online_booking', $setting->waarde, DAY_IN_SECONDS); 155 } 156 } 157 158 $setting = $this->transients->get($subdomain . '_show_old_voucher_sales'); 159 if ($setting === false) { 160 try { 161 $setting = Http::get($subdomain, 'instellingen/allow_old_vouchers_sales'); 162 } catch (\Exception $e) { 163 return; 164 } 165 if (is_object($setting) && property_exists($setting, 'waarde')) { 166 $this->transients->set($subdomain . '_show_old_voucher_sales', $setting->waarde, DAY_IN_SECONDS); 167 } 168 } 169 } 170 136 171 137 172 //TODO: change to :never when we support only PHP 8.1+ … … 143 178 $errors += ContactForm::clearCache(); 144 179 $errors += Products::clearCache(); 180 $errors += Settings::clearCache(); 145 181 $errors += Vouchers::clearCache(); 146 182 … … 174 210 public function loadAdminScripts(): void 175 211 { 176 wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '4.0.0', true); 177 wp_localize_script('recras-admin', 'recras_l10n', [ 212 $l10n = [ 178 213 'contact_form' => __('Contact form', $this::TEXT_DOMAIN), 179 214 'no_connection' => __('Could not connect to your Recras', $this::TEXT_DOMAIN), … … 183 218 'package_availability' => __('Package availability', $this::TEXT_DOMAIN), 184 219 'product' => __('Product', $this::TEXT_DOMAIN), 220 'showOnlineBooking' => 'yes', 221 'showVoucherSales' => 'yes', 185 222 'voucherInfo' => __('Voucher info', $this::TEXT_DOMAIN), 186 223 'voucherSales' => __('Voucher sales', $this::TEXT_DOMAIN), 187 ]); 224 ]; 225 226 if (!Settings::allowOnlinePackageBooking()) { 227 $l10n['showOnlineBooking'] = 'no'; 228 } 229 if (!Settings::allowOldVoucherSales()) { 230 $l10n['showVoucherSales'] = 'no'; 231 } 232 233 wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '6.3.0', true); 234 wp_localize_script('recras-admin', 'recras_l10n', $l10n); 188 235 wp_enqueue_script('recras-admin'); 189 236 wp_enqueue_style('recras-admin-style', $this->baseUrl . '/css/admin-style.css', [], '6.0.7'); -
recras/tags/6.3.0/src/Settings.php
r2953659 r3221428 115 115 116 116 117 public static function clearCache(): void 117 public static function allowOnlinePackageBooking(): bool 118 { 119 global $recrasPlugin; 120 121 $subdomain = get_option('recras_subdomain'); 122 if (!$subdomain) { 123 return true; 124 } 125 $setting = $recrasPlugin->transients->get($subdomain . '_show_old_online_booking'); 126 // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest 127 return ($setting === 'no') ? false : true; 128 } 129 130 131 public static function allowOldVoucherSales(): bool 132 { 133 global $recrasPlugin; 134 135 $subdomain = get_option('recras_subdomain'); 136 if (!$subdomain) { 137 return true; 138 } 139 $setting = $recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales'); 140 // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest 141 return ($setting === 'no') ? false : true; 142 } 143 144 /** 145 * Clear voucher template cache (transients) 146 */ 147 public static function clearCache(): int 148 { 149 global $recrasPlugin; 150 151 $subdomain = get_option('recras_subdomain'); 152 $errors = 0; 153 if ($recrasPlugin->transients->get($subdomain . '_show_old_online_booking')) { 154 $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_online_booking'); 155 } 156 if ($recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales')) { 157 $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_voucher_sales'); 158 } 159 160 return $errors; 161 } 162 163 /** 164 * Admin page to clear the cache 165 */ 166 public static function clearCachePage(): void 118 167 { 119 168 if (!current_user_can('edit_pages')) { -
recras/tags/6.3.0/src/Transient.php
r3121563 r3221428 25 25 } 26 26 27 public function set(string $name, $value): bool 27 // HOUR_IN_SECONDS is defined by WordPress 28 public function set(string $name, $value, int $expiration = HOUR_IN_SECONDS): bool 28 29 { 29 return set_transient(self::BASE . $name, $value, HOUR_IN_SECONDS);30 return set_transient(self::BASE . $name, $value, $expiration); 30 31 } 31 32 } -
recras/tags/6.3.0/src/Vouchers.php
r3217607 r3221428 63 63 public static function renderVoucherSales($attributes): string 64 64 { 65 if (!Settings::allowOldVoucherSales()) { 66 error_log('The old method of selling vouchers is integrated on your website, but is disabled in your Recras'); 67 return ''; 68 } 69 65 70 if (is_string($attributes)) { 66 71 $attributes = []; -
recras/trunk/changelog.md
r3217607 r3221428 1 1 # Changelog 2 3 ## 6.3.0 (2025-01-13) 4 * The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance 5 * Plugin now requires WP 6.5 or higher 2 6 3 7 ## 6.2.3 (2025-01-06) -
recras/trunk/editor/plugin.js
r2612483 r3221428 16 16 }); 17 17 18 editor.addButton('recras-booking', { 19 title: recras_l10n.online_booking, 20 image: url + '/online-booking.svg', 21 onclick: function() { 22 tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking'); 23 } 24 }); 18 if (recras_l10n.showOnlineBooking === 'yes') { 19 editor.addButton('recras-booking', { 20 title: recras_l10n.online_booking, 21 image: url + '/online-booking.svg', 22 onclick: function() { 23 tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking'); 24 } 25 }); 26 } 25 27 26 28 editor.addButton('recras-bookprocess', { … … 48 50 }); 49 51 50 editor.addButton('recras-voucher-sales', { 51 title: recras_l10n.voucherSales, 52 image: url + '/vouchers.svg', 53 onclick: function() { 54 tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales'); 55 } 56 }); 52 if (recras_l10n.showVoucherSales === 'yes') { 53 editor.addButton('recras-voucher-sales', { 54 title: recras_l10n.voucherSales, 55 image: url + '/vouchers.svg', 56 onclick: function () { 57 tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales'); 58 } 59 }); 60 } 57 61 58 62 editor.addButton('recras-voucher-info', { -
recras/trunk/readme.txt
r3217607 r3221428 3 3 Tags: recras, recreation, reservation, booking, voucher 4 4 Tested up to: 6.7 5 Stable tag: 6. 2.35 Stable tag: 6.3.0 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 77 77 78 78 == Changelog == 79 80 = 6.3.0 = 81 * The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance 82 * Plugin now requires WP 6.5 or higher 79 83 80 84 = 6.2.3 = -
recras/trunk/recras-wordpress-plugin.php
r3217607 r3221428 3 3 Plugin Name: Recras WordPress Plugin 4 4 Plugin URI: https://www.recras.nl/ 5 Version: 6. 2.35 Version: 6.3.0 6 6 Description: Easily integrate your Recras data into your own site 7 Requires at least: 6. 47 Requires at least: 6.5 8 8 Requires PHP: 7.4.0 9 9 Author: Recras -
recras/trunk/src/Gutenberg.php
r2915644 r3221428 69 69 ], 70 70 ]; 71 72 if (!Settings::allowOnlinePackageBooking()) { 73 unset($gutenbergBlocks['onlinebooking']); 74 } 75 if (!Settings::allowOldVoucherSales()) { 76 unset($gutenbergBlocks['voucher-sales']); 77 } 78 71 79 foreach ($gutenbergBlocks as $key => $block) { 72 80 $handle = 'recras-gutenberg-' . $key; -
recras/trunk/src/OnlineBooking.php
r3217607 r3221428 13 13 public static function renderOnlineBooking($attributes): string 14 14 { 15 if (!Settings::allowOnlinePackageBooking()) { 16 error_log('Online booking of packages is integrated on your website, but is disabled in your Recras'); 17 return ''; 18 } 19 15 20 if (is_string($attributes)) { 16 21 $attributes = []; -
recras/trunk/src/Plugin.php
r3217607 r3221428 17 17 $this->setBaseUrl(); 18 18 $this->transients = new Transient(); 19 20 // Needs to run before: Gutenberg::addBlocks, self::loadAdminScripts 21 $this->checkOldSettings(); 19 22 20 23 // Init Localisation … … 90 93 'edit_pages', 91 94 Settings::PAGE_CACHE, 92 ['\Recras\Settings', 'clearCache ']95 ['\Recras\Settings', 'clearCachePage'] 93 96 ); 94 97 add_submenu_page( … … 122 125 * Register our shortcodes 123 126 */ 124 p ublicfunction addShortcodes(): void127 private function addShortcodes(): void 125 128 { 126 129 add_shortcode(Availability::SHORTCODE, [Availability::class, 'renderAvailability']); … … 134 137 } 135 138 139 private function checkOldSettings(): void 140 { 141 $subdomain = get_option('recras_subdomain'); 142 if (!$subdomain) { 143 return; 144 } 145 146 $setting = $this->transients->get($subdomain . '_show_old_online_booking'); 147 if ($setting === false) { 148 try { 149 $setting = Http::get($subdomain, 'instellingen/allow_online_package_booking'); 150 } catch (\Exception $e) { 151 return; 152 } 153 if (is_object($setting) && property_exists($setting, 'waarde')) { 154 $this->transients->set($subdomain . '_show_old_online_booking', $setting->waarde, DAY_IN_SECONDS); 155 } 156 } 157 158 $setting = $this->transients->get($subdomain . '_show_old_voucher_sales'); 159 if ($setting === false) { 160 try { 161 $setting = Http::get($subdomain, 'instellingen/allow_old_vouchers_sales'); 162 } catch (\Exception $e) { 163 return; 164 } 165 if (is_object($setting) && property_exists($setting, 'waarde')) { 166 $this->transients->set($subdomain . '_show_old_voucher_sales', $setting->waarde, DAY_IN_SECONDS); 167 } 168 } 169 } 170 136 171 137 172 //TODO: change to :never when we support only PHP 8.1+ … … 143 178 $errors += ContactForm::clearCache(); 144 179 $errors += Products::clearCache(); 180 $errors += Settings::clearCache(); 145 181 $errors += Vouchers::clearCache(); 146 182 … … 174 210 public function loadAdminScripts(): void 175 211 { 176 wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '4.0.0', true); 177 wp_localize_script('recras-admin', 'recras_l10n', [ 212 $l10n = [ 178 213 'contact_form' => __('Contact form', $this::TEXT_DOMAIN), 179 214 'no_connection' => __('Could not connect to your Recras', $this::TEXT_DOMAIN), … … 183 218 'package_availability' => __('Package availability', $this::TEXT_DOMAIN), 184 219 'product' => __('Product', $this::TEXT_DOMAIN), 220 'showOnlineBooking' => 'yes', 221 'showVoucherSales' => 'yes', 185 222 'voucherInfo' => __('Voucher info', $this::TEXT_DOMAIN), 186 223 'voucherSales' => __('Voucher sales', $this::TEXT_DOMAIN), 187 ]); 224 ]; 225 226 if (!Settings::allowOnlinePackageBooking()) { 227 $l10n['showOnlineBooking'] = 'no'; 228 } 229 if (!Settings::allowOldVoucherSales()) { 230 $l10n['showVoucherSales'] = 'no'; 231 } 232 233 wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '6.3.0', true); 234 wp_localize_script('recras-admin', 'recras_l10n', $l10n); 188 235 wp_enqueue_script('recras-admin'); 189 236 wp_enqueue_style('recras-admin-style', $this->baseUrl . '/css/admin-style.css', [], '6.0.7'); -
recras/trunk/src/Settings.php
r2953659 r3221428 115 115 116 116 117 public static function clearCache(): void 117 public static function allowOnlinePackageBooking(): bool 118 { 119 global $recrasPlugin; 120 121 $subdomain = get_option('recras_subdomain'); 122 if (!$subdomain) { 123 return true; 124 } 125 $setting = $recrasPlugin->transients->get($subdomain . '_show_old_online_booking'); 126 // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest 127 return ($setting === 'no') ? false : true; 128 } 129 130 131 public static function allowOldVoucherSales(): bool 132 { 133 global $recrasPlugin; 134 135 $subdomain = get_option('recras_subdomain'); 136 if (!$subdomain) { 137 return true; 138 } 139 $setting = $recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales'); 140 // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest 141 return ($setting === 'no') ? false : true; 142 } 143 144 /** 145 * Clear voucher template cache (transients) 146 */ 147 public static function clearCache(): int 148 { 149 global $recrasPlugin; 150 151 $subdomain = get_option('recras_subdomain'); 152 $errors = 0; 153 if ($recrasPlugin->transients->get($subdomain . '_show_old_online_booking')) { 154 $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_online_booking'); 155 } 156 if ($recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales')) { 157 $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_voucher_sales'); 158 } 159 160 return $errors; 161 } 162 163 /** 164 * Admin page to clear the cache 165 */ 166 public static function clearCachePage(): void 118 167 { 119 168 if (!current_user_can('edit_pages')) { -
recras/trunk/src/Transient.php
r3121563 r3221428 25 25 } 26 26 27 public function set(string $name, $value): bool 27 // HOUR_IN_SECONDS is defined by WordPress 28 public function set(string $name, $value, int $expiration = HOUR_IN_SECONDS): bool 28 29 { 29 return set_transient(self::BASE . $name, $value, HOUR_IN_SECONDS);30 return set_transient(self::BASE . $name, $value, $expiration); 30 31 } 31 32 } -
recras/trunk/src/Vouchers.php
r3217607 r3221428 63 63 public static function renderVoucherSales($attributes): string 64 64 { 65 if (!Settings::allowOldVoucherSales()) { 66 error_log('The old method of selling vouchers is integrated on your website, but is disabled in your Recras'); 67 return ''; 68 } 69 65 70 if (is_string($attributes)) { 66 71 $attributes = [];
Note: See TracChangeset
for help on using the changeset viewer.