• Resolved helvetica123

    (@helvetica123)


    Hi, I just now lefted another mega menu plugin because of their theme important option doesn’t match one click import rules.

    I selected your plugin because I can add menu theme to theme without upload theme file.

    but I couldn’t find any option to set enabled menu theme from theme function.php.

    I want to add menu theme and set its theme enabled for specific WordPress menu automatically.

    need to shrink import demo data steps.

    It is so important for my theme also for all one-click-demo-import supported themes.

    I wait your messages..

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author megamenu

    (@megamenu)

    Hi helvetica,

    Please check the “Changing the default theme” section at the bottom of this page:

    https://www.megamenu.com/documentation/theme-developers/

    Regards,
    Tom

    Thread Starter helvetica123

    (@helvetica123)

    Hi, Thanks for your fast reply.However, I couldn’t do it:

    my menu editing URL on wp-admin ends with this:

    edit&menu=36

    I saved the theme with this code:

    function megamenu_add_theme_default_1611861871($themes) {
        $themes["cadefault_1611861871"] = array(

    So, I tried set the theme to the menu with this code:

    function megamenu_override_default_theme($value) {
        // change 'primary' to your menu location ID
        if ( !isset($value['36']['theme']) ) {
            $value['36']['theme'] = 'cadefault_1611861871'; // change my_custom_theme_key to the ID of your exported theme
        }
    
        return $value;
    }
    add_filter('default_option_megamenu_settings', 'megamenu_override_default_theme');

    but I couldn’t set it as enabled.the menu works also menu theme is saved.

    Also I tried to delete data on plugin tools.

    so, I am waiting your help again.

    Plugin Author megamenu

    (@megamenu)

    Hi helvetica123,

    Please upload your theme somewhere and link to it here so I can install it and debug it locally.

    Regards,
    Tom

    Thread Starter helvetica123

    (@helvetica123)

    Thanks for your developer-friendly reply.Because of some specific reasons, I can’t upload the theme.I tried this also on twenty-twenty and I couldn’t get success.Can you create modified twenty-twenty? I think there is no code cause conflict in my theme.So, I can integrate this feature to my theme.I don’t know the reason but I miss some coding things.

    Plugin Author megamenu

    (@megamenu)

    Hi helvetica123,

    I think I see the problem. You have used “36” in the code (in place of “primary”), but it should reference the ID of the menu location (the one specified when you did “register_nav_menu”), not the ID of the menu. The ID of the menu will be different for all of your users so you cannot reference it this way.

    Regards,
    Tom

    Thread Starter helvetica123

    (@helvetica123)

    Hi, yes it was my mistake but after the change you said, the problem exists still. In functions.php of twenty-twenty theme,

    menu locations are saved like this:

    /**
     * Register navigation menus uses wp_nav_menu in five places.
     */
    function twentytwenty_menus() {
    
    	$locations = array(
    		'primary'  => __( 'Desktop Horizontal Menu', 'twentytwenty' ),
    		'expanded' => __( 'Desktop Expanded Menu', 'twentytwenty' ),
    		'mobile'   => __( 'Mobile Menu', 'twentytwenty' ),
    		'footer'   => __( 'Footer Menu', 'twentytwenty' ),
    		'social'   => __( 'Social Menu', 'twentytwenty' ),
    	);
    
    	register_nav_menus( $locations );
    }
    
    add_action( 'init', 'twentytwenty_menus' );

    I created a menu by hand and set it for all of these 5 menu locations.

    Then, I changed ‘primary’ to ‘mobile’ in the sample function.You can see all related code to the plugin in function.php on the below link:

    https://paste.ofcode.org/fh7XSeyRGAegNExZPH4XHV

    These are related code issues.Also I tried delete data and re-enable plugin.

    Plugin Author megamenu

    (@megamenu)

    Hi helvetica123,

    Here is a copy of generatepress with the default theme set to “My custom theme”:

    https://wetransfer.com/downloads/514370bb05aa7230f30c8b6161e237cc20210203103521/070185fa86f0ec6db7888e684792478f20210203103534/0e5f7c

    I think I see the problem now – you want MMM to be automatically enabled upon activation, but that is not possible, the user must manually activate it. (Your default theme menu should work even without MMM enabled, and then MMM can be used to enhance it if the user chooses to). Instead, maybe you could detect whether MMM is enabled or not (check inside the megamenu_settings option) and show a notice asking them to enable it.

    Regards,
    Tom

    • This reply was modified 4 years, 1 month ago by megamenu.
    Thread Starter helvetica123

    (@helvetica123)

    yes, my problem is exactly that.The option would be better for theme developers.Thanks for plugin and helps

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Set menu as enabled automatically’ is closed to new replies.