コード例 #1
0
 /**
  * Validates the arguments array.
  *
  * @since 0.5.0
  * @param WPWD\Components\Widget $parent the parent component
  * @return bool|WPDLib\Util\Error an error object if an error occurred during validation, true if it was validated, false if it did not need to be validated
  */
 public function validate($parent = null)
 {
     $status = parent::validate($parent);
     if ($status === true) {
         $this->args = Utility::validate_position_args($this->args);
     }
     return $status;
 }
コード例 #2
0
 /**
  * Validates the arguments array.
  *
  * @since 0.5.0
  * @param WPWD\Components\Section $parent the parent component
  * @return bool|WPDLib\Util\Error an error object if an error occurred during validation, true if it was validated, false if it did not need to be validated
  */
 public function validate($parent = null)
 {
     $status = parent::validate($parent);
     if ($status === true) {
         if (is_array($this->args['class'])) {
             $this->args['class'] = implode(' ', $this->args['class']);
         }
         if (!empty($this->args['class'])) {
             $this->args['class'] .= ' ';
         }
         $this->args['class'] .= 'widefat';
         if (isset($this->args['options']) && !is_array($this->args['options'])) {
             $this->args['options'] = array();
         }
         $this->_field = FieldManager::get_instance($this->args);
         if ($this->_field === null) {
             return new UtilError('no_valid_field_type', sprintf(__('The field type %1$s assigned to the field component %2$s is not a valid field type.', 'widgets-definitely'), $this->args['type'], $this->slug), '', ComponentManager::get_scope());
         }
         if (null === $this->args['default']) {
             $this->args['default'] = $this->_field->validate();
         }
         $this->args = Utility::validate_position_args($this->args);
     }
     return $status;
 }