diff --git a/core/includes/class-tm-mega-menu-widget-manager.php b/core/includes/class-tm-mega-menu-widget-manager.php index 4c1c557..c4d0671 100644 --- a/core/includes/class-tm-mega-menu-widget-manager.php +++ b/core/includes/class-tm-mega-menu-widget-manager.php @@ -28,7 +28,6 @@ class tm_mega_menu_widget_manager { * @since 1.0.0 */ public function __construct() { - add_action( 'init', array( $this, 'register_sidebar' ) ); add_action( 'wp_ajax_tm_mega_menu_edit_widget', array( $this, 'show_widget_form' ) ); @@ -39,6 +38,32 @@ public function __construct() { add_action( 'wp_ajax_tm_mega_menu_move_widget', array( $this, 'move_widget' ) ); add_filter( 'widget_update_callback', array( $this, 'persist_tm_mega_menu_widget_settings' ), 10, 4 ); + + // Compatibility with WordPress 4.8 (text and media Widgets) + add_action( 'admin_footer-nav-menus.php', array( $this, 'admin_print_footer_scripts' ) ); + add_action( 'admin_print_scripts-nav-menus.php', array( $this, 'admin_print_scripts' ) ); + add_action( 'admin_print_styles-nav-menus.php', array( $this, 'admin_print_styles' ) ); + } + + /** + * Print the widgets.php admin scripts on the nav-menus.php page. + */ + public function admin_print_footer_scripts() { + do_action( 'admin_footer-widgets.php' ); + } + + /** + * Print the widgets.php admin scripts on the nav-menus.php page. + */ + public function admin_print_scripts() { + do_action( 'admin_print_scripts-widgets.php' ); + } + + /** + * Print the widgets.php admin styles on the nav-menus.php page. + */ + public function admin_print_styles() { + do_action( 'admin_print_styles-widgets.php' ); } /** @@ -399,14 +424,16 @@ public function _show_widget_form( $widget_id ) { ?>