swallow( 'header', $name, $args ); } /** * Prints the plugin footer and swallows the theme footer. * * @param string|null $name Footer name from get_footer(). * @param array $args Arguments from get_footer(). * @return void */ public function override_footer( $name = null, $args = [] ) { if ( ! headfoot_footer_enabled() ) { return; } if ( ! is_array( $args ) ) { $args = []; } require HEADFOOT_DIR . 'templates/theme-footer.php'; // The plugin template already ran this hook. remove_all_actions( 'wp_footer' ); $this->swallow( 'footer', $name, $args ); } /** * Loads the theme file once with the same lookup that WordPress uses and discards its output. * * @param string $part header or footer. * @param string|null $name Template name. * @param array $args Template arguments. * @return void */ private function swallow( $part, $name, $args ) { $templates = []; $name = (string) $name; if ( '' !== $name ) { $templates[] = "{$part}-{$name}.php"; } $templates[] = "{$part}.php"; ob_start(); locate_template( $templates, true, true, $args ); ob_end_clean(); } }