5 Commits
v0.12.0 ... dev

Author SHA1 Message Date
d39abc0dd1 Bump version to 0.12.1
All checks were successful
Create Release Package / build-release (push) Successful in 1m10s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:27:58 +01:00
a1155af6a0 Fix AJAX handler timing: register directly instead of on woocommerce_loaded
The woocommerce_loaded hook may have already fired by the time our plugin
initializes. Register the AJAX handler directly since we've already verified
WooCommerce is active.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:24:31 +01:00
23f073339a Fix WooCommerce sync button: AJAX handler registration and icon alignment
- Register ProductSync AJAX handler independently from full integration init
- AJAX now available on settings page even when integration is not yet enabled
- Improved icon vertical alignment with explicit margin-top adjustment
- Added better error handling and console logging in JS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:22:14 +01:00
c92be303e8 Fix WooCommerce product sync button functionality
- Move sync handler from wc-integration.js to admin.js (uses wpBnbAdmin)
- Add CSS for button icon vertical alignment with inline-flex
- Add spin animation for sync button icon during operation
- Add sync status styling (success/error colors)
- Add i18n strings for syncing messages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:17:17 +01:00
ada838a1e4 Add Dashboard link to plugin action links on plugins page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:09:15 +01:00
7 changed files with 168 additions and 3 deletions

View File

@@ -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/),
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
### Security

View File

@@ -2098,3 +2098,49 @@
width: 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;
}

View File

@@ -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.
$(document).ready(function() {
initLicenseManagement();
@@ -1214,6 +1267,7 @@
initBookingServices();
initDashboardCharts();
initReportsPage();
initWooCommerceSync();
});
})(jQuery);

View File

@@ -130,7 +130,11 @@ final class Manager {
// 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() ) {
return;
}

View File

@@ -25,6 +25,13 @@ use Magdev\WpBnb\Taxonomies\RoomType;
*/
final class ProductSync {
/**
* Track if admin AJAX has been initialized.
*
* @var bool
*/
private static bool $admin_ajax_initialized = false;
/**
* Initialize product synchronization.
*
@@ -40,8 +47,27 @@ final class ProductSync {
// Add linked room info to product edit screen.
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.
add_action( 'wp_ajax_wp_bnb_sync_all_rooms', array( self::class, 'ajax_sync_all_rooms' ) );
self::$admin_ajax_initialized = true;
}
/**

View File

@@ -350,6 +350,8 @@ final class Plugin {
'checkingUpdates' => __( 'Checking for updates...', 'wp-bnb' ),
'occupancy' => __( 'Occupancy %', 'wp-bnb' ),
'revenue' => __( 'Revenue', 'wp-bnb' ),
'syncing' => __( 'Syncing...', 'wp-bnb' ),
'syncComplete' => __( 'Sync complete', 'wp-bnb' ),
),
);

View File

@@ -3,7 +3,7 @@
* Plugin Name: WP BnB Management
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-bnb
* 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 PHP: 8.3
* Author: Marco Graetsch
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
// 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.
define( 'WP_BNB_PATH', plugin_dir_path( __FILE__ ) );
@@ -189,3 +189,23 @@ function wp_bnb_deactivate(): void {
}
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' );