option('dark_mode_enable') && apply_filters('kadence_dark_mode_enable', true)) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$cookie_name = substr(base_convert(md5(get_site_url()), 16, 32), 0, 12) . '-paletteCookie';
$vars['color_switch_cookie_name'] = $cookie_name;
}
}
return $vars;
});
add_filter('theme_page_templates', [$this, 'registerTemplate'], 9999);
add_filter('template_include', [$this, 'maybeIncludeTemplate'], 99999);
add_action('fluent_community/theme_content', [$this, 'renderWpContent'], 10, 2);
// support for blocksy
add_action('fluent_community/theme_body_atts', function ($themeName) {
if ($themeName == 'blocksy') {
echo blocksy_body_attr(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
});
add_action('fluent_community/template_footer', [$this, 'renderMobileMenu']);
}
public function registerTemplate($templates)
{
if (wp_is_block_theme()) {
return $templates;
}
$templates['fluent-community-frame.php'] = esc_html__('FluentCommunity Frame', 'fluent-community');
$templates['fluent-community-frame-full.php'] = esc_html__('FluentCommunity Full Width Frame', 'fluent-community');
return $templates;
}
public function maybeIncludeTemplate($template)
{
// check if the current theme is block based theme or not
if (wp_is_block_theme()) {
$template_slug = get_page_template_slug();
if ($template_slug != 'wp-custom-template-community-template') {
return $template;
}
return $this->loadBlockBasedTemplateAssets($template);
}
global $post;
if (isset($post->ID)) {
$template_slug = get_page_template_slug($post->ID);
$fluentTemplates = [
'fluent-community-frame.php',
'fluent-community-frame-full.php',
];
$template_slug = apply_filters('fluent_community/template_slug', $template_slug);
if (in_array($template_slug, $fluentTemplates)) {
// Determine the absolute path to the template file within your plugin.
$plugin_template = plugin_dir_path(__FILE__) . 'templates/' . $template_slug;
// If the file exists, return its path.
if (file_exists($plugin_template)) {
$this->loadScriptsAndStyles();
return $plugin_template;
}
}
}
// Otherwise, return the default theme template.
return $template;
}
public function loadBlockBasedTemplateAssets($template)
{
$this->loadScriptsAndStyles();
return $template;
}
public function renderWpContent($themeName, $wrapperType = 'default')
{
switch ($themeName) {
case 'blocksy':
$this->renderBlocksy();
break;
case 'astra':
$this->renderAstra();
break;
case 'kadence':
$this->renderKadence();
break;
case 'generatepress':
$this->renderGeneratePress();
break;
case 'oceanwp':
$this->renderOceanWP();
break;
case 'neve':
$this->renderNeve();
break;
case 'hello-elementor':
get_template_part('template-parts/single');
break;
case 'bricks':
$this->renderBricks($wrapperType);
break;
case 'breakdance-zero':
$this->renderBreakdance();
break;
default:
$this->renderFallBack($wrapperType);
break;
}
}
public function loadScriptsAndStyles()
{
$themeName = get_option('template');
add_filter('body_class', function ($classes) use ($themeName) {
$classes[] = 'fluent_com_wp_pages';
if (
$themeName === 'breakdance-zero' &&
!in_array('breakdance', $classes, true)
) {
$classes[] = 'breakdance';
}
return $classes;
});
add_action('wp_head', function () use ($themeName) {
$isAlignSupportedTheme = in_array($themeName, ['blocksy'], true);
?>