set( array_merge( $this->get(), $partial ) ); } /** * Gets the callback for sanitizing the setting's value before saving. * * @since 1.181.0 * * @return callable Sanitize callback. */ protected function get_sanitize_callback() { return function ( $settings ) { if ( ! is_array( $settings ) ) { return array(); } $sanitized_settings = array(); foreach ( self::SETTING_KEYS as $key ) { if ( isset( $settings[ $key ] ) && is_array( $settings[ $key ] ) ) { $sanitized_settings[ $key ] = $this->sanitize_goal_type_selections( $settings[ $key ] ); } } return $sanitized_settings; }; } /** * Sanitizes the per-goal-type selections, validating `ecommerce` and `lead` * sub-keys as string arrays. * * @since 1.181.0 * * @param array $selections Goal type selections to sanitize. * @return array The sanitized selections. */ private function sanitize_goal_type_selections( $selections ) { $sanitized = array(); foreach ( self::GOAL_TYPE_KEYS as $goal_type ) { if ( isset( $selections[ $goal_type ] ) && is_array( $selections[ $goal_type ] ) ) { $sanitized[ $goal_type ] = Sanitize::sanitize_string_list( $selections[ $goal_type ] ); } } return $sanitized; } }