Custom_JS.php
1 year ago
Hover_Effect.php
1 year ago
Image_Masking.php
2 months ago
Liquid_Glass_Effect.php
5 months ago
Post_Duplicator.php
2 months ago
Promotion.php
9 months ago
Reading_Progress.php
5 months ago
Scroll_to_Top.php
5 months ago
Table_of_Content.php
2 weeks ago
Vertical_Text_Orientation.php
7 months ago
Wrapper_Link.php
2 months ago
index.php
3 years ago
Scroll_to_Top.php
460 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' => sprintf( |
| 63 | /* translators: %s: Edit link to the Global Scroll to Top settings. */ |
| 64 | __('You can modify the Global Scroll to Top by <strong><a href="%s">Clicking Here</a></strong>', 'essential-addons-for-elementor-lite'), |
| 65 | esc_url( get_bloginfo('url') . '/wp-admin/post.php?post=' . $global_settings['eael_ext_scroll_to_top']['post_id'] . '&action=elementor' ) |
| 66 | ), |
| 67 | 'content_classes' => 'eael-warning', |
| 68 | 'separator' => 'before', |
| 69 | 'condition' => [ |
| 70 | 'eael_ext_scroll_to_top' => 'yes', |
| 71 | ], |
| 72 | ] |
| 73 | ); |
| 74 | } else { |
| 75 | $element->add_control( |
| 76 | 'eael_ext_scroll_to_top_global', |
| 77 | [ |
| 78 | 'label' => __('Enable Scroll to Top Globally', 'essential-addons-for-elementor-lite'), |
| 79 | 'description' => __('Enabling this option will effect on entire site.', 'essential-addons-for-elementor-lite'), |
| 80 | 'type' => Controls_Manager::SWITCHER, |
| 81 | 'default' => 'no', |
| 82 | 'label_on' => __('Yes', 'essential-addons-for-elementor-lite'), |
| 83 | 'label_off' => __('No', 'essential-addons-for-elementor-lite'), |
| 84 | 'return_value' => 'yes', |
| 85 | 'separator' => 'before', |
| 86 | 'condition' => [ |
| 87 | 'eael_ext_scroll_to_top' => 'yes', |
| 88 | ], |
| 89 | ] |
| 90 | ); |
| 91 | |
| 92 | $element->add_control( |
| 93 | 'eael_ext_scroll_to_top_global_display_condition', |
| 94 | [ |
| 95 | 'label' => __('Display On', 'essential-addons-for-elementor-lite'), |
| 96 | 'type' => Controls_Manager::SELECT, |
| 97 | 'default' => 'all', |
| 98 | 'options' => [ |
| 99 | 'posts' => __('All Posts', 'essential-addons-for-elementor-lite'), |
| 100 | 'pages' => __('All Pages', 'essential-addons-for-elementor-lite'), |
| 101 | 'all' => __('All Posts & Pages', 'essential-addons-for-elementor-lite'), |
| 102 | ], |
| 103 | 'condition' => [ |
| 104 | 'eael_ext_scroll_to_top' => 'yes', |
| 105 | 'eael_ext_scroll_to_top_global' => 'yes', |
| 106 | ], |
| 107 | 'separator' => 'before', |
| 108 | ] |
| 109 | ); |
| 110 | } |
| 111 | |
| 112 | $element->add_control( |
| 113 | 'eael_ext_scroll_to_top_position_text', |
| 114 | [ |
| 115 | 'label' => esc_html__('Position', 'essential-addons-for-elementor-lite'), |
| 116 | 'type' => Controls_Manager::SELECT, |
| 117 | 'default' => 'bottom-right', |
| 118 | 'label_block' => false, |
| 119 | 'options' => [ |
| 120 | 'bottom-left' => esc_html__('Bottom Left', 'essential-addons-for-elementor-lite'), |
| 121 | 'bottom-right' => esc_html__('Bottom Right', 'essential-addons-for-elementor-lite'), |
| 122 | ], |
| 123 | 'separator' => 'before', |
| 124 | 'condition' => [ |
| 125 | 'eael_ext_scroll_to_top' => 'yes', |
| 126 | ], |
| 127 | ] |
| 128 | ); |
| 129 | |
| 130 | $element->add_control( |
| 131 | 'eael_ext_scroll_to_top_position_bottom', |
| 132 | [ |
| 133 | 'label' => __('Bottom', 'essential-addons-for-elementor-lite'), |
| 134 | 'type' => Controls_Manager::SLIDER, |
| 135 | 'size_units' => ['px', 'em', '%'], |
| 136 | 'range' => [ |
| 137 | 'px' => [ |
| 138 | 'min' => 0, |
| 139 | 'max' => 1000, |
| 140 | 'step' => 1, |
| 141 | ], |
| 142 | 'em' => [ |
| 143 | 'min' => 0, |
| 144 | 'max' => 50, |
| 145 | 'step' => 1, |
| 146 | ], |
| 147 | '%' => [ |
| 148 | 'min' => 0, |
| 149 | 'max' => 100, |
| 150 | 'step' => 1, |
| 151 | ], |
| 152 | ], |
| 153 | 'default' => [ |
| 154 | 'unit' => 'px', |
| 155 | 'size' => 15, |
| 156 | ], |
| 157 | 'selectors' => [ |
| 158 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'bottom: {{SIZE}}{{UNIT}}', |
| 159 | ], |
| 160 | 'condition' => [ |
| 161 | 'eael_ext_scroll_to_top' => 'yes', |
| 162 | ], |
| 163 | ] |
| 164 | ); |
| 165 | |
| 166 | $element->add_control( |
| 167 | 'eael_ext_scroll_to_top_position_left', |
| 168 | [ |
| 169 | 'label' => __('Left', 'essential-addons-for-elementor-lite'), |
| 170 | 'type' => Controls_Manager::SLIDER, |
| 171 | 'size_units' => ['px', 'em', '%'], |
| 172 | 'range' => [ |
| 173 | 'px' => [ |
| 174 | 'min' => 0, |
| 175 | 'max' => 1000, |
| 176 | 'step' => 1, |
| 177 | ], |
| 178 | 'em' => [ |
| 179 | 'min' => 0, |
| 180 | 'max' => 50, |
| 181 | 'step' => 1, |
| 182 | ], |
| 183 | '%' => [ |
| 184 | 'min' => 0, |
| 185 | 'max' => 100, |
| 186 | 'step' => 1, |
| 187 | ], |
| 188 | ], |
| 189 | 'default' => [ |
| 190 | 'unit' => 'px', |
| 191 | 'size' => 15, |
| 192 | ], |
| 193 | 'selectors' => [ |
| 194 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'left: {{SIZE}}{{UNIT}}', |
| 195 | ], |
| 196 | 'condition' => [ |
| 197 | 'eael_ext_scroll_to_top' => 'yes', |
| 198 | 'eael_ext_scroll_to_top_position_text' => 'bottom-left', |
| 199 | ], |
| 200 | ] |
| 201 | ); |
| 202 | |
| 203 | $element->add_control( |
| 204 | 'eael_ext_scroll_to_top_position_right', |
| 205 | [ |
| 206 | 'label' => __('Right', 'essential-addons-for-elementor-lite'), |
| 207 | 'type' => Controls_Manager::SLIDER, |
| 208 | 'size_units' => ['px', 'em', '%'], |
| 209 | 'range' => [ |
| 210 | 'px' => [ |
| 211 | 'min' => 0, |
| 212 | 'max' => 1000, |
| 213 | 'step' => 1, |
| 214 | ], |
| 215 | 'em' => [ |
| 216 | 'min' => 0, |
| 217 | 'max' => 50, |
| 218 | 'step' => 1, |
| 219 | ], |
| 220 | '%' => [ |
| 221 | 'min' => 0, |
| 222 | 'max' => 100, |
| 223 | 'step' => 1, |
| 224 | ], |
| 225 | ], |
| 226 | 'default' => [ |
| 227 | 'unit' => 'px', |
| 228 | 'size' => 15, |
| 229 | ], |
| 230 | 'selectors' => [ |
| 231 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'right: {{SIZE}}{{UNIT}}', |
| 232 | ], |
| 233 | 'condition' => [ |
| 234 | 'eael_ext_scroll_to_top' => 'yes', |
| 235 | 'eael_ext_scroll_to_top_position_text' => 'bottom-right', |
| 236 | ], |
| 237 | ] |
| 238 | ); |
| 239 | |
| 240 | $element->add_control( |
| 241 | 'eael_ext_scroll_to_top_button_width', |
| 242 | [ |
| 243 | 'label' => __('Width', 'essential-addons-for-elementor-lite'), |
| 244 | 'type' => Controls_Manager::SLIDER, |
| 245 | 'size_units' => ['px'], |
| 246 | 'range' => [ |
| 247 | 'px' => [ |
| 248 | 'min' => 0, |
| 249 | 'max' => 1000, |
| 250 | 'step' => 1, |
| 251 | ], |
| 252 | ], |
| 253 | 'default' => [ |
| 254 | 'unit' => 'px', |
| 255 | 'size' => 50, |
| 256 | ], |
| 257 | 'selectors' => [ |
| 258 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'width: {{SIZE}}{{UNIT}};', |
| 259 | ], |
| 260 | 'separator' => 'before', |
| 261 | 'condition' => [ |
| 262 | 'eael_ext_scroll_to_top' => 'yes', |
| 263 | ], |
| 264 | ] |
| 265 | ); |
| 266 | |
| 267 | $element->add_control( |
| 268 | 'eael_ext_scroll_to_top_button_height', |
| 269 | [ |
| 270 | 'label' => __('Height', 'essential-addons-for-elementor-lite'), |
| 271 | 'type' => Controls_Manager::SLIDER, |
| 272 | 'size_units' => ['px'], |
| 273 | 'range' => [ |
| 274 | 'px' => [ |
| 275 | 'min' => 0, |
| 276 | 'max' => 1000, |
| 277 | 'step' => 1, |
| 278 | ], |
| 279 | ], |
| 280 | 'default' => [ |
| 281 | 'unit' => 'px', |
| 282 | 'size' => 50, |
| 283 | ], |
| 284 | 'selectors' => [ |
| 285 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'height: {{SIZE}}{{UNIT}};', |
| 286 | ], |
| 287 | 'condition' => [ |
| 288 | 'eael_ext_scroll_to_top' => 'yes', |
| 289 | ], |
| 290 | ] |
| 291 | ); |
| 292 | |
| 293 | $element->add_control( |
| 294 | 'eael_ext_scroll_to_top_z_index', |
| 295 | [ |
| 296 | 'label' => __('Z Index', 'essential-addons-for-elementor-lite'), |
| 297 | 'type' => Controls_Manager::SLIDER, |
| 298 | 'size_units' => ['px'], |
| 299 | 'range' => [ |
| 300 | 'px' => [ |
| 301 | 'min' => 0, |
| 302 | 'max' => 9999, |
| 303 | 'step' => 10, |
| 304 | ], |
| 305 | ], |
| 306 | 'default' => [ |
| 307 | 'unit' => 'px', |
| 308 | 'size' => 9999, |
| 309 | ], |
| 310 | 'selectors' => [ |
| 311 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'z-index: {{SIZE}}', |
| 312 | ], |
| 313 | 'condition' => [ |
| 314 | 'eael_ext_scroll_to_top' => 'yes', |
| 315 | ], |
| 316 | ] |
| 317 | ); |
| 318 | |
| 319 | |
| 320 | $element->add_control( |
| 321 | 'eael_ext_scroll_to_top_button_opacity', |
| 322 | [ |
| 323 | 'label' => __('Opacity', 'essential-addons-for-elementor-lite'), |
| 324 | 'type' => Controls_Manager::SLIDER, |
| 325 | 'range' => [ |
| 326 | 'px' => [ |
| 327 | 'min' => 0, |
| 328 | 'max' => 1, |
| 329 | 'step' => 0.01, |
| 330 | ], |
| 331 | ], |
| 332 | 'default' => [ |
| 333 | 'unit' => 'px', |
| 334 | 'size' => 0.7, |
| 335 | ], |
| 336 | 'selectors' => [ |
| 337 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'opacity: {{SIZE}};', |
| 338 | ], |
| 339 | 'condition' => [ |
| 340 | 'eael_ext_scroll_to_top' => 'yes', |
| 341 | ], |
| 342 | ] |
| 343 | ); |
| 344 | |
| 345 | $element->add_control( |
| 346 | 'eael_ext_scroll_to_top_button_icon_image', |
| 347 | [ |
| 348 | 'label' => esc_html__('Icon', 'essential-addons-for-elementor-lite'), |
| 349 | 'type' => Controls_Manager::ICONS, |
| 350 | 'default' => [ |
| 351 | 'value' => 'fas fa-chevron-up', |
| 352 | 'library' => 'fa-solid', |
| 353 | ], |
| 354 | 'separator' => 'before', |
| 355 | 'condition' => [ |
| 356 | 'eael_ext_scroll_to_top' => 'yes', |
| 357 | ], |
| 358 | ] |
| 359 | ); |
| 360 | |
| 361 | $element->add_control( |
| 362 | 'eael_ext_scroll_to_top_button_icon_note', |
| 363 | [ |
| 364 | 'type' => Controls_Manager :: RAW_HTML, |
| 365 | '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' ), |
| 366 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 367 | 'condition' => [ |
| 368 | 'eael_ext_scroll_to_top' => 'yes', |
| 369 | ], |
| 370 | ] |
| 371 | ); |
| 372 | |
| 373 | $element->add_control( |
| 374 | 'eael_ext_scroll_to_top_button_icon_size', |
| 375 | [ |
| 376 | 'label' => __('Icon Size', 'essential-addons-for-elementor-lite'), |
| 377 | 'type' => Controls_Manager::SLIDER, |
| 378 | 'default' => [ |
| 379 | 'size' => 16, |
| 380 | 'unit' => 'px', |
| 381 | ], |
| 382 | 'size_units' => ['px'], |
| 383 | 'range' => [ |
| 384 | 'px' => [ |
| 385 | 'min' => 0, |
| 386 | 'max' => 100, |
| 387 | 'step' => 1, |
| 388 | ], |
| 389 | ], |
| 390 | 'selectors' => [ |
| 391 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 392 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 393 | ], |
| 394 | 'condition' => [ |
| 395 | 'eael_ext_scroll_to_top' => 'yes', |
| 396 | ], |
| 397 | ] |
| 398 | ); |
| 399 | |
| 400 | $element->add_control( |
| 401 | 'eael_ext_scroll_to_top_button_icon_color', |
| 402 | [ |
| 403 | 'label' => __('Icon Color', 'essential-addons-for-elementor-lite'), |
| 404 | 'type' => Controls_Manager::COLOR, |
| 405 | 'default' => '#ffffff', |
| 406 | 'selectors' => [ |
| 407 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button i' => 'color: {{VALUE}}', |
| 408 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button svg' => 'fill: {{VALUE}}', |
| 409 | ], |
| 410 | 'condition' => [ |
| 411 | 'eael_ext_scroll_to_top' => 'yes', |
| 412 | ], |
| 413 | ] |
| 414 | ); |
| 415 | |
| 416 | $element->add_control( |
| 417 | 'eael_ext_scroll_to_top_button_bg_color', |
| 418 | [ |
| 419 | 'label' => __('Background Color', 'essential-addons-for-elementor-lite'), |
| 420 | 'type' => Controls_Manager::COLOR, |
| 421 | 'default' => '#000000', |
| 422 | 'selectors' => [ |
| 423 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'background-color: {{VALUE}}', |
| 424 | ], |
| 425 | 'condition' => [ |
| 426 | 'eael_ext_scroll_to_top' => 'yes', |
| 427 | ], |
| 428 | ] |
| 429 | ); |
| 430 | |
| 431 | $element->add_control( |
| 432 | 'eael_ext_scroll_to_top_button_border_radius', |
| 433 | [ |
| 434 | 'label' => __('Border Radius', 'essential-addons-for-elementor-lite'), |
| 435 | 'type' => Controls_Manager::SLIDER, |
| 436 | 'size_units' => ['px'], |
| 437 | 'range' => [ |
| 438 | 'px' => [ |
| 439 | 'min' => 0, |
| 440 | 'max' => 50, |
| 441 | 'step' => 1, |
| 442 | ], |
| 443 | ], |
| 444 | 'default' => [ |
| 445 | 'unit' => 'px', |
| 446 | 'size' => 5, |
| 447 | ], |
| 448 | 'selectors' => [ |
| 449 | '.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'border-radius: {{SIZE}}{{UNIT}}', |
| 450 | ], |
| 451 | 'condition' => [ |
| 452 | 'eael_ext_scroll_to_top' => 'yes', |
| 453 | ], |
| 454 | ] |
| 455 | ); |
| 456 | |
| 457 | $element->end_controls_section(); |
| 458 | } |
| 459 | } |
| 460 |