Custom_JS.php
1 year ago
Hover_Effect.php
1 year ago
Post_Duplicator.php
1 year ago
Promotion.php
1 year ago
Reading_Progress.php
3 years ago
Scroll_to_Top.php
1 year ago
Table_of_Content.php
1 year ago
Wrapper_Link.php
1 year ago
index.php
3 years ago
Scroll_to_Top.php
456 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Essential_Addons_Elementor\Extensions; |
| 4 | |
| 5 | if (!defined('ABSPATH')) { |
| 6 | exit; |
| 7 | } |
| 8 | |
| 9 | use \Elementor\Controls_Manager; |
| 10 | use \Essential_Addons_Elementor\Classes\Helper; |
| 11 | |
| 12 | class Scroll_to_Top |
| 13 | { |
| 14 | |
| 15 | public function __construct() |
| 16 | { |
| 17 | add_action('elementor/documents/register_controls', [$this, 'register_controls'], 10); |
| 18 | } |
| 19 | |
| 20 | public function register_controls($element) |
| 21 | { |
| 22 | if (Helper::prevent_extension_loading(get_the_ID())) { |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | $global_settings = get_option('eael_global_settings'); |
| 27 | |
| 28 | $element->start_controls_section( |
| 29 | 'eael_ext_scroll_to_top_section', |
| 30 | [ |
| 31 | 'label' => __('<i class="eaicon-logo"></i> Scroll to Top', 'essential-addons-for-elementor-lite'), |
| 32 | 'tab' => Controls_Manager::TAB_SETTINGS, |
| 33 | ] |
| 34 | ); |
| 35 | |
| 36 | $element->add_control( |
| 37 | 'eael_ext_scroll_to_top', |
| 38 | [ |
| 39 | 'label' => __('Enable Scroll to Top', '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_scroll_to_top_has_global', |
| 50 | [ |
| 51 | 'label' => __('Enabled Globally?', 'essential-addons-for-elementor-lite'), |
| 52 | 'type' => Controls_Manager::HIDDEN, |
| 53 | 'default' => (isset($global_settings['eael_ext_scroll_to_top']['enabled']) ? $global_settings['eael_ext_scroll_to_top']['enabled'] : false), |
| 54 | ] |
| 55 | ); |
| 56 | |
| 57 | if (isset($global_settings['eael_ext_scroll_to_top']['enabled']) && ($global_settings['eael_ext_scroll_to_top']['enabled'] == true) && get_the_ID() != $global_settings['eael_ext_scroll_to_top']['post_id'] && get_post_status($global_settings['eael_ext_scroll_to_top']['post_id']) == 'publish') { |
| 58 | $element->add_control( |
| 59 | 'eael_ext_scroll_to_top_global_warning_text', |
| 60 | [ |
| 61 | 'type' => Controls_Manager::RAW_HTML, |
| 62 | 'raw' => __('You can modify the Global Scroll to Top by <strong><a href="' . get_bloginfo('url') . '/wp-admin/post.php?post=' . $global_settings['eael_ext_scroll_to_top']['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_scroll_to_top' => 'yes', |
| 67 | ], |
| 68 | ] |
| 69 | ); |
| 70 | } else { |
| 71 | $element->add_control( |
| 72 | 'eael_ext_scroll_to_top_global', |
| 73 | [ |
| 74 | 'label' => __('Enable Scroll to Top 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_scroll_to_top' => 'yes', |
| 84 | ], |
| 85 | ] |
| 86 | ); |
| 87 | |
| 88 | $element->add_control( |
| 89 | 'eael_ext_scroll_to_top_global_display_condition', |
| 90 | [ |
| 91 | 'label' => __('Display On', 'essential-addons-for-elementor-lite'), |
| 92 | 'type' => 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_scroll_to_top' => 'yes', |
| 101 | 'eael_ext_scroll_to_top_global' => 'yes', |
| 102 | ], |
| 103 | 'separator' => 'before', |
| 104 | ] |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | $element->add_control( |
| 109 | 'eael_ext_scroll_to_top_position_text', |
| 110 | [ |
| 111 | 'label' => esc_html__('Position', 'essential-addons-for-elementor-lite'), |
| 112 | 'type' => Controls_Manager::SELECT, |
| 113 | 'default' => 'bottom-right', |
| 114 | 'label_block' => false, |
| 115 | 'options' => [ |
| 116 | 'bottom-left' => esc_html__('Bottom Left', 'essential-addons-for-elementor-lite'), |
| 117 | 'bottom-right' => esc_html__('Bottom Right', 'essential-addons-for-elementor-lite'), |
| 118 | ], |
| 119 | 'separator' => 'before', |
| 120 | 'condition' => [ |
| 121 | 'eael_ext_scroll_to_top' => 'yes', |
| 122 | ], |
| 123 | ] |
| 124 | ); |
| 125 | |
| 126 | $element->add_control( |
| 127 | 'eael_ext_scroll_to_top_position_bottom', |
| 128 | [ |
| 129 | 'label' => __('Bottom', 'essential-addons-for-elementor-lite'), |
| 130 | 'type' => Controls_Manager::SLIDER, |
| 131 | 'size_units' => ['px', 'em', '%'], |
| 132 | 'range' => [ |
| 133 | 'px' => [ |
| 134 | 'min' => 0, |
| 135 | 'max' => 1000, |
| 136 | 'step' => 1, |
| 137 | ], |
| 138 | 'em' => [ |
| 139 | 'min' => 0, |
| 140 | 'max' => 50, |
| 141 | 'step' => 1, |
| 142 | ], |
| 143 | '%' => [ |
| 144 | 'min' => 0, |
| 145 | 'max' => 100, |
| 146 | 'step' => 1, |
| 147 | ], |
| 148 | ], |
| 149 | 'default' => [ |
| 150 | 'unit' => 'px', |
| 151 | 'size' => 15, |
| 152 | ], |
| 153 | 'selectors' => [ |
| 154 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'bottom: {{SIZE}}{{UNIT}}', |
| 155 | ], |
| 156 | 'condition' => [ |
| 157 | 'eael_ext_scroll_to_top' => 'yes', |
| 158 | ], |
| 159 | ] |
| 160 | ); |
| 161 | |
| 162 | $element->add_control( |
| 163 | 'eael_ext_scroll_to_top_position_left', |
| 164 | [ |
| 165 | 'label' => __('Left', 'essential-addons-for-elementor-lite'), |
| 166 | 'type' => Controls_Manager::SLIDER, |
| 167 | 'size_units' => ['px', 'em', '%'], |
| 168 | 'range' => [ |
| 169 | 'px' => [ |
| 170 | 'min' => 0, |
| 171 | 'max' => 1000, |
| 172 | 'step' => 1, |
| 173 | ], |
| 174 | 'em' => [ |
| 175 | 'min' => 0, |
| 176 | 'max' => 50, |
| 177 | 'step' => 1, |
| 178 | ], |
| 179 | '%' => [ |
| 180 | 'min' => 0, |
| 181 | 'max' => 100, |
| 182 | 'step' => 1, |
| 183 | ], |
| 184 | ], |
| 185 | 'default' => [ |
| 186 | 'unit' => 'px', |
| 187 | 'size' => 15, |
| 188 | ], |
| 189 | 'selectors' => [ |
| 190 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'left: {{SIZE}}{{UNIT}}', |
| 191 | ], |
| 192 | 'condition' => [ |
| 193 | 'eael_ext_scroll_to_top' => 'yes', |
| 194 | 'eael_ext_scroll_to_top_position_text' => 'bottom-left', |
| 195 | ], |
| 196 | ] |
| 197 | ); |
| 198 | |
| 199 | $element->add_control( |
| 200 | 'eael_ext_scroll_to_top_position_right', |
| 201 | [ |
| 202 | 'label' => __('Right', 'essential-addons-for-elementor-lite'), |
| 203 | 'type' => Controls_Manager::SLIDER, |
| 204 | 'size_units' => ['px', 'em', '%'], |
| 205 | 'range' => [ |
| 206 | 'px' => [ |
| 207 | 'min' => 0, |
| 208 | 'max' => 1000, |
| 209 | 'step' => 1, |
| 210 | ], |
| 211 | 'em' => [ |
| 212 | 'min' => 0, |
| 213 | 'max' => 50, |
| 214 | 'step' => 1, |
| 215 | ], |
| 216 | '%' => [ |
| 217 | 'min' => 0, |
| 218 | 'max' => 100, |
| 219 | 'step' => 1, |
| 220 | ], |
| 221 | ], |
| 222 | 'default' => [ |
| 223 | 'unit' => 'px', |
| 224 | 'size' => 15, |
| 225 | ], |
| 226 | 'selectors' => [ |
| 227 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'right: {{SIZE}}{{UNIT}}', |
| 228 | ], |
| 229 | 'condition' => [ |
| 230 | 'eael_ext_scroll_to_top' => 'yes', |
| 231 | 'eael_ext_scroll_to_top_position_text' => 'bottom-right', |
| 232 | ], |
| 233 | ] |
| 234 | ); |
| 235 | |
| 236 | $element->add_control( |
| 237 | 'eael_ext_scroll_to_top_button_width', |
| 238 | [ |
| 239 | 'label' => __('Width', 'essential-addons-for-elementor-lite'), |
| 240 | 'type' => Controls_Manager::SLIDER, |
| 241 | 'size_units' => ['px'], |
| 242 | 'range' => [ |
| 243 | 'px' => [ |
| 244 | 'min' => 0, |
| 245 | 'max' => 1000, |
| 246 | 'step' => 1, |
| 247 | ], |
| 248 | ], |
| 249 | 'default' => [ |
| 250 | 'unit' => 'px', |
| 251 | 'size' => 50, |
| 252 | ], |
| 253 | 'selectors' => [ |
| 254 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'width: {{SIZE}}{{UNIT}};', |
| 255 | ], |
| 256 | 'separator' => 'before', |
| 257 | 'condition' => [ |
| 258 | 'eael_ext_scroll_to_top' => 'yes', |
| 259 | ], |
| 260 | ] |
| 261 | ); |
| 262 | |
| 263 | $element->add_control( |
| 264 | 'eael_ext_scroll_to_top_button_height', |
| 265 | [ |
| 266 | 'label' => __('Height', 'essential-addons-for-elementor-lite'), |
| 267 | 'type' => Controls_Manager::SLIDER, |
| 268 | 'size_units' => ['px'], |
| 269 | 'range' => [ |
| 270 | 'px' => [ |
| 271 | 'min' => 0, |
| 272 | 'max' => 1000, |
| 273 | 'step' => 1, |
| 274 | ], |
| 275 | ], |
| 276 | 'default' => [ |
| 277 | 'unit' => 'px', |
| 278 | 'size' => 50, |
| 279 | ], |
| 280 | 'selectors' => [ |
| 281 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'height: {{SIZE}}{{UNIT}};', |
| 282 | ], |
| 283 | 'condition' => [ |
| 284 | 'eael_ext_scroll_to_top' => 'yes', |
| 285 | ], |
| 286 | ] |
| 287 | ); |
| 288 | |
| 289 | $element->add_control( |
| 290 | 'eael_ext_scroll_to_top_z_index', |
| 291 | [ |
| 292 | 'label' => __('Z Index', 'essential-addons-for-elementor-lite'), |
| 293 | 'type' => Controls_Manager::SLIDER, |
| 294 | 'size_units' => ['px'], |
| 295 | 'range' => [ |
| 296 | 'px' => [ |
| 297 | 'min' => 0, |
| 298 | 'max' => 9999, |
| 299 | 'step' => 10, |
| 300 | ], |
| 301 | ], |
| 302 | 'default' => [ |
| 303 | 'unit' => 'px', |
| 304 | 'size' => 9999, |
| 305 | ], |
| 306 | 'selectors' => [ |
| 307 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'z-index: {{SIZE}}', |
| 308 | ], |
| 309 | 'condition' => [ |
| 310 | 'eael_ext_scroll_to_top' => 'yes', |
| 311 | ], |
| 312 | ] |
| 313 | ); |
| 314 | |
| 315 | |
| 316 | $element->add_control( |
| 317 | 'eael_ext_scroll_to_top_button_opacity', |
| 318 | [ |
| 319 | 'label' => __('Opacity', 'essential-addons-for-elementor-lite'), |
| 320 | 'type' => Controls_Manager::SLIDER, |
| 321 | 'range' => [ |
| 322 | 'px' => [ |
| 323 | 'min' => 0, |
| 324 | 'max' => 1, |
| 325 | 'step' => 0.01, |
| 326 | ], |
| 327 | ], |
| 328 | 'default' => [ |
| 329 | 'unit' => 'px', |
| 330 | 'size' => 0.7, |
| 331 | ], |
| 332 | 'selectors' => [ |
| 333 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'opacity: {{SIZE}};', |
| 334 | ], |
| 335 | 'condition' => [ |
| 336 | 'eael_ext_scroll_to_top' => 'yes', |
| 337 | ], |
| 338 | ] |
| 339 | ); |
| 340 | |
| 341 | $element->add_control( |
| 342 | 'eael_ext_scroll_to_top_button_icon_image', |
| 343 | [ |
| 344 | 'label' => esc_html__('Icon', 'essential-addons-for-elementor-lite'), |
| 345 | 'type' => Controls_Manager::ICONS, |
| 346 | 'default' => [ |
| 347 | 'value' => 'fas fa-chevron-up', |
| 348 | 'library' => 'fa-solid', |
| 349 | ], |
| 350 | 'separator' => 'before', |
| 351 | 'condition' => [ |
| 352 | 'eael_ext_scroll_to_top' => 'yes', |
| 353 | ], |
| 354 | ] |
| 355 | ); |
| 356 | |
| 357 | $element->add_control( |
| 358 | 'eael_ext_scroll_to_top_button_icon_note', |
| 359 | [ |
| 360 | 'type' => Controls_Manager :: RAW_HTML, |
| 361 | 'raw' => __( 'If a page is not supported <strong>Font Awesome Icon</strong> please use <strong>SVG</strong> icon instead of it.', 'essential-addons-for-elementor-lite' ), |
| 362 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 363 | 'condition' => [ |
| 364 | 'eael_ext_scroll_to_top' => 'yes', |
| 365 | ], |
| 366 | ] |
| 367 | ); |
| 368 | |
| 369 | $element->add_control( |
| 370 | 'eael_ext_scroll_to_top_button_icon_size', |
| 371 | [ |
| 372 | 'label' => __('Icon Size', 'essential-addons-for-elementor-lite'), |
| 373 | 'type' => Controls_Manager::SLIDER, |
| 374 | 'default' => [ |
| 375 | 'size' => 16, |
| 376 | 'unit' => 'px', |
| 377 | ], |
| 378 | 'size_units' => ['px'], |
| 379 | 'range' => [ |
| 380 | 'px' => [ |
| 381 | 'min' => 0, |
| 382 | 'max' => 100, |
| 383 | 'step' => 1, |
| 384 | ], |
| 385 | ], |
| 386 | 'selectors' => [ |
| 387 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 388 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 389 | ], |
| 390 | 'condition' => [ |
| 391 | 'eael_ext_scroll_to_top' => 'yes', |
| 392 | ], |
| 393 | ] |
| 394 | ); |
| 395 | |
| 396 | $element->add_control( |
| 397 | 'eael_ext_scroll_to_top_button_icon_color', |
| 398 | [ |
| 399 | 'label' => __('Icon Color', 'essential-addons-for-elementor-lite'), |
| 400 | 'type' => Controls_Manager::COLOR, |
| 401 | 'default' => '#ffffff', |
| 402 | 'selectors' => [ |
| 403 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button i' => 'color: {{VALUE}}', |
| 404 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button svg' => 'fill: {{VALUE}}', |
| 405 | ], |
| 406 | 'condition' => [ |
| 407 | 'eael_ext_scroll_to_top' => 'yes', |
| 408 | ], |
| 409 | ] |
| 410 | ); |
| 411 | |
| 412 | $element->add_control( |
| 413 | 'eael_ext_scroll_to_top_button_bg_color', |
| 414 | [ |
| 415 | 'label' => __('Background Color', 'essential-addons-for-elementor-lite'), |
| 416 | 'type' => Controls_Manager::COLOR, |
| 417 | 'default' => '#000000', |
| 418 | 'selectors' => [ |
| 419 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'background-color: {{VALUE}}', |
| 420 | ], |
| 421 | 'condition' => [ |
| 422 | 'eael_ext_scroll_to_top' => 'yes', |
| 423 | ], |
| 424 | ] |
| 425 | ); |
| 426 | |
| 427 | $element->add_control( |
| 428 | 'eael_ext_scroll_to_top_button_border_radius', |
| 429 | [ |
| 430 | 'label' => __('Border Radius', 'essential-addons-for-elementor-lite'), |
| 431 | 'type' => Controls_Manager::SLIDER, |
| 432 | 'size_units' => ['px'], |
| 433 | 'range' => [ |
| 434 | 'px' => [ |
| 435 | 'min' => 0, |
| 436 | 'max' => 50, |
| 437 | 'step' => 1, |
| 438 | ], |
| 439 | ], |
| 440 | 'default' => [ |
| 441 | 'unit' => 'px', |
| 442 | 'size' => 5, |
| 443 | ], |
| 444 | 'selectors' => [ |
| 445 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'border-radius: {{SIZE}}{{UNIT}}', |
| 446 | ], |
| 447 | 'condition' => [ |
| 448 | 'eael_ext_scroll_to_top' => 'yes', |
| 449 | ], |
| 450 | ] |
| 451 | ); |
| 452 | |
| 453 | $element->end_controls_section(); |
| 454 | } |
| 455 | } |
| 456 |