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