$model * @param int $post_id * @param string $subtree_id * @return array */ protected function analyze( array $model, int $post_id, string $subtree_id ): array { $result = Design_Mutator::edit( $model, static function ( array &$settings, array $element ): array { $changes = array(); foreach ( array( 'margin', 'margin_tablet', 'margin_mobile' ) as $key ) { if ( ! isset( $settings[ $key ] ) || ! is_array( $settings[ $key ] ) ) { continue; } $margin = $settings[ $key ]; $negative = false; foreach ( array( 'top', 'right', 'bottom', 'left' ) as $side ) { if ( isset( $margin[ $side ] ) && is_numeric( $margin[ $side ] ) && (float) $margin[ $side ] < 0 ) { $negative = true; $margin[ $side ] = '0'; } } if ( $negative ) { $changes = array_merge( $changes, Design_Mutator::set( $settings, $key, $margin ) ); } } return $changes; } ); if ( is_wp_error( $result ) ) { return $result; } return Design_Mutator::report( $result, __( 'Reset negative margins to zero.', 'acrossai-abilities-manager' ), __( 'No negative margins were found in scope, so nothing was changed.', 'acrossai-abilities-manager' ) ); } }