buy
Filters

Overview

Filters enable the admin to modify/hook into certain aspects of the task being done. There are several Filters in Webuzo that you can take advantage of.

The following guide will show you how the Server Admin can configure Filter Functions to customize the installation, upgrade, email and several other events.

  • SSH to your server and go to the following path:
/path/to/webuzo/enduser/hooks/
  • You can see the file filter.txt.
  • Rename the file to make it a PHP file as filter.php.
  • Uncomment the function that matches your requirement, add the code inside the function as per your requirements, and save the file.
  • That’s it you have configured your filter.

insert_filter

  • We make use of insert_filter function to trigger a specific filter.

insert_filter(string $tag, string $function_to_add, int $priority, int $accepted_args);

Parameters

ParamTypeDescription
$tagstring/RequiredAction name that triggers the specific function.
$function_to_addstring/RequiredName of the function to be triggered.
$priorityint/optionalPriority in which you want the filter to be triggered. (Default is 10)
$accepted_argsint/optionalNumber of arguments accepted by the filter function. (Default is 1)

Example 
Following is the example describing how a filter is triggered by an action:

If you would like to make some changes whenever an error is triggered in Webuzo, you will have to rename the file filter.txt to filter.php and uncomment the following part and add the code in my_error_handle() function.

insert_filter('error_handle', 'my_error_handle', 1, 1);

function my_error_handle($error){
     // Add your custom code here
}

insert_filter adds the data added by you to Webuzo and when the appropriate event is triggered your respective function is called. For eg., in the above example, whenever the event error_handle occurs, function my_error_handle is called and the code inside the same is executed. 

pre_install

Description 
The pre_install filter will trigger your function before the installation process for any script is started.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_install:

insert_filter('pre_install', 'my_pre_install', 1); 
function my_pre_install(){ 
global $soft, $software, $globals; 
// Do stuff here e.g. is as follows
if($soft == 26){  
//Do things only if its WordPress
 }
} 

post_install

Description 
The post_install filter will trigger your function after a script is installed.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the installation.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation
[dbprefix] => table prefix of installation
)

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_install:

insert_filter('post_install', 'my_post_install', 1, 1); 
// @param   array $installation Details of the new installation 
function my_post_install($installation){ 
global $soft, $software, $globals; 
// Do stuff here e.g. is as follows   
if($soft == 26){  
//Do things only if its WordPress 
 } 
} 

pre_mail

Description 

  • The pre_mail filter will trigger your function whenever any mail is sent via Webuzo (e.g installing scripts, removing installation, etc).
  • The main usage of this filter is if you want to send out a CUSTOM Email or want to perform any action before an email is sent. e.g. if an Admin does not want to send an EMAIL of the installation of a script or any other process, then the Admin can Disable Email forcefully using this filter.

Parameters

KeyValueDescription
$arrayarray/RequiredContains details of an Email which is being sent.
Array (
[0] => Array
(
[to] => Email of USER
[subject] => Email SUBJECT
[message] => Email BODY
)
)

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_mail:

insert_filter('pre_mail', 'my_pre_mail', 1, 1);
 // @param array $array Details of the email to be sent. 
function my_pre_mail($array){ 
global $globals; ////////////////////////////////////////////////////////////////////////////////// 
// $array  - Will contain the Email Content which is being sent // //////////////////////////////////////////////////////////////////////////////////
 global $globals; 
foreach($array as $k => $v){                             
 if($v['to'] == USER_EMAIL){       
               // Do the STUFF                
 }                
 // Update the Email subject          
       $array[$k]['subject'] = 'My Custom Subject';        
 }        
 return $array; 
} 

pre_import

Description 
The pre_import filter will trigger your function right before an installation is being imported.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_import:

insert_filter('pre_import', 'my_pre_import', 1); 
function my_pre_import(){
 global $soft, $software, $globals; 
// Do stuff here e.g. is as follows 
if($soft == 26){  
//Do things only if its WordPress  
} 
} 

post_import

Description 
The post_import filter will trigger your function after an installation is imported.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the installation.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation
)

Usage 
Uncomment the following part and add your code inside the function my_post_import:

insert_filter('post_import', 'my_post_import', 1, 1); 
// @param array   $installation Details of the installation imported function my_post_import($installation){ 
global $soft, $software, $globals; 
// Do stuff here e.g. is as follows
 if($soft == 26){  
//Do things only if its WordPress  
}
 } 

pre_upgrade

Description 
The pre_upgrade filter will trigger your function right before an installation is upgraded.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the installation.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation
)

Usage 
Uncomment the following part and add your code inside the function my_pre_upgrade:

insert_filter('pre_upgrade', 'my_pre_upgrade', 1, 1); 
// @param    array $installation Details of the installation being upgraded 
function my_pre_upgrade($installation){ 
global $soft, $software, $globals; 
// Do stuff here e.g. is as follows 
if($soft == 26){
  //Do things only if its WordPress 
 }
 } 

post_upgrade

Description 
The post_upgrade filter will trigger your function after an installation is upgraded.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the installation.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation )

Usage 
Uncomment the following part and add your code inside the function my_post_upgrade:

insert_filter('post_upgrade', 'my_post_upgrade', 1, 1); 
// @param    array $installation Details of the installation upgraded function my_post_upgrade($installation){ 
global $soft, $software, $globals; 
// Do stuff here e.g. is as follows 
if($soft == 26){
 //Do things only if its WordPress
 }
 } 

pre_remove

Description 
The pre_remove filter will trigger your function right before an installation is removed.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the installation.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation )

Usage 
Uncomment the following part and add your code inside the function my_pre_remove:

insert_filter('pre_remove', 'my_pre_remove', 1, 1); 
// @param  array $installation Details of the installation being removed function my_pre_remove($installation){ 
global $soft, $software, $globals;
// Do stuff here e.g. is as follows 
if($soft == 26){  
//Do things only if its WordPress
 }
 }

post_remove

Description 
The post_remove filter will trigger your function after an installation is removed.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the installation.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation )

Usage 
Uncomment the following part and add your code inside the function my_post_remove:

insert_filter('post_remove', 'my_post_remove', 1, 1); 
// @param  array $installation Details of the installation removed
function my_post_remove($installation){
 global $soft, $software, $globals;
 // Do stuff here e.g. is as follows 
if($soft == 26){ 
//Do things only if its WordPress
}
 } 

pre_clone

Description 
The pre_clone filter will trigger your function before the clone process is started.

Usage 
Uncomment the following part and add your code inside the function my_pre_clone:

insert_filter('pre_clone', 'my_pre_clone', 1); 
function my_pre_clone(){ 
global $soft, $software, $globals; 
// Do stuff here e.g. is as follows 
if($soft == 26){ 
//Do things only if its WordPress 
} 
} 

post_clone

Description 
The post_clone filter will trigger your function after an installation is cloned.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the installation.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation )

Usage 
Uncomment the following part and add your code inside the function my_post_clone:

insert_filter('post_clone', 'my_post_clone', 1, 1);
// @param   array $installation Details of the installation cloned
function my_post_clone($installation){
 global $soft, $software, $globals;
 // Do stuff here e.g. is as follows 
if($soft == 26){ 
//Do things only if its WordPress
 }
 } 

error_handle

Description 
The error_handle filter will trigger your function when an error is triggered in Webuzo and return the custom errors defined within.

Parameters

KeyValueDescription
$errorarray/RequiredContains the list of Webuzo error(s) occurred.
Array (
[ERROR_NAME] => ERROR_DESC )

Usage 
Uncomment the following part and add your code inside the function my_error_handle:

insert_filter('error_handle', 'my_error_handle', 1, 1); 
function my_error_handle($error){   
// Add your custom code here      
$error['my_cust_err'] = 'My Custom Error';     
return $error; 
} 

post_load_settings

Description 
The post_load_settings filter will trigger your function after Install Form Settings are loaded and before the form is displayed in Webuzo.

Usage 
Uncomment the following part and add your code inside the function my_post_load_settings:

insert_filter('post_load_settings', 'my_post_load_settings', 1, 1); 
// @param   array $settings Contains Install Form Fields 
function my_post_load_settings($settings){ 
 // Add your custom code here
} 

pre_webuzo_upgrade

Description 
The pre_webuzo_upgrade filter will trigger your function before Webuzo Core Upgrade function is called.

Usage 
Uncomment the following part and add your code inside the function my_pre_webuzo_upgrade:

insert_filter('pre_webuzo_upgrade', 'my_pre_webuzo_upgrade', 1);
function my_pre_webuzo_upgrade(){ 
// Add your custom code here 
} 

post_webuzo_upgrade

Description 
The post_webuzo_upgrade filter will trigger your function after Webuzo Core Upgrade function is called.

Usage 
Uncomment the following part and add your code inside the function my_post_webuzo_upgrade:

insert_filter('post_webuzo_upgrade', 'my_post_webuzo_upgrade', 1); 
function my_post_webuzo_upgrade(){ 
// Add your custom code here 
} 

post_unzip

Description 
The post_unzip filter will trigger your function after the script package is unzipped when installing the script or upgrading, cloning, etc.

Usage 
Uncomment the following part and add your code inside the function my_post_unzip:

insert_filter('post_unzip', 'my_post_unzip', 1); 
function my_post_unzip(){ 
// Add your custom code here 
} 

post_top_scripts_interface

Description 
This filter allows you to add custom content after Top Scripts is rendered in Enduser Panel.

insert_filter('post_top_scripts_interface', 'my_post_top_scripts_interface', 1);
function my_post_top_scripts_interface(){ 
// Add your custom code here 
} 

Description 
The navbar_links filter will trigger your function before displaying the links in Navbar in Webuzo Enduser Panel (top right hand corner). Use this filter to Add/Remove the navbar links.

Parameters

KeyValueDescription
$navbararray/RequiredContains details of the installation.
Array (
[‘goto_control_panel’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘add_domain’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_demo’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_rating’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_installations’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_tasklist’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_settings’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_backups’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_email_settings’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_premium_themes’] => Array(
[‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_sync’] => Array( [‘fullscreen’] => HTML content for the link
[‘responsive’] => HTML content for the link )
[‘goto_help’] => Array( [‘fullscreen’] => HTML content for the link [‘responsive’] => HTML content for the link )
[‘goto_logout’] => Array(
[‘fullscreen’] => HTML content for the link [‘responsive’] => HTML content for the link )
)

Usage 
Uncomment the following part and add your code inside the function my_navbar_links:

insert_filter('navbar_links', 'my_navbar_links', 1, 1); 
// @param   array $navbar contains the navbar links 
function my_navbar_links($navbar){ 
// Add your custom code here 

unset($navbar['goto_email_settings']); // Example to disable email settings link 
unset($navbar['goto_backups']); // Example to disable backups link 
return $navbar; 
} 

eu_php_bin

Description 
The eu_php_bin filter is used to define a php binary path if you are using custom PHP binary and want to define the same in Webuzo.

Parameters

KeyValueDescription
$php_binstring/RequiredContains path of the php binary.

Usage 
Uncomment the following part and add your code inside the function my_eu_php_bin:

insert_filter('eu_php_bin', 'my_eu_php_bin', 1, 1); 
// @param string $php_bin Path of php binary 
function my_eu_php_bin($php_bin){ 
// Add your custom code here 
$php_bin = '/PATH/TO/PHPBIN'; 
return $php_bin; 
} 

post_load_dbdetails

Description 
The post_load_dbdetails filter is used to set database details to be pre-filled on install form.

Parameters

KeyValueDescription
$dbdetailsarray/RequiredContains prefilled DB details for the installation.
Array (
[‘dbname’] => db_name,
[‘dbusername’] => db_username,
[‘dbuserpass’] => db_userpass,
[‘dbhost’] => db_host )

Usage 
Uncomment the following part and add your code inside the function my_post_load_dbdetails:

insert_filter('post_load_dbdetails', 'my_post_load_dbdetails', 1, 1); 
// @param  array $dbdetails Prefilled DB details for the installation function my_post_load_dbdetails($dbdetails){
// Add your custom code here 
$dbdetails['dbname'] = '';
$dbdetails['dbusername'] = ''; // This can be used only in Webuzo Remote 
$dbdetails['dbuserpass'] = ''; // This can be used only in Webuzo Remote 
$dbdetails['dbhost'] = ''; // This can be used only in Webuzo Remote 
return $dbdetails; 
} 

pre_update_email

Description 

  • The pre_update_email filter will trigger your function whenever an UPDATE becomes available for an installation AND before an email is sent to the user informing him about the update.
  • The main usage of this filter is if you want to send out a CUSTOM Email when a script update is available. e.g. if a new version of WordPress is available, Webuzo will load all the list of users who have WordPress installations and will email them of the same. But if you want to send them an email yourself, you can use this filter.

Usage 
Uncomment the following part and add your code inside the function my_pre_update_email:

insert_filter('pre_update_email', 'my_pre_update_email', 1); 
function my_pre_update_email(){ 
global $globals, $ins_list, $updated_scripts, $scripts; 
// $ins_list    - Will contain the details of the OUTDATED installations of all users immediately when an update becomes available 
// $updated_scripts  - The scripts which just got updated 
// $scripts  - Detailed information about all the scripts. foreach($ins_list as $username => $scriptwise){ 
// Do what needs to be done ! 
// $scriptwise will now contain the list of installations in the format of array(SCRIPTID => array()); 
foreach($scriptwise as $_sid => $_ins){ 
// Loop through the installations 
foreach($_ins as $kk => $vv){ 
    } 
   } 
 } 
} 

post_adddomain

Description 
The post_adddomain filter will trigger your function after a Domain is added.

Note : This filter is only available in Webuzo Remote.

Parameters

KeyValueDescription
$didstring/RequiredDomain ID of the domain added.

Usage 
Uncomment the following part and add your code inside the function my_post_adddomain:

insert_filter('post_adddomain', 'my_post_adddomain', 1, 1); 
// @param   string $did Domain ID of the domain added 
function my_post_adddomain($did){ 
global $softpanel, $globals; 
// Do stuff here 
// e.g. is for if you want to perform action only for apache 
} 

post_editdomain

Description 
This filter will trigger your function after a Domain is edited.

Note : This filter is only available in Webuzo Remote.

Parameters

KeyValueDescription
$didstring/RequiredDomain ID of the domain added.

Usage 
Uncomment the following part and add your code inside the function my_post_editdomain:

insert_filter('post_editdomain', 'my_post_editdomain', 1, 1); 
// @param   string $did Domain ID of the domain edited 
function my_post_editdomain($did){ 
global $softpanel, $globals; 
// Do stuff here 
// e.g. is for if you want to perform action only for apache 
} 

remote_exec_url

Description 
This filter can be used if you want to use custom URLs for Webuzo Remote calls to perform tasks such as install, etc.

Note : This filter is available only available on Webuzo Remote.

Parameters

KeyValueDescription
$softint/RequiredScript ID to be installed.

Usage 
Uncomment the following part and add your code inside the function my_post_load_soft:

insert_filter('post_load_soft', 'my_post_load_soft', 1, 1); 
// @param  array $soft Contains softid 
function my_post_load_soft($soft){
 // Add your custom code here 
return $soft; 
} 

post_load_soft

Description 
This filter can be used to modify the id of the script to be installed.

Parameters

KeyValueDescription
$softint/RequiredScript ID to be installed.

Usage 
Uncomment the following part and add your code inside the function my_post_load_soft:

insert_filter('post_load_soft', 'my_post_load_soft', 1, 1); 
// @param  array $soft Contains softid 
function my_post_load_soft($soft){
 // Add your custom code here 
return $soft; 
} 

pre_addcron

Description 
The pre_addcron filter will trigger your function right before the cron job is added for an installation while installing the script. You can make changes to the cron execution time as well as the cron command.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_addcron:

insert_filter('pre_addcron', 'my_pre_addcron', 1, 1); 
function my_pre_addcron($cron){
 global $soft, $software, $globals; 
//Add your custom cron command in $cron array. 
$cron['cron_min'] = ''; 
$cron['cron_hour'] = '';  
$cron['cron_day'] = ''; 
$cron['cron_month'] = ''; 
$cron['cron_weekday'] = ''; 
$cron['cron_command'] = ''; 
return $cron; 
} 

post_addcron

Description 
The post_addcron filter will trigger your function right after the cron job is added during an installation.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_addcron:

insert_filter('post_addcron', 'my_post_addcron', 1, 1); 
function my_post_addcron($cron){ 
global $soft, $software, $globals; 
//Add your custom code here. 
} 

pre_backup

Description 
The pre_backup filter will trigger your function right before the backup started.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_backup:

insert_filter('pre_backup', 'my_pre_backup', 1, 1); 
function my_pre_backup($data){ 
//Add your custom code here. 
} 

post_backup

Description 
The post_backup filter will trigger your function right after the backup finished.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_backup:

insert_filter('post_backup', 'my_post_backup', 1, 1);
function my_post_backup($data){
 //Add your custom code here. 
} 

soft_php_bin

Description 
Use this filter to pass the path to PHP binary which should be used to perform operations like Clone, Remote Import, etc.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_soft_php_bin:

insert_filter('soft_php_bin', 'my_soft_php_bin', 1, 1); 
function my_soft_php_bin($phpbin){ 
// Note : The PHP binary should be a CLI PHP binary 
$phpbin = '/PATH/TO/PHPBIN'; //Define your php binary here 
return $phpbin; 
} 

pre_webuzo_upgrade_check

Description 
The pre_webuzo_upgrade_check filter will trigger your function before the Webuzo Core Upgrade check is performed.

Note : This filter is for Webuzo core upgrade and not script updates.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_webuzo_upgrade_check:

insert_filter('pre_webuzo_upgrade_check',  'my_pre_webuzo_upgrade_check', 1); 
function my_pre_webuzo_upgrade_check(){ 
// Add your custom code here 
} 

upgrade_webuzo_to_version

Description 
The upgrade_webuzo_to_version filter will trigger your function and define the version of Webuzo you want to upgrade to. Make sure you pass correct version of Webuzo you want to upgrade to, otherwise you will be upgraded to the latest version.

  • If you enter the version as less than the Webuzo version you are currently at, Webuzo will be upgraded to the latest version.
  • If you pass the version greater than or equal to the Webuzo version you are currently at but less than or equal to the latest Webuzo version, Webuzo will be upgraded to that particular version. But if the passed version is greater than the latest Webuzo version, your Webuzo will be upgraded to the latest version only.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_upgrade_webuzo_to_version:

insert_filter('upgrade_webuzo_to_version', 'my_upgrade_webuzo_to_version', 1); 
function my_upgrade_webuzo_to_version(){ 
return '2.8.5'; // this example will upgrade Webuzo to 2.8.5 
} 

check_files_exist

Description 
The check_files_exist filter will trigger your function when Webuzo checks for files already exists while installing a script, use this filter to add or remove the list of files existing in the path where you are installing a script. The list returned after applying this filter is the list for which the user will be reported of files already exists (with an option to overwrite the files).

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_check_files_exist:

insert_filter('check_files_exist', 'my_check_files_exist', 1, 1); 
function my_check_files_exist($exists){ 
//e.g if you want to unset .htaccess  
if(in_array('.htaccess', $exists)){ 
  $htaccess_key = array_search('.htaccess', $exists);
  unset($exists[$htaccess_key]); 
} 
return $exists; 
} 

post_loadinstallations

Description 
The post_loadinstallations filter will trigger your function before loading installations of a user in Webuzo. You will get a list of all your installations here so that you can modify the details as per your requirement and return the list back.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_loadinstallations:

insert_filter('post_loadinstallations', 'my_post_loadinstallations', 1, 1); 
// @param   array $data List of installations 
function my_post_loadinstallations($data){ 
r_print($data);         
//Write your code here         
//Use this if you want to save the changes you made to the installation details 
saveinstallations($data); 
return $data; 
} 

post_listinstallations

Description 
The post_listinstallations filter will trigger your function before listing installations of all the users in Webuzo Admin. You will get a list of all your installations of all the users here so that you can modify the details as per your requirement and return the list back.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_listinstallations:

insert_filter('post_listinstallations', 'my_post_listinstallations', 1, 1); 
// @param  array $data List of installations 
function my_post_listinstallations($data){ 
r_print($data);
//Write your code here
//Use this if you want to save the changes you made to the installation details
saveinstallations($data); 
return $data;
} 

pre_upgrade_outdated_plugins

Description 
The pre_upgrade_outdated_plugins filter will trigger your function before upgrading the outdated plugins. You will get a list of all the outdated plugins so that you can make the changes to the list as per your need and return the list back.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_upgrade_outdated_plugins:

insert_filter('pre_upgrade_outdated_plugins', 'my_pre_upgrade_outdated_plugins', 1, 1); 
// @param   array $plugins List of outdated plugins 
function my_pre_upgrade_outdated_plugins($plugins){ 
//Filter the list as per your need 
//Example of the plugins list you will get here
r_print($plugins); // This will print the list of outdated plugins
return $plugins; 
} 

pre_upgrade_outdated_theme

Description 
The pre_upgrade_outdated_theme filter will trigger your function before upgrading the active outdated theme. You will get the data of your active outdated theme so that you can make the changes to the data as per your need and return it back.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_upgrade_outdated_theme:

insert_filter('pre_upgrade_outdated_theme','my_pre_upgrade_outdated_theme', 1, 1); 
// @param  object $theme_data Theme's data 
function my_pre_upgrade_outdated_theme($theme_data){ 
//Make changes as per your need 
//Example of the theme's api data you will get here
r_print($theme_data); // This will print the list of outdated themes
return $theme_data; 
} 

dns_server_ip

Description 
The dns_server_ip filter will trigger your function and will make the domain point to the IP defined in the filter in case the DNS has not propogated yet and the domain is still pointing the old server.

Usage 
Uncomment the following part inside filter.php and define the IP where you want your domain to point to in the code inside the function my_dns_server_ip:

insert_filter('dns_server_ip', 'my_dns_server_ip', 1, 1); 
// @param  string $domain The Domain to which the call will be made
function my_dns_server_ip($domain){
 $ip = '1.2.3.4'; //Define the IP where your domain should point 
return $ip; 
} 

pre_createdb

Description  The pre_createdb filter will trigger your function before the database is created by Webuzo during script install.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_createdb:

insert_filter('pre_createdb', 'my_pre_createdb', 1);  
function my_pre_createdb(){  
global $__settings;  
// Execute your code here  
echo  $__settings['softdb']; // This will echo the  Database Name
echo  $__settings['softdbhost']; // This will echo the  Database  Host  
echo  $__settings['softdbuser']; // This will echo the  Database  User  
echo  $__settings['softdbpass']; // This will echo the  Database  Pass  
echo  $__settings['dbprefix']; // This will echo the  Table Prefix
}  

post_createdb

Description 
The post_createdb filter will trigger your function after the database is created by Webuzo during script install.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_createdb:

insert_filter('post_createdb', 'my_post_createdb', 1); 
function my_post_createdb(){ 
global $__settings; 
// Execute your code here 
echo  $__settings['softdb']; // This will echo the  Database Name
echo  $__settings['softdbhost']; // This will echo the  Database  Host  
echo  $__settings['softdbuser']; // This will echo the  Database  User  
echo  $__settings['softdbpass']; // This will echo the  Database  Pass  
echo  $__settings['dbprefix']; // This will echo the  Table Prefix 
} 

domains_list

Description 
The domains_list filter will trigger your function after the domains list is propagated by Webuzo. This filter allows you to add/remove domains from the domains list generated by Webuzo. 

Usage 
Uncomment the following part inside filter.php and define the IP where you want your domain to point to in the code inside the function my_domains_list:

insert_filter('domains_list', 'my_domains_list', 1, 1); 
// @param   string $domains Domains list with domain name in the key and path to the domain in value 
function my_domains_list($domains){ 
// example to remove a domain name from the domains list 
unset($domains['example.com']); 

// example to add a domain name 
// Note : In case of Webuzo Remote and Enterprise, the domain you are adding here should be added in the panel 
$domains['example.com'] = '/home/example/public_html'; 

// Return the list of domains 
return $domains; 
} 

pre_staging

Description 
The pre_staging filter will trigger your function before the Staging process is started. 

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_staging:

insert_filter('pre_staging', 'my_pre_staging', 1, 1); 
function my_pre_staging(){ 
global $soft, $software, $globals;
 // Do stuff here e.g. is as follows 
if($soft == 26){
 //Do things only if its WordPress 
} 
} 

post_staging

Description 
The post_staging filter will trigger your function after the staging copy of an installation is created.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the staging installation created.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation )

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_staging:

insert_filter('post_staging', 'my_post_staging', 1, 1); 
// @param  array $installation Details of the staging installation created 
function my_post_staging($installation){
 global $soft, $software, $globals;
 // Do stuff here e.g. is as follows 
if($soft == 26){  
//Do things only if its WordPress 
 } 
} 

pre_pushtolive

Description 
The pre_pushtolive filter will trigger your function before a staging installation is pushed to live. 

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_pushtolive:

insert_filter('pre_pushtolive', 'my_pre_pushtolive', 1, 1);
 function my_pre_pushtolive(){
 global $soft, $software, $globals;
 // Do stuff here e.g. is as follows 
if($soft == 26){
 //Do things only if its WordPress
 }
 } 

post_pushtolive

Description 
The post_pushtolive filter will trigger your function after a staging installation is pushed to live.

Parameters

KeyValueDescription
$installationarray/RequiredContains details of the live installation into which the staging environment is pushed.
Array (
[insid] => installation id
[sid] => script id
[ver] => installed version of script
[itime] => installation time
[softpath] => path to installation
[softurl] => installation URL
[softdb] => database name of installation
[softdbuser] => database user of installation
[softdbhost] => database host of installation
[softdbpass] => database password of installation )

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_pushtolive:

insert_filter('post_pushtolive', 'my_post_pushtolive', 1, 1); 
// @param   array $installation Details of the live installation into which the staging environment is pushed 
function my_post_pushtolive($installation){
global $soft, $software, $globals; 
// Do stuff here e.g. is as follows 
if($soft == 26){
 //Do things only if its WordPress  
}
} 

pre_addcron_auto_backup

Description 
The pre_addcron_auto_backup filter will trigger your function right before the cron job for auto backup is added for an installation while installing/editing the script. You can make changes to the cron execution time as well as the cron command.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_addcron_auto_backup:

insert_filter('pre_addcron_auto_backup', 'my_pre_addcron_auto_backup', 1, 1); 
function my_pre_addcron_auto_backup($cron){ 
global $soft, $software, $globals; 
//Add your custom cron command in $cron array. 
$cron['cron_min'] = ''; 
$cron['cron_hour'] = '';  
$cron['cron_day'] = '';
$cron['cron_month'] = ''; 
$cron['cron_weekday'] = '';
$cron['cron_command'] = ''; 
return $cron;
} 

post_addcron_auto_backup

Description 
The post_addcron_auto_backup filter will trigger your function right after the cron job for auto backup is added for an installation while installing/editing the script.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_addcron_auto_backup:

insert_filter('post_addcron_auto_backup', 'my_post_addcron_auto_backup', 1, 1); 
function my_post_addcron_auto_backup($cron){
 global $soft, $software, $globals; 
//Add your custom code here.
 } 

faqs

Description 
The faqs filter will trigger your function before displaying the FAQs in the enduser panel. You can edit existing FAQs, remove existing FAQs or add new FAQs.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_faqs:

insert_filter('faqs', 'my_faqs', 1, 1); 
function my_faqs($faqs){
// Add a FAQ
$faqs['custom_faq_1']['question'] = 'Customized Question';
$faqs['custom_faq_1']['answer'] = 'Customized Answer';
// Unset an existing FAQ
unset($faqs['webuzo_intro']);
return $faqs;
} 

check_softpath_exist

Description 
The check_softpath_exist filter will trigger when a user is installing a script in a sub-directory. Webuzo will check if the directory already exists and pass on to this filter. If you want to make a custom check or overwrite the check done by Webuzo you can use this filter.

Usage 
Uncomment the following part inside filter.php and add your code inside the function check_softpath_exist:

insert_filter('check_softpath_exist', 'my_check_softpath_exist', 1, 1); 
function check_softpath_exist($softpath_exist, $softpath){
//Return false to allow Webuzo to continue installation OR true to stop installation.
return false;
}

auto_upgrade_installation_accessible

Description 
The auto_upgrade_installation_accessible filter can be used to force upgrade even if the installation is not accessible via curl OR can be used if the user do not want to allow auto upgrade.
Webuzo will skip the curl call check for the installation during upgrade if return true and Webuzo will not allow auto upgrade if return false.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_auto_upgrade_installation_accessible

insert_filter('auto_upgrade_installation_accessible', 'my_auto_upgrade_installation_accessible', 1, 1); 
function my_auto_upgrade_installation_accessible($is_accessible){
// Return true if you want to force upgrade even if the installation is not accessible via curl
return true;
// Return false if you do not want to allow auto upgrade
return false;
}

pre_filelist

Description 
The pre_filelist filter can be used to return the files/folders list in a specific directory.
Webuzo will skip its process of listing and will use the array returned by this filter.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_pre_filelist

insert_filter('pre_filelist', 'my_pre_filelist', 1, 3);
function my_pre_filelist($filelist, $scandir, $options){  
// Return the filelist array
     return $filelist; 
}

Parameters
$filelist : (array) This will always be empty in pre_filelist filter
$scandir : (string) This is the directory for which you need to return the files/folders
$options : (array) This contains the constrains you need to use while calculating the list
Structure of $options parameter :

$options = array('sub_directories' => $searchSubdirs, // 1 - to search in sub directories
            'directories_only' => $directoriesonly, // 1 - to look for directories only OR 0 - for files and dirs
            'maximum_level' => $maxlevel, // Maximum number of recursions for sub dirs | 'all' refers to no limit
            'start_level' => $level); // The sub-directory level to start with

Sample structure of the $filelist array you need to return

File in the 1st level
[/var/www/html/file.txt] => Array
(
[level] => 1
[dir] => 0
[name] => file.txt
[path] => /var/www/html/
)

Directory in the 1st level
[/var/www/html/dir] => Array
(
[level] => 1
[dir] => 1
[name] => dir
[path] => /var/www/html/
)

File in the 2nd level
[/var/www/html/dir/new.php] => Array
(
[level] => 2
[dir] => 0
[name] => new.php
[path] => /var/www/html/dir/
)

post_filelist

Description 
The post_filelist filter can be used to modify the files/folders list in a specific directory calculated by Webuzo.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_filelist

insert_filter('post_filelist', 'my_post_filelist', 1, 3);
function my_post_filelist($filelist, $scandir, $options){  
// Return the filelist array
     return $filelist; 
}

Parameters
$filelist : (array) This will be the list calculated by Webuzo. You can make changes in this array and return the new array
$scandir : (string) This is the directory for which you need to return the files/folders
$options : (array) This contains the constrains you need to use while calculating the list
Structure of $options parameter :

$options = array('sub_directories' => $searchSubdirs, // 1 - to search in sub directories
            'directories_only' => $directoriesonly, // 1 - to look for directories only OR 0 - for files and dirs
            'maximum_level' => $maxlevel, // Maximum number of recursions for sub dirs | 'all' refers to no limit
            'start_level' => $level); // The sub-directory level to start with

Sample structure of the $filelist array you need to return

File in the 1st level
[/var/www/html/file.txt] => Array
(
[level] => 1
[dir] => 0
[name] => file.txt
[path] => /var/www/html/
)

Directory in the 1st level
[/var/www/html/dir] => Array
(
[level] => 1
[dir] => 1
[name] => dir
[path] => /var/www/html/
)

File in the 2nd level
[/var/www/html/dir/new.php] => Array
(
[level] => 2
[dir] => 0
[name] => new.php
[path] => /var/www/html/dir/
)

pre_import_save

Description 
This filter allows you to modify the installation details before it is saved while importing the installation (by enduser).

Note : This filter is executed only when installations are imported by Endusers

Usage 
Uncomment the following part inside filter.php and add your code inside the function pre_import_save:

insert_filter('pre_import_save', 'my_pre_import_save', 1, 1);
 function my_pre_import_save($ins){
// If you would like to save a WordPress installation into your custom WordPress package you can update SID 
$ins['sid'] = 10001;
// This will save the SID of the installation to 10001
// Similarly you can modify any details you want before saving the installation
return ins;
 }

pre_admin_import_save

Description 
This filter allows you to modify the installation details before it is saved while importing the installation (by admin/CLI).

Note : This filter is executed only when installations are imported by Admin from GUI or Command Line

Usage 
Uncomment the following part inside filter.php and add your code inside the function pre_admin_import_save:

insert_filter('pre_admin_import_save', 'my_pre_admin_import_save', 1, 1);
 function my_pre_admin_import_save($ins){
// If you would like to save a WordPress installation into your custom WordPress package you can update SID
$ins['sid'] = 10001;
// This will save the SID of the installation to 10001
// Similarly you can modify any details you want before saving the installation
return ins;
 }

pre_upgrade_plugins

Description 
This filter allows you to make changes to the outdated plugins list (add or remove) before upgrading the same.

Usage 
Uncomment the following part inside filter.php and add your code inside the function pre_upgrade_plugins:

insert_filter('pre_upgrade_plugins', 'my_pre_upgrade_plugins', 1, 3);
function my_pre_upgrade_plugins($outdated_plugins, $soft, $username){
// If you want to remove any plugin before upgrading unset($outdated_plugins['pagelayer/pagelayer.php']); 
// Return the $outdated_plugins array to continue with plugins upgrade 
return $outdated_plugins;
 }

Parameters
$outdated_plugins : (array) This is an array with the list of outdated plugins that will be upgraded. You can make changes in this array and return the updated array.
$soft : (int) This is the id of the script for which plugins are being upgraded
$username : (string) This contains the username for which the upgrades are being done

Structure of $outdated_plugins parameter is as follows :

Array( 
        [pagelayer/pagelayer.php] => stdClass Object (  
                [id] => w.org/plugins/pagelayer  
                [slug] => pagelayer  
                [plugin] => pagelayer/pagelayer.php  
                [new_version] => 1.1.0  
                [url] => https://wordpress.org/plugins/pagelayer/
                [package] => http://downloads.wordpress.org/plugin/pagelayer.1.1.0.zip  
                [tested] => 5.4  
                [requires_php] => 5.5  
                [compatibility] => Array ( )  
                [Name] => PageLayer  
        ) 
)

pre_upgrade_themes

Description 
This filter allows you to make changes to the outdated themes list (add or remove) before upgrading the same.

Usage 
Uncomment the following part inside filter.php and add your code inside the function pre_upgrade_themes:

insert_filter('pre_upgrade_themes', 'my_pre_upgrade_themes', 1, 3);
function my_pre_upgrade_themes($outdated_themes, $soft, $username){
// If you want to remove any theme before upgrading unset($outdated_themes['twentytwenty']);
// Return the $outdated_themes array to continue with themes upgrade
return $outdated_themes;
 }

Parameters
$outdated_themes: (array) This is an array with the list of outdated themes that will be upgraded. You can make changes in this array and return the updated array.
$soft : (int) This is the id of the script for which themes are being upgraded
$username : (string) This contains the username for which the upgrades are being done

Structure of $outdated_themes parameter is as follows :

Array(
[twentytwenty] => stdClass Object (
[name] => Twenty Twenty
[slug] => twentytwenty
[version] => 1.2
[preview_url] => https://wp-themes.com/twentytwenty
[author] => wordpressdotorg
[screenshot_url] => //ts.w.org/wp-content/themes/twentytwenty/screenshot.png?ver=1.2
[rating] => 84
[num_ratings] => 34
[downloaded] => 757989
[last_updated] => 2020-03-31
[homepage] => https://wordpress.org/themes/twentytwenty/
[download_link] => http://downloads.wordpress.org/theme/twentytwenty.1.2.zip
)
)
)

post_header

Description 
This filter allows you to print any custom message after Webuzo header is loaded, this filter will be called on all pages after loading the header

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_header:

insert_filter('post_header', 'my_post_header', 1);
function my_post_header(){
    echo 'This is a custom message';
}

post_load_sets

Description 
This filter allows you to modify the WordPress sets loaded. This filter includes both admin and enduser sets list.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_load_sets:

insert_filter('post_load_sets', 'my_post_load_sets', 1, 1);
function my_post_load_sets($sets){
// To remove an admin set from the list 
// Note : _admin is added at the end of set name for admin sets 
unset($sets['SET_NAME_admin']); 

// To remove an enduser set from the list 
unset($sets['SET_NAME']);

// To set the default state of the set as checked for installation 
$sets['SET_NAME']['default_value'] = 1; 

return $sets;
}

Parameters
$sets: (array) This is an array with the list of WordPress sets added by admin/endusers. You can make changes in this array and return the updated array.

Structure of the $sets array

Array
(
    [SET_NAME_admin] => Array
        (
            [plugins] => Array
                (
                    [loginizer] => Loginizer
                )
            [default_value] => 0 
            [themes] => Array 
                ( 
                   [twentytwenty] => Twenty Twenty 
               ) 
           [admin_set] => 1 
        )
)

post_load_sets_admin

Description 
This filter allows you to modify the admin WordPress sets loaded. This filter includes only admin sets list.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_post_load_sets_admin:

insert_filter('post_load_sets_admin', 'my_post_load_sets_admin', 1, 1);
function my_post_load_sets_admin($sets){
// To remove an admin set from the list 
// Note : _admin is added at the end of set name for admin sets 
unset($sets['SET_NAME_admin']); 

// To set the default state of the set as checked for installation 
$sets['SET_NAME_admin']['default_value'] = 1;

return $sets;
}

Parameters
$sets: (array) This is an array with the list of WordPress sets added by admin. You can make changes in this array and return the updated array.

Structure of the $sets array

Array
(
    [SET_NAME_admin] => Array
        (
            [plugins] => Array
                (
                    [loginizer] => Loginizer
                )
            [default_value] => 0
            [themes] => Array 
                ( 
                    [twentytwenty] => Twenty Twenty 
                ) 
            [admin_set] => 1 
        )
)

exclude_files_clone

Description 
This filter allows you to exclude files/folders from being copied to the clone installation.

Usage 
Uncomment the following part inside filter.php and add your code inside the function exclude_files_clone:

insert_filter('exclude_files_clone', 'my_exclude_files_clone', 1, 2);
function my_exclude_files_clone($exclude_files, $softpath){
// $exclude_files is expected as an array 
// Add files/folders to be excluded 
     $exclude_files[] = $softpath.'/.htaccess'; 
     $exclude_files[] = $softpath.'/cache'; 
     return $exclude_files;
}

Parameters 
$exclude_files : (array) This will be the list of files to be excluded calculated by Webuzo. You can make changes in this array and return the new array.
$softpath : (string) This is the path of the live installation.

exclude_files_staging

Description 
This filter allows you to exclude files/folders from being copied to the staging installation.

Usage 
Uncomment the following part inside filter.php and add your code inside the function exclude_files_staging

insert_filter('exclude_files_staging', 'my_exclude_files_staging', 1, 2);
function my_exclude_files_staging($exclude_files, $softpath){
// $exclude_files is expected as an array
// Add files/folders to be excluded
$exclude_files[] = $softpath.'/.htaccess';
$exclude_files[] = $softpath.'/cache';
return $exclude_files;
}

Parameters 
$exclude_files : (array) This will be the list of files to be excluded calculated by Webuzo. You can make changes in this array and return the new array.
$softpath : (string) This is the path of the live installation.

exclude_files_pushtolive

Description 
This filter allows you to exclude files/folders from being copied from staging installation to live installation.

Usage 
Uncomment the following part inside filter.php and add your code inside the function exclude_files_pushtolive:

insert_filter('exclude_files_pushtolive', 'my_exclude_files_pushtolive', 1, 2);
function my_exclude_files_pushtolive($exclude_files, $softpath){
// $exclude_files is expected as an array 
// Add files/folders to be excluded 
      $exclude_files[] = $softpath.'/.htaccess';
      $exclude_files[] = $softpath.'/cache'; 
      return $exclude_files;
}

Parameters 
$exclude_files : (array) This will be the list of files to be excluded calculated by Webuzo. You can make changes in this array and return the new array.
$softpath : (string) This is the path of the staging installation.

exclude_files_remoteimport

Description 
This filter allows you to exclude files/folders from being imported.

Usage 
Uncomment the following part inside filter.php and add your code inside the function exclude_files_remoteimport:

insert_filter('exclude_files_remoteimport', 'my_exclude_files_remoteimport', 1, 2);
function my_exclude_files_remoteimport($exclude_files, $softpath){
// $exclude_files is expected as an array
// Add files/folders to be excluded
      $exclude_files[] = $softpath.'/.htaccess';
      $exclude_files[] = $softpath.'/cache';
      return $exclude_files;
}

Parameters 
$exclude_files : (array) This will be the list of files to be excluded calculated by Webuzo. You can make changes in this array and return the new array.
$softpath : (string) This is the path of the installation which is to be imported.

exclude_files_backup

Description 
This filter allows you to exclude files/folders from being backup.

Usage 
Uncomment the following part inside filter.php and add your code inside the function exclude_files_backup:

insert_filter('exclude_files_backup', 'my_exclude_files_backup', 1, 2);
function my_exclude_files_backup($exclude_files, $softpath){
// $exclude_files is expected as an array
// Add files/folders to be excluded
$exclude_files[] = $softpath.'/.htaccess';
$exclude_files[] = $softpath.'/cache';
return $exclude_files;
}

Parameters 
$exclude_files : (array) This will be the list of files to be excluded calculated by Webuzo. You can make changes in this array and return the new array.
$softpath : (string) This is the path of the backup installation.

Define PHP Version

You can also define the PHP version in the Pre Install Filter if you are using multiple PHP versions on your server.

  • Uncomment the part defining pre_install filter as explained above.
  • Add your code to Identify the PHP version in the function my_pre_install()
insert_filter('pre_install', 'my_pre_install', 1); 
function my_pre_install(){ 
global $soft, $software, $globals; 
// Your Code to Identify the PHP version 
$version = phpversion(); 
define('php_version', $version); 
} 
  • If the PHP version is defined here then Webuzo will skip its process to detect the PHP version while installing a Script.
  • The above example is for pre_install filter. You can similarly configure the pre_upgrade and pre_clone filter to skip the php version check during the upgrade and clone process respectively.

Define PERL Version

You can also define the PERL version in the Pre Install Filter.

  • Uncomment the part defining pre_install filter as explained above.
  • Define the PERL version in the function you used while adding the pre install filter (my_pre_install() in this case)
insert_filter('pre_install', 'my_pre_install', 1);
 function my_pre_install(){
 global $soft, $software, $globals;
 // Your Code to Identify the PERL version
define('perl_version', '5.8.8'); 
} 
  • If the PERL version is defined here then Webuzo will skip its process to detect the PERL version while installing a Script.
  • The above example is for pre_install filter. You can similarly configure the pre_upgrade and pre_clone filter to skip the PERL version check during the upgrade and clone process respectively.

Define MySQL Version

You can also define the MySQL version in the Pre Install Filter.

  • Uncomment the part defining pre_install filter as explained above.
  • Define the MySQL version in the function my_pre_install()
insert_filter('pre_install', 'my_pre_install', 1); 
function my_pre_install(){ 
global $soft, $software, $globals; 
// Your Code to Identify the MySQL version 
define('mysql_version', '5.7.0'); 
} 
  • If the MySQL version is defined here then Webuzo will skip its process to detect the MySQL version while installing a Script.
  • The above example is for pre_install filter. You can similarly configure the pre_upgrade and pre_clone filter to skip the MySQL version check during the upgrade and clone process respectively.

Define Loaded Extensions

You can also define the list of enabled PHP extensions in the Pre Install Filter.

  • Uncomment the part defining pre_install filter as explained above.
  • Define the list of enabled PHP extensions in the function my_pre_install()
insert_filter('pre_install', 'my_pre_install', 1);
function my_pre_install(){ 
global $soft, $software, $globals, $__hooks; 
// E.g 
$__hooks['loaded_extension'] = array('mysqli', 'curl', 'gd');         
//If $__hooks['loaded_extension'] is the only extension loaded list and you do not want Webuzo to detect the extensions, then you can define the following constant.
define('PHP_EXT_EXHAUSTIVE', 1); 
} 
  • If the extension is defined as enabled here then Webuzo will skip its process to detect the PHP extension enabled while installing a Script.
  • The above example is for pre_install filter. You can similarly configure the pre_upgrade and pre_clone filter to skip the PHP extensions check during the upgrade and clone process respectively.

Define Functions Enabled

You can also define the list of enabled PHP functions in the Pre Install Filter.

  • Uncomment the part defining pre_install filter as explained above.
  • Define the list of enabled PHP functions in the function my_pre_install()
insert_filter('pre_install', 'my_pre_install', 1); 
function my_pre_install(){ 
global $soft, $software, $globals, $__hooks; 
// E.g 
$__hooks['function_exists'] = array('phpinfo', 'exec','shell_exec'); 
} 
  • If the function is defined as enabled here then Webuzo will skip its process to detect the PHP function enabled while installing a Script.
  • The above example is for pre_install filter. You can similarly configure the pre_upgrade and pre_clone filter to skip the PHP function exists check during the upgrade and clone process respectively.

Change PHP Version using .htaccess

.htaccess is used by many web hosts to change PHP version for their users. You can do this using Webuzo for the scripts that require a certain minimum PHP version.

Note : This example assumes that you run PHP 5.6 as default for the user and this filter will switch the version to PHP 7.2.

  • Add the following code in the file /path/to/webuzo/enduser/hooks/filter.php
insert_filter('pre_install', 'my_pre_install', 1); 
function my_pre_install(){ global $soft, $software, $globals, $scripts;
 // Do stuff here e.g. is as follows 
 // $scripts[$soft]['php_min'] holds the minimum PHP required by the script currently being installed
if($scripts[$soft]['php_min'] >= '7.2'){
 $version = '7.2.0';
 define('php_version', $version); 
}
} 
  • This pre install filter will skip the PHP version check by Webuzo.
  • Now you have to create the .htaccess file with the content to switch PHP version to 7.3
  • Add the following code to my_post_install() function in the file /path/to/webuzo/enduser/hooks/filter.php
insert_filter('post_install', 'my_post_install', 1, 1);
// @param   array $installation Details of the new installation function my_post_install($installation){
 global $soft, $software, $globals, $scripts; 
// Do stuff here e.g. is as follows 
// $scripts[$soft]['php_min'] holds the minimum PHP required by the script currently being installed
if($scripts[$soft]['php_min'] >= '7.3'){
 $data = "AddHandler application/x-httpd-php73 .php\n"; 
if(sfile_exists($installation['softpath'].'/.htaccess')){
 $tmp_data = sfile($installation['softpath'].'/.htaccess'); 
if(!preg_match('/AddHandler(\s*?)application/is', $tmp_data)){
 $data .= $tmp_data; 
}
 } 
swrite($installation['softpath'].'/.htaccess', $data, 1); 
}
 } 
  • This will create the .htaccess file with the required content and if the script has a .htaccess then it will write the content to the existing file.
  • Now we also need to define the PHP version during the Upgrade process.
  • Add the following code to my_pre_upgrade() function in the file /path/to/webuzo/enduser/hooks/filter.php
insert_filter('pre_upgrade', 'my_pre_upgrade', 1, 1); 
// @param   array $installation Details of the installation being upgraded 
function my_pre_upgrade($installation){ 
global $soft, $software, $globals, $scripts; 
// Do stuff here e.g. is as follows
// $scripts[$soft]['php_min'] holds the minimum PHP required by the script currently being installed
 if($scripts[$soft]['php_min'] >= '7.3'){
 $version = '7.3.0'; 
define('php_version', $version);
 }
 } 
  • This pre upgrade filter will skip the PHP version check by Webuzo.
  • Now you have to create the .htaccess file with the content to switch PHP version to 7.3
  • Add the following code to my_post_upgrade() function in the file /path/to/webuzo/enduser/hooks/filter.php
insert_filter('post_upgrade', 'my_post_upgrade', 1, 1); 
// @param   array $installation Details of the installation upgraded
function my_post_upgrade($installation){
 global $soft, $software, $globals, $scripts; 
// Do stuff here e.g. is as follows 
// $scripts[$soft]['php_min'] holds the minimum PHP required by the script currently being installed
if($scripts[$soft]['php_min'] >= '7.3'){
 $data = "AddHandler application/x-httpd-php73 .php\n"; 
if(sfile_exists($installation['softpath'].'/.htaccess')){ 
$tmp_data = sfile($installation['softpath'].'/.htaccess'); 
if(!preg_match('/AddHandler(\s*?)application/is', $tmp_data)){
 $data .= $tmp_data; 
}
 } 
swrite($installation['softpath'].'/.htaccess', $data, 1); 
}
 } 
  • This will create the .htaccess file with the required content if the content does not exist.
  • Thats it you have the filter configured to switch PHP version.
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list