• The Mega Menu Widgets are being loaded by APMM_Class->ap_megamenu_includes() which checks if the $id exists as a Class or not before loading it. It pulls that list from APMM_Class->menuincludes() which holds the following:

    
    return array(
        'wpmegamenuwalker_class' => APMM_PATH . 'inc/frontend/WPMegamenuWalker_Class.php',
        'ap_menu_settings' => APMM_PATH . 'inc/admin/menu_settings_class.php', //admin menu display class
        'ap_theme_settings' => APMM_PATH . 'inc/admin/theme_settings_class.php', //admin menu display class
        'wpmm_menu_widget_manager' => APMM_PATH . 'inc/admin/widget-manager_class.php',
        'wp_mega_menu_widget' => APMM_PATH . 'inc/admin/wpmegamenu-widget.php',
    );
    

    When it loads the wp_mega_menu_widget Class using that Array, it is also actually loading the WP_Mega_Menu_Contact_Info, WP_Mega_Menu_PRO_LinkImage, and WP_Mega_Menu_PRO_HtmlText Classes since they are all in the same file, which means that if those Classes already exist, it still loads the file as it never checked for those.

    This would normally be fine as the Classes are individually wrapped by if ( ! class_exists() ), but since this happens at the instantiation of the main Plugin Class rather than at a Hook it makes it very challenging to include your own version of the Class(es) before it can. I’ve tried naming the directory of my own plugin things like 0-ap-mega-menu-overrides and aap-mega-menu-overrides to try to get mine to load up first and nothing seems to outspeed the inclusion of that file in the AP Mega Menu plugin.

    If APMM_Class->ap_megamenu_includes() could run at plugins_loaded or later and/or a Filter be placed on APMM_Class->menuincludes() to modify the returned Array that would be very helpful! I really appreciate the work you’ve done with this plugin! It has saved me a lot of time so far.

Viewing 1 replies (of 1 total)
  • Thread Starter d4mation

    (@d4mation)

    In case it helps anyone, I realized how to ensure getting my code to load first: Deactivate AP Mega Menu, activate your Plugin which modifies the Widget Classes, then Reactivate AP Mega Menu. What matters more is the order the Plugins were set as “active” in wp_options under active_plugins rather than the alphabetical order of the directory names.

    Adding an Action and/or Filter should make this less prone to error though.

Viewing 1 replies (of 1 total)
  • The topic ‘Cannot override most Mega Menu Widgets’ is closed to new replies.