=== WPFront Scroll Top ===
Contributors: syammohanm
Donate link: https://wpfront.com/donate/
Tags: scroll to top, back to top, back-to-top, smooth scroll, back-to-top-button
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 4.0.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Adds a lightweight, accessible "Scroll to Top" button with customizable appearance, position and smooth-scroll behavior to improve navigation and UX.

== Description ==
Enhance user experience and site navigation with a lightweight, customizable "Scroll to Top" button. This plugin adds a smooth-scrolling button that appears as users scroll down the page and disappears when they return to the top.

Designed for speed and seamless integration, it works with any WordPress theme and includes options for custom icons, button position, color, animation, and intelligent display rules. No coding required—just install and configure in minutes.

Perfect for blogs, long-form articles, eCommerce sites, or any website where easy navigation improves usability.

### Highlights

* Lightweight and performance-first back-to-top button — now 100% jQuery-free (vanilla JS + CSS only).
* Dependency-free, no external scripts needed.
* Smooth, configurable animation and positioning.
* Accessibility-minded (ARIA labels, keyboard support, screen-reader text) with SEO-friendly semantic markup.
* Modern SVG icon set — 28 bundled lightweight inline SVGs using `currentColor` for easy theming, with color/hover controls, visual grid picker and the `wpfront_scroll_top_svg_icons` filter; Font Awesome remains available for backward compatibility (deprecated).
* Works with any theme; configurable per-page visibility with smart include/exclude rules.

### Key Features & Customization
* **Intelligent Display**: Automatically appears as users scroll down, then disappears when at the top.
* **Smooth Scroll Animation**: Vanilla JavaScript with `requestAnimationFrame` and `easeInOutQuad` easing; configurable scroll offset, duration, opacity and fade.
* **Flexible Destinations**:
    - Internal Page Scroll: Link the button to any specific element within the current page (configurable container selector and offset).
    - External Page Redirection: Redirect users to any other page or URL.
* **Customizable Button Design**:
    - Choose between SVG icons (28 bundled, grid picker — Recommended), text, custom image (PNG/SVG), or Font Awesome icons (deprecated, bundled locally).
    - SVG icons scale with button size, use `currentColor` for automatic color theming, support icon color, hover color and custom CSS, and are extensible via the `wpfront_scroll_top_svg_icons` filter.
    - Use any image URL for complete branding control.
* **Responsive Control**:
    - **Mobile-Friendly**: Option to hide the button on smaller devices/windows for better mobile UX.
    - **iFrame Compatibility**: Ensures it doesn't appear inappropriately within iframes.
* **Targeted Visibility**: Show or hide the button on specific pages/posts or keywords (`home`, `category`, `author`, `tag`, `search`, `archive`) with autocomplete search.
* **Temporary Display**: Auto-hide the button after a set duration for a cleaner interface.
* **Accessibility Focused**: Built with ARIA labels and screen reader text for inclusive navigation.
* **SEO-Friendly Markup**: Employs semantically correct HTML elements (`button` or `a` depending on action) for optimal search engine and accessibility performance.
* **Optimized Performance**: Small async JavaScript bundle and minimal CSS; SVG icons are inline with no extra request and respect CSS `color`. Dynamic CSS optionally cached to `uploads/wpfront-scroll-top/style.css` with inline fallback for fast delivery.
* **Modern Admin Panel**: Tabbed, searchable settings built with WordPress Components — grouped fields, color pickers, SVG/image grids, media-library integration and REST-powered page search.
* **Caching-Plugin Aware**: Automatically purges well known caches on save/activate/deactivate.

== Installation ==

1. Click Plugins/Add New from the WordPress admin panel.
1. Search for "WPFront Scroll Top" and install.
1. Configure plugin using **Scroll Top** link under **Settings** menu.

== Frequently Asked Questions ==

1. **What is the "Scroll to Top" button, and how does it work?**
The "Scroll to Top" button is a convenient navigation feature that appears on your website as users scroll down a page. With a single click, it allows them to effortlessly return to the top of the page with a smooth, animated scroll, significantly improving the user experience, especially on long-form content.

1. **Is the "Scroll to Top" button always visible?**
No. The button gracefully appears only after a user has scrolled down a certain distance on the page and disappears when they are at the top, ensuring it doesn't obstruct content unnecessarily. You can also configure an Auto-Hide feature to make it disappear after a few seconds of inactivity.

1. **Can I customize the design of the button?**
You can choose simple text with background color, a custom image (PNG or SVG), or pick from 28 bundled SVG icons (Recommended) with configurable icon color, hover color and custom CSS. Font Awesome icons are still available for backward compatibility but are deprecated and bundled locally (only loaded when that style is selected). You also have full control over position, size, colors and hover effects. SVG icons use `currentColor` so the CSS `color` property controls the visible color and they scale with the configured button width/height.

1. **Can the button link to something other than the top of the page?**
Besides scrolling to the top, you can configure the button to:
    * Link to an In-Page Element: Direct users to a specific section or HTML element (like an anchor point) anywhere on the current page.
    * Redirect to a Different URL: Use the button to send users to another page on your site or even an external website.

1. **Can I control where the button appears on my website?**
You can easily enable or disable the "Scroll to Top" button on specific pages, posts, or custom post types through the plugin's settings, giving you full flexibility over its visibility. Since 4.0.0 you can also use keywords like `category`, `author`, `tag`, `search`, `archive` and `home` (now matches static front page as well as blog home) in the include/exclude lists.

1. **Is the plugin accessible for all users?**
The plugin is built with proper ARIA labels and includes screen reader text, ensuring that users relying on assistive technologies can navigate your site effectively and experience the benefits of the button. SVG icons are rendered with `aria-hidden="true"` and the container retains the ARIA label.

1. **Will this work with my theme?**
The plugin is designed to work with any well-coded theme that includes `wp_head()` and `wp_footer()`. If your theme modifies those hooks, consult the support forum for compatibility tips.

1. **How do I change the icon or position?**
In **Settings → Scroll Top → Style**, choose **SVG icon (Recommended)**, **Image button**, **Text button** or **Font Awesome button (Deprecated)**. For SVG, use the visual grid to pick from 28 bundled icons and set icon color, hover color, size and custom CSS. For Image, pick a built-in PNG, enter a custom image URL or use the Media Library. Position and size (corner location, margins, width/height) are in the same screen — set 0 for auto-fit.

1. **Does this affect site performance?**
No significant impact — the plugin loads a small, async JavaScript bundle and minimal CSS. SVG icons are inline SVGs (no font file or extra request) and use `currentColor` for efficient styling. If you enable “CSS enqueue file” under settings, dynamic CSS is cached to `uploads/wpfront-scroll-top/style.css` for efficient delivery; otherwise it is inlined. Font Awesome is bundled locally and only loaded when that (deprecated) style is selected.

1. **Is it compatible with the block editor (Gutenberg)?**
Yes. The plugin provides front-end behavior only and does not interfere with editor blocks; settings are managed from the admin settings page.

1. **What changed in 4.0.0? Do I need to do anything after updating?**
4.0.0 is a major rewrite: jQuery was removed (frontend is now vanilla JS), the settings screen was rebuilt with WordPress Components and saves via REST API, the codebase moved to PSR-4/strict types, and assets are built with pnpm + Webpack. For most sites no action is needed — just verify the button display after update. Requires WordPress 6.0+ and PHP 7.4+. If you have custom JavaScript that used the old global `wpfront_scroll_top_data.data` or jQuery events, migrate it to the new flat global `wpfrontScrollTopData` and vanilla JS. Page-display rules and custom CSS are preserved. Since 4.0.0, SVG icon support with 30 bundled icons has been added as the recommended style (Font Awesome now deprecated); existing Font Awesome configurations continue to work.

1. **Does the plugin still use an external CDN for Font Awesome?**
No. Since 4.0.0 Font Awesome 4.7.0 is bundled inside the plugin under `assets/vendor/font-awesome/` (no maxcdn/Cloudflare request). It is enqueued only when the button style is set to Font Awesome. You can still override the URL via the “Font Awesome URL” setting if needed. For new sites we recommend using SVG icons instead, which require no external or bundled font.

1. **Are SVG icons preferred over Font Awesome?**
Yes. SVG icons are the recommended style. They are lightweight inline SVGs (no font file or extra stylesheet), scale crisply with the button size, respect the button `color` via `currentColor`, and support a visual grid picker, icon color, hover color and custom CSS. Font Awesome is kept only for backward compatibility and is marked **Deprecated** in the settings UI; it will continue to work but requires loading the Font Awesome stylesheet.

1. **Can I add my own SVG icons?**
Yes. Use the `wpfront_scroll_top_svg_icons` filter to add, remove or replace icons. Return an associative array `slug => svg markup`. Use `viewBox="0 0 24 24"` and `currentColor` for proper color scaling and `aria-hidden="true"` for accessibility. Your icons appear automatically in the admin grid and front-end rendering. Example: `add_filter('wpfront_scroll_top_svg_icons', function($icons){ $icons['my-icon']='<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="..."/></svg>'; return $icons; });`

== Screenshots ==

1. Settings page — Tabbed, searchable configuration for display, style, action, location, filters, accessibility, and CSS.
2. SVG icons grid — Pick from 28 bundled SVG icons and customize icon and hover colors.
3. Image icons grid — Choose a built-in image, enter a custom URL, or select from the Media Library.
4. Button actions — Scroll to top, scroll to an element, or link to a page or custom URL.

== Changelog ==

= 4.0.0 =
* Major rewrite — modern, dependency-free codebase for faster performance and long-term maintainability.
* Removed jQuery dependency: frontend now uses vanilla JavaScript with `requestAnimationFrame` + `easeInOutQuad` smooth scroll; smaller bundle and no jQuery conflicts.
* Completely redesigned settings UI using WordPress Components: tabbed and searchable, grouped fields, color pickers, image grid, media-library integration and debounced REST search for pages.
* PHP 7.4+ and WordPress 6.0+ required; PSR-4 namespaced code with strict types and DI container (`src/`).
* Font Awesome now bundled locally under `assets/vendor/font-awesome/` (previously maxcdn) and enqueued only when needed; handle renamed to `wpfront-scroll-top-font-awesome`.
* Frontend rendering changed from JS-injected markup on `window.load` to server-rendered markup.
* Smooth-scroll supports custom container selectors, element offsets and multi-container targets; negative durations/offsets are clamped for safety.
* Dynamic CSS handling: base styles from `assets/bundle/scroll-top.css` plus dynamic rules cached to `uploads/wpfront-scroll-top/style.css` when enabled (mtime-versioned, file via `WP_Filesystem`) with inline fallback.
* Page-display filter extended with keyword tokens `category`, `author`, `tag`, `search`, `archive` and `home` now matches `is_front_page() || is_home()` (previously `is_home()` only); stored ID lists remain compatible.
* Color validation widened to accept `rgba()`, `#RGBA` and `#RRGGBBAA`; text/selector fields now sanitized with `sanitize_text_field`.
* Lifecycle improvements: installer/updater with `wpfront-scroll-top-version` option, update lock transient, dynamic-CSS regeneration on update, activation redirect and multisite-aware uninstall (removes settings, version option and `uploads/wpfront-scroll-top/`).
* Caching: automatic purge for WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Fastest Cache, SG Optimizer, Breeze, Cache Enabler, FlyingPress and others on save/activate/deactivate; added `wpfront_scroll_top_clear_cache` action.
* Accessibility/SEO: semantic `button`/`a` container, `aria-label`/`title`/`screen-reader-text` handling preserved with empty-value skipping and default fallback.
* Developer note: old globals and AJAX endpoint changed — `wpfront_scroll_top_data.data` → flat `wpfrontScrollTopData`, and `wpfront_scroll_top_submit_data` (AJAX) → REST; please update custom integrations.

= 3.1.0 =
* Added version switching between v3 (Legacy) and v4. An admin notice on the settings page allows administrators to toggle between versions with a single click.
* New installations now default to v4. Sites with existing settings continue to use v3 (Legacy) unless switched.
* Font Awesome is now marked as deprecated in the v3 settings UI; existing Font Awesome configurations continue to work.
* Minimum requirements updated to WordPress 6.0 and PHP 7.4.

= 3.0.1 =
* Defect fix.

= 3.0.0 =
* Breaking changes are introduced. Please verify the display after the upgrade.
* These breaking changes are needed for accessibility and SEO friendly markup.
* The container will either be a button or an anchor element.
* There could be multiple span inside the container depending on your configuration.
* Minimum PHP version required is 7.2.
* Accessibility and more CSS settings are available.
* Deprecated settings are removed.

= 2.2 =
* Compatibility fixes.

= 2.1.1 =
* Bug fix.

= 2.1 =
* [Deprecated] Small device settings.
* New UI.
* Title HTML attribute.
* PHP compatibility fixes.
* HTML validation fixes.
* Performance improvements.

= 2.0.7 =
* XSS fix. Thanks to 'Vlad Visse'.

= 2.0.6 =
* XSS fix. Thanks to 'Asif Nawaz Minhas'.

= 2.0.5 =
* XSS fix.

= 2.0.4 =
* WP compatibility fix.

= 2.0.3 =
* jQuery deprecation fixes.
* Compatibility fixes.
* SiteGround conflict fix.

= 2.0.2 =
* Fixes WordPress 5.2 site health, wp_version_check, conflict.

= 2.0.1 =
* Link to element.
* Link to page.
* Select image from media library easily.
* Performance improvements.

= 1.6.2 =
* Requires minimum PHP 5.3.
* Bug fixes.
* Moved menu under 'Settings' menu.
* PHP 7.2 compatibility fixes.

= 1.6.1 =
* Undefined variable fix.

= 1.6 =
* Font Awesome icons support.
* New image icons.
* Setting for moving menu under 'Settings'.
* Performance improvement.
* UI improvement.
* PHP 7 compatibility fixes.

= 1.5 =
* JavaScript async.
* Minified files.
* Language files removed.

= 1.4.5 =
* Ukrainian translation added. Thanks to Ivanka Skakun.

= 1.4.4 =
* Zerif theme compatibility fix.

= 1.4.3 =
* Media upload bug fix.

= 1.4.2 =
* Bug fixes.
* German language added.

= 1.4.1 =
* Bug fixes
* Russian language added

= 1.4 =
* Image ALT attribute
* Language translations

= 1.3 =
* Auto hide
* Hide on wp-admin
* Hide on iframes
* Pages/posts filter

= 1.2 =
* Text button option
* Bug fixes

= 1.1.1 =
* Stability improvements
* New menu structure

= 1.1 =
* New option to hide on mobile devices
* Fixed conflicts with other plugins

= 1.0.1 =
* Bug fixes

= 1.0 =
* Initial release

== Upgrade Notice ==

= 4.0.0 =
Major rewrite: jQuery removed, admin UI rebuilt. No action needed - verify button display. Requires WP 6.0+ / PHP 7.4+. Clear cache if styles look stale. SVG icons (28 bundled) now recommended; Font Awesome deprecated but still functional.

= 3.1.0 =
Version switching between v3 (Legacy) and v4. New installs default to v4; existing settings stay on v3 unless switched. Font Awesome is deprecated. Requires WP 6.0+ / PHP 7.4+.

= 3.0.1 =
* Defect fix.

= 3.0.0 =
* Breaking changes are introduced. Please verify the display after the upgrade.

= 2.2 =
* Compatibility fixes.

= 2.1.1 =
* Bug fix.

= 2.1 =
* Performance improvements.

= 2.0.7 =
* XSS fix.

= 2.0.6 =
* XSS fix.

= 2.0.5 =
* XSS fix.

= 2.0.4 =
* Compatibility fix.

= 2.0.3 =
* Compatibility fixes.

= 2.0.2 =
* Bug fix.

= 2.0.1 =
* New features added.

= 1.6.2 =
* Bug and compatibility fixes.

= 1.6.1 =
* Bug fix.

= 1.6 =
* Performance improvements and new features added.

= 1.5 =
* Performance improvements.

= 1.4.5 =
* Language translation added.

= 1.4.4 =
* Compatibility fix.

= 1.4.3 =
* Bug fix.

= 1.4.2 =
* Bug fixes.

= 1.4.1 =
* A couple of bug fixes

= 1.4 =
* Now you can set alt attribute for image

= 1.3 =
* Now you can auto hide it
* Hide on wp-admin/iframes
* Pages/posts filter added

= 1.2 =
* Text based button added

= 1.1.1 =
* Improved stability

= 1.1 =
* New option to hide on mobile devices
* Fixed conflicts with other plugins

= 1.0.1 =
* Bug fixes

= 1.0 =
* Initial release
