/**
  * Custom filter on the name due to WP's limitations:
  * http://code.google.com/p/wordpress-custom-content-type-manager/issues/detail?id=271
  */
 public function save_definition_filter($posted_data)
 {
     $posted_data = parent::save_definition_filter($posted_data);
     // Are there any invalid characters? 1st char. must be a letter (req'd for valid prop/func names)
     if (!empty($posted_data['name']) && !preg_match('/^[a-z]*$/', $posted_data['name'])) {
         $this->errors['name'][] = __('Due to WordPress limitations, WYSIWYG fields can contain ONLY lowercase letters.', CCTM_TXTDOMAIN);
         $posted_data['name'] = preg_replace('/[^a-z]/', '', $posted_data['name']);
     }
     return $posted_data;
 }
Ejemplo n.º 2
0
 /**
  * Validate and sanitize any submitted data. Used when editing the definition for
  * this type of element. Default behavior here is to require only a unique name and
  * label. Override this if customized validation is required.
  *
  *     into the field values.
  *
  * @param array   $posted_data = $_POST data
  * @return array filtered field_data that can be saved OR can be safely repopulated
  */
 public function save_definition_filter($posted_data)
 {
     $posted_data = parent::save_definition_filter($posted_data);
     if (empty($posted_data['alternate_input']) && empty($posted_data['options'])) {
         $this->errors['options'][] = __('At least one option or alternate input is required.', CCTM_TXTDOMAIN);
     }
     return $posted_data;
     // filtered data
 }
 /**
  * Handle the "checked by default" option
  *
  * @param array $posted_data -- a copy of $_POST
  * @return array	filtered $_POST data
  */
 public function save_definition_filter($posted_data)
 {
     $posted_data = parent::save_definition_filter($posted_data);
     if (!isset($posted_data['checked_by_default'])) {
         $posted_data['checked_by_default'] = 0;
         // set it
     }
     return $posted_data;
 }