feat: Implement Siti Stock Plugin for WooCommerce integration
- Added core plugin structure with main class Siti_Stock_Plugin. - Implemented settings management through Siti_Stock_Settings. - Developed admin interface for settings configuration via Siti_Stock_Admin. - Created inventory management with external stock handling in Siti_Stock_Inventory_Manager. - Integrated synchronization service to fetch and apply stock updates from external API in Siti_Stock_Sync_Service. - Added custom product data store to manage combined stock values in Siti_Stock_Product_Data_Store. - Registered hooks for admin menus, settings, and synchronization processes. - Implemented REST API endpoint for triggering stock sync. - Added cron scheduling for automatic stock synchronization. - Included localization support for Dutch language.
This commit is contained in:
58
includes/class-siti-stock-admin-notices.php
Normal file
58
includes/class-siti-stock-admin-notices.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles temporary admin notices.
|
||||
*/
|
||||
class Siti_Stock_Admin_Notices {
|
||||
|
||||
const TRANSIENT_KEY = 'siti_stock_notice';
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*/
|
||||
public function register_hooks() {
|
||||
add_action( 'admin_notices', array( $this, 'render_flash_notice' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Store notice in transient for later output.
|
||||
*
|
||||
* @param string $message Message.
|
||||
* @param string $type Notice type.
|
||||
*/
|
||||
public function add_notice( $message, $type = 'success' ) {
|
||||
set_transient(
|
||||
self::TRANSIENT_KEY,
|
||||
array(
|
||||
'message' => $message,
|
||||
'type' => $type,
|
||||
),
|
||||
30
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render notice if stored.
|
||||
*/
|
||||
public function render_flash_notice() {
|
||||
$notice = get_transient( self::TRANSIENT_KEY );
|
||||
|
||||
if ( ! $notice ) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete_transient( self::TRANSIENT_KEY );
|
||||
|
||||
$type = in_array( $notice['type'], array( 'error', 'warning', 'success', 'info' ), true ) ? $notice['type'] : 'info';
|
||||
|
||||
printf(
|
||||
'<div class="notice notice-%1$s is-dismissible"><p>%2$s</p></div>',
|
||||
esc_attr( $type ),
|
||||
esc_html( $notice['message'] )
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user