Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d39abc0dd1 | |||
| a1155af6a0 | |||
| 23f073339a | |||
| c92be303e8 | |||
| ada838a1e4 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.12.1] - 2026-02-04
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed WooCommerce product sync button not working on settings page
|
||||||
|
- Fixed AJAX handler registration timing (now registered directly instead of on `woocommerce_loaded` hook)
|
||||||
|
- Fixed sync button icon vertical alignment
|
||||||
|
- Added Dashboard link to WordPress plugins list page
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Better error handling and console logging for WooCommerce sync AJAX requests
|
||||||
|
|
||||||
## [0.12.0] - 2026-02-04
|
## [0.12.0] - 2026-02-04
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|||||||
@@ -2098,3 +2098,49 @@
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
WooCommerce Sync Button
|
||||||
|
============================================ */
|
||||||
|
.bnb-sync-rooms-btn {
|
||||||
|
display: inline-flex !important;
|
||||||
|
align-items: center !important;
|
||||||
|
gap: 6px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bnb-sync-rooms-btn .dashicons {
|
||||||
|
font-size: 16px;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
line-height: 16px;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-top: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bnb-sync-rooms-btn .dashicons.bnb-spin {
|
||||||
|
animation: bnb-spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes bnb-spin {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-status {
|
||||||
|
margin-left: 10px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-status .bnb-sync-success {
|
||||||
|
color: #00a32a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-status .bnb-sync-error {
|
||||||
|
color: #d63638;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1199,6 +1199,59 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize WooCommerce sync button.
|
||||||
|
*/
|
||||||
|
function initWooCommerceSync() {
|
||||||
|
var $syncBtn = $('.bnb-sync-rooms-btn');
|
||||||
|
|
||||||
|
if (!$syncBtn.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$syncBtn.on('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var $btn = $(this);
|
||||||
|
var $status = $btn.parent().find('.sync-status');
|
||||||
|
|
||||||
|
$btn.prop('disabled', true);
|
||||||
|
$btn.find('.dashicons').addClass('bnb-spin');
|
||||||
|
$status.text(wpBnbAdmin.i18n.syncing || 'Syncing...');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: wpBnbAdmin.ajaxUrl,
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
action: 'wp_bnb_sync_all_rooms',
|
||||||
|
nonce: wpBnbAdmin.nonce
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
if (response.success) {
|
||||||
|
$status.html('<span class="bnb-sync-success">' + response.data.message + '</span>');
|
||||||
|
} else {
|
||||||
|
var errorMsg = response.data && response.data.message ? response.data.message : 'Unknown error';
|
||||||
|
$status.html('<span class="bnb-sync-error">' + errorMsg + '</span>');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
var errorMsg = wpBnbAdmin.i18n.error || 'Error occurred';
|
||||||
|
if (xhr.responseJSON && xhr.responseJSON.data && xhr.responseJSON.data.message) {
|
||||||
|
errorMsg = xhr.responseJSON.data.message;
|
||||||
|
} else if (error) {
|
||||||
|
errorMsg = error;
|
||||||
|
}
|
||||||
|
$status.html('<span class="bnb-sync-error">' + errorMsg + '</span>');
|
||||||
|
console.error('WP-BnB Sync Error:', status, error, xhr.responseText);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$btn.prop('disabled', false);
|
||||||
|
$btn.find('.dashicons').removeClass('bnb-spin');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize on document ready.
|
// Initialize on document ready.
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
initLicenseManagement();
|
initLicenseManagement();
|
||||||
@@ -1214,6 +1267,7 @@
|
|||||||
initBookingServices();
|
initBookingServices();
|
||||||
initDashboardCharts();
|
initDashboardCharts();
|
||||||
initReportsPage();
|
initReportsPage();
|
||||||
|
initWooCommerceSync();
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|||||||
@@ -130,7 +130,11 @@ final class Manager {
|
|||||||
// Declare HPOS compatibility.
|
// Declare HPOS compatibility.
|
||||||
add_action( 'before_woocommerce_init', array( self::class, 'declare_hpos_compatibility' ) );
|
add_action( 'before_woocommerce_init', array( self::class, 'declare_hpos_compatibility' ) );
|
||||||
|
|
||||||
// Only initialize components if integration is enabled.
|
// Always register admin AJAX handlers immediately (for settings page).
|
||||||
|
// Must be called directly, not via hook, since woocommerce_loaded may have already fired.
|
||||||
|
ProductSync::init_admin_ajax();
|
||||||
|
|
||||||
|
// Only initialize full components if integration is enabled.
|
||||||
if ( ! self::is_enabled() ) {
|
if ( ! self::is_enabled() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ use Magdev\WpBnb\Taxonomies\RoomType;
|
|||||||
*/
|
*/
|
||||||
final class ProductSync {
|
final class ProductSync {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track if admin AJAX has been initialized.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static bool $admin_ajax_initialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize product synchronization.
|
* Initialize product synchronization.
|
||||||
*
|
*
|
||||||
@@ -40,8 +47,27 @@ final class ProductSync {
|
|||||||
// Add linked room info to product edit screen.
|
// Add linked room info to product edit screen.
|
||||||
add_action( 'woocommerce_product_options_general_product_data', array( self::class, 'add_product_room_info' ) );
|
add_action( 'woocommerce_product_options_general_product_data', array( self::class, 'add_product_room_info' ) );
|
||||||
|
|
||||||
|
// Register admin AJAX if not already done.
|
||||||
|
self::init_admin_ajax();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize admin AJAX handlers only.
|
||||||
|
*
|
||||||
|
* Called separately from init() to ensure AJAX is available on settings page
|
||||||
|
* even when full integration is not yet enabled.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function init_admin_ajax(): void {
|
||||||
|
if ( self::$admin_ajax_initialized ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// AJAX handler for syncing all rooms.
|
// AJAX handler for syncing all rooms.
|
||||||
add_action( 'wp_ajax_wp_bnb_sync_all_rooms', array( self::class, 'ajax_sync_all_rooms' ) );
|
add_action( 'wp_ajax_wp_bnb_sync_all_rooms', array( self::class, 'ajax_sync_all_rooms' ) );
|
||||||
|
|
||||||
|
self::$admin_ajax_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -350,6 +350,8 @@ final class Plugin {
|
|||||||
'checkingUpdates' => __( 'Checking for updates...', 'wp-bnb' ),
|
'checkingUpdates' => __( 'Checking for updates...', 'wp-bnb' ),
|
||||||
'occupancy' => __( 'Occupancy %', 'wp-bnb' ),
|
'occupancy' => __( 'Occupancy %', 'wp-bnb' ),
|
||||||
'revenue' => __( 'Revenue', 'wp-bnb' ),
|
'revenue' => __( 'Revenue', 'wp-bnb' ),
|
||||||
|
'syncing' => __( 'Syncing...', 'wp-bnb' ),
|
||||||
|
'syncComplete' => __( 'Sync complete', 'wp-bnb' ),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
24
wp-bnb.php
24
wp-bnb.php
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: WP BnB Management
|
* Plugin Name: WP BnB Management
|
||||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-bnb
|
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-bnb
|
||||||
* Description: A comprehensive Bed & Breakfast management system for WordPress. Manage buildings, rooms, bookings, and guests.
|
* Description: A comprehensive Bed & Breakfast management system for WordPress. Manage buildings, rooms, bookings, and guests.
|
||||||
* Version: 0.12.0
|
* Version: 0.12.1
|
||||||
* Requires at least: 6.0
|
* Requires at least: 6.0
|
||||||
* Requires PHP: 8.3
|
* Requires PHP: 8.3
|
||||||
* Author: Marco Graetsch
|
* Author: Marco Graetsch
|
||||||
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Plugin version constant - MUST match Version in header above.
|
// Plugin version constant - MUST match Version in header above.
|
||||||
define( 'WP_BNB_VERSION', '0.12.0' );
|
define( 'WP_BNB_VERSION', '0.12.1' );
|
||||||
|
|
||||||
// Plugin path constants.
|
// Plugin path constants.
|
||||||
define( 'WP_BNB_PATH', plugin_dir_path( __FILE__ ) );
|
define( 'WP_BNB_PATH', plugin_dir_path( __FILE__ ) );
|
||||||
@@ -189,3 +189,23 @@ function wp_bnb_deactivate(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
register_deactivation_hook( __FILE__, 'wp_bnb_deactivate' );
|
register_deactivation_hook( __FILE__, 'wp_bnb_deactivate' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add action links to the plugins page.
|
||||||
|
*
|
||||||
|
* @param array $links Existing plugin action links.
|
||||||
|
* @return array Modified plugin action links.
|
||||||
|
*/
|
||||||
|
function wp_bnb_plugin_action_links( array $links ): array {
|
||||||
|
$dashboard_link = sprintf(
|
||||||
|
'<a href="%s">%s</a>',
|
||||||
|
esc_url( admin_url( 'admin.php?page=wp-bnb' ) ),
|
||||||
|
esc_html__( 'Dashboard', 'wp-bnb' )
|
||||||
|
);
|
||||||
|
|
||||||
|
array_unshift( $links, $dashboard_link );
|
||||||
|
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter( 'plugin_action_links_' . WP_BNB_BASENAME, 'wp_bnb_plugin_action_links' );
|
||||||
|
|||||||
Reference in New Issue
Block a user