/** * Helper function * Used in output functions to build the markup of the landing sections * @since 1.0 */ function cuttz_landing_section_markup($section_name) { if (!is_singular()) { return; } global $post; $context = cuttz_get_landing_section_context($section_name); $cuttz_ls_section_options = get_post_meta($post->ID, '_cuttz_ls_section_options', 1); if (!$cuttz_ls_section_options) { return; } $section_title = $cuttz_ls_section_options['ls_' . $section_name . '_title']; $section_title = apply_filters('cuttz_landing_section_title', $section_title); $section_content = $cuttz_ls_section_options['ls_' . $section_name . '_content']; $hide_section_desktop = isset($cuttz_ls_section_options['ls_' . $section_name . '_hide_desktop']) ? $cuttz_ls_section_options['ls_' . $section_name . '_hide_desktop'] : false; $hide_section_mobile = isset($cuttz_ls_section_options['ls_' . $section_name . '_hide_mobile']) ? $cuttz_ls_section_options['ls_' . $section_name . '_hide_mobile'] : false; // Hide if hidden and not visiting on mobile if ($hide_section_desktop && !cuttz_is_mobile()) { return; } // Hide if hidden and only on mobile if ($hide_section_mobile && cuttz_is_mobile()) { return; } if ($section_title || $section_content) { ?> <div class = "<?php echo $context; ?> cuttz-landing-section"> <?php cuttz_structural_wrap_open($context); ?> <section class="ls-<?php echo $context; ?> landing-section"> <?php if ($section_title) { echo '<h2 class="landing-section-title">' . $section_title . '</h2>'; } ?> <?php if ($section_content) { echo '<div class="landing-section-content">' . apply_filters('the_content', $section_content) . '</div>'; } ?> </section> <?php cuttz_structural_wrap_close($context); ?> </div> <?php } }
/** * Modifies the front-end as per the landing page settings set in the post editor screen. * @return none * @since 1.0 */ function landing_page_settings() { if (!current_theme_supports('cuttz-landing-page-experience')) { return; } if (cuttz_is_mobile()) { // Bail, if on mobile or if not single post type return; } if (!is_singular() && !cuttz_is_woo_shop()) { return; } if (get_option('show_on_front') === 'page' && is_home()) { $page_id = get_option('page_for_posts'); } else { if (cuttz_is_woo_shop()) { $page_id = wc_get_page_id('shop'); } else { $page_id = get_the_ID(); } } /* Execute all the other hide/show options in Landing Page Experience metabox */ $cuttz_template_options = get_post_meta($page_id, '_cuttz_template_options', 1); $hide_header = isset($cuttz_template_options['hide-header']) ? $cuttz_template_options['hide-header'] : false; $hide_breadcrumbs = isset($cuttz_template_options['hide-breadcrumbs']) ? $cuttz_template_options['hide-breadcrumbs'] : false; $hide_page_title = isset($cuttz_template_options['hide-page-title']) ? $cuttz_template_options['hide-page-title'] : false; $hide_widgets_above_header = isset($cuttz_template_options['hide-widgets-above-header']) ? $cuttz_template_options['hide-widgets-above-header'] : false; $hide_widgets_below_header = isset($cuttz_template_options['hide-widgets-below-header']) ? $cuttz_template_options['hide-widgets-below-header'] : false; $hide_widgets_above_footer = isset($cuttz_template_options['hide-widgets-above-footer']) ? $cuttz_template_options['hide-widgets-above-footer'] : false; $hide_after_entry_widget = isset($cuttz_template_options['hide-after-entry-widget']) ? $cuttz_template_options['hide-after-entry-widget'] : false; $hide_footer_widgets = isset($cuttz_template_options['hide-footer-widgets']) ? $cuttz_template_options['hide-footer-widgets'] : false; $hide_footer = isset($cuttz_template_options['hide-footer']) ? $cuttz_template_options['hide-footer'] : false; if ($hide_header) { remove_action('genesis_header', 'genesis_header_markup_open', 5); remove_action('genesis_header', 'genesis_header_markup_close', 15); remove_action('genesis_header', 'genesis_do_header'); } if ($hide_breadcrumbs) { // Do not remove breadcrumbs as per SEO guidelines; hide it via CSS instead add_filter('body_class', 'cuttz_seo_hide_breadcrumbs'); } if ($hide_page_title) { if (!is_home()) { add_filter('post_class', 'cuttz_hide_title_class'); } if (in_array('woocommerce/woocommerce.php', get_option('active_plugins'))) { if (is_woocommerce() || is_cart() || is_checkout()) { add_filter('woocommerce_show_page_title', '__return_false'); } } } if ($hide_widgets_above_header) { remove_action('genesis_before_header', 'cuttz_sidebar_before_header'); } if ($hide_widgets_below_header) { remove_action('genesis_after_header', 'cuttz_sidebar_after_header'); } if ($hide_widgets_above_footer) { remove_action('genesis_before_footer', 'cuttz_sidebar_above_footer', 5); } if ($hide_after_entry_widget) { remove_theme_support('genesis-after-entry-widget-area'); } if ($hide_footer_widgets) { remove_action('genesis_before_footer', 'genesis_footer_widget_areas'); } if ($hide_footer) { remove_action('genesis_footer', 'cuttz_do_nav_footer', 5); remove_action('genesis_footer', 'genesis_footer_markup_open', 5); remove_action('genesis_footer', 'genesis_footer_markup_close', 5); remove_action('genesis_footer', 'genesis_do_footer'); } }
/** * Used to build/show the mobile template on the front-end * @return type * @since 1.0 */ function cuttz_display_mobile_view() { if (!current_theme_supports('cuttz-mobile-landing-page-experience')) { return; } // Bail if not visiting on mobile if (!cuttz_is_mobile()) { return; } if (is_home()) { $page_id = get_option('page_for_posts'); } else { if (cuttz_is_woo_shop()) { $page_id = wc_get_page_id('shop'); } else { $page_id = get_the_ID(); } } $cuttz_mobile_landing_optionset = get_post_meta($page_id, '_cuttz_mobile_landing_options', 1); $use_global = is_array($cuttz_mobile_landing_optionset) && array_key_exists('mobile_use_global', $cuttz_mobile_landing_optionset) ? $cuttz_mobile_landing_optionset['mobile_use_global'] : true; if ($use_global) { $hide_header = genesis_get_option('mlp_hide_header', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_breadcrumbs = genesis_get_option('mlp_hide_breadcrumbs', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_page_title = genesis_get_option('mlp_hide_page_title', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_widgets_above_header = genesis_get_option('mlp_hide_widgets_above_header', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_widgets_below_header = genesis_get_option('mlp_hide_widgets_below_header', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_widgets_above_footer = genesis_get_option('mlp_hide_widgets_above_footer', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_after_entry_widget = genesis_get_option('mlp_hide_after_entry_widget', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_sidebars = genesis_get_option('mlp_hide_sidebars', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_footer_widgets = genesis_get_option('mlp_hide_fwidgets', CHILD_SETTINGS_FIELD_EXTRAS, false); $hide_footer = genesis_get_option('mlp_hide_footer', CHILD_SETTINGS_FIELD_EXTRAS, false); } else { if (!is_singular() && !cuttz_is_woo_shop()) { return; } $hide_header = isset($cuttz_mobile_landing_optionset['mobile-hide-header']) ? $cuttz_mobile_landing_optionset['mobile-hide-header'] : false; $hide_breadcrumbs = isset($cuttz_mobile_landing_optionset['mobile-hide-breadcrumbs']) ? $cuttz_mobile_landing_optionset['mobile-hide-breadcrumbs'] : false; $hide_page_title = isset($cuttz_mobile_landing_optionset['mobile-hide-page-title']) ? $cuttz_mobile_landing_optionset['mobile-hide-page-title'] : false; $hide_widgets_above_header = isset($cuttz_mobile_landing_optionset['mobile-hide-widgets-above-header']) ? $cuttz_mobile_landing_optionset['mobile-hide-widgets-above-header'] : false; $hide_widgets_below_header = isset($cuttz_mobile_landing_optionset['mobile-hide-widgets-below-header']) ? $cuttz_mobile_landing_optionset['mobile-hide-widgets-below-header'] : false; $hide_widgets_above_footer = isset($cuttz_mobile_landing_optionset['mobile-hide-widgets-above-footer']) ? $cuttz_mobile_landing_optionset['mobile-hide-widgets-above-footer'] : false; $hide_after_entry_widget = isset($cuttz_mobile_landing_optionset['mobile-hide-after-entry-widget']) ? $cuttz_mobile_landing_optionset['mobile-hide-after-entry-widget'] : false; $hide_sidebars = isset($cuttz_mobile_landing_optionset['mobile-hide-sidebars']) ? $cuttz_mobile_landing_optionset['mobile-hide-sidebars'] : false; $hide_footer_widgets = isset($cuttz_mobile_landing_optionset['mobile-hide-footer-widgets']) ? $cuttz_mobile_landing_optionset['mobile-hide-footer-widgets'] : false; $hide_footer = isset($cuttz_mobile_landing_optionset['mobile-hide-footer']) ? $cuttz_mobile_landing_optionset['mobile-hide-footer'] : false; } /** Disable options if selected in the metabox. Hides the relevant page elements if disabled on a page **/ if ($hide_header) { remove_action('genesis_header', 'genesis_header_markup_open', 5); remove_action('genesis_header', 'genesis_header_markup_close', 15); remove_action('genesis_header', 'genesis_do_header'); } if ($hide_breadcrumbs) { // Do not remove breadcrumbs as per SEO guidelines; hide it via CSS instead add_filter('body_class', 'cuttz_seo_hide_breadcrumbs'); } if ($hide_page_title) { if (!is_home()) { add_filter('post_class', 'cuttz_hide_title_class'); } if (in_array('woocommerce/woocommerce.php', get_option('active_plugins'))) { if (is_woocommerce() || is_cart() || is_checkout()) { add_filter('woocommerce_show_page_title', '__return_false'); } } } if ($hide_widgets_above_header) { remove_action('genesis_before_header', 'cuttz_sidebar_before_header'); } if ($hide_widgets_below_header) { remove_action('genesis_after_header', 'cuttz_sidebar_after_header'); } if ($hide_widgets_above_footer) { remove_action('genesis_before_footer', 'cuttz_sidebar_above_footer', 5); } if ($hide_after_entry_widget) { remove_theme_support('genesis-after-entry-widget-area'); } if ($hide_sidebars) { // Force full-width-content layout setting add_filter('genesis_site_layout', 'cuttz_force_full_width_layout'); } if ($hide_footer_widgets) { remove_action('genesis_before_footer', 'genesis_footer_widget_areas'); } if ($hide_footer) { remove_action('genesis_footer', 'cuttz_do_nav_footer', 5); remove_action('genesis_footer', 'genesis_footer_markup_open', 5); remove_action('genesis_footer', 'genesis_footer_markup_close', 5); remove_action('genesis_footer', 'genesis_do_footer'); } }
/** * Inserts certain body classes for styling purposes * @param array $classes * @return array * @since 1.0 */ function cuttz_body_classes($classes) { $classes[] = genesis_get_option('layout', cuttz_get_skin_page_id(), false); $classes[] = genesis_get_option('skin', CHILD_SETTINGS_FIELD_EXTRAS, false); $footer_widgets = genesis_get_option('footer-widgets-count', CHILD_SETTINGS_FIELD_EXTRAS, false); $classes[] = 'footer-' . $footer_widgets; $classes[] = 'cuttz'; if (cuttz_is_mobile()) { $classes[] = 'cuttz-mobile-viewport'; } return $classes; }