• Resolved NDDT

    (@nddt)


    Hi,

    I tried to integrate the PlugIn with a theme I’m developing. It worked fine in the frontend after i had changed the hook for initialisation to ‘after-theme-setup’.
    In the Backend i could see the “Mega Menu Settings”. But the Buttons on the Menu-Items weren’t displayer. Can you give me some pointers why this problem occurs?

    https://www.ads-software.com/plugins/megamenu/

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

    (@megamenu)

    Hi NDDT,

    Are you installing the plugin as a normal plugin or are you trying to package it in with the theme itself? If the latter then that may present a problem with paths, and might explain why the JavaScript which adds the buttons to each menu item aren’t being displayed.

    Instead of packaging the plugin directly with the theme I recommend using this instead: https://tgmpluginactivation.com/

    If you’re already using that method, could you explain what you’re using the after_theme_setup hook for? Do you see any JavaScript errors in the console on the menu page?

    Regards,
    Tom

    Thread Starter NDDT

    (@nddt)

    Hi Tom,

    thanks for your reply. I packaged the plugin with a theme. And u were right. The paths to the javascript were the problem.

    I solved it by setting the path-variables to:

    define( 'MEGAMENU_VERSION',    $this->version );
    define( 'MEGAMENU_BASE_URL',   trailingslashit(get_template_directory_uri() . '/inc/plugins/megamenu') );
    define( 'MEGAMENU_PATH',       get_template_directory() . '/inc/plugins/megamenu/' );

    For evrybody else reading this: You also have to change the init-hook to:

    add_action( 'after_setup_theme', array( 'Mega_Menu', 'init' ), 10 );

    Thread Starter NDDT

    (@nddt)

    I have one more question: Where would i change the initial values for the options-page?

    Plugin Author megamenu

    (@megamenu)

    Hi NDDT,

    Although what you’ve done will work, it may present problems further down the line… either your users will be stuck on v1.6 (there are already lots of extra cool features in v1.7) or when they update the plugin your changes will break – and they’ll have 2 copies of Max Mega Menu installed (one in your theme, one in the usual wp-content/plugins directory).

    Also, if you’re planning on submitting your theme to ThemeForest then they will reject it as you’re not allowed to include plugins directly in the themes (you must use the TGM Plugin class that I linked to above), I’m not sure what the www.ads-software.com guidelines are but I suspect it would be the same story.

    I personally am not fussed how you do it, just letting you know you might run into some issues doing it that way ??

    Which options-page do you mean?

    Regards,
    Tom

    Thread Starter NDDT

    (@nddt)

    Hi Tom,

    I won’t sell the Theme and it will only be handled by us. I’m developing it this way to set up new websites faster.

    Thats why i want to change the default-values of Appearance-> Mega Menu.

    Plugin Author megamenu

    (@megamenu)

    Hi NDDT,

    There’s not really a way to do that properly, but if you set up the menu how you’d like (with all the settings etc), then do…

    $settings = get_option('megamenu_settings');
    
    var_dump($settings);

    … you will see all the saved settings.

    You’ll need to work out a way to insert those same settings when the theme is activated, something like this:

    $options = array(
        'css' => 'fs',
        'second_click' => 'go'
    );
    
    update_option('megamenu_settings', $options);

    Regards,
    Tom

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Theme-Integration’ is closed to new replies.