__( 'ReleaseCart', 'releasecart' ) ) ); $files = glob( $this->patternsBasePath() . '*.php' ); foreach ( is_array( $files ) ? $files : array() as $file ) { $properties = include $file; if ( ! is_array( $properties ) || '' === (string) ( $properties['title'] ?? '' ) || '' === (string) ( $properties['content'] ?? '' ) ) { continue; } $properties['categories'] = array_values( array_unique( array_merge( (array) ( $properties['categories'] ?? array() ), array( Registrar::CATEGORY_SLUG ) ) ) ); register_block_pattern( 'releasecart/' . basename( $file, '.php' ), $properties ); } } /** * Get the pattern directory. * * @return string */ protected function patternsBasePath(): string { return RELEASECART_PATH . 'patterns/'; } }