public static function save_metaboxes($post_id)
 {
     // Check if our nonce is set.
     if (!isset($_POST['stm_custom_nonce'])) {
         return $post_id;
     }
     if (!wp_verify_nonce($_POST['stm_custom_nonce'], plugin_basename(__FILE__))) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // Check the user's permissions.
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     sForms::setData($_POST['stm_custom_data']);
     if (sForms::validate()) {
         foreach (sForms::$data as $fieldName => $value) {
             //if( ! is_array($value)) $value = sanitize_text_field( $value );
             update_post_meta($post_id, $fieldName, $value);
         }
     } else {
         echo 'error';
     }
 }
Beispiel #2
0
 private static function validate_captcha(sForms $Field, &$errors)
 {
     if (!Captcha::check($Field->getValue())) {
         $errors['captcha'] = true;
     }
 }