{"id":2023,"date":"2019-01-01T11:11:00","date_gmt":"2019-01-01T11:11:00","guid":{"rendered":"http:\/\/www.softaculous.com\/blog\/?post_type=docs&#038;p=2023"},"modified":"2023-09-08T11:40:31","modified_gmt":"2023-09-08T11:40:31","slug":"adding-plugins","status":"publish","type":"docs","link":"https:\/\/www.softaculous.com\/blog\/docs\/developers\/extending-softaculous\/adding-plugins\/","title":{"rendered":"Adding Plugins"},"content":{"rendered":"\n<p class=\"alert alert-info\"><strong>Note:&nbsp;<\/strong>This feature is available since Softaculous 4.5.0<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Overview<\/h3>\n\n\n\n<p>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)<\/p>\n\n\n\n<p>A sample plugin example is available here\u00a0:\u00a0<a href=\"https:\/\/www.softaculous.com\/blog\/wp-content\/uploads\/2023\/09\/plugins.zip\">File:Plugins.zip<\/a><\/p>\n\n\n\n<p>Download the above file and unzip it at the following path.<\/p>\n\n\n\n<p class=\"bash hljs\">\/PATH\/TO\/softaculous\/conf\/mods\/SCRIPT_SOFTNAME\/<\/p>\n\n\n\n<p>You can find the SCRIPT_SOFTNAME from iscripts.php located at <\/p>\n\n\n\n<p class=\"bash hljs\">\/PATH\/TO\/softaculous\/enduser\/iscripts.php<\/p>\n\n\n\n<p>For e.g. in the above zip file we have explained the plugin integration for WordPress and its softname is &#8216;wp&#8217; so the path where you have to unzip the above file would be&nbsp;:<\/p>\n\n\n\n<p class=\"bash hljs\"><strong>\/PATH\/TO\/softaculous\/conf\/mods\/wp\/<\/strong><\/p>\n\n\n\n<p>Note: If the above folder does not exist you will need to create the same.<\/p>\n\n\n\n<p>In the above zip file there are three files available.<br>1. mods.php<br>2. mod_install.xml<br>3. sample_plugin.zip (in this example&nbsp;: smart-maintenance-mode.zip)<br><\/p>\n\n\n\n<p>To add the plugins in Softaculous without making custom package please follow the below steps&nbsp;:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">mod_install.xml<\/h3>\n\n\n\n<p>This file is responsible for displaying plugin(s) option for installing to enduser. In sample file following code is available&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">&lt;softinstall xmlns=\"http:\/\/www.softaculous.com\"&gt; <br>   &lt;settings&gt; <br>      &lt;group&gt; <br>        &lt;heading&gt;{{select_plugins}}&lt;\/heading&gt; <br>        &lt;input type=\"checkbox\" name=\"smart-maintenance-mode\" value=\"off\"&gt;<br>        &lt;head&gt;Smart Maintenance Mode&lt;\/head&gt; <br>        &lt;exp&gt;If selected Smart Maintenance Mode plugin will be <br>        installed and activated with your installation.&lt;br \/&gt; Click <br>        &lt;a  href=\"http:\/\/wordpress.org\/plugins\/smart-maintenance-mode\/\" target=\"_blank\"&gt;here&lt;\/a&gt; <br>        to visit plugin site.<br>        &lt;\/exp&gt; <br>        &lt;\/input&gt; <br>      &lt;\/group&gt; <br>   &lt;\/settings&gt; <br>&lt;\/softinstall&gt;<\/pre>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">&lt;softinstall xmlns=\"http:\/\/www.softaculous.com\"&gt;\n\t&lt;settings&gt;\n\t\t&lt;group&gt;\n                       &lt;heading&gt;{{select_plugins}}&lt;\/heading&gt;\n                       YOUR_PLUGIN_RELATED_CODE\n                &lt;\/group&gt;\n\t&lt;\/settings&gt;\n&lt;\/softinstall&gt;<\/pre>\n\n\n\n<p>Only the following part will change according to your plugin information&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">&lt;input type=\"checkbox\" name=\"smart-maintenance-mode\" value=\"off\"&gt;<br>   &lt;head&gt;Smart Maintenance Mode&lt;\/head&gt;   <br>   &lt;exp&gt;If selected Smart Maintenance Mode plugin will be installed and activated with your installation.&lt;br\/&gt; <br>   Click &lt;a href=\"http:\/\/wordpress.org\/plugins\/smart-maintenance mode\/\"target=\"_blank\"&gt;here&lt;\/a&gt; to visit plugin site. <br>   &lt;\/exp&gt; <br>&lt;\/input&gt;<\/pre>\n\n\n\n<p>In&nbsp;<strong>&lt;input&gt;<\/strong>&nbsp;tag please specify the&nbsp;<strong>name<\/strong>&nbsp;of your plugin and the zip name should be the same.<br><strong>&lt;head&gt;<\/strong>&nbsp;tag is responsible for displaying the name of the plugin on installation wizard page of the script.<br><strong>&lt;exp&gt;<\/strong>&nbsp;tag is responsible for displaying the small description\/explanation of the plugin.<br><\/p>\n\n\n\n<p>If you want to add more than one plugin you can add it as following code&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">&lt;softinstall xmlns=\"http:\/\/www.softaculous.com\"&gt;\n\t&lt;settings&gt;\n\t\t&lt;group&gt;\n\t\t\t&lt;heading&gt;{{select_plugins}}&lt;\/heading&gt;\n\t\t\t&lt;input type=\"checkbox\" name=\"name_of_plgin1\" value=\"off\"&gt;\n\t\t\t\t&lt;head&gt;heading_of_plgin1&lt;\/head&gt;\n\t\t\t\t&lt;exp&gt;explanation_of_plugin1&lt;\/exp&gt;\n\t\t\t&lt;\/input&gt;\n\t\t\t&lt;input type=\"checkbox\" name=\"name_of_plgin2\" value=\"off\"&gt;\n\t\t\t\t&lt;head&gt;heading_of_plgin2&lt;\/head&gt;\n\t\t\t\t&lt;exp&gt;explanation_of_plugin1&lt;\/exp&gt;\n\t\t\t&lt;\/input&gt;\n\t\t\t&lt;input type=\"checkbox\" name=\"name_of_plgin3\" value=\"off\"&gt;\n\t\t\t\t&lt;head&gt;heading_of_plgin3&lt;\/head&gt;\n\t\t\t\t&lt;exp&gt;explanation_of_plugin1&lt;\/exp&gt;\n\t\t\t&lt;\/input&gt;\n\t\t&lt;\/group&gt;\n\t&lt;\/settings&gt;\n&lt;\/softinstall&gt;<\/pre>\n\n\n\n<p>Following is the screenshot of the sample plugin&nbsp;:&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1094\" height=\"122\" src=\"http:\/\/www.softaculous.com\/blog\/wp-content\/uploads\/2019\/01\/Sample_plugin-1.png\" alt=\"\" class=\"wp-image-2032\" srcset=\"https:\/\/www.softaculous.com\/blog\/wp-content\/uploads\/2019\/01\/Sample_plugin-1.png 1094w, https:\/\/www.softaculous.com\/blog\/wp-content\/uploads\/2019\/01\/Sample_plugin-1-300x33.png 300w, https:\/\/www.softaculous.com\/blog\/wp-content\/uploads\/2019\/01\/Sample_plugin-1-768x86.png 768w, https:\/\/www.softaculous.com\/blog\/wp-content\/uploads\/2019\/01\/Sample_plugin-1-1024x114.png 1024w\" sizes=\"auto, (max-width: 1094px) 100vw, 1094px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">mods.php<\/h3>\n\n\n\n<p>This is the main file which is responsible for parsing the mod_install.xml and installing plugin.<\/p>\n\n\n\n<p>All the function have the prefix as __SCRIPT_SOFTNAME. In this example&nbsp;<em>__wp<\/em>&nbsp;is for integrating WordPress plugin. It will change according to your requirements.<\/p>\n\n\n\n<p>Following function are responsible for parsing the mod_install.xml and installing plugins.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">__wp_mod_settings()<\/h4>\n\n\n\n<p>This function is responsible for parsing the mod_install.xml file and displaying an option to choose plugins to users on installation wizard.<\/p>\n\n\n\n<p>In this function you dont have to change anything as all is dependent on mod_install.xml<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">__pre_mod_install()<\/h4>\n\n\n\n<p>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.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">__post_mod_install()<\/h4>\n\n\n\n<p>This function is responsible for installation process of your plugin after the installation of the script.<\/p>\n\n\n\n<p>In above both function __pre_mod_install() and __post_mod_install() you can use the following functions to fulfill your requirements&nbsp;:&nbsp;<br><strong>sunzip(<em>source<\/em>,&nbsp;<em>destination<\/em>)<\/strong>&nbsp;&#8211; It will unzip the source.zip at the destination.<br><strong>smkdir(<em>target_dir<\/em>, permission)<\/strong>&nbsp;&#8211; It will make the target directory and give the permission accordingly.<br><strong>schmod(<em>target_dir<\/em>, permission)<\/strong>&nbsp;&#8211; It will change the target directory permission.<br><strong>sdb_query(<em>query<\/em>,&nbsp;<em>dbhost<\/em>,&nbsp;<em>dbuser<\/em>,&nbsp;<em>dbpass<\/em>,&nbsp;<em>database<\/em>)<\/strong>&nbsp;&#8211; It will execute the query.<\/p>\n","protected":false},"featured_media":0,"parent":1691,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","docs_category":[],"class_list":["post-2023","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/2023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/comments?post=2023"}],"version-history":[{"count":22,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/2023\/revisions"}],"predecessor-version":[{"id":5448,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/2023\/revisions\/5448"}],"up":[{"embeddable":true,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/1691"}],"wp:attachment":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/media?parent=2023"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs_category?post=2023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}