$primitives Primitive settings (after hoisting removed __dynamic__ entries). * @param array $widget_config Widget config from `Widget_Type_Resolver::resolve_type_config()`. * * @return array{ * valid: array, * error: \WP_Error|null, * } */ public static function validate_shape( string $widget_type, array $primitives, array $widget_config ): array { $controls = is_array( $widget_config['controls'] ?? null ) ? $widget_config['controls'] : []; $schema = V3_Json_Schema_Builder::build( $controls, array_keys( $primitives ) ); $shape = V3_Json_Schema_Builder::check_settings_shape( $primitives, $schema ); if ( empty( $shape['errors'] ) ) { return [ 'valid' => $shape['valid'], 'error' => null, ]; } $messages = []; foreach ( $shape['errors'] as $key => $reason ) { $messages[] = sprintf( 'V3 widget "%s" property "%s": %s', $widget_type, $key, $reason ); } return [ 'valid' => $shape['valid'], 'error' => new \WP_Error( 'elementor_invalid_settings', implode( '; ', $messages ), [ 'status' => \WP_Http::BAD_REQUEST ] ), ]; } }