header or footer */ public static function get_slug_map() { /** * Filters the map from template part slugs to locations. * * @param array $map slug => header or footer. */ $map = apply_filters( 'headfoot_block_template_part_slugs', [ 'header' => 'header', 'footer' => 'footer', ] ); return is_array( $map ) ? $map : []; } /** * Swaps a template part for the plugin template that matches the request. * * @param string $html Rendered block. * @param array $block Parsed block. * @return string */ public function replace_part( $html, $block ) { $slug = isset( $block['attrs']['slug'] ) ? (string) $block['attrs']['slug'] : ''; if ( '' === $slug ) { return $html; } $map = self::get_slug_map(); if ( ! isset( $map[ $slug ] ) ) { return $html; } if ( 'header' === $map[ $slug ] ) { // The header area carries the below header section. return headfoot_header_enabled() ? Kses::filter( headfoot_get_header_html() ) : $html . Kses::filter( headfoot_get_below_header_html() ); } if ( 'footer' === $map[ $slug ] ) { // The footer area carries the above footer section. return headfoot_footer_enabled() ? Kses::filter( headfoot_get_footer_html() ) : Kses::filter( headfoot_get_above_footer_html() ) . $html; } return $html; } }