/** * Custom CSS * * @since 1.0 */ function dslc_custom_css() { if (!is_singular() && !is_archive() && !is_author() && !is_search() && !is_404() && !is_home()) { return; } global $dslc_active; global $dslc_css_style; global $content_width; global $dslc_googlefonts_array; global $dslc_all_googlefonts_array; global $dslc_post_types; $composer_code = ''; $template_code = ''; $lc_width = dslc_get_option('lc_max_width', 'dslc_plugin_options'); if (empty($lc_width)) { $lc_width = $content_width . 'px'; } else { if (strpos($lc_width, 'px') === false && strpos($lc_width, '%') === false) { $lc_width = $lc_width . 'px'; } } // Filter $lc_width ( for devs ) $lc_width = apply_filters('dslc_content_width', $lc_width); $template_ID = false; // If single, load template if (is_singular($dslc_post_types)) { $template_ID = dslc_st_get_template_ID(get_the_ID()); } // If archive, load template if (is_archive() && !is_author() && !is_search()) { $template_ID = dslc_get_option(get_post_type(), 'dslc_plugin_options_archives'); } if (is_author()) { $template_ID = dslc_get_option('author', 'dslc_plugin_options_archives'); } if (is_search()) { $template_ID = dslc_get_option('search_results', 'dslc_plugin_options_archives'); } if (is_404()) { $template_ID = dslc_get_option('404_page', 'dslc_plugin_options_archives'); } // Header/Footer if ($template_ID) { $header_footer = dslc_hf_get_ID($template_ID); } else { if (is_singular($dslc_post_types)) { $template_ID = dslc_st_get_template_ID(get_the_ID()); $header_footer = dslc_hf_get_ID($template_ID); } else { $header_footer = dslc_hf_get_ID(get_the_ID()); } } // Header if ($header_footer['header']) { $header_code = get_post_meta($header_footer['header'], 'dslc_code', true); $composer_code .= $header_code; } // Footer if ($header_footer['footer']) { $footer_code = get_post_meta($header_footer['footer'], 'dslc_code', true); $composer_code .= $footer_code; } // Template content if ($template_ID) { $composer_code .= get_post_meta($template_ID, 'dslc_code', true); } // Post/Page content $post_id = get_the_ID(); $composer_code .= get_post_meta($post_id, 'dslc_code', true); echo '<style type="text/css">'; // If composer not used on this page stop execution if ($composer_code) { // Replace shortcode names $composer_code = str_replace('dslc_modules_section', 'dslc_modules_section_gen_css', $composer_code); $composer_code = str_replace('dslc_modules_area', 'dslc_modules_area_gen_css', $composer_code); $composer_code = str_replace('[dslc_module]', '[dslc_module_gen_css]', $composer_code); $composer_code = str_replace('[dslc_module ', '[dslc_module_gen_css ', $composer_code); $composer_code = str_replace('[/dslc_module]', '[/dslc_module_gen_css]', $composer_code); // Do CSS shortcode do_shortcode($composer_code); // Google Fonts Import $gfonts_output_subsets = ''; $gfonts_subsets_arr = dslc_get_option('lc_gfont_subsets', 'dslc_plugin_options_performance'); if (!$gfonts_subsets_arr) { $gfonts_subsets_arr = array('latin', 'latin-ext', 'cyrillic', 'cyrillic-ext'); } foreach ($gfonts_subsets_arr as $gfonts_subset) { if ($gfonts_output_subsets == '') { $gfonts_output_subsets .= $gfonts_subset; } else { $gfonts_output_subsets .= ',' . $gfonts_subset; } } if (!defined('DS_LIVE_COMPOSER_GFONTS') || DS_LIVE_COMPOSER_GFONTS) { $gfonts_output_prepend = '@import url("//fonts.googleapis.com/css?family='; $gfonts_output_append = '&subset=' . $gfonts_output_subsets . '"); '; $gfonts_ouput_inner = ''; foreach ($dslc_googlefonts_array as $gfont) { if (in_array($gfont, $dslc_all_googlefonts_array)) { $gfont = str_replace(' ', '+', $gfont); if ($gfont != '') { if ($gfonts_ouput_inner == '') { $gfonts_ouput_inner .= $gfont . ':100,200,300,400,500,600,700,800,900'; } else { $gfonts_ouput_inner .= '|' . $gfont . ':100,200,300,400,500,600,700,800,900'; } } } } $gfonts_output = $gfonts_output_prepend . $gfonts_ouput_inner . $gfonts_output_append; if ($gfonts_ouput_inner != '') { echo $gfonts_output; } } } // Wrapper width echo '.dslc-modules-section-wrapper, .dslca-add-modules-section { width : ' . $lc_width . '; } '; // Initial ( default ) row CSS echo dslc_row_get_initial_style(); // Echo CSS style if (!$dslc_active && $composer_code) { echo $dslc_css_style; } echo '</style>'; }
/** * Add custom classes to the body tag * * @since 1.0 */ function dslc_body_class($classes) { global $dslc_post_types; $proceed = false; $has_lc_content = false; $has_lc_header_footer = false; if (is_archive() && !is_author() && !is_search()) { $template_id = dslc_get_option(get_post_type(), 'dslc_plugin_options_archives'); if ($template_id) { $proceed = true; $has_lc_content = true; } } if (is_author()) { $template_id = dslc_get_option('author', 'dslc_plugin_options_archives'); if ($template_id) { $proceed = true; $has_lc_content = true; } } if (is_search()) { $template_id = dslc_get_option('search_results', 'dslc_plugin_options_archives'); if ($template_id) { $proceed = true; $has_lc_content = true; } } if (is_singular()) { $proceed = true; } if (false === $proceed) { return $classes; } // If page in LC mode, force the class? if (isset($_GET['dslc'])) { $has_lc_content = true; } // Still nothing, let's check if there's real LC content on the page. if (!$has_lc_content) { // Get the dslc_code custom field. $dslc_code = get_post_meta(get_the_ID(), 'dslc_code', true); // If there is LC content, allow the class? if ($dslc_code) { $has_lc_content = true; } } // Still nothing, let's check if it's a post and has an LC template. if (!$has_lc_content && is_singular($dslc_post_types)) { // Get the ID of the template. $template_id = dslc_st_get_template_ID(get_the_ID()); // If template exists, allow the class. if ($template_id) { $has_lc_content = true; } } // Let's check if it has LC powered header/footer. $header_footer = dslc_hf_get_ID(get_the_ID()); if ($header_footer['header'] || $header_footer['footer']) { $has_lc_header_footer = true; } // If has LC content append class. if ($has_lc_content || $has_lc_header_footer) { $classes[] = 'dslc-page'; } if ($has_lc_content) { $classes[] = 'dslc-page-has-content'; } if ($has_lc_header_footer) { $classes[] = 'dslc-page-has-hf'; } // If responsive disabled append class. if (defined('DS_LIVE_COMPOSER_RESPONSIVE') && !DS_LIVE_COMPOSER_RESPONSIVE) { $classes[] = 'dslc-res-disabled'; } // Return the modified array. return $classes; }
/** * Get the footer output code * * @since 1.0.2 * * @param int $post_ID ID of the post/page. Default false. * @return string The HTML ouput of the footer for a defined post/page */ function dslc_hf_get_footer($post_ID = false) { // Var defaults $append = ''; $wrapper_end = ''; // Wrap if header handled by theme if (defined('DS_LIVE_COMPOSER_HF_AUTO') && !DS_LIVE_COMPOSER_HF_AUTO) { $wrapper_end = '</div>'; } // If the page displayed is header/footer, do not repeat if (is_singular('dslc_hf')) { return $wrapper_end; } // Get header/footer ID associated with the post $header_footer = dslc_hf_get_ID($post_ID); // If there is a footer applied if ($header_footer['footer'] && is_numeric($header_footer['footer'])) { // Get the footer LC code $footer_code = get_post_meta($header_footer['footer'], 'dslc_code', true); // If the "position" option value exists if (get_post_meta($header_footer['footer'], 'dslc_hf_position', true)) { // Set the "position" option value to the one from the settings $footer_position = get_post_meta($header_footer['footer'], 'dslc_hf_position', true); } else { // Set the "position" option value to default "relative" $footer_position = 'relative'; } // If editor active? Add a link to the footer editing. if (dslc_is_editor_active('access')) { $footer_link = DSLC_EditorInterface::get_editor_link($header_footer['footer']); // Set the HTML for the edit overlay. $append = '<div class="dslc-hf-block-overlay"><a target="_blank" href="' . $footer_link . '" class="dslc-hf-block-overlay-button dslca-link">' . __('Edit Footer', 'live-composer-page-builder') . '</a></div>'; } // Add the header code to the variable holder. return '<div id="dslc-footer" class="dslc-footer-pos-' . $footer_position . '">' . do_shortcode($footer_code) . $append . '</div>' . $wrapper_end; // If no header applied } else { return '' . $wrapper_end; } }