/** * Deploy From Staging * Sends the api request to deploy from stagin */ public function deploy_staging() { if (!is_user_logged_in()) { wp_die("Must be an autheticated user"); } if (!current_user_can('administrator')) { wp_die("Must be an administrator"); } if (!defined("PWP_NAME") or !defined('WPE_APIKEY')) { echo "This process could not be started."; } require_once WPE_PLUGIN_DIR . '/class-wpeapi.php'; $db_mode = @$_REQUEST['db_mode'] ?: 'default'; $email = @$_REQUEST['email'] ?: get_option('admin_email'); $tables = @$_REQUEST['tables'] ?: false; $api = new WPE_API(); $api->set_arg('method', 'deploy-from-staging'); $api->set_arg('db_mode', esc_attr($db_mode)); $api->set_arg('email', esc_attr($email)); if ($tables) { $api->set_arg('tables', implode('&', $tables)); } $api->set_arg('headers', "Host:api.wpengine.com"); $api->post(); if (!$api->is_error()) { echo "Your request has been submitted. You will receive an email once it has been processed"; } else { echo $api->is_error(); } die; }
function wpe_api_domain_manage($domain) { // Ensure we have some default values, in case they aren't set (Prevents PHP Notices) $page = isset($_GET['page']) ? $_GET['page'] : ''; $action = isset($_POST['action']) ? $_POST['action'] : ''; $request = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; //make sure we're on a domain mapping plugin if ($page == 'dm_domains_admin' or $page == 'domainmapping') { //don't do anything if we're editing if ($action == 'edit') { //maybe oneday we'll do something //save or add the domain } elseif (!empty($_POST) and ($action == 'save' or $action == 'add')) { //validate the referrer check_admin_referer('domain_mapping'); //load the api class include_once WPE_PLUGIN_DIR . '/class-wpeapi.php'; $api = new WPE_API(); if (preg_match('/(\\;|\\,|\\?)/', $_POST['domain']) or !preg_match('/[A-z]|[1-9]|\\./', $_POST['domain'])) { $api->set_notice("The domain you entered was not valid."); if ($api->is_error()) { unset($_POST); } } else { //set the method and domain $api->set_arg('method', 'domain'); $api->set_arg('domain', $_POST['domain']); //do the api request and send the reponse to the admin screen $api->get()->set_notice(); } //delete a domain } elseif ($request == 'delete' or $request == 'del') { //check_admin_referer('domain_mapping'); //load the api class include_once WPE_PLUGIN_DIR . '/class-wpeapi.php'; $api = new WPE_API(); //set the method and domain $api->set_arg('method', 'domain-remove'); $api->set_arg('domain', $_REQUEST['domain']); //do the api request and send the reponse to the admin screen $api->get()->set_notice(); error_log('del:' . var_export($api, true)); } } }
/** * Removes domain from WPEngine domains list when this domain is unmapped * from a blog. * * @since 4.0.4 * @action domainmapping_deleted_domain * * @access public * @param string $domain The domain name to remove. */ public function remove_domain_from_wpengine($domain) { // return if we can't locate WPEngine API class if (!$this->_locate_wpengine_api()) { return; } // add domain to WPEngine $api = new WPE_API(); // set the method and domain $api->set_arg('method', 'domain-remove'); $api->set_arg('domain', $domain); // do the api request $api->get(); }
function __construct($args = array()) { parent::__construct($args); $this->notices = array(); }