File: /var/www/laracopilot.stgviitor.com/laracopilot-wp/wp-content/themes/laracopilot-v2/page.php
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package LaraCopilot_V2
*/
get_header();
?>
<main id="primary" class="site-main">
<?php
while (have_posts()) :
the_post();
// Detect if this is a LaraCopilot Marketplace page
$content = get_the_content();
$is_lcm_page = false;
$lcm_shortcodes = [
'lcm_registration_form',
'lcm_directory',
'lcm_profile',
'lcm_dashboard',
'lcm_enquiry_form'
];
foreach ($lcm_shortcodes as $shortcode) {
if (has_shortcode($content, $shortcode)) {
$is_lcm_page = true;
break;
}
}
// Also check against plugin settings for robustness
$lcm_settings = get_option('lcm_settings', []);
$lcm_pages = [
(int) ($lcm_settings['marketplace_page_id'] ?? 0),
(int) ($lcm_settings['dashboard_page_id'] ?? 0)
];
if (in_array(get_the_ID(), $lcm_pages, true)) {
$is_lcm_page = true;
}
// CMS Page Detection
$cms_slugs = array('privacy-policy', 'terms', 'security', 'cookie-policy');
$is_cms_page = is_page($cms_slugs);
if ($is_lcm_page) {
// Render marketplace content directly for a clean, full-width layout
echo '<div class="lcm-clean-page-wrapper">';
the_content();
echo '</div>';
} elseif ($is_cms_page) {
// Professional CMS layout
echo '<div class="cms-container">';
the_content();
echo '</div>';
} else {
// Standard theme rendering
get_template_part('template-parts/content', 'page');
}
// If comments are open or we have at least one comment, load up the comment template.
if (! $is_lcm_page && (comments_open() || get_comments_number())) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
<?php
if ((! isset($is_lcm_page) || ! $is_lcm_page) && (! isset($is_cms_page) || ! $is_cms_page)) {
get_sidebar();
}
get_footer();