/** * Get post specific CSS styles and paste it to head. * * @since 4.0.0 */ function cherry_post_inline_styles() { $post_id = get_queried_object_id(); $post_type = get_post_type($post_id); if (!$post_type || !post_type_supports($post_type, 'cherry-post-style')) { return; } if (wp_style_is(CHERRY_DYNAMIC_CSS_HANDLE, 'enqueued')) { $handle = CHERRY_DYNAMIC_CSS_HANDLE; } else { $cherry_styles = cherry_get_styles(); $handle = isset($cherry_styles['style']) ? $cherry_styles['style']['handle'] : false; } if (!$handle) { return; } $header_bg = cherry_current_page()->get_property('background', 'header'); if (!$header_bg) { return; } $custom_bg = cherry_get_background_css('.site-header', $header_bg); /** * Filter a custom background style. * * @since 4.0.0 * @param string $custom_bg Background style. * @param int $post_id The post ID. */ $custom_bg = apply_filters('cherry_post_inline_styles', $custom_bg, $post_id); if (!$custom_bg) { return; } wp_add_inline_style($handle, sanitize_text_field($custom_bg)); }
/** * Display a site content wrapper. * * @since 4.0.0 * @return string HTML-markup for content. */ function cherry_content_wrap() { if (!did_action('cherry_content')) { $wrapper = ''; if (false !== cherry_display_sidebar(apply_filters('cherry_get_main_sidebar', 'sidebar-main'))) { $layout = cherry_current_page()->get_property('layout'); $class = sanitize_html_class($layout . '-wrapper'); /** * Filter a CSS-class for site content wrapper. * * @since 4.0.0 * @param $class CSS-class for content wrapper. */ $wrapper_class = apply_filters('cherry_content_sidebar_wrapper_class', $class); $wrapper = sprintf('<div class="%s">', $wrapper_class); } printf('%1$s<div id="primary" class="content-area"><main %2$s>', $wrapper, cherry_get_attr('main')); } else { echo '</main></div>'; } }
/** * Get shop columns number * * @since 1.0.0 * @param int $cols initiall columns number. * @return int */ public function get_shop_columns($cols = 4) { if (null !== $this->loop_cols) { return $this->loop_cols; } $layout = cherry_current_page()->get_property('layout'); $s = 'sidebar'; $c = 'content'; if (in_array($layout, array("{$s}-{$c}", "{$c}-{$s}"))) { $this->loop_cols = 3; return $this->loop_cols; } if (in_array($layout, array("{$s}-{$c}-{$s}", "{$s}-{$s}-{$c}", "{$c}-{$s}-{$s}"))) { $this->loop_cols = 2; return $this->loop_cols; } $this->loop_cols = $cols; return $this->loop_cols; }
function cherry_hide_sidebar($display, $id) { if (did_action('cherry_footer')) { return $display; } $sidebar_main = apply_filters('cherry_get_main_sidebar', 'sidebar-main'); $sidebar_secondary = apply_filters('cherry_get_secondary_sidebar', 'sidebar-secondary'); $allowed_sidebars = array($sidebar_main, $sidebar_secondary); $allowed_sidebars = apply_filters('cherry_hide_allowed_sidebars', $allowed_sidebars, $display, $id); if (!in_array($id, $allowed_sidebars)) { return $display; } $layout = cherry_current_page()->get_property('layout'); if ('no-sidebar' == $layout) { return false; } if ($sidebar_main == $sidebar_secondary) { static $cherry_sidebar_counter = 0; } if (('sidebar-content' == $layout || 'content-sidebar' == $layout) && apply_filters('cherry_get_secondary_sidebar', 'sidebar-secondary') == $id) { if (isset($cherry_sidebar_counter) && !$cherry_sidebar_counter) { $cherry_sidebar_counter++; return $display; } return false; } return $display; }