The WPML Installer helps theme authors provide multilingual-ready themes to their clients. A tiny chunk of PHP code will offer your clients the option to buy, install, and activate WPML right from within your theme.

You gain:

  • Greater credibility with your clients, since WPML is integrated into the theme
  • Light and simple integration for yourself
  • A streamlined process for installing WPML
  • A nice affiliate commission on every sale from your theme

All it takes is adding our Installer folder to your theme, calling it to initialize, and choosing where to place the WPML installer GUI in your theme.

How it works for your clients

Before we delve into how this is done, I’d like to show you what your client will see once you have added the WPML Embedded Installer:

Adding the Installer code to themes and plugins

Want to include the WPML Installer in your theme or plugin?

You can now clone it from our public Gitlab here: https://git.onthegosystems.com/installer/installer

If you have any problems please contact our Compatibility Team and we will help.

Then, follow the steps below.

  1. Add WPML Installer folder to your themes folder – You’ll receive from us a zipped (installer.zip) file. Extract it, and add it to your theme’s folder structure, as shown in the screen below.

    WPML installer in theme root

    WPML installer in theme root

  2. Include ‘loader.php’ before the ‘init’ event – inside the installer folder, there is a ‘loader.php’ file that needs to be included in your theme’s functions.php file. This is shown in the following code and screenshot. Please note the PHP comments for the required value of each field.
    //include the WPML installer in the theme
    include get_template_directory() . '/installer/loader.php';
    WP_Installer_Setup($wp_installer_instance,
    	array(
    		'plugins_install_tab' => 1, // optional, default value: 0
    		'affiliate_id:wpml' => '99999', // optional, default value: empty
    		'affiliate_key:wpml' => 'NNNNNNNNNN', // optional, default value: empty
    		'src_name' => 'NAME OF THEME', // optional, default value: empty, needed for coupons
    		'src_author' => '',// optional, default value: empty, needed for coupons
    		'repositories_include' => array('wpml') // optional, default to empty (show all)
    	)
    );
    

    WPML installer theme functions

    WPML installer theme functions

After this step, we will see the WPML Installer in Plugins → Add New page; Note that there is a new ‘Commercial’ tab, where WPML will appear.

WPML installer new plugins page

WPML installer new plugins page

Add a new WPML Installer tab to your theme options

In this example, we add a new tab to the theme options admin screen. The code below is specific to our example theme, and shows how to register multiple tabs. You can use this code for inspiration, but note that your theme will use different code. Thus, you cannot copy/paste it “as is.”

You can find more complete guides on adding tabs to theme options for WordPress here:
http://www.smashingmagazine.com/2011/10/20/create-tabs-wordpress-settings-pages/

http://docs.reduxframework.com/core/arguments/#help_tabs

https://upthemes.com/upthemes-framework/documentation/

  1. We first add a new tab for the ‘WPML Installer’
    function cmsms_options_general_tabs() {
    	$tabs = array();
    	$tabs['general'] = __('General', 'cmsmasters');
    	$tabs['sidebar'] = __('Sidebars', 'cmsmasters');
    	$tabs['sitemap'] = __('Sitemap', 'cmsmasters');
    	$tabs['error'] = __('404', 'cmsmasters');
    	$tabs['code'] = __('Custom Codes', 'cmsmasters');
    	//WPML Installer handler
    	$tabs['wpml'] = __('WPML Installer', 'cmsmasters');
    	if (class_exists('Cmsms_Form_Builder')) {
    		$tabs['recaptcha'] = __('reCAPTCHA', 'cmsmasters');
    	}
    	return $tabs;
    
  2. We then add a case to cmsms_form_field_fn(). In this framework, this is the function that injects options into different theme tabs. Make sure this function is called after the “init” hook.
    case 'wpml':
    echo '
    <div class="wrap otgsi_downloads_form">';
    // CONFIG
        $config['template'] = 'compact'; //required
        $config['product_name'] = 'WPML'; 
        $config['box_title'] = 'Multilingual GoodDay';
        $config['name'] = 'GoodDay'; //name of theme/plugin 
        $config['box_description'] = 'GoodDay theme is fully compatible with WPML - the WordPress Multilingual plugin. WPML lets you add languages to your existing sites and includes advanced translation management.'; 
        $config['repository'] = 'wpml'; // required
        $config['package'] = 'multilingual-cms'; // required
        $config['product'] = 'multilingual-cms'; // required  
        WP_Installer_Show_Products($config);   
    echo "</div>
    
    ";
    break;
    
  3. The final result is shown below as well as in the short video. Your clients can now install and activate WPML from within your theme, making it very easy for them to transform their sites into multilingual

    WPML installer in theme options

    WPML installer in theme options

Using Your Affiliate ID

WPML Installer works with our affiliate program, which offers you a commission from every sale that you make. You can include your affiliate information in Installer. WPML sales that start from within your theme are counted toward your affiliate account.

To enjoy affiliate commission, you need to set your affiliate ID and Key. Get these values from your WPML account, under ‘Affiliates.’

Set your affiliate ID and Key in the corresponding arguments of the WP_Installer_Setup call, described above.

Support for the Embedded Installer

Need our help with this? Contact us here: http://wpml.org/forums/forum/english-support/ . Please select ‘Embedded Installer’ from the list of subjects.