Skip to main content

FluentCommunity Theme for all pages (including TutorLMS, + any CPT

This is an update to my previous post about making FluentCommunity header and sidebar consistent on any page and custom post type without changing the layout of the page/post content, and the default FluentCommunity Frame forces page content into its grid which ends up loading Fluents CSS instead of the page/post layout.

With the custom post which I will share below, I have been able to integrate the header and sidebar menu to all pages (like buddyboss header/panel).

FluentCommunity on Elementor Page without content layout changeMedia image

FluentCommunity on TutorLMS Lesson Page
Media image

TutorLMS with Dark ModeMedia image

I will develop this more to make sure the dark mode works with other plugins but this is my current snippet.
(If you want to load only for logged in users you can private message me, but this loads the header and footer for all pages either logged in or not.

Code Snippet

  1. add_filter( 'show_admin_bar', '__return_false' );
  2. Β 
  3. add_action( 'template_redirect', function () {
  4. Β 
  5. Β  Β  if ( is_admin() ) {
  6. Β  Β  Β  Β  return;
  7. Β  Β  }
  8. Β 
  9. Β  Β  if ( ! has_action( 'fluent_community/enqueue_global_assets' ) ) {
  10. Β  Β  Β  Β  return;
  11. Β  Β  }
  12. Β 
  13. Β  Β  do_action( 'fluent_community/enqueue_global_assets', true );
  14. Β 
  15. Β  Β  add_filter( 'body_class', function ( $classes ) {
  16. Β  Β  Β  Β  $classes[] = 'fluent_com_wp_pages';
  17. Β  Β  Β  Β  return $classes;
  18. Β  Β  } );
  19. Β 
  20. Β  Β  add_action( 'wp_head', function () {
  21. Β  Β  Β  Β  echo '<style id="fcom-chrome-layout">
  22. Β  Β  Β  Β  Β  Β html { font-size: 100%; }
  23. Β  Β  Β  Β  Β  Β .feed_layout { --global-vw: var(--fcom-main-content-width, 100vw); }
  24. Β  Β  Β  Β  Β  Β <a data-user_name="media" class="fcom_mention fcom_route" href="https://community.wpmanageninja.com/portal/u/media/">Media Rocketeer</a> (min-width: 1024px) {
  25. Β  Β  Β  Β  Β  Β  Β  Β .feeds_main.fcom_wp_content {
  26. Β  Β  Β  Β  Β  Β  Β  Β  Β  Β padding: 0 !important;
  27. Β  Β  Β  Β  Β  Β  Β  Β }
  28. Β  Β  Β  Β  Β  Β }
  29. Β  Β  Β  Β  Β  Β [data-vertical-spacing*="top"] {
  30. Β  Β  Β  Β  Β  Β  Β  Β padding-top: 0 !important;
  31. Β  Β  Β  Β  Β  Β }
  32. Β  Β  Β  Β  Β  Β .hero-section[data-type=type-1] {
  33. Β  Β  Β  Β  Β  Β  Β  Β margin-bottom: 0 !important;
  34. Β  Β  Β  Β  Β  Β }
  35. Β  Β  Β  Β </style>';
  36. Β 
  37. Β  Β  Β  Β  if ( class_exists( '\FluentCommunity\App\Services\Helper' )
  38. Β  Β  Β  Β  Β  Β  && \FluentCommunity\App\Services\Helper::hasColorScheme() ) {
  39. Β  Β  Β  Β  Β  Β  echo '<script>
  40. Β  Β  Β  Β  Β  Β  Β  Β (function(){
  41. Β  Β  Β  Β  Β  Β  Β  Β  Β  Β var s = localStorage.getItem("fcom_global_storage");
  42. Β  Β  Β  Β  Β  Β  Β  Β  Β  Β if(s){s=JSON.parse(s);if(s&&s.fcom_color_mode==="dark"){
  43. Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β document.documentElement.classList.add("dark");
  44. Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β document.documentElement.setAttribute("data-color-mode","dark");
  45. Β  Β  Β  Β  Β  Β  Β  Β  Β  Β }}
  46. Β  Β  Β  Β  Β  Β  Β  Β })();
  47. Β  Β  Β  Β  Β  Β </script>';
  48. Β  Β  Β  Β  }
  49. Β  Β  }, 5 );
  50. Β 
  51. Β  Β  ob_start();
  52. Β  Β  do_action( 'fluent_community/before_portal_dom' );
  53. Β  Β  $fc_before_portal = ob_get_clean();
  54. Β 
  55. Β  Β  ob_start();
  56. Β  Β  do_action( 'fluent_community/portal_header', 'wp' );
  57. Β  Β  $fc_header = ob_get_clean();
  58. Β 
  59. Β  Β  ob_start();
  60. Β  Β  do_action( 'fluent_community/portal_sidebar', 'wp' );
  61. Β  Β  $fc_sidebar = ob_get_clean();
  62. Β 
  63. Β  Β  ob_start();
  64. Β  Β  do_action( 'fluent_community/template_footer' );
  65. Β  Β  $fc_footer = ob_get_clean();
  66. Β 
  67. Β  Β  $fc_open =
  68. Β  Β  Β  Β  $fc_before_portal
  69. Β  Β  Β  Β  . '<div class="fcom_wrap fcom_wp_frame">'
  70. Β  Β  Β  Β  . Β  '<div class="fluent_com">'
  71. Β  Β  Β  Β  . Β  Β  '<div class="fhr_wrap">'
  72. Β  Β  Β  Β  . Β  Β  Β  $fc_header
  73. Β  Β  Β  Β  . Β  Β  Β  '<div class="fhr_content">'
  74. Β  Β  Β  Β  . Β  Β  Β  Β  '<div class="fhr_home">'
  75. Β  Β  Β  Β  . Β  Β  Β  Β  Β  '<div class="feed_layout">'
  76. Β  Β  Β  Β  . Β  Β  Β  Β  Β  Β  '<div class="spaces">'
  77. Β  Β  Β  Β  . Β  Β  Β  Β  Β  Β  Β  '<div id="fluent_community_sidebar_menu" class="space_contents">'
  78. Β  Β  Β  Β  . Β  Β  Β  Β  Β  Β  Β  Β  $fc_sidebar
  79. Β  Β  Β  Β  . Β  Β  Β  Β  Β  Β  Β  '</div>'
  80. Β  Β  Β  Β  . Β  Β  Β  Β  Β  Β  '</div>'
  81. Β  Β  Β  Β  . Β  Β  Β  Β  Β  Β  '<div class="feeds_main fcom_wp_content fcom_fallback_wp_content">';
  82. Β 
  83. Β  Β  $fc_close =
  84. Β  Β  Β  Β  Β  Β  '</div>'
  85. Β  Β  Β  Β  . '</div>'
  86. Β  Β  Β  Β  . '</div>'
  87. Β  Β  Β  Β  . '</div>'
  88. Β  Β  Β  Β  . '</div>'
  89. Β  Β  Β  Β  . '</div>'
  90. Β  Β  Β  Β  . '</div>'
  91. Β  Β  Β  Β  . $fc_footer;
  92. Β 
  93. Β  Β  ob_start( function ( $html ) use ( $fc_open, $fc_close ) {
  94. Β 
  95. Β  Β  Β  Β  $html = preg_replace_callback(
  96. Β  Β  Β  Β  Β  Β  '/(<body\b[^>]*>)/i',
  97. Β  Β  Β  Β  Β  Β  function ( $match ) use ( $fc_open ) {
  98. Β  Β  Β  Β  Β  Β  Β  Β  return $match[1] . $fc_open;
  99. Β  Β  Β  Β  Β  Β  },
  100. Β  Β  Β  Β  Β  Β  $html,
  101. Β  Β  Β  Β  Β  Β  1
  102. Β  Β  Β  Β  );
  103. Β 
  104. Β  Β  Β  Β  $html = preg_replace_callback(
  105. Β  Β  Β  Β  Β  Β  '/<\/body>/i',
  106. Β  Β  Β  Β  Β  Β  function ( $match ) use ( $fc_close ) {
  107. Β  Β  Β  Β  Β  Β  Β  Β  return $fc_close . $match[0];
  108. Β  Β  Β  Β  Β  Β  },
  109. Β  Β  Β  Β  Β  Β  $html,
  110. Β  Β  Β  Β  Β  Β  1
  111. Β  Β  Β  Β  );
  112. Β 
  113. Β  Β  Β  Β  return $html;
  114. Β  Β  } );
  115. Β 
  116. }, 1 );

Justice Akorede

if you can't copy the code snippet properly, you can get it here
FluentCommunity Header/Sidebar all pages and CPT - Pastebin.com

Bryan William

Will it work on Thrive Apprentice

Justice Akorede

Bryan WilliamΒ haven't tried it, but I believe it should 100%

Bryan William

Justice AkoredeΒ Thrive plugins are very stubborn; they hardly support external integration

Justice Akorede

Bryan WilliamΒ try it out first. if it does not work, delete it afterwards. But like I said, I'm still 100% positive it'll work

Claudy Scoufy

Is it possible to use only the header, without the sidebar?