PATH:
home
/
letacommog
/
aperobusiness
/
wp-content
/
themes
/
deep
/
inc
/
api
<?php /** * Webnus deep envato class. * * @author Webnus */ class Deep_Envato { /** * User for cashing directory */ public $purchase_code; /** * Deep remote update path */ public $update_path; /** * Deep current version */ public $current_version; /** * Deep slug */ public $slug; public function __construct() { $theme_data = wp_get_theme(); $this->slug = $theme_data->Template; $this->current_version = $theme_data->Version; $this->purchase_code = get_option('deep_purchase', ''); add_filter( 'pre_set_site_transient_update_themes', array( $this, 'check_update' ) ); add_filter( 'upgrader_post_install', array( $this, 'after_install' ), 10, 3 ); add_action( 'wp_ajax_wnThemeActivate', array( $this, 'get_purchase_code' ) ); } /** * Set update path. * * @author Webnus */ public function set_update_path( $update_path ) { $this->update_path = $update_path; } /** * Get update path. * * @author Webnus */ public function get_update_path() { return $this->update_path; } public function get_purchase_code() { check_ajax_referer( 'colorCategoriesNonce', 'nonce' ); $purchase_code_val = $_POST['purchaseCodeVal']; $purchase_code_type = $_POST['purchaseCodeType']; $item_name = ''; switch ($purchase_code_type) { case 'one': $item_name = '1 License for All Themes'; break; case 'yearly': $item_name = 'Yearly Access to All Themes'; break; case 'lifetime': $item_name = 'Lifetime Access to All Themes'; break; } update_option( 'deep_purchase', $purchase_code_val); update_option( 'deep_purchase_type', $purchase_code_type); $verify_url = 'http://webnus.biz/webnus.net/theme-api/verify?activate&item_name=' . urlencode($item_name) . '&id=' . $purchase_code_val . '&url=' . get_home_url(); $ch_verify = curl_init( $verify_url ); curl_setopt( $ch_verify, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch_verify, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch_verify, CURLOPT_CONNECTTIMEOUT, 5 ); $cinit_verify_data = curl_exec( $ch_verify ); curl_close( $ch_verify ); $result = ( $cinit_verify_data == 'activate' ) ? 'success' : 'failed'; update_option( 'deep_purchase_validation', $result ); echo $cinit_verify_data; wp_die(); // this is required to terminate immediately and return a proper response } /** * Add our self-hosted autoupdate deep to the filter transien * * @author Webnus */ public function check_update( $transient ) { if ( empty( $transient->checked ) ) { return $transient; } // Get the remote version $new_version = json_decode( json_encode( $this->get_deep_info('version')->version ), true ); // Set deep update path $dl_link = ! is_null( $this->get_deep_info('dl') ) ? $this->set_update_path( $this->get_deep_info('dl') ) : NULL; // If a newer version is available, add the update if ( version_compare( $this->current_version, $new_version, '<' ) ) { $transient->response[$this->slug] = array( 'theme' => $this->slug, 'package' => $this->get_update_path(), 'new_version' => $new_version, ); } elseif ( isset( $transient->response[$this->slug] ) ) { unset( $transient->response[$this->slug] ); } return $transient; } public function after_install( $response, $hook_extra, $result ) { global $wp_filesystem; // Get global FS object $install_directory = get_template_directory(); // Our theme directory $result['destination_name'] = $this->slug; // Set the destination name for the rest of the stack $result['remote_destination'] = $install_directory; // Set the remote destination for the rest of the stack $wp_filesystem->move( $result['destination'], $install_directory ); // Move files to the theme dir $result['destination'] = $install_directory; // Set the destination for the rest of the stack return $result; } /** * Return details from envato * @author Webnus */ public function get_deep_info( $type = 'dl' ) { if ( $type == 'dl' ) { $item_name = ''; switch (get_option( 'deep_purchase_type' )) { case 'one': $item_name = '1 License for All Themes'; break; case 'yearly': $item_name = 'Yearly Access to All Themes'; break; case 'lifetime': $item_name = 'Lifetime Access to All Themes'; break; } $verify_url = 'http://webnus.biz/webnus.net/theme-api/verify?item_name=' . urlencode($item_name) . '&id=' . $this->purchase_code . '&url=' . get_home_url(); } elseif ( $type == 'version' ) { $verify_url = 'http://webnus.biz/webnus.net/theme-api/version'; } else { return; } $ch_verify = curl_init( $verify_url ); curl_setopt( $ch_verify, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch_verify, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch_verify, CURLOPT_CONNECTTIMEOUT, 5 ); $cinit_verify_data = curl_exec( $ch_verify ); curl_close( $ch_verify ); if ( $cinit_verify_data != '' ) { return json_decode( $cinit_verify_data ); } else { return false; } } } if ( is_admin() ) { new Deep_Envato; }
[+]
..
[-] envato.php
[edit]