feat: Add banner management functionality
- Implemented a new Banner model to represent banner data. - Created a BannerRepository for database interactions related to banners. - Developed a BannerService to handle business logic for banners. - Added admin views for listing and adding banners. - Integrated banner hooks for frontend rendering and click tracking. - Created frontend styles and scripts for banner display and interaction. - Updated database migrations to include a new banners table. - Enhanced AdminController to manage banner actions and pages.
This commit is contained in:
@@ -5,13 +5,15 @@ if (!defined('ABSPATH')) {
|
||||
}
|
||||
|
||||
use Sodino\Controllers\AdminController;
|
||||
use Sodino\Repositories\BannerRepository;
|
||||
use Sodino\Repositories\RuleRepository;
|
||||
use Sodino\Repositories\UpsellRepository;
|
||||
|
||||
// Initialize admin
|
||||
$ruleRepository = new RuleRepository();
|
||||
$upsellRepository = new UpsellRepository();
|
||||
$adminController = new AdminController($ruleRepository, $upsellRepository);
|
||||
$bannerRepository = new BannerRepository();
|
||||
$adminController = new AdminController($ruleRepository, $upsellRepository, $bannerRepository);
|
||||
|
||||
// Add menu
|
||||
add_action('admin_menu', [$adminController, 'addMenu']);
|
||||
@@ -41,13 +43,20 @@ add_action('admin_enqueue_scripts', function($hook) use ($adminController) {
|
||||
'nonce' => wp_create_nonce('sodino_search_products'),
|
||||
]);
|
||||
}
|
||||
|
||||
if (strpos($hook, 'sodino_page_sodino-add-banner') !== false) {
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script('sodino-banner-admin', plugin_dir_url(__FILE__) . 'js/banner-admin.js', ['jquery'], SODINO_VERSION, true);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle delete for any Sodino admin page
|
||||
if (isset($_GET['page']) && strpos($_GET['page'], 'sodino') === 0 && isset($_GET['action']) && $_GET['action'] === 'delete') {
|
||||
add_action('admin_init', [$adminController, 'handleDelete']);
|
||||
}
|
||||
|
||||
if (isset($_GET['page']) && strpos($_GET['page'], 'sodino') === 0 && isset($_GET['action']) && in_array($_GET['action'], ['delete_banner', 'toggle_banner_status'], true)) {
|
||||
add_action('admin_init', [$adminController, 'handleBannerActions']);
|
||||
}
|
||||
// Handle upsell actions
|
||||
if (isset($_GET['page']) && strpos($_GET['page'], 'sodino') === 0 && isset($_GET['action']) && in_array($_GET['action'], ['delete_upsell', 'toggle_upsell_status'], true)) {
|
||||
add_action('admin_init', [$adminController, 'handleUpsellActions']);
|
||||
|
||||
Reference in New Issue
Block a user