'circle', 'sanitize_callback' => 'sanitize_text_field' )); register_setting('scroll_to_top_options', 'scroll_to_top_bg_color', array( 'default' => '#333333', 'sanitize_callback' => 'sanitize_hex_color' )); register_setting('scroll_to_top_options', 'scroll_to_top_text_color', array( 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color' )); register_setting('scroll_to_top_options', 'scroll_to_top_size', array( 'default' => 'medium', 'sanitize_callback' => 'sanitize_text_field' )); register_setting('scroll_to_top_options', 'scroll_to_top_position', array( 'default' => 'bottom-right', 'sanitize_callback' => 'sanitize_text_field' )); register_setting('scroll_to_top_options', 'scroll_to_top_show_mobile', array( 'default' => '1', 'sanitize_callback' => 'rest_sanitize_boolean' )); } public function render_settings_page() { if (!current_user_can('manage_options')) { return; } include self::$plugin_dir . 'admin/settings-page.php'; } public function enqueue_frontend_assets() { $settings = $this->get_settings(); wp_enqueue_style( 'scroll-to-top-styles', self::$plugin_url . 'assets/frontend.css', array(), '1.0.0' ); wp_enqueue_script( 'scroll-to-top-script', self::$plugin_url . 'assets/frontend.js', array(), '1.0.0', true ); wp_localize_script('scroll-to-top-script', 'scrollToTopSettings', array( 'style' => $settings['style'], 'bgColor' => $settings['bg_color'], 'textColor' => $settings['text_color'], 'size' => $settings['size'], 'position' => $settings['position'], 'showMobile' => $settings['show_mobile'], )); } public function enqueue_admin_assets($hook) { if ('settings_page_scroll-to-top-settings' !== $hook) { return; } wp_enqueue_style( 'scroll-to-top-admin-styles', self::$plugin_url . 'assets/admin.css', array(), '1.0.0' ); wp_enqueue_script( 'scroll-to-top-admin-script', self::$plugin_url . 'assets/admin.js', array(), '1.0.0', true ); } private function get_settings() { return array( 'style' => get_option('scroll_to_top_style', 'circle'), 'bg_color' => get_option('scroll_to_top_bg_color', '#333333'), 'text_color' => get_option('scroll_to_top_text_color', '#ffffff'), 'size' => get_option('scroll_to_top_size', 'medium'), 'position' => get_option('scroll_to_top_position', 'bottom-right'), 'show_mobile' => get_option('scroll_to_top_show_mobile', '1'), ); } } Scroll_To_Top::get_instance();