コード例 #1
0
 public function action_init()
 {
     if (!is_admin()) {
         return;
     }
     if (!isset($_GET['page']) || self::PAGE !== $_GET['page']) {
         return;
     }
     if (!WPUtils::is_submitting()) {
         return;
     }
     $cap = 'administrator';
     if (!current_user_can($cap)) {
         return;
     }
     if (!wp_verify_nonce($_POST[self::PAGE . '_nonce'], self::PAGE)) {
         return;
     }
     $subaction = trim(stripslashes($_POST['subaction']));
     switch ($subaction) {
         case 'sync_to_s3':
             try {
                 $this->sync_blog_uploads();
                 $this->message = 'Site uploads synchronized!';
             } catch (\Exception $e) {
                 $this->error = true;
                 $this->message = 'Something went wrong. Amazon said: ' . $e->getMessage();
             }
             break;
     }
 }
コード例 #2
0
ファイル: AdminSettingsPanel.php プロジェクト: nowzoo/wp-s3
 public function action_init()
 {
     if (!is_admin()) {
         return;
     }
     if (!isset($_GET['page']) || Plugin::SITE_OPTION_AWS !== $_GET['page']) {
         return;
     }
     if (!WPUtils::is_submitting()) {
         return;
     }
     if (is_multisite()) {
         $cap = 'manage_network';
     } else {
         $cap = 'administrator';
     }
     if (!current_user_can($cap)) {
         return;
     }
     if (!wp_verify_nonce($_POST[Plugin::SITE_OPTION_AWS . '_nonce'], Plugin::SITE_OPTION_AWS)) {
         return;
     }
     $option = WPUtils::trim_stripslashes_deep($_POST[Plugin::SITE_OPTION_AWS]);
     $validated = Plugin::validate_aws_option($error, $option);
     Plugin::set_aws_option($option, $validated);
     $this->message = $validated ? 'AWS S3 options updated!' : $error;
     $this->error = !$validated;
 }
コード例 #3
0
 /**
  * Save the data...
  */
 public function action_init()
 {
     if (!is_admin()) {
         return;
     }
     if (!isset($_GET['page']) || Plugin::SITE_OPTION_DOMAINS !== $_GET['page']) {
         return;
     }
     if (!WPUtils::is_submitting()) {
         return;
     }
     $cap = 'manage_network';
     if (!current_user_can($cap)) {
         return;
     }
     if (!wp_verify_nonce($_POST[Plugin::SITE_OPTION_DOMAINS . '_nonce'], Plugin::SITE_OPTION_DOMAINS)) {
         return;
     }
     $sites = Plugin::get_sites_map();
     $option = WPUtils::trim_stripslashes_deep($_POST[Plugin::SITE_OPTION_DOMAINS]);
     $ids_to_domains = array();
     $subdomains_to_domains = array();
     $sites = Plugin::get_sites_map();
     foreach ($option as $site_id => $domain) {
         $domain = trim($domain);
         $domain = strtolower($domain);
         if (!empty($domain)) {
             $ids_to_domains[intval($site_id)] = array('domain' => $domain, 'subdomain' => $sites[$site_id]->domain);
             $subdomains_to_domains[$sites[$site_id]->domain] = $domain;
         }
     }
     Plugin::set_option(compact('ids_to_domains', 'subdomains_to_domains'));
     $this->message = 'Domain settings updated!';
 }