Пример #1
0
 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));
         }
     }
 }
Пример #2
0
 /**
  * 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();
 }