| 1 |
<?php |
| 2 |
/** |
| 3 |
* Master Addons Template with Header/Footer |
| 4 |
*/ |
| 5 |
|
| 6 |
use MasterAddons\Inc\Admin\Theme_Builder\Theme_Builder; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
// Get the template ID that was stored in wp_query |
| 13 |
global $wp_query; |
| 14 |
$template_id = $wp_query->get( 'master_template_id' ); |
| 15 |
|
| 16 |
get_header(); |
| 17 |
|
| 18 |
// Render Master Addons template content |
| 19 |
if ( $template_id && class_exists( 'MasterAddons\Inc\Admin\Theme_Builder\Theme_Builder' ) ) { |
| 20 |
$content = Theme_Builder::render_elementor_content( $template_id ); |
| 21 |
if ( ! empty( $content ) ) { |
| 22 |
echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor rendered HTML content |
| 23 |
} else { |
| 24 |
// Fallback: If no content, show appropriate default content |
| 25 |
if ( is_search() ) { |
| 26 |
?> |
| 27 |
<div class="master-addons-search-results"> |
| 28 |
<h1><?php /* translators: %s: search query term */ printf( esc_html__( 'Search Results for: %s', 'master-addons' ), esc_html( get_search_query() ) ); ?></h1> |
| 29 |
<?php |
| 30 |
if ( have_posts() ) { |
| 31 |
while ( have_posts() ) { |
| 32 |
the_post(); |
| 33 |
the_title( '<h2><a href="' . get_permalink() . '">', '</a></h2>' ); |
| 34 |
the_excerpt(); |
| 35 |
} |
| 36 |
} else { |
| 37 |
echo '<p>' . esc_html__( 'No results found.', 'master-addons' ) . '</p>'; |
| 38 |
} |
| 39 |
?> |
| 40 |
</div> |
| 41 |
<?php |
| 42 |
} elseif ( is_404() ) { |
| 43 |
?> |
| 44 |
<div class="master-addons-404"> |
| 45 |
<h1><?php esc_html_e( '404 - Page Not Found', 'master-addons' ); ?></h1> |
| 46 |
<p><?php esc_html_e( 'The page you are looking for could not be found.', 'master-addons' ); ?></p> |
| 47 |
</div> |
| 48 |
<?php |
| 49 |
} elseif ( is_category() ) { |
| 50 |
?> |
| 51 |
<div class="master-addons-category"> |
| 52 |
<h1><?php single_cat_title(); ?></h1> |
| 53 |
<?php the_archive_description( '<div class="archive-description">', '</div>' ); ?> |
| 54 |
<?php |
| 55 |
if ( have_posts() ) { |
| 56 |
while ( have_posts() ) { |
| 57 |
the_post(); |
| 58 |
the_title( '<h2><a href="' . get_permalink() . '">', '</a></h2>' ); |
| 59 |
the_excerpt(); |
| 60 |
} |
| 61 |
} else { |
| 62 |
echo '<p>' . esc_html__( 'No posts found in this category.', 'master-addons' ) . '</p>'; |
| 63 |
} |
| 64 |
?> |
| 65 |
</div> |
| 66 |
<?php |
| 67 |
} elseif ( is_tag() ) { |
| 68 |
?> |
| 69 |
<div class="master-addons-tag"> |
| 70 |
<h1><?php single_tag_title(); ?></h1> |
| 71 |
<?php the_archive_description( '<div class="archive-description">', '</div>' ); ?> |
| 72 |
<?php |
| 73 |
if ( have_posts() ) { |
| 74 |
while ( have_posts() ) { |
| 75 |
the_post(); |
| 76 |
the_title( '<h2><a href="' . get_permalink() . '">', '</a></h2>' ); |
| 77 |
the_excerpt(); |
| 78 |
} |
| 79 |
} else { |
| 80 |
echo '<p>' . esc_html__( 'No posts found with this tag.', 'master-addons' ) . '</p>'; |
| 81 |
} |
| 82 |
?> |
| 83 |
</div> |
| 84 |
<?php |
| 85 |
} elseif ( is_author() ) { |
| 86 |
?> |
| 87 |
<div class="master-addons-author"> |
| 88 |
<h1><?php /* translators: %s: author display name */ printf( esc_html__( 'Posts by %s', 'master-addons' ), esc_html( get_the_author() ) ); ?></h1> |
| 89 |
<?php the_archive_description( '<div class="author-description">', '</div>' ); ?> |
| 90 |
<?php |
| 91 |
if ( have_posts() ) { |
| 92 |
while ( have_posts() ) { |
| 93 |
the_post(); |
| 94 |
the_title( '<h2><a href="' . get_permalink() . '">', '</a></h2>' ); |
| 95 |
the_excerpt(); |
| 96 |
} |
| 97 |
} else { |
| 98 |
echo '<p>' . esc_html__( 'No posts found by this author.', 'master-addons' ) . '</p>'; |
| 99 |
} |
| 100 |
?> |
| 101 |
</div> |
| 102 |
<?php |
| 103 |
} elseif ( is_date() ) { |
| 104 |
?> |
| 105 |
<div class="master-addons-date"> |
| 106 |
<h1><?php the_archive_title(); ?></h1> |
| 107 |
<?php |
| 108 |
if ( have_posts() ) { |
| 109 |
while ( have_posts() ) { |
| 110 |
the_post(); |
| 111 |
the_title( '<h2><a href="' . get_permalink() . '">', '</a></h2>' ); |
| 112 |
the_excerpt(); |
| 113 |
} |
| 114 |
} else { |
| 115 |
echo '<p>' . esc_html__( 'No posts found for this date.', 'master-addons' ) . '</p>'; |
| 116 |
} |
| 117 |
?> |
| 118 |
</div> |
| 119 |
<?php |
| 120 |
} elseif ( is_archive() ) { |
| 121 |
?> |
| 122 |
<div class="master-addons-archive"> |
| 123 |
<h1><?php the_archive_title(); ?></h1> |
| 124 |
<?php the_archive_description( '<div class="archive-description">', '</div>' ); ?> |
| 125 |
<?php |
| 126 |
if ( have_posts() ) { |
| 127 |
while ( have_posts() ) { |
| 128 |
the_post(); |
| 129 |
the_title( '<h2><a href="' . get_permalink() . '">', '</a></h2>' ); |
| 130 |
the_excerpt(); |
| 131 |
} |
| 132 |
} else { |
| 133 |
echo '<p>' . esc_html__( 'No posts found.', 'master-addons' ) . '</p>'; |
| 134 |
} |
| 135 |
?> |
| 136 |
</div> |
| 137 |
<?php |
| 138 |
} elseif ( is_singular('page') ) { |
| 139 |
?> |
| 140 |
<div class="master-addons-page"> |
| 141 |
<?php |
| 142 |
if ( have_posts() ) { |
| 143 |
while ( have_posts() ) { |
| 144 |
the_post(); |
| 145 |
the_title( '<h1>', '</h1>' ); |
| 146 |
the_content(); |
| 147 |
} |
| 148 |
} |
| 149 |
?> |
| 150 |
</div> |
| 151 |
<?php |
| 152 |
} elseif ( is_singular() ) { |
| 153 |
?> |
| 154 |
<div class="master-addons-single"> |
| 155 |
<?php |
| 156 |
if ( have_posts() ) { |
| 157 |
while ( have_posts() ) { |
| 158 |
the_post(); |
| 159 |
the_title( '<h1>', '</h1>' ); |
| 160 |
the_content(); |
| 161 |
} |
| 162 |
} |
| 163 |
?> |
| 164 |
</div> |
| 165 |
<?php |
| 166 |
} |
| 167 |
} |
| 168 |
} else { |
| 169 |
// Debug: Show what went wrong |
| 170 |
echo '<!-- Master Addons Debug: Template ID = ' . esc_html( $template_id ) . ', Class exists = ' . ( class_exists( 'MasterAddons\Inc\Admin\Theme_Builder\Theme_Builder' ) ? 'yes' : 'no' ) . ' -->'; |
| 171 |
} |
| 172 |
|
| 173 |
get_footer(); |
| 174 |
|