Пример #1
0
 /**
  * check for, sanitize, and store our options
  *
  * @return [type] [description]
  */
 public function store_settings()
 {
     // make sure we have our settings item
     if (empty($_POST['yourls-options'])) {
         return;
     }
     // verify our nonce
     if (!isset($_POST['yourls_settings_save']) || !wp_verify_nonce($_POST['yourls_settings_save'], 'yourls_settings_save_nonce')) {
         return;
     }
     // cast our options as a variable
     $data = (array) $_POST['yourls-options'];
     // set an empty
     $store = array();
     // check and sanitize the URL
     if (!empty($data['url'])) {
         $store['url'] = esc_url(YOURLSCreator_Helper::strip_trailing_slash($data['url']));
     }
     // check and sanitize the API key
     if (!empty($data['api'])) {
         $store['api'] = sanitize_text_field($data['api']);
     }
     // check the boolean for autosave
     if (!empty($data['sav'])) {
         $store['sav'] = true;
     }
     // check the boolean for scheduled
     if (!empty($data['sch'])) {
         $store['sch'] = true;
     }
     // check the boolean for shortlink
     if (!empty($data['sht'])) {
         $store['sht'] = true;
     }
     // check the boolean for using CPTs
     if (!empty($data['cpt'])) {
         $store['cpt'] = true;
     }
     // check the each possible CPT
     if (!empty($data['cpt']) && !empty($data['typ'])) {
         $store['typ'] = YOURLSCreator_Helper::sanitize_array_text($data['typ']);
     }
     // filter it
     $store = array_filter($store);
     // pass it
     self::save_redirect_settings($store);
 }