You've already forked wp-fedistream
All checks were successful
Create Release Package / build-release (push) Successful in 1m2s
- Added $loading_page_template flag in TemplateLoader - template-wrapper.php sets flag before loading theme header/footer - Shortcodes::render_template() returns early if flag is set - Prevents recursion from theme components, widgets, or other plugins Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Template wrapper for FediStream Twig templates.
|
|
*
|
|
* @package WP_FediStream
|
|
*/
|
|
|
|
// Prevent direct file access.
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
use WP_FediStream\Plugin;
|
|
use WP_FediStream\Frontend\TemplateLoader;
|
|
|
|
// Enter page template loading mode - this completely blocks nested FediStream rendering.
|
|
TemplateLoader::enter_page_template_loading();
|
|
|
|
// Also enter shortcode context to prevent recursive shortcode processing in post content.
|
|
TemplateLoader::enter_shortcode_context();
|
|
|
|
// Get template context.
|
|
$context = TemplateLoader::get_context();
|
|
|
|
// Determine template name.
|
|
$template_name = '';
|
|
|
|
if ( is_singular( 'fedistream_artist' ) ) {
|
|
$template_name = 'single/artist';
|
|
} elseif ( is_singular( 'fedistream_album' ) ) {
|
|
$template_name = 'single/album';
|
|
} elseif ( is_singular( 'fedistream_track' ) ) {
|
|
$template_name = 'single/track';
|
|
} elseif ( is_singular( 'fedistream_playlist' ) ) {
|
|
$template_name = 'single/playlist';
|
|
} elseif ( is_post_type_archive( 'fedistream_artist' ) ) {
|
|
$template_name = 'archive/artist';
|
|
} elseif ( is_post_type_archive( 'fedistream_album' ) ) {
|
|
$template_name = 'archive/album';
|
|
} elseif ( is_post_type_archive( 'fedistream_track' ) ) {
|
|
$template_name = 'archive/track';
|
|
} elseif ( is_post_type_archive( 'fedistream_playlist' ) ) {
|
|
$template_name = 'archive/playlist';
|
|
} elseif ( is_tax( 'fedistream_genre' ) ) {
|
|
$template_name = 'archive/taxonomy';
|
|
$context['taxonomy_name'] = __( 'Genre', 'wp-fedistream' );
|
|
} elseif ( is_tax( 'fedistream_mood' ) ) {
|
|
$template_name = 'archive/taxonomy';
|
|
$context['taxonomy_name'] = __( 'Mood', 'wp-fedistream' );
|
|
}
|
|
|
|
// Get the plugin instance.
|
|
$plugin = Plugin::get_instance();
|
|
|
|
get_header();
|
|
?>
|
|
|
|
<main id="fedistream-content" class="fedistream-main">
|
|
<?php
|
|
if ( $template_name ) {
|
|
try {
|
|
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
echo $plugin->render( $template_name, $context );
|
|
} catch ( \Exception $e ) {
|
|
if ( WP_DEBUG ) {
|
|
echo '<div class="fedistream-error">';
|
|
echo '<p>' . esc_html__( 'Template Error:', 'wp-fedistream' ) . ' ' . esc_html( $e->getMessage() ) . '</p>';
|
|
echo '</div>';
|
|
}
|
|
}
|
|
} else {
|
|
// Fallback to default content.
|
|
if ( have_posts() ) {
|
|
while ( have_posts() ) {
|
|
the_post();
|
|
the_content();
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
</main>
|
|
|
|
<?php
|
|
// Exit shortcode context and page template loading mode.
|
|
TemplateLoader::exit_shortcode_context();
|
|
TemplateLoader::exit_page_template_loading();
|
|
|
|
get_footer();
|