WordPress plugin intelligence profile

Envato Toolkit

Validate purchase code, check for item update & support expiration, download newest version, lookup for user details, search for Envato item id & more

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 5.7
Current version1.4
WordPress coverageTested up to WordPress 5.7
Minimum stackWP 4.6 · PHP 5.4
Directory statusactive
Last directory update26 Apr 20215y ago
Active installations5K+Adoption metric — not a quality score
WordPress.org rating2.8 / 5 from 9 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Envato Toolkit version 1.4 as active, updated 5y ago and tested up to WordPress 5.7.

Overview

About this plugin

It is a 3 files library + Visual UI, to validate the purchase codes of your customers, get details about specific Envato user (country, city, total followers, total sales, avatar), get his license purchase and support expiration dates, license type he bought, check for updates of purchased plugins and themes and get the download links for them.

Plus – this library has Envato Item Id search feature by providing plugin’s or theme’s name and author. So – yes, this is a tool you, as a developer / author, have been looking for months.

If you are looking for the library-only version to integrate into your plugin / theme, it’s on GitHub:

Envato Toolkit (Standalone)

The main purpose of this plugin is to help you to start much easier without having a headache trying to understand WordPress - Envato Market plugins code, that is the only one built by Envato, and has so complicated and unclear code, that you never get how it works (see example below).

When I tried to create plugin’s [Check for Update] and [Validate Purchase Code] feature-buttons in the plugin myself, and I saw the code of the WordPress - Envato Market plugin, I was shocked how badly it is written and how you should not to code.

e. – pAA0aBCdeFGhiJKlmNOpqRStuVWxyZ44. , clean code coding standards and paradigms, you’d probably just have these five lines of code, so that every developer would get it:

', 'envato-toolkit')); }

Now lets see how the same task traceback looks like in WordPress - Envato Market plugin:

-

)] Check if the token is empty:

', 'envato-market' ) ); }

-

)] Parse it from another string:

$token = trim( str_replace( 'Bearer', '', $args['headers']['Authorization'] ) );

-

)] Parse it one more time – this time from arguments array:

public function request( $url, $args = array() ) { $defaults = array( 'timeout' => 20, ); $args = wp_parse_args( $args, $defaults ); }

-

)] Transfer the token variable one more time – this time via params:

item_id='. $id. '&shorten_url=true'; return $this->request( $url, $args ); } }

-

)] Pass it again – this time get it to args array from another method call:

function maybe_deferred_download( $options ) { $args = $this->set_bearer_args(); $options['package'] = envato_market()->api()->download( $vars['item_id'], $args ); return $options; }

-

)] Wrap the token into multi-dimensional string array:

$args = array( 'headers' => array( 'Authorization' => 'Bearer '. $token, ), );

-

)] Pass the wrapped token one more time – this time get it from get_option:

foreach ( envato_market()->get_option( 'items', array() ) as $item ) { if ( $item['id'] === $id ) { $token = $item['token']; break; } }

-

)] So what’s in this get_option? – Correct, another call to another method – get_options():

public function get_option( $name, $default = '' ) { $options = self::get_options(); $name = self::sanitize_key( $name ); return isset( $options[ $name ] )? $options[ $name ]: $default; }

-

php -> get_options()] Finally, after almost 10 steps in the tree, we are finally getting the original

WordPress method call, but now I’m getting confused again – what is that option_name variable here:

public function get_options() { return get_option( $this->option_name, array() ); }

-

php -> init_globals()] Here is it is – the option name key name is… Oh wait…

No it is not here it. It is equals to another variable, who is is put

in another clean-up function – look like I’m keep seeing this for the 2 time in the tree – the sanitization of sanitization:

$this->option_name = self::sanitize_key( $this->slug );

-

php -> init_globals()] So the option name key name is the name of $this->slug.

Now lets see what is the value of $this->slug:

$this->slug = 'envato-market';

) steps to understand one variable. And the whole code of that plugin is like that. The example above was the headache I had, until I realized that I must write a new Envato API Management Toolkit, instead of trying to use what Envato is giving, because otherwise I won’t get anything working ever.

And, I believe, that many other developers had the same issue when tried to create update check feature for their plugins or themes.

So instead of using that library for myself, I decided that I want to help all these developers to save their time, and I’m sharing this code with you. I’m releasing it under MIT license, which allows you to use this code in your plugin without any restrictions for both – free and commercial use.

Plus – I’m giving a promise to you, that this plugin is and will always be 100% free, without any ads, ‘Subscribe’, ‘Follow us’, ‘Check our page’, ‘Get Pro Version’ or similar links.

If you created in hi-quality code a valuable additional functionality to the library and you want to share it with everyone – I’m open here to support your efforts, and add your code to the plugin’s library, so that we all together make this plugin better for authors – the better is the plugin, the better plugins authors will make for their customers. The better quality products we will have on the internet, the happier people will be all over the world.

Finally – the code is poetry – the better is the plugin, the happier is the world.

The pseudo-code of example output of the plugin is this:

>

=$license['support_active'] == 1? >

>. > followers on Envato.

1. =$isValidTargetLicense? =$targetLicenseSupportActive == 1?

>

2. >. > followers on Envato.

3. =$pluginUpdateAvailable? >" target="_blank" title="Download newest version">Download newest version</a>

4. =$themeUpdateAvailable? >" target="_blank" title="Download newest version">Download newest version</a>

5. >

6. >

And the example input of the output above, it this:

$objToolkit = new EnvatoAPIManager($toolkitSettings);

// Details about you $purchasedPlugins = $objToolkit->getPurchasedPluginsWithDetails(); $plugins = array(); foreach($purchasedPlugins AS $pluginId => $purchasedPlugin) { $purchasedPlugin['licenses'] = $objToolkit->getLicensesByItemId($pluginId); $plugins[$pluginId] = $purchasedPlugin; }

$purchasedThemes = $objToolkit->getPurchasedThemesWithDetails(); $themes = array(); foreach($purchasedThemes AS $themeId => $purchasedTheme) { $purchasedTheme['licenses'] = $objToolkit->getLicensesByItemId($themeId); $themes[$themeId] = $purchasedTheme; }

= FALSE) { $view->authorCity = $authorDetails['city']; $view->authorCountry = $authorDetails['country']; $view->authorSales = $authorDetails['sales']; $view->authorFollowers = $authorDetails['followers']; } else { $view->authorCity = ''; $view->authorCountry = ''; $view->authorSales = 0; $view->authorFollowers = 0; }

// 1. $targetLicenseDetails['support_expiration_time']; $view->targetLicenseSupportActive = $targetLicenseDetails['support_active'];

// 2. Details About Target Envato User $targetUserDetails = $objToolkit->getUserDetails($sanitizedTargetUsername); // View vars $view->targetUsername = esc_html($sanitizedTargetUsername); // Ready for print $view->targetUserCity = $targetUserDetails['city']; $view->targetUserCountry = $targetUserDetails['country']; $view->targetUserSales = $targetUserDetails['sales']; $view->targetUserFollowers = $targetUserDetails['followers'];

// 3.

Status of Purchased Plugin ID $availablePluginVersion = $objToolkit->getAvailableVersion($sanitizedTargetPluginId); $pluginUpdateAvailable = version_compare($sanitizedInstalledPluginVersion, $availablePluginVersion, '<'); // View vars $view->targetPluginId = intval($sanitizedTargetPluginId); // Ready for print $view->installedPluginVersion = esc_html($sanitizedInstalledPluginVersion); // Ready for print $view->nameOfTargetPluginId = esc_html($objToolkit->getItemName($sanitizedTargetPluginId)); $view->availablePluginVersion = $availablePluginVersion; $view->pluginUpdateAvailable = $pluginUpdateAvailable; $view->pluginUpdateDownloadUrl = $pluginUpdateAvailable?

$objToolkit->getDownloadUrlIfPurchased($sanitizedTargetPluginId): '';

// 4.

Status of Purchased Theme ID $availableThemeVersion = $objToolkit->getAvailableVersion($sanitizedTargetThemeId); $themeUpdateAvailable = version_compare($sanitizedInstalledThemeVersion, $availableThemeVersion, '<'); // View vars $view->targetThemeId = intval($sanitizedTargetThemeId); // Ready for print $view->installedThemeVersion = esc_html($sanitizedInstalledThemeVersion); // Ready for print $view->nameOfTargetThemeId = esc_html($objToolkit->getItemName($sanitizedTargetThemeId)); $view->availableThemeVersion = $availableThemeVersion; $view->themeUpdateAvailable = $themeUpdateAvailable; $view->themeUpdateDownloadUrl = $themeUpdateAvailable?

$objToolkit->getDownloadUrlIfPurchased($sanitizedTargetThemeId): '';

// 5. Envato Item Id of Purchased Plugin $view->targetPluginName = esc_html($sanitizedTargetPluginName); // Ready for print $view->targetPluginAuthor = esc_html($sanitizedTargetPluginAuthor); // Ready for print $view->foundPluginId = $objToolkit->getItemIdByPluginAndAuthorIfPurchased($sanitizedTargetPluginName, $sanitizedTargetPluginAuthor);

// 6. Envato Item Id of Purchased Theme $view->targetThemeName = esc_html($sanitizedTargetThemeName); // Ready for print $view->targetThemeAuthor = esc_html($sanitizedTargetThemeAuthor); // Ready for print $view->foundThemeId = $objToolkit->getItemIdByThemeAndAuthorIfPurchased($sanitizedTargetThemeName, $sanitizedTargetThemeAuthor);

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • purchase validator
  • update checker
  • api
  • envato
  • license
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 5.7

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 5.7.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to5.7
Minimum requirementsWordPress 4.6 · PHP 5.4
Update activity26 Apr 20215y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.