← Back
Editing: class-settings-handler.php
<?php namespace GD_cORe\handlers; if (!defined('ABSPATH')) { exit; } /** * The admin-specific functionality of the plugin. * * @package GD_cORe * @subpackage GD_cORe/admin */ class Settings extends Main { public function __construct() { parent::__construct(); } /** * Calls API and gets current WPMU DEV access token * * @since 2.2.2 * @return string|null */ public function retrieve_wpmudevAT() { $response = $this->gdcore_http_request("api-settings?accountId=" . \GD_cORe_Site_Auth::account_id(), 'GET'); if (is_wp_error($response)) { error_log('API settings fetch failed: ' . $response->get_error_message()); return null; } $result = json_decode($response, true); return $result['wpmuDevAT'] ?? null; } /** * Loads the WPMU DEV token and registers it in WP options if not already present * * @since 2.2.2 * @access public */ public function load_wpmudevtoken() { if (!get_option('wpmudev_apikey')) { $token = $this->retrieve_wpmudevAT(); if (!empty($token)) { update_option('wpmudev_apikey', $token); } } } /** * Resets the WPMU DEV token in WP options * * @since 3.0.0 * @access public */ public function reset_wpmudevtoken() { $token = $this->retrieve_wpmudevAT(); if (!empty($token)) { update_option('wpmudev_apikey', $token); } } /** * Retrieves Gravity Forms license key from GD Core API * * @since 4.1.2 * @return string|null */ public function retrieve_gravityforms_license() { $response = $this->gdcore_http_request("api-settings?accountId=" . \GD_cORe_Site_Auth::account_id(), 'GET'); if (is_wp_error($response)) { error_log('API settings fetch failed: ' . $response->get_error_message()); return null; } $result = json_decode($response, true); return $result['gravityFormsLicense'] ?? null; } /** * Loads Gravity Forms license and registers it in WP options * * @since 4.1.2 * @access public */ public function load_gravityforms_license() { if (!get_option('rg_gforms_key')) { $license = $this->retrieve_gravityforms_license(); if (!empty($license)) { update_option('rg_gforms_key', $license, false); } } } }
Save File
Cancel