Jump to content
Sign in to follow this  
dil_bert

Include Max mega menu Plugin into theme - eg. the twentyseventeen - the parallax-theme

Recommended Posts

hello dear Freaks  - good day. 

 

i am just in the early planning stages of a new proejct - a project that will be created wordpress and a theme called twentyseventeen - and the Max-Mega-Menu

Note: this ideas that i discuss here - might sound like a hackish idea - and probably many of you think that they are very very unusual. So i want to discuss all the ideas with you - in order to make up my mind and to go a safe way and finally to avoid risks.

question: can i do this project like i described it. 
 


i want to add the Max Mega Menu plugin into my theme for a new project.

What i've done so far is the following:

a.copy and paste plugin folder into my theme (the twentyseventeen)
b.include megamenu.php file into my theme function.php file

Needed to work: what do i need to do - what is still on the shedule: 

a. include with theme
b. active when theme active
c. So, how can I include this plugin and activate it when my theme is activated?


so the question is: can i include a plugin in my theme by calling it from my functions.php. 


pitfalls and cons: 
- Also, we shouldn't move parts of the plugin directly to the theme,
- It might be looking for a file that isn't there and throw an error.


reasons that support this idea: 

conclusio: So, the right way to do this is have the complete plugin in a subdirectory of our theme and call it only after we have checked 
whether it hasn't already be loaded so far.  With this i can try to avoid running into issues rooted by the integration of the plugin 
directly into the theme. This can be done by checking the existence of a certain function or class that we know is available in the plugin. 

add_action('after_setup_theme', 'wpse237683_load_plugin');

function wpse237683_load_plugin() {
    if (!class_exists('wpse3333237683')) {
        include_once (get_template_directory() . 'plugins/wpse3333237683/wpse3333237683.php');
        }
    }

 

note: to include a plugin directly inside a theme - will cause fatal errors - due to some rejecton of either Wordpress and the theme itself. we can use TGMPA for including plugins with themes: http://tgmpluginactivation.com/


btw we can make use of a PHP library like TGMPA that will help here: http://tgmpluginactivation.com/

Quote


TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.


Further reading: http://code.tutsplus.com/tutorials/using-the-tgm-plugin-activation-library-in-your-themes--cms-20901
Using TGMPA means the plugin remains a plugin, WordPress loads it in the normal 'plugin' way, and users will get  plugin updates as they're released.

 

Quote


By using classes that are utilized within WordPress, the TGM Plugin Activation library can automatically install, update and activate multiple plugins that are either bundled with a theme, downloaded from the WordPress Plugin Repository or downloaded elsewhere on the internet (perhaps a private repository).
The library uses the WP_Filesystem Abstraction class to find the best way to install the plugins - WP_Filesystem searches through a number of methods (Direct, FTP, FTP Sockets, SSH) and determines the best one to use based on the user’s server setup. If any FTP credentials are needed, a form will be displayed to prompt users to input their FTP credentials in order to continue processing the request. The library uses WordPress’ own Plugin_Upgrader and Plugin_Installer_Skin and extensions of other WordPress upgrader classes to handle singular and bulk installations.

Note: this ideas that i discuss here - might sound like a hackish idea - and probably many of you think that they are very very unusual. So i want to discuss all the ideas with you - in order to make up my mind and to go a safe way and finally to avoid risks.

question: can i do this project like i described it. 

 

 

 

Edited by dil_bert

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.