PluginProbe ʕ •ᴥ•ʔ
FrontBlocks for Gutenberg/GeneratePress / trunk
FrontBlocks for Gutenberg/GeneratePress vtrunk
trunk 0.2.0 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 ci-artifacts
frontblocks / includes / Frontend / ReadingProgress.php
frontblocks / includes / Frontend Last commit date
Animations.php 1 month ago BackButton.php 7 months ago BeforeAfter.php 1 month ago BlockPatterns.php 4 months ago Carousel.php 1 week ago ColumnsSameHeight.php 1 week ago ContainerEdgeAlignment.php 4 weeks ago Counter.php 1 month ago DownloadButton.php 1 week ago Events.php 4 weeks ago FaqSchema.php 1 week ago FluidTypography.php 4 weeks ago Gallery.php 8 months ago GravityFormsInline.php 1 month ago Headline.php 4 weeks ago InsertPost.php 1 month ago ProductCategories.php 4 weeks ago ReadingProgress.php 7 months ago ReadingTime.php 8 months ago ShapeAnimations.php 4 weeks ago StackedImages.php 4 months ago StickyColumn.php 4 weeks ago SvgUpload.php 4 weeks ago Testimonials.php 8 months ago TextAnimation.php 1 month ago UserText.php 4 weeks ago
ReadingProgress.php
85 lines
1 <?php
2 /**
3 * Reading Progress Bar module for FrontBlocks.
4 *
5 * @package FrontBlocks
6 * @author Closemarketing
7 * @copyright 2025 Closemarketing
8 * @version 1.0
9 */
10
11 namespace FrontBlocks\Frontend;
12
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * ReadingProgress class.
17 *
18 * @since 1.0.0
19 */
20 class ReadingProgress {
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_assets' ) );
27 add_action( 'wp_footer', array( $this, 'render_reading_progress_bar' ) );
28 }
29
30 /**
31 * Check if reading progress is enabled.
32 *
33 * @return bool
34 */
35 private function is_enabled() {
36 $options = get_option( 'frontblocks_settings', array() );
37 return (bool) ( $options['enable_reading_progress'] ?? false );
38 }
39
40 /**
41 * Enqueue frontend styles and scripts.
42 *
43 * @return void
44 */
45 public function enqueue_frontend_assets() {
46 // Only load on singular posts (blog entries).
47 if ( ! is_singular( 'post' ) || ! $this->is_enabled() ) {
48 return;
49 }
50
51 wp_enqueue_style(
52 'frontblocks-reading-progress',
53 FRBL_PLUGIN_URL . 'assets/reading-progress/frontblocks-reading-progress.css',
54 array(),
55 FRBL_VERSION
56 );
57
58 wp_enqueue_script(
59 'frontblocks-reading-progress',
60 FRBL_PLUGIN_URL . 'assets/reading-progress/frontblocks-reading-progress.js',
61 array(),
62 FRBL_VERSION,
63 true
64 );
65 }
66
67 /**
68 * Render the reading progress bar HTML.
69 *
70 * @return void
71 */
72 public function render_reading_progress_bar() {
73 // Only render on singular posts (blog entries).
74 if ( ! is_singular( 'post' ) || ! $this->is_enabled() ) {
75 return;
76 }
77 ?>
78 <div class="frbl-reading-progress-bar" role="progressbar" aria-label="<?php echo esc_attr__( 'Reading progress', 'frontblocks' ); ?>" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
79 <div class="frbl-reading-progress-fill"></div>
80 </div>
81 <?php
82 }
83 }
84
85