public function query_fonts($sortby = 'date', $retry = false) { $fonts_query = wp_remote_get(add_query_arg(array('license' => headway_get_license_key(), 'sortby' => $sortby), trailingslashit($this->api_url)), array('timeout' => 20)); /* If the original query to Headway cannot connect, find a way to proxy to Headway's CDN */ if (is_wp_error($fonts_query)) { $fonts_query = wp_remote_get($this->backup_api_url . '/' . headway_get_license_key() . '/' . $sortby, array('timeout' => 20)); } return json_decode(wp_remote_retrieve_body($fonts_query), true); }
public static function display() { /* Output */ $options = array('body' => array('installed_plugins' => self::get_installed_plugins(), 'installed_themes' => self::get_installed_themes(), 'install_nonces' => self::get_install_nonces(), 'license_key' => headway_get_license_key(), 'headway_options_url' => admin_url('admin.php?page=headway-options'), 'admin_url' => untrailingslashit(admin_url()))); $addons_request = wp_remote_post(HEADWAY_EXTEND_DATA_URL, $options); $addons = wp_remote_retrieve_body($addons_request); if (!$addons || $addons_request['response']['code'] != 200) { echo '<h2>Headway Extend</h2>'; echo '<h3>Whoops!</h3>'; echo '<p>There was a problem fetching the addons from Headway Extend. Please try again later.</p>'; } else { echo $addons; } }
function headway_validate_license_key() { global $wp_version; if (!headway_get_license_key()) { return array('error' => 'Please provide a license key.'); } $request_parameters = array('timeout' => 5, 'body' => array('wp_version' => $wp_version, 'php_version' => phpversion(), 'headway_version' => HEADWAY_VERSION, 'home_url' => home_url(), 'license_key' => headway_get_license_key())); $request = wp_remote_post(HEADWAY_LICENSE_VALIDATION_URL, $request_parameters); $license_validation = wp_remote_retrieve_body($request); if (is_serialized($license_validation)) { return maybe_unserialize($license_validation); } return false; }
<div class="big-tabs-container"> <div class="big-tab" id="tab-general-content"> <?php if (is_main_site()) { $license_validation_request = headway_validate_license_key(); $license_validation = null; if ($error = headway_get('error', $license_validation_request)) { $license_validation = '<span class="red license-key-validation">' . $error . '</span>'; } elseif ($success = headway_get('success', $license_validation_request)) { $license_validation = '<span class="green license-key-validation">' . $success . '</span>'; } $form = array(array('id' => 'license-key', 'size' => 'large', 'value' => headway_get_license_key(), 'type' => 'text', 'masked' => true, 'label' => 'License Key', 'description' => 'Please enter your license key here. This will be used to authenticate your site so you can take advantage of the automatic updates, Headway Extend, and more.<br /><br />You may find your license key in the <a href="http://headwaythemes.com/dashboard" target="_blank">Headway Members Dashboard</a>.', 'suffix' => $license_validation)); HeadwayAdminInputs::generate($form, 'form-table license-key-input-table'); echo '<h3 class="title title-hr">General</h3>'; } else { echo '<h3 class="title">General</h3>'; } $form = array(array('id' => 'favicon', 'size' => 'large', 'type' => 'text', 'label' => 'Favicon URL', 'value' => HeadwayOption::get('favicon'), 'description' => 'A favicon is the little image that sits next to your address in the favorites menu and on tabs. If you do not know how to save an image as an icon you can go to <a href="http://www.favicon.cc/" target="_blank">favicon.cc</a> and draw or import an image.'), array('id' => 'feed-url', 'size' => 'large', 'type' => 'text', 'label' => 'Feed URL', 'description' => 'If you use any service like <a href="http://feedburner.google.com/" target="_blank">FeedBurner</a>, type the feed URL here.', 'value' => HeadwayOption::get('feed-url'))); HeadwayAdminInputs::generate($form); ?> <h3 class="title title-hr">Admin Preferences</h3> <?php $form = array(array('id' => 'menu-setup', 'type' => 'radio', 'label' => 'Default Admin Page', 'value' => HeadwayOption::get('menu-setup', false, 'getting-started'), 'radios' => array(array('value' => 'getting-started', 'label' => 'Getting Started'), array('value' => 'visual-editor', 'label' => 'Visual Editor'), array('value' => 'options', 'label' => 'Options')), 'description' => 'Select which admin page you would like to be directed to when you click on "Headway" in the WordPress Admin.')); HeadwayAdminInputs::generate($form); ?>
public function display_plugin_changelog() { if (headway_get('plugin') != $this->slug || !($update_info = $this->retrieve_update_info())) { return; } $changelog_request = wp_remote_get(str_replace('{KEY}', headway_get_license_key(), $update_info['changelog_url'])); $changelog = wp_remote_retrieve_body($changelog_request); echo $changelog; die; }
public static function get_addon_info($api, $action, $args) { if (!$api && headway_get('headway')) { /* Output */ $addon_info_request = wp_remote_post(add_query_arg(array('action' => 'addon-info'), HEADWAY_EXTEND_DATA_URL), array('body' => array('slug' => headway_get('slug'), 'license_key' => headway_get_license_key()))); $addon_info = wp_remote_retrieve_body($addon_info_request); if (!is_serialized($addon_info) || $addon_info_request['response']['code'] != 200) { return false; } $addon_info = maybe_unserialize($addon_info); $api = new stdClass(); $api->name = $addon_info['name']; $api->version = $addon_info['version']; $api->download_link = str_replace('{KEY}', headway_get_license_key(), $addon_info['download_url']); } return $api; }