public function activateLicense() { $params = array(); $params['username'] = $this->post('username'); $params['key'] = $this->post('key'); $params['api_key'] = $this->post('api_key'); $params['url'] = get_site_url(); $params['ip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''; $params['dkey'] = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20); $string = 'activatelicense?'; $request_url = self::getWpbControlUrl(array($string, http_build_query($params, '', '&'))); $response = wp_remote_get($request_url, array('timeout' => 300)); if (is_wp_error($response)) { echo json_encode(array('result' => false)); die; } $result = json_decode($response['body']); if (!is_object($result)) { echo json_encode(array('result' => false)); die; } if ((bool) $result->result === true || (int) $result->code === 401 && isset($result->deactivation_key)) { $this->setDeactivationLicense(isset($result->code) && (int) $result->code === 401 ? $result->deactivation_key : $params['dkey']); update_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'envato_username', $params['username']); update_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'envato_api_key', $params['api_key']); update_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'js_composer_purchase_code', $params['key']); echo json_encode(array('result' => true)); die; } echo $response['body']; die; }
/** * Adds themes css class to body tag. * @param $classes * @return array */ public function addThemeBodyClass($classes) { if (!class_exists('WPBakeryVisualComposerSettings')) { return $classes; } $theme = ($theme = get_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'themes')) ? $theme : ''; if (!empty($theme)) { $classes[] = 'vct_' . preg_replace('/\\.css$/', '', $theme); } return $classes; }