Automattic\WooCommerce\Abilities
ActionableAbility::execute_change
Run the change. This is the execute callback of the ability.
Метод класса: ActionableAbility{}
Хуков нет.
Возвращает
mixed|\WP_Error. The output of prepare_response(), or the WP_Error of the step that refused the change.
Использование
$ActionableAbility = new ActionableAbility(); $ActionableAbility->execute_change( $input );
- $input(разное)
- Ability input.
По умолчанию:null
Код ActionableAbility::execute_change() ActionableAbility::execute change WC 11.3.0
public function execute_change( $input = null ) {
$input = is_array( $input ) ? $input : array();
$subject = $this->load( $input );
if ( is_wp_error( $subject ) ) {
return $subject;
}
$updates = array();
if ( ExtensibleAbilities::is_enabled() ) {
$extensions = is_array( $input['extensions'] ?? null ) ? $input['extensions'] : array();
$updates = $this->prepare_fields( $extensions );
if ( is_wp_error( $updates ) ) {
return $updates;
}
}
$changed = $this->change( $subject, $input );
if ( is_wp_error( $changed ) ) {
return $changed;
}
$rejected = $this->apply_fields( $subject, $updates );
if ( null === $rejected && ExtensibleAbilities::is_enabled() ) {
$rejected = $this->validate( $subject );
}
if ( null !== $rejected ) {
return $rejected;
}
$saved = $this->save( $subject );
if ( is_wp_error( $saved ) ) {
return $saved;
}
return $this->prepare_response( $subject );
}