wp_create_nonce('sodino_search_products'), 'ajaxUrl' => admin_url('admin-ajax.php') ]); } // Banner specific scripts if (strpos($hook, 'sodino-add-banner') !== false || 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 admin actions */ add_action('admin_init', function() use ($ruleController, $settingsController, $adminController) { $page = $_GET['page'] ?? ''; $action = $_GET['action'] ?? ''; // Rule actions if ($page === 'sodino-rules' && $action === 'delete') { $ruleController->delete(); } // Settings actions if ($page === 'sodino-settings' && $action === 'clear_cache') { $settingsController->clearCache(); } // Banner actions if (strpos($page, 'sodino') === 0 && in_array($action, ['delete_banner', 'toggle_banner_status'], true)) { $adminController->handleBannerActions(); } // Upsell actions if (strpos($page, 'sodino') === 0 && in_array($action, ['delete_upsell', 'toggle_upsell_status'], true)) { $adminController->handleUpsellActions(); } }); /** * Show admin notices */ add_action('admin_notices', function() { $notice = get_transient('sodino_admin_notice'); if ($notice) { $class = $notice['type'] === 'error' ? 'notice-error' : 'notice-success'; printf( '
%s