init_frontend(); } } /** * Enqueue admin styles */ public function enqueue_admin_styles($hook) { // Only load on our plugin's admin page if (strpos($hook, 'abovewp-page-loader') !== false) { wp_enqueue_style( 'abovewp-font-inter', 'https://fonts.bunny.net/css?family=inter:400,500,600,700', array(), null ); wp_enqueue_style( 'abovewp-admin-default', AWPLR_URL . 'assets/css/admin-page-default.css', array('abovewp-font-inter'), AWPLR_VERSION ); } } /** * Remove WordPress admin notices on plugin pages */ public function remove_admin_notices_on_plugin_pages() { $screen = get_current_screen(); // Only remove notices on our plugin pages if (isset($screen->id) && ( strpos($screen->id, 'abovewp-page-loader') !== false || strpos($screen->id, 'toplevel_page_abovewp') !== false )) { // Remove all admin notices remove_all_actions('admin_notices'); remove_all_actions('all_admin_notices'); // Add our custom CSS using wp_add_inline_style wp_add_inline_style('abovewp-admin-default', ' .notice, .updated, .update-nag, .error, .warning, .info { display: none !important; } '); } } /** * Initialize frontend functionality */ private function init_frontend() { // Enqueue scripts and styles add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); // Add loader CSS in head to prevent sizing delays add_action('wp_head', array($this, 'add_loader_css'), 1); // Add loader HTML add_action('wp_body_open', array($this, 'add_loader_html')); } /** * Display plugin card on AboveWP dashboard */ public function display_plugin_card() { ?>
get_option('awplr_animation_duration', 1000), 'delay' => get_option('awplr_delay', 300), 'loaderColor' => get_option('awplr_color', '#0073aa'), 'backgroundColor' => get_option('awplr_background_color', '#ffffff'), 'animationType' => $animation_type, 'svgUrl' => get_option('awplr_svg_url', ''), 'imageUrl' => get_option('awplr_image_url', ''), 'animationSize' => get_option('awplr_animation_size', 150), 'showText' => get_option('awplr_show_text', true), 'loadingText' => get_option('awplr_text', ''), ) ); } /** * Add the loader CSS to the head */ public function add_loader_css() { // Get animation settings $loader_color = esc_attr(get_option('awplr_color', '#0073aa')); $background_color = esc_attr(get_option('awplr_background_color', '#ffffff')); $animation_size = absint(get_option('awplr_animation_size', 150)); // Add inline CSS for the loader in head $custom_css = sprintf( '/* AboveWP Page Loader - Immediate display styles */ #abovewp-page-loader { background-color: %s !important; position: fixed; top: 0; left: 0; width: 100%% !important; height: 100%% !important; z-index: 999999 !important; display: flex !important; align-items: center; justify-content: center; transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out; } #abovewp-page-loader.hidden { opacity: 0; visibility: hidden; } .loader-content { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; } .loader-spinner { border-top-color: %s !important; width: %dpx !important; height: %dpx !important; border: 3px solid rgba(0, 115, 170, 0.2); border-radius: 50%%; animation: awplr-spin 1s ease-in-out infinite; margin-bottom: 20px; } .loader-animation { width: %dpx !important; height: %dpx !important; margin-bottom: 20px; display: flex; justify-content: center; align-items: center; } .loader-logo h2 { color: %s !important; font-size: 24px; font-weight: 600; margin: 0; } @keyframes awplr-spin { to { transform: rotate(360deg); } }', $background_color, $loader_color, $animation_size, $animation_size, $animation_size, $animation_size, $loader_color ); // Output CSS directly in head echo '' . "\n"; } /** * Add the loader HTML to the website */ public function add_loader_html() { // Get animation settings $animation_type = get_option('awplr_animation_type', 'spinner'); $loader_color = esc_attr(get_option('awplr_color', '#0073aa')); $background_color = esc_attr(get_option('awplr_background_color', '#ffffff')); $animation_size = absint(get_option('awplr_animation_size', 150)); $svg_url = esc_url(get_option('awplr_svg_url', '')); $image_url = esc_url(get_option('awplr_image_url', '')); $show_text = (bool) get_option('awplr_show_text', true); $loading_text = esc_html(get_option('awplr_text', '')); ?>