| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
die('-1'); |
| 5 |
} |
| 6 |
|
| 7 |
class QuadMenu_Elementor { |
| 8 |
|
| 9 |
public function __construct() { |
| 10 |
//add_filter('wp_nav_menu_args', array($this, 'elementor'), 10, 1); |
| 11 |
add_action('elementor/widgets/widgets_registered', array($this, 'module')); |
| 12 |
add_action('elementor/widgets/widgets_registered', array($this, 'exclude')); |
| 13 |
add_action('wp_footer', array($this, 'footer')); |
| 14 |
} |
| 15 |
|
| 16 |
function exclude($elementor) { |
| 17 |
|
| 18 |
if (!class_exists('Elementor\\Plugin')) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
$elementor->unregister_widget_type('wp-widget-quadmenu_widget'); |
| 23 |
} |
| 24 |
|
| 25 |
function module($elementor) { |
| 26 |
|
| 27 |
if (!class_exists('Elementor\\Plugin')) { |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
require_once 'elementor/module.php'; |
| 32 |
|
| 33 |
$elementor->register_widget_type(new Elementor\QuadMenu()); |
| 34 |
} |
| 35 |
|
| 36 |
function footer() { |
| 37 |
|
| 38 |
if (!class_exists('Elementor\\Plugin')) { |
| 39 |
return; |
| 40 |
} |
| 41 |
//if (!Elementor\Plugin::$instance->editor->is_edit_mode() && !Elementor\Plugin::$instance->preview->is_preview_mode()) { |
| 42 |
// return; |
| 43 |
//} |
| 44 |
|
| 45 |
if (!property_exists('Elementor\Plugin', 'instance')) { |
| 46 |
return; |
| 47 |
} |
| 48 |
|
| 49 |
if (!@Elementor\Plugin::$instance->preview) { |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
if (!@Elementor\Plugin::$instance->preview->is_preview_mode()) { |
| 54 |
return; |
| 55 |
} |
| 56 |
?> |
| 57 |
<script> |
| 58 |
jQuery(function ($) { |
| 59 |
if (window.elementorFrontend) { |
| 60 |
|
| 61 |
elementorFrontend.hooks.addAction('frontend/element_ready/global', function (response) { |
| 62 |
|
| 63 |
var $quadmenu = $('nav#quadmenu', $(response)); |
| 64 |
|
| 65 |
if ($quadmenu.length) { |
| 66 |
|
| 67 |
setTimeout(function () { |
| 68 |
$quadmenu.quadmenu(); |
| 69 |
}, 100); |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
}); |
| 74 |
} |
| 75 |
}); |
| 76 |
</script> |
| 77 |
<?php |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
new QuadMenu_Elementor(); |
| 84 |
|