Easy Webinar Plugin on Steroids

Easy Webinar Plugin: getRemote_version() Speed Up

If you already use Easy Webinar Plugin (4.2.7 or older) within your WordPress website, you probably noticed a kind of slow dashboard.

In this article you can learn how to speedup EWP with a piece of code snippet. All you need to have is basic knowledge of PHP editing, and FTP access to website host.

4 Simple Steps

Step One: Go to FTP where you have installed WordPress website and backup file /wp-content/plugins/webinar_plugin/webinar-plugin.php

Step Two: Open file /wp-content/plugins/webinar_plugin/webinar-plugin.php in some text editor (even Notepad can help, but I truly recommend you Sublime Text 3).

Step Three: Find method getRemote_version() which is located at line 939 in plugin version EWP(4.2.7)

Step Four: Replace complete original function getRemote_version() with cacheable version. So this:

public function getRemote_version(){
  global $wpdb;
  $wpdb->webinar_license = "webinar_license";
  $license_key_arr = $wpdb->get_results("Select * FROM $wpdb->webinar_license");
  $license_key = $license_key_arr[0]->key;
  $client_site = get_site_url();
  $request = wp_remote_post($this->update_path, array('body' => array('action' => 'ewp-version','license_series' => $license_key,'client_site' => $client_site)));
  
  if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200){
    return $request['body'];
  }
  else {
    echo 'heena';
  }
  return false;
}

becomes this:

public function getRemote_version() {
  if ( false === ( $request = get_transient( 'ewp_latest_version' ) ) ) {
    global $wpdb;
    $wpdb->webinar_license = 'webinar_license';
    $license_key_arr = $wpdb->get_results( "SELECT * FROM $wpdb->webinar_license" );
    $license_key = $license_key_arr[0]->key;
    $client_site = get_site_url();
    $request = wp_remote_post(
      $this->update_path,
      array(
        'body' => array(
          'action'         => 'ewp-version',
          'license_series' => $license_key,
          'client_site'    => $client_site,
        ),
      )
    );

    if ( ! is_wp_error( $request ) || 200 === wp_remote_retrieve_response_code( $request ) ) {
      set_transient( 'ewp_latest_version', $request['body'], 6 * HOUR_IN_SECONDS );
      return $request['body'];
    } else {
      echo 'heena';
    }
  } else {
    return $request;
  }
  return false;
}

Explanation of code

By default, EWP doing multiple checks for latest version of plugin by calling home (remote) server to get latest version number. This can slowdown code execution (waiting response from remote server, multiplied by numerous calls per single page load). My idea was to prevent this and optimize calls, by involving local WordPress cache for plugin’s latest version data, through Transients API.

New plugin version can’t be released on each second, minute, or even hour. Because of that, 1+ remote call per page load is waste of bandwidth and time. So we can, for a while, locally store latest version number fetched from remote server and simply check local data on same page loads.

In this tweak I store latest version info for 6 hours. Simple as that.

Please note, Easy Webinar support confirmed that they’ll apply this enhancement to upcoming release. I’m expecting to EWP(4.2.8) come with fix already implemented. If not, simply refactor my version of method getRemote_version() and tweak core plugin file.

Did this tips helped you?

If you found this tips useful, feel free to 


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.