\S*?)\[(?\S*?)]/', $name, $array ); if ( ! empty( $array['field'] ) && ! empty( $array['key'] ) ) { return isset( $settings[ $array['field'] ][ $array['key'] ] ) && 'checked' === $settings[ $array['field'] ][ $array['key'] ]; } // Standard non array names. return isset( $settings[ $name ] ) && 'checked' === $settings[ $name ]; } /** * Apply a callback to all elements of an array recursively. * * Like `array_walk_recursive` except returns the result as * a new array instead of requiring you pass the array element by reference * and alter it directly. * * @since 8.6.5 * * @param callable $callback - Callback for each element in each level of array. * @param array $to_recurse - Array to recurse. * * @return array */ public function array_map_recursive( callable $callback, array $to_recurse ): array { $output = []; foreach ( $to_recurse as $key => $data ) { if ( \is_array( $data ) ) { $output[ $key ] = $this->array_map_recursive( $callback, $data ); } else { $output[ $key ] = $callback( $data ); } } return $output; } }