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