Adding Plugins

Note: This feature is available since Softaculous 4.5.0

Overview

This Page will help you in adding plugin option to your users. (For e.g. If you want to provide certain plugins to your users while installing WordPress or any other script)

A sample plugin example is available here : File:Plugins.zip

Download the above file and unzip it at the following path.

/PATH/TO/softaculous/conf/mods/SCRIPT_SOFTNAME/

You can find the SCRIPT_SOFTNAME from iscripts.php located at

/PATH/TO/softaculous/enduser/iscripts.php

For e.g. in the above zip file we have explained the plugin integration for WordPress and its softname is ‘wp’ so the path where you have to unzip the above file would be :

/PATH/TO/softaculous/conf/mods/wp/

Note: If the above folder does not exist you will need to create the same.

In the above zip file there are three files available.
1. mods.php
2. mod_install.xml
3. sample_plugin.zip (in this example : smart-maintenance-mode.zip)

To add the plugins in Softaculous without making custom package please follow the below steps :

mod_install.xml

This file is responsible for displaying plugin(s) option for installing to enduser. In sample file following code is available :

<softinstall xmlns="http://www.softaculous.com"> 
<settings>
<group>
<heading>{{select_plugins}}</heading>
<input type="checkbox" name="smart-maintenance-mode" value="off">
<head>Smart Maintenance Mode</head>
<exp>If selected Smart Maintenance Mode plugin will be
installed and activated with your installation.<br /> Click
<a href="http://wordpress.org/plugins/smart-maintenance-mode/" target="_blank">here</a>
to visit plugin site.
</exp>
</input>
</group>
</settings>
</softinstall>

While making plugins the following three lines will be same for all the plugin that you are going to make and same for the closing tags of the following tag.

<softinstall xmlns="http://www.softaculous.com">
	<settings>
		<group>
                       <heading>{{select_plugins}}</heading>
                       YOUR_PLUGIN_RELATED_CODE
                </group>
	</settings>
</softinstall>

Only the following part will change according to your plugin information :

<input type="checkbox" name="smart-maintenance-mode" value="off">
<head>Smart Maintenance Mode</head>
<exp>If selected Smart Maintenance Mode plugin will be installed and activated with your installation.<br/>
Click <a href="http://wordpress.org/plugins/smart-maintenance mode/"target="_blank">here</a> to visit plugin site.
</exp>
</input>

In <input> tag please specify the name of your plugin and the zip name should be the same.
<head> tag is responsible for displaying the name of the plugin on installation wizard page of the script.
<exp> tag is responsible for displaying the small description/explanation of the plugin.

If you want to add more than one plugin you can add it as following code :

<softinstall xmlns="http://www.softaculous.com">
	<settings>
		<group>
			<heading>{{select_plugins}}</heading>
			<input type="checkbox" name="name_of_plgin1" value="off">
				<head>heading_of_plgin1</head>
				<exp>explanation_of_plugin1</exp>
			</input>
			<input type="checkbox" name="name_of_plgin2" value="off">
				<head>heading_of_plgin2</head>
				<exp>explanation_of_plugin1</exp>
			</input>
			<input type="checkbox" name="name_of_plgin3" value="off">
				<head>heading_of_plgin3</head>
				<exp>explanation_of_plugin1</exp>
			</input>
		</group>
	</settings>
</softinstall>

Following is the screenshot of the sample plugin : 

mods.php

This is the main file which is responsible for parsing the mod_install.xml and installing plugin.

All the function have the prefix as __SCRIPT_SOFTNAME. In this example __wp is for integrating WordPress plugin. It will change according to your requirements.

Following function are responsible for parsing the mod_install.xml and installing plugins.

__wp_mod_settings()

This function is responsible for parsing the mod_install.xml file and displaying an option to choose plugins to users on installation wizard.

In this function you dont have to change anything as all is dependent on mod_install.xml

__pre_mod_install()

If there are some requirement settings or per-requisite for your plugin, than it should be checked/processes in this function. This function will be called before the installation of the scripts is started.

__post_mod_install()

This function is responsible for installation process of your plugin after the installation of the script.

In above both function __pre_mod_install() and __post_mod_install() you can use the following functions to fulfill your requirements : 
sunzip(sourcedestination) – It will unzip the source.zip at the destination.
smkdir(target_dir, permission) – It will make the target directory and give the permission accordingly.
schmod(target_dir, permission) – It will change the target directory permission.
sdb_query(querydbhostdbuserdbpassdatabase) – It will execute the query.

Was this helpful to you?