Title: Envato Toolkit
Author: KestutisIT
Published: <strong>June 21, 2017</strong>
Last modified: April 26, 2021

---

Search plugins

![](https://ps.w.org/toolkit-for-envato/assets/banner-772x250.png?rev=1682947)

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://ps.w.org/toolkit-for-envato/assets/icon-256x256.png?rev=1692171)

# Envato Toolkit

 By [KestutisIT](https://profiles.wordpress.org/kestutisit/)

[Download](https://downloads.wordpress.org/plugin/toolkit-for-envato.zip)

 * [Details](https://test.wordpress.org/plugins/toolkit-for-envato/#description)
 * [Reviews](https://test.wordpress.org/plugins/toolkit-for-envato/#reviews)
 *  [Installation](https://test.wordpress.org/plugins/toolkit-for-envato/#installation)
 * [Development](https://test.wordpress.org/plugins/toolkit-for-envato/#developers)

 [Support](https://wordpress.org/support/plugin/toolkit-for-envato/)

## Description

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)](https://github.com/KestutisIT/EnvatoToolkit)

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.

For example – you would like to give an error message, if Envato user token is empty,
which is a required string, i.e. – `pAA0aBCdeFGhiJKlmNOpqRStuVWxyZ44`. If you like
K.I.S.S., PSR-2, D.R.Y., clean code coding standards and paradigms, you’d probably
just have these five lines of code, so that every developer would get it:

    ```
    $token = get_user_meta(get_current_user_id(), 'envato_token', TRUE);
    if($token == "")
    {
        return new \WP_Error('api_token_error', __('An API token is required.', 'envato-toolkit'));
    }
    ```

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

 1.  `[Api.php -> request(..)]` Check if the token is empty:
 2.      ```
         if ( empty( $token ) )
         {
             return new WP_Error( 'api_token_error', __( 'An API token is required.', 'envato-market' ) );
         }
         ```
     
 3.  `[Api.php -> request(..)]` Parse it from another string:
 4.      ```
         $token = trim( str_replace( 'Bearer', '', $args['headers']['Authorization'] ) );
         ```
     
 5.  `[Api.php -> request(..)]` Parse it one more time – this time from arguments array:
 6.      ```
         public function request( $url, $args = array() ) {
             $defaults = array(
                 'timeout' => 20,
             );
             $args = wp_parse_args( $args, $defaults );
         }
         ```
     
 7.  `[Api.php -> download(..)]` Transfer the token variable one more time – this time
     via params:
 8.      ```
         class Envato_Market_API {
             public function download( $id, $args = array() ) {
                 $url = 'https://api.envato.com/v2/market/buyer/download?item_id=' . $id . '&shorten_url=true';
                 return $this->request( $url, $args );
             }
         }
         ```
     
 9.  `[admin.php -> maybe_deferred_download(..)]` Pass it again – this time get it 
     to args array from another method call:
 10.     ```
         function maybe_deferred_download( $options ) {
             $args = $this->set_bearer_args();
             $options['package'] = envato_market()->api()->download( $vars['item_id'], $args );
             return $options;
         }
         ```
     
 11. `[admin.php -> set_bearer_args(..)]` Wrap the token into multi-dimensional string
     array:
 12.     ```
         $args = array(
             'headers' => array(
                 'Authorization' => 'Bearer ' . $token,
             ),
         );
         ```
     
 13. `[admin.php -> set_bearer_args(..)]` Pass the wrapped token one more time – this
     time get it from get_option:
 14.     ```
         foreach ( envato_market()->get_option( 'items', array() ) as $item ) {
             if ( $item['id'] === $id ) {
                 $token = $item['token'];
                 break;
             }
         }
         ```
     
 15. `[admin.php -> get_option(..)]` So what’s in this `get_option`? – Correct, another
     call to another method – `get_options()`:
 16.     ```
         public function get_option( $name, $default = '' ) {
             $options = self::get_options();
             $name = self::sanitize_key( $name );
             return isset( $options[ $name ] ) ? $options[ $name ] : $default;
         }
         ```
     
 17. `[admin.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:
 18.     ```
         public function get_options() {
             return get_option( $this->option_name, array() );
         }
         ```
     
 19. `[envato-market.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:
 20.     ```
         $this->option_name = self::sanitize_key( $this->slug );
         ```
     
 21. `[envato-market.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`:
 22.     ```
         $this->slug        = 'envato-market';
         ```
     

So it takes **eleven (!)** 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:

    ```
    Details about you:
    ----------------------------------------------------------
    List of all different plugins you bought:
    <?php foreach($plugins AS $pluginId => $plugin): ?>
        <?='Plugin Id: '.$pluginId.', Name: '.$plugin['name'];?>, Licenses:
        <?php foreach($plugin['licenses'] AS $license): ?>
            Code: <?=$license['purchase_code'];?>,
            License: <?=$license['license'];?>,
            Purchased: <?=$license['license_purchase_date'];?> <?=$license['license_purchase_time'];?>,
            Expires: <?=$license['support_expiration_date'];?> <?=$license['support_expiration_time'];?>,
            Support Status: <?=$license['support_active'];?>
        <?php endforeach; ?>
    <?php endforeach; ?>

    List of all different themes you bought:
    <?php foreach($themes AS $themeId => $theme): ?>
        <?='Theme Id: '.$themeId.', Name: '.$theme['name'];?>, Licenses:
        <?php foreach($theme['licenses'] AS $license): ?>
            Code: <?=$license['purchase_code'];?>,
            License: <?=$license['license'];?>,
            Purchased: <?=$license['license_purchase_date'];?> <?=$license['license_purchase_time'];?>,
            Expires: <?=$license['support_expiration_date'];?> <?=$license['support_expiration_time'];?>,
            Status: <?=$license['support_active'] == 1 ? "Supported" : "Support Expired";?>
        <?php endforeach; ?>
    <?php endforeach; ?>

    Your summary:
    Your location is <?=$authorCity;?>, <?=$authorCountry;?>.
    You've sold your items <?=$authorSales;?> times and you have <?=$authorFollowers;?> followers on Envato.

    1. Your Customer's License Details
    ----------------------------------------------------------
    Purchase Code: <?=$targetPurchaseCode;?>
    Is Valid License: <?=$isValidTargetLicense ? 'Yes' : 'No';?>
    Buyer Username: <?=$targetLicenseBuyer;?>
    License Type: <?=$targetLicenseType;?>
    Purchased At: <?=$targetLicensePurchasedAt;?>
    Supported Until: <?=$targetLicenseSupportedUntil;?>
    Support Status: <?=$targetLicenseSupportActive == 1 ? "Supported" : "Support Expired";?>

    2. Details About Target Envato User - <?=$targetUsername;?>
    ----------------------------------------------------------
    <?=$targetUsername;?> is located in <?=$targetUserCity;?>, <?=$targetUserCountry;?>.
    He sold his items <?=$targetUserSales;?> times and has <?=$targetUserFollowers;?> followers on Envato.

    3. Status of Purchased Plugin ID - <?=$targetPluginId;?>
    ----------------------------------------------------------
    Plugin Name: <?=$nameOfTargetPluginId;?>
    Plugin Update Available: <?=$pluginUpdateAvailable ? 'Yes' : 'No';?>
    Installed Plugin Version: <?=$installedPluginVersion;?>
    Available Plugin Version: <?=$availablePluginVersion;?>
    Plugin Update Download URL:
    <a href="<?=$pluginUpdateDownloadUrl;?>" target="_blank" title="Download newest version">Download newest version</a>

    4. Status of Purchased Theme ID - <?=$targetThemeId;?>:
    ----------------------------------------------------------
    Theme Name: <?=$nameOfTargetThemeId;?>
    Theme Update Available: <?=$themeUpdateAvailable ? 'Yes' : 'No';?>
    Installed Theme Version: <?=$installedThemeVersion;?>
    Available Theme Version: <?=$availableThemeVersion;?>
    Theme Update Download URL:
    <a href="<?=$themeUpdateDownloadUrl;?>" target="_blank" title="Download newest version">Download newest version</a>

    5. Envato Item Id of Purchased Plugin
    ----------------------------------------------------------
    Searched for Name: <?=$targetPluginName;?>
    Searched for Author: <?=$targetPluginAuthor;?>
    Found Plugin Id: <?=$foundPluginId;?>

    6. Envato Item Id of Purchased Theme
    ----------------------------------------------------------
    Searched for Name: <?=$targetThemeName;?>
    Searched for Author: <?=$targetThemeAuthor;?>
    Found Theme Id: <?=$foundThemeId;?>
    ```

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;
    }

    $authorDetails = $objToolkit->getUserDetails($sanitizedEnvatoUsername);
    // View vars
    $view->plugins = $plugins;
    $view->themes = $themes;
    if($authorDetails != 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. Details About Target Purchase Code
    $targetLicenseDetails = $objToolkit->getLicenseDetails($sanitizedTargetPurchaseCode);
    // View vars
    $view->targetPurchaseCode = esc_html($sanitizedTargetPurchaseCode); // Ready for print
    $view->isValidTargetLicense = $objToolkit->isValidLicense($sanitizedTargetPurchaseCode);
    $view->targetLicenseBuyer = $targetLicenseDetails['buyer_username'];
    $view->targetLicense = $targetLicenseDetails['license'];
    $view->targetLicensePurchasedAt = $targetLicenseDetails['license_purchase_date'].' '.$targetLicenseDetails['license_purchase_time'];
    $view->targetLicenseSupportedUntil = $targetLicenseDetails['support_expiration_date'].' '.$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);
    ```

## Screenshots

[⌊Envato Toolkit - Search input⌉⌊Envato Toolkit - Search input⌉[

Envato Toolkit – Search input

[⌊Envato Toolkit - Search results⌉⌊Envato Toolkit - Search results⌉[

Envato Toolkit – Search results

## Installation

This section describes how to install the plugin and get it working.

 1. Upload `EnvatoToolkit` (or `toolkit-for-envato`) to the `/wp-content/plugins/` 
    directory.
 2. Activate the plugin through the ‘Plugins’ menu in WordPress.
 3. Go to admin menu item `EnvatoToolkit` and enter your Envato Username, Envato API
    Key and Envato Private Token.
 4. That’s it.

## FAQ

### How does it work?

This plugin uses both – Envato Edge API and Envato Market API to retrieve required
data automatically, without any need of server-in-the-middle.
 So there is no need
to save your head revision number or last version on your server, it will get that
that automatically from Envato via it’s API.

## Reviews

![](https://secure.gravatar.com/avatar/1242818c8032ad58d4ef5fea9d3399dc1c51702748b8d35c26a38913a12234ca?
s=60&d=retro&r=g)

### 󠀁[Very Bad](https://wordpress.org/support/topic/very-bad-62/)󠁿

 [mn_azab](https://profiles.wordpress.org/mn_azab/) May 2, 2018 1 reply

Worst and useless plugin and can’t update the theme and using the deprecated plugin.

![](https://secure.gravatar.com/avatar/3dcb1a2377a0c4e629babbf23dd19cad6211e0eb53ffd49a4770a1c9d04551a0?
s=60&d=retro&r=g)

### 󠀁[Does not serve the purpose](https://wordpress.org/support/topic/does-not-serve-the-purpose/)󠁿

 [](https://profiles.wordpress.org/b2bmike/) April 27, 2018 1 reply

I’ve installed it and then had to remove cause it did not work as expected. The 
previous version was way better

![](https://secure.gravatar.com/avatar/8f93ff39854d2dec4a1aaa9bfb56e796381ad39361844503d13246e707bc1ae2?
s=60&d=retro&r=g)

### 󠀁[Doesn’t provide any service – not even update theme capability](https://wordpress.org/support/topic/doesnt-provide-any-service-not-even-update-theme-capability/)󠁿

 [grayfair](https://profiles.wordpress.org/grayfair/) April 6, 2018 1 reply

Doesn’t provide any service – not even update theme capability

![](https://secure.gravatar.com/avatar/723aa12edad53c34a7034f1901b59e1d32efbb98d0301eddf4b8a1dce108aba2?
s=60&d=retro&r=g)

### 󠀁[Overly Complicated](https://wordpress.org/support/topic/overly-complicated-2/)󠁿

 [neuroticartist](https://profiles.wordpress.org/neuroticartist/) March 19, 2018
1 reply

overly complicated and frustrating to use, how about this, add your Envato username
and PW and save. voila! Too easy? OK I’ll even add an API, but it STILL is too complicated.
I’ll stick to the pain int he arse old fashioned way, at least I know how to figure
that out.

![](https://secure.gravatar.com/avatar/bffae6064f19e0b0cf2aaba327192738f1738ddd8dc6b57cfa5f19bf40d64964?
s=60&d=retro&r=g)

### 󠀁[In a desparate situation and got good help.](https://wordpress.org/support/topic/in-a-desparate-situation-and-got-good-help/)󠁿

 [dogyardkitchen1](https://profiles.wordpress.org/dogyardkitchen1/) March 6, 2018

My Medico plugin had gotten our of snyc with my site. These guys helped me get it
fixed up just right. It was a big help.

![](https://secure.gravatar.com/avatar/e3725ed630b0fc57fa1e7ec58ec20310fc4baa19d7e3461fa4f0abc2cc37e301?
s=60&d=retro&r=g)

### 󠀁[Pointless](https://wordpress.org/support/topic/pointless-9/)󠁿

 [REALBLM](https://profiles.wordpress.org/realblm/) February 23, 2018 1 reply

I don’t get what’s the point of this plugin! He doesn’t allow to install / update
your plugins.. He doesn’t allow to install / update your themes… One of the most
useless plugins in the market. Maybe these 5 stars reviews are from developers EDIT:
i changed my review from 1 star to 4, since from other comments i saw that this 
is usefull only for authors, so i don’t want to ruin the feedbacks, but the developers
should be clear and not use the same name of the already existing plugin as a clickbait(
that’s why i rated it 4/5), because if someone is searching for a plugin that allow
to update your themeforest things into wordpress, this come as first choice with
the same name. That’s not fair

 [ Read all 10 reviews ](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/)

## Contributors & Developers

“Envato Toolkit” is open source software. The following people have contributed 
to this plugin.

Contributors

 *   [ KestutisIT ](https://profiles.wordpress.org/kestutisit/)

[Translate “Envato Toolkit” into your language.](https://translate.wordpress.org/projects/wp-plugins/toolkit-for-envato)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/toolkit-for-envato/),
check out the [SVN repository](https://plugins.svn.wordpress.org/toolkit-for-envato/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/toolkit-for-envato/)
by [RSS](https://plugins.trac.wordpress.org/log/toolkit-for-envato/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.4

 * Improved debugging.

#### 1.3

 * Added support for purchase time and license expiration time. Plus split to two
   fields on ‘license_type’ to ‘license’ and ‘license_type’.

#### 1.2

 * Added support for the situations if Envato API is down, plus added detailed error
   message handler.

#### 1.1

 * Removed 1 redundant API class method that should be handled by the controller,
   not a model. Plus, for security reasons, changelog.txt is no more in the plugin
   folder (so that there would be no way to discover the actual plugin version by
   public.

#### 1.0

 * Initial release!

## Meta

 *  Version **1.4**
 *  Last updated **5 years ago**
 *  Active installations **5,000+**
 *  WordPress version ** 4.6 or higher **
 *  Tested up to **5.7.15**
 *  PHP version ** 5.4 or higher **
 *  Language
 * [English (US)](https://wordpress.org/plugins/toolkit-for-envato/)
 * Tags
 * [api](https://test.wordpress.org/plugins/tags/api/)[envato](https://test.wordpress.org/plugins/tags/envato/)
   [license](https://test.wordpress.org/plugins/tags/license/)
 *  [Advanced View](https://test.wordpress.org/plugins/toolkit-for-envato/advanced/)

## Ratings

 2.8 out of 5 stars.

 *  [  3 5-star reviews     ](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/?filter=5)
 *  [  1 4-star review     ](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/?filter=3)
 *  [  1 2-star review     ](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/?filter=2)
 *  [  4 1-star reviews     ](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/toolkit-for-envato/reviews/)

## Contributors

 *   [ KestutisIT ](https://profiles.wordpress.org/kestutisit/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/toolkit-for-envato/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://profiles.wordpress.org/KestutisIT)