In this FAQ we will explore how to protect a plug-in with the ionCube Encoder so that it can be registered by WordPress.

When files are protected with ionCube they are encoded at a binary level, this means WordPress is no longer able to scan the mangled output for the header preamble required to register the plug-in. This issue can be resolved by customising the appearance of your encoded file output to contain a plain text header along with the standard ionCube preamble. If you are using the GUI, custom header preambles for encoded files can be set on the ‘Customisation’ tab of your project settings which include the required WordPress plug-in preamble as part of a custom PHP preamble file.

 

The contents of the wp_preamble.php file is shown below. The section between /* and */ is the part of your file that can be edited to include your WordPress plug-in information.

/*
Plugin Name: My Plugin
Plugin URI: https://www.myioncubeplugin.com
Description: This describes the plugin.
Version: 1.0
Author: Your Name
Author URI: http://myioncubepluginwebsite.com
License: GPL2
License URL: https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain: my-plugin
*/
if(!extension_loaded(‘ionCube Loader’)){echo(“Site error: the “.(php_sapi_name()==’cli’?’ionCube’:'<a href=”http://www.ioncube.com”>ionCube</a>’).” PHP Loader needs to be installed. This is a widely used PHP extension for running ionCube protected PHP code, website security and malware blocking.\n\nPlease visit “.(php_sapi_name()==’cli’?’get-loader.ioncube.com’:'<a href=”http://get-loader.ioncube.com”>get-loader.ioncube.com</a>’).” for install assistance.\n\n”);}else{die(‘The file ‘.__FILE__.” is corrupted.\n”);}exit(199);

Encoding your entire project with this custom file will result in the plugin being registered multiple times with WordPress. For the plug-in to be registered once by WordPress, encode the file that uses your custom preamble by itself in a separate ionCube project. This will mean that the preamble is only used for one file rather than all of your encoded files. Copying this single file into your main encoded project will result in your WordPress plug-in being successfully registered.

If you are using the command line Encoder, you can specify your preamble file by using the following:

–preamble-file <file>

This information can also be found in section 3.10.6 of our User-Guide.

After all of these steps have been followed, you should have an encoded WordPress plug-in!

So what’s next?

Now that you have produced a compatible WordPress plug-in you’ll want to maximise the protection and benefit of using ionCube. With version 10, the best feature for this is Dynamic Keys. This will give you unrivalled protection for your plugin. You can read about Dynamic Keys in this article and in section 4.3 of the User Guide.

If you want to test this tutorial and look at everything else ionCube has to offer then our Free Trial is available here.

FAQ: How do I encode a WordPress plug-in?
twitterlinkedinmail