# easy-elements/1.3.6/includes/Extensions/ProgressBar/ReadingProgressBar.php

Easy Elements for Elementor – Addons &amp; Website Templates, version 1.3.6. 125 lines.

- Page: https://pluginprobe.com/plugins/easy-elements/1.3.6/code/includes/Extensions/ProgressBar/ReadingProgressBar.php
- Raw: https://pluginprobe.com/plugins/easy-elements/1.3.6/raw/includes/Extensions/ProgressBar/ReadingProgressBar.php
- Modified: 2026-03-01T04:05:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-elements/1.3.6/code/includes/Extensions/ProgressBar/ReadingProgressBar.php#L10-L20`.

```php
<?php
namespace Easyel\EasyElements\Extensions\ProgressBar;
/**
 * Easy ReadingProgressBar
 *
 * @package EasyElements
 */

if (!defined('ABSPATH')) {
    exit;
}

use \Elementor\Controls_Manager;

class ReadingProgressBar {

	protected bool $should_render = false;

	/**
	 * Holds the singleton instance
	 *
	 * @var Easy_readingprogressbar|null
	 */
	private static $instance = null;

	/**
	 * Constructor
	 */
	private function __construct() {

        $tab_slug = 'extensions';
        $extensions_settings = get_option('easy_element_' . $tab_slug, [] );

        $enable_reading_progress_bar = isset( $extensions_settings['enable_reading_progress_bar'] ) ? $extensions_settings['enable_reading_progress_bar'] : 0;

        if(  (int) $enable_reading_progress_bar !== 1 ) {
            return;
        }

		add_action( 'wp_footer', [ $this, 'easyel_render_progressbar_html'] );
		add_action( 'wp_enqueue_scripts', [ $this, "easy_progressbar_scripts" ] );  

	}

	/**
	 * Get instance
	 */
	public static function get_instance() : self {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	public function easy_progressbar_scripts() {

		if ( ! $this->should_display_progressbar() ) {
			return;
		}

		wp_enqueue_style(
			'easy-progress-bar',
			EASYELEMENTS_DIR_URL . 'includes/Extensions/ProgressBar/assets/css/progress-bar.css',
			[],
			EASYELEMENTS_VER
		);

		$settings = get_option( 'easyel_reading_progressbar_settings', [] );
		$height   = !empty( $settings['reading_progressbar_height'] ) ? absint( $settings['reading_progressbar_height'] ) : 5;
		$color    = !empty( $settings['reading_progressbar_color'] ) ? $settings['reading_progressbar_color'] : '#7400c1';
		$position = isset( $settings['reading_progressbar_position'] ) ? $settings['reading_progressbar_position'] : 'top';
		$pos_css  = ( $position === 'bottom' ) ? 'bottom:0; top:auto;' : 'top:0; bottom:auto;';

		$custom_css = "
			.easyel-progress-wrapper { height: {$height}px; {$pos_css} }
			.easyel-reading-progress-bar { height: {$height}px; --easyel-progress-color: {$color}; }
		";

		wp_add_inline_style( 'easy-progress-bar', $custom_css );

		if ( ! did_action( 'elementor/loaded' ) ) {
			return;
		}

		wp_enqueue_script(
			'easyel-editor-script',
			EASYELEMENTS_DIR_URL . 'includes/Extensions/ProgressBar/assets/js/progress-bar.js',
			[ 'jquery' ],
			EASYELEMENTS_VER,
			true
		);
	}

	private function should_display_progressbar() {
		$settings = get_option( 'easyel_reading_progressbar_settings', [] );
		if ( empty( $settings ) ) {
			return false;
		}

		$display_on = isset( $settings['reading_progressbar_display'] ) ? (array) $settings['reading_progressbar_display'] : [];
		
		$should_show = in_array( 'global', $display_on );

		return apply_filters( 'easyel/reading_progressbar_should_show', $should_show, $settings, $display_on );
	}

	public function easyel_render_progressbar_html() {

		if ( $this->should_display_progressbar() ) {
			$this->render_progressbar_html();
		}
	}

	private function render_progressbar_html() {

		echo '<div class="easyel-progress-wrapper">
			<progress id="easyel-reading-progress-bar"
				class="easyel-reading-progress-bar"
				value="0"
				max="100"></progress>
		</div>';
	}

}

```
