Skip to content

Commit

Permalink
Bug fixed: Mezclados los outputs de los métodos fields() de cada clas…
Browse files Browse the repository at this point in the history
…e hija de WASP\Setting_Fields\Setting_Fields
  • Loading branch information
rogertm committed Apr 5, 2024
1 parent aac543c commit dc158d2
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion classes/setting-fields/class-wasp-setting-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function render()
*/
function validate()
{
$fields = $this->fields();
$fields = $this->merged_fields();

foreach ( $fields as $key => $value ) :
$input[$value['meta']] = ( isset( $_POST[$value['meta']] ) && null !== $_POST[$value['meta']] )
Expand All @@ -193,4 +193,25 @@ function validate()

return $input;
}

/**
* Merge fields from every child class
* @return array
*
* @since 1.0.2
*/
private function merged_fields()
{
$fields = $this->fields();

$result = array();
foreach ( get_declared_classes() as $class ) :
if ( is_subclass_of( $class, __CLASS__ ) ) :
$instance = new $class;
$result = array_merge( $result, $instance->fields() );
endif;
endforeach;

return $result;
}
}

0 comments on commit dc158d2

Please sign in to comment.