Custom_JS.php
5 years ago
Post_Duplicator.php
4 years ago
Promotion.php
4 years ago
Reading_Progress.php
4 years ago
Scroll_to_Top.php
4 years ago
Table_of_Content.php
4 years ago
Reading_Progress.php
215 lines
| 1 | <?php |
| 2 | namespace Essential_Addons_Elementor\Extensions; |
| 3 | |
| 4 | if (!defined('ABSPATH')) { |
| 5 | exit; |
| 6 | } |
| 7 | |
| 8 | use \Elementor\Controls_Manager; |
| 9 | use \Essential_Addons_Elementor\Classes\Helper; |
| 10 | |
| 11 | class Reading_Progress |
| 12 | { |
| 13 | |
| 14 | public function __construct() |
| 15 | { |
| 16 | add_action('elementor/documents/register_controls', [$this, 'register_controls'], 10); |
| 17 | } |
| 18 | |
| 19 | public function register_controls($element) |
| 20 | { |
| 21 | if (Helper::prevent_extension_loading(get_the_ID())) { |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | $global_settings = get_option('eael_global_settings'); |
| 26 | |
| 27 | $element->start_controls_section( |
| 28 | 'eael_ext_reading_progress_section', |
| 29 | [ |
| 30 | 'label' => __('<i class="eaicon-logo"></i> Reading Progress Bar', 'essential-addons-for-elementor-lite'), |
| 31 | 'tab' => Controls_Manager::TAB_SETTINGS, |
| 32 | ] |
| 33 | ); |
| 34 | |
| 35 | $element->add_control( |
| 36 | 'eael_ext_reading_progress', |
| 37 | [ |
| 38 | 'label' => __('Enable Reading Progress Bar', 'essential-addons-for-elementor-lite'), |
| 39 | 'type' => Controls_Manager::SWITCHER, |
| 40 | 'default' => 'no', |
| 41 | 'label_on' => __('Yes', 'essential-addons-for-elementor-lite'), |
| 42 | 'label_off' => __('No', 'essential-addons-for-elementor-lite'), |
| 43 | 'return_value' => 'yes', |
| 44 | ] |
| 45 | ); |
| 46 | |
| 47 | $element->add_control( |
| 48 | 'eael_ext_reading_progress_has_global', |
| 49 | [ |
| 50 | 'label' => __('Enabled Globally?', 'essential-addons-for-elementor-lite'), |
| 51 | 'type' => Controls_Manager::HIDDEN, |
| 52 | 'default' => (isset($global_settings['reading_progress']['enabled']) ? $global_settings['reading_progress']['enabled'] : false), |
| 53 | ] |
| 54 | ); |
| 55 | |
| 56 | if (isset($global_settings['reading_progress']['enabled']) && ($global_settings['reading_progress']['enabled'] == true) && get_the_ID() != $global_settings['reading_progress']['post_id'] && get_post_status($global_settings['reading_progress']['post_id']) == 'publish') { |
| 57 | $element->add_control( |
| 58 | 'eael_global_warning_text', |
| 59 | [ |
| 60 | 'type' => Controls_Manager::RAW_HTML, |
| 61 | 'raw' => __('You can modify the Global Reading Progress Bar by <strong><a href="' . get_bloginfo('url') . '/wp-admin/post.php?post=' . $global_settings['reading_progress']['post_id'] . '&action=elementor">Clicking Here</a></strong>', 'essential-addons-for-elementor-lite'), |
| 62 | 'content_classes' => 'eael-warning', |
| 63 | 'separator' => 'before', |
| 64 | 'condition' => [ |
| 65 | 'eael_ext_reading_progress' => 'yes', |
| 66 | ], |
| 67 | ] |
| 68 | ); |
| 69 | } else { |
| 70 | $element->add_control( |
| 71 | 'eael_ext_reading_progress_global', |
| 72 | [ |
| 73 | 'label' => __('Enable Reading Progress Bar Globally', 'essential-addons-for-elementor-lite'), |
| 74 | 'description' => __('Enabling this option will effect on entire site.', 'essential-addons-for-elementor-lite'), |
| 75 | 'type' => Controls_Manager::SWITCHER, |
| 76 | 'default' => 'no', |
| 77 | 'label_on' => __('Yes', 'essential-addons-for-elementor-lite'), |
| 78 | 'label_off' => __('No', 'essential-addons-for-elementor-lite'), |
| 79 | 'return_value' => 'yes', |
| 80 | 'separator' => 'before', |
| 81 | 'condition' => [ |
| 82 | 'eael_ext_reading_progress' => 'yes', |
| 83 | ], |
| 84 | ] |
| 85 | ); |
| 86 | |
| 87 | $element->add_control( |
| 88 | 'eael_ext_reading_progress_global_display_condition', |
| 89 | [ |
| 90 | 'label' => __('Display On', 'essential-addons-for-elementor-lite'), |
| 91 | 'type' => Controls_Manager::SELECT, |
| 92 | 'default' => 'all', |
| 93 | 'options' => [ |
| 94 | 'posts' => __('All Posts', 'essential-addons-for-elementor-lite'), |
| 95 | 'pages' => __('All Pages', 'essential-addons-for-elementor-lite'), |
| 96 | 'all' => __('All Posts & Pages', 'essential-addons-for-elementor-lite'), |
| 97 | ], |
| 98 | 'condition' => [ |
| 99 | 'eael_ext_reading_progress' => 'yes', |
| 100 | 'eael_ext_reading_progress_global' => 'yes', |
| 101 | ], |
| 102 | 'separator' => 'before', |
| 103 | ] |
| 104 | ); |
| 105 | } |
| 106 | |
| 107 | $element->add_control( |
| 108 | 'eael_ext_reading_progress_position', |
| 109 | [ |
| 110 | 'label' => esc_html__('Position', 'essential-addons-for-elementor-lite'), |
| 111 | 'type' => Controls_Manager::SELECT, |
| 112 | 'default' => 'top', |
| 113 | 'label_block' => false, |
| 114 | 'options' => [ |
| 115 | 'top' => esc_html__('Top', 'essential-addons-for-elementor-lite'), |
| 116 | 'bottom' => esc_html__('Bottom', 'essential-addons-for-elementor-lite'), |
| 117 | ], |
| 118 | 'separator' => 'before', |
| 119 | 'condition' => [ |
| 120 | 'eael_ext_reading_progress' => 'yes', |
| 121 | ], |
| 122 | ] |
| 123 | ); |
| 124 | |
| 125 | $element->add_control( |
| 126 | 'eael_ext_reading_progress_height', |
| 127 | [ |
| 128 | 'label' => __('Height', 'essential-addons-for-elementor-lite'), |
| 129 | 'type' => Controls_Manager::SLIDER, |
| 130 | 'size_units' => ['px'], |
| 131 | 'range' => [ |
| 132 | 'px' => [ |
| 133 | 'min' => 0, |
| 134 | 'max' => 100, |
| 135 | 'step' => 1, |
| 136 | ], |
| 137 | ], |
| 138 | 'default' => [ |
| 139 | 'unit' => 'px', |
| 140 | 'size' => 5, |
| 141 | ], |
| 142 | 'selectors' => [ |
| 143 | '.eael-reading-progress-wrap .eael-reading-progress' => 'height: {{SIZE}}{{UNIT}} !important', |
| 144 | '.eael-reading-progress-wrap .eael-reading-progress .eael-reading-progress-fill' => 'height: {{SIZE}}{{UNIT}} !important', |
| 145 | ], |
| 146 | 'separator' => 'before', |
| 147 | 'condition' => [ |
| 148 | 'eael_ext_reading_progress' => 'yes', |
| 149 | ], |
| 150 | ] |
| 151 | ); |
| 152 | |
| 153 | $element->add_control( |
| 154 | 'eael_ext_reading_progress_bg_color', |
| 155 | [ |
| 156 | 'label' => __('Background Color', 'essential-addons-for-elementor-lite'), |
| 157 | 'type' => Controls_Manager::COLOR, |
| 158 | 'default' => '', |
| 159 | 'selectors' => [ |
| 160 | '.eael-reading-progress' => 'background-color: {{VALUE}}', |
| 161 | ], |
| 162 | 'separator' => 'before', |
| 163 | 'condition' => [ |
| 164 | 'eael_ext_reading_progress' => 'yes', |
| 165 | ], |
| 166 | ] |
| 167 | ); |
| 168 | |
| 169 | $element->add_control( |
| 170 | 'eael_ext_reading_progress_fill_color', |
| 171 | [ |
| 172 | 'label' => __('Fill Color', 'essential-addons-for-elementor-lite'), |
| 173 | 'type' => Controls_Manager::COLOR, |
| 174 | 'default' => '#1fd18e', |
| 175 | 'selectors' => [ |
| 176 | 'div.eael-reading-progress-wrap div.eael-reading-progress div.eael-reading-progress-fill' => 'background-color: {{VALUE}} !important', |
| 177 | ], |
| 178 | 'separator' => 'before', |
| 179 | 'condition' => [ |
| 180 | 'eael_ext_reading_progress' => 'yes', |
| 181 | ], |
| 182 | ] |
| 183 | ); |
| 184 | |
| 185 | $element->add_control( |
| 186 | 'eael_ext_reading_progress_animation_speed', |
| 187 | [ |
| 188 | 'label' => __('Animation Speed', 'essential-addons-for-elementor-lite'), |
| 189 | 'type' => Controls_Manager::SLIDER, |
| 190 | 'size_units' => ['px'], |
| 191 | 'range' => [ |
| 192 | 'px' => [ |
| 193 | 'min' => 0, |
| 194 | 'max' => 1000, |
| 195 | 'step' => 1, |
| 196 | ], |
| 197 | ], |
| 198 | 'default' => [ |
| 199 | 'unit' => 'px', |
| 200 | 'size' => 50, |
| 201 | ], |
| 202 | 'selectors' => [ |
| 203 | '.eael-reading-progress-wrap .eael-reading-progress .eael-reading-progress-fill' => 'transition: width {{SIZE}}ms ease;', |
| 204 | ], |
| 205 | 'separator' => 'before', |
| 206 | 'condition' => [ |
| 207 | 'eael_ext_reading_progress' => 'yes', |
| 208 | ], |
| 209 | ] |
| 210 | ); |
| 211 | |
| 212 | $element->end_controls_section(); |
| 213 | } |
| 214 | } |
| 215 |