/** * Adds custom classes to the array of body classes. * * @since Fruitful theme 1.0 */ function fruitful_body_classes($classes) { // Adds a class of group-blog to blogs with more than 1 published author if (is_multi_author()) { $classes[] = 'group-blog'; } if (class_exists('Woocommerce')) { if (is_shop()) { $classes[] = 'shop-page '; } } $theme_options = fruitful_get_theme_options(); if (isset($theme_options['responsive']) && $theme_options['responsive'] == 'on') { $classes[] = 'responsive'; } return $classes; }
function fruitful_get_container_background_color() { $options = fruitful_get_theme_options(); ?> <fieldset> <input type="text" id="container_bg_color" class="colorPicker" name="fruitful_theme_options[container_bg_color]" value="<?php echo esc_attr($options['container_bg_color']); ?> " data-default-color="#ffffff" /> </fieldset> <?php }
function fruitful_get_content_with_custom_sidebar($curr_sidebar = null) { global $post; function get_content_part() { global $post; ?> <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php /* Start the Loop */ $page_on_front = get_option('page_on_front'); $page_for_posts = get_option('page_for_posts'); if (is_page() && !empty($page_on_front) && !empty($page_for_posts) && $page_on_front == $page_for_posts) { echo '<div class="alert alert-danger"><strong>' . __("Front page displays Error.", 'fruitful') . '</strong> ' . __('Select different pages!', 'fruitful') . '</div>'; } else { if (!is_archive() && !is_search() && !is_404()) { if (is_home()) { if (have_posts()) { /* The loop */ while (have_posts()) { the_post(); do_action('before_post_content_loop'); get_template_part('content', get_post_format()); do_action('after_post_content_loop'); } fruitful_content_nav('nav-below'); } else { get_template_part('no-results', 'index'); } } else { if (have_posts()) { while (have_posts()) { the_post(); if (is_page() && !is_front_page() && !is_home()) { get_template_part('content', 'page'); if (fruitful_state_page_comment()) { comments_template('', true); } } else { if (is_single()) { get_template_part('content', get_post_format()); fruitful_content_nav('nav-below'); if (fruitful_state_post_comment()) { if (comments_open() || '0' != get_comments_number()) { comments_template(); } } } else { if (is_front_page()) { get_template_part('content', 'page'); } } } } } } } else { ?> <section id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php if (have_posts()) { ?> <header class="page-header"> <h1 class="page-title"> <?php if (is_archive()) { if (is_category()) { printf(__('Category Archives: %s', 'fruitful'), '<span>' . single_cat_title('', false) . '</span>'); } elseif (is_tag()) { printf(__('Tag Archives: %s', 'fruitful'), '<span>' . single_tag_title('', false) . '</span>'); } elseif (is_author()) { the_post(); printf(__('Author Archives: %s', 'fruitful'), '<span class="vcard"><a class="url fn n" href="' . get_author_posts_url(get_the_author_meta("ID")) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a></span>'); rewind_posts(); } elseif (is_day()) { printf(__('Daily Archives: %s', 'fruitful'), '<span>' . get_the_date() . '</span>'); } elseif (is_month()) { printf(__('Monthly Archives: %s', 'fruitful'), '<span>' . get_the_date('F Y') . '</span>'); } elseif (is_year()) { printf(__('Yearly Archives: %s', 'fruitful'), '<span>' . get_the_date('Y') . '</span>'); } else { _e('Archives', 'fruitful'); } } if (is_search()) { printf(__('Search Results for: %s', 'fruitful'), '<span>' . get_search_query() . '</span>'); } ?> </h1> <?php if (is_category()) { $category_description = category_description(); if (!empty($category_description)) { echo apply_filters('category_archive_meta', '<div class="taxonomy-description">' . $category_description . '</div>'); } } elseif (is_tag()) { $tag_description = tag_description(); if (!empty($tag_description)) { echo apply_filters('tag_archive_meta', '<div class="taxonomy-description">' . $tag_description . '</div>'); } } ?> </header><!-- .page-header --> <?php /* Start the Loop */ while (have_posts()) { the_post(); do_action('before_post_content_loop'); get_template_part('content', get_post_format()); do_action('after_post_content_loop'); } fruitful_content_nav('nav-below'); } else { if (is_404()) { get_template_part('content', '404'); } else { get_template_part('no-results', 'archive'); } } ?> </div><!-- #content .site-content --> </section><!-- #primary .content-area --> <?php } } ?> </div> </div> <?php } function get_html_custom_post_template($content_class, $sidebar_class, $curr_sidebar, $content_type) { global $post; $is_sidebar = true; $is_sidebar = fruitful_is_woo_sidebar(); if ($content_type == 0) { ?> <?php get_content_part(); ?> <?php } else { if ($content_type == 1) { ?> <div class="eleven columns <?php echo $content_class; ?> "><?php get_content_part(); ?> </div> <?php if ($is_sidebar && is_page()) { ?> <div class="five columns <?php echo $sidebar_class; ?> "> <?php get_sidebar($curr_sidebar); ?> </div> <?php } else { ?> <div class="five columns <?php echo $sidebar_class; ?> "> <?php get_sidebar($curr_sidebar); ?> </div> <?php } ?> <?php } else { if ($content_type == 2) { ?> <div class="eleven columns <?php echo $content_class; ?> "> <?php get_content_part(); ?> </div> <?php if ($is_sidebar && is_page()) { ?> <div class="five columns <?php echo $sidebar_class; ?> "> <?php get_sidebar($curr_sidebar); ?> </div> <?php } else { ?> <div class="five columns <?php echo $sidebar_class; ?> "> <?php get_sidebar($curr_sidebar); ?> </div> <?php } ?> <?php } } } } $curr_template = ''; $options = fruitful_get_theme_options(); if (fruitful_is_latest_posts_page()) { $curr_template = esc_attr($options['latest_posts_templ']); } elseif (is_archive()) { if (is_tag()) { $curr_template = esc_attr($options['layout_tag_templ']); } elseif (is_category()) { $curr_template = esc_attr($options['layout_cat_templ']); } elseif (is_author()) { $curr_template = esc_attr($options['layout_author_templ']); } else { $curr_template = esc_attr($options['layout_archive_templ']); } } elseif (is_404()) { $curr_template = esc_attr($options['layout_404_templ']); } elseif (is_search()) { $curr_template = esc_attr($options['layout_search_templ']); } else { $default_blog_template = get_post_meta(get_option('page_for_posts', true), '_fruitful_page_layout', true) ? get_post_meta(get_option('page_for_posts', true), '_fruitful_page_layout', true) - 1 : 1; $default_post_template = get_post_meta($post->ID, '_fruitful_page_layout', true) ? get_post_meta($post->ID, '_fruitful_page_layout', true) - 1 : esc_attr($options['layout_single_templ']); $default_page_template = get_post_meta($post->ID, '_fruitful_page_layout', true) ? get_post_meta($post->ID, '_fruitful_page_layout', true) - 1 : esc_attr($options['layout_page_templ']); if (!fruitful_is_blog()) { if (is_archive()) { $curr_template = $default_blog_template; } else { if (class_exists('BuddyPress')) { $bp_pages = get_option('bp-pages'); //possible pages - activity, members, register, activate foreach ($bp_pages as $bp_page_slug => $bp_page_id) { if (bp_is_current_component($bp_page_slug)) { $curr_template = get_post_meta($bp_page_id, '_fruitful_page_layout', true) ? get_post_meta($bp_page_id, '_fruitful_page_layout', true) - 1 : 0; } else { $curr_template = $default_page_template; } } } else { $curr_template = $default_page_template; } } } else { if (is_single()) { $curr_template = $default_post_template; } else { $curr_template = $default_blog_template; } } } if ($curr_template == 0) { get_html_custom_post_template('alpha', 'omega', $curr_sidebar, $curr_template); } else { if ($curr_template == 1) { get_html_custom_post_template('alpha', 'omega', $curr_sidebar, $curr_template); } else { if ($curr_template == 2) { get_html_custom_post_template('omega', 'alpha', $curr_sidebar, $curr_template); } else { if (is_home()) { $curr_template = 1; } get_html_custom_post_template('alpha', 'omega', $curr_sidebar, $curr_template); } } } }
public function display_field($data = array(), $echo = true) { $field = $data; $option_name = $data = ''; $id = isset($field['id']) ? $field['id'] : ''; $type = isset($field['type']) ? $field['type'] : ''; $option_name = $id; $option = fruitful_get_theme_options(); if (isset($option)) { $data = $option[$option_name]; } if ($data == null && isset($field['default'])) { $data = $field['default']; } elseif ($data === null) { $data = ''; } $html = ''; switch ($type) { case 'text': if (!empty($field['box-title'])) { $html .= '<h4>' . esc_attr($field['box-title']) . '</h4>'; } $html .= '<input class="text-input" id="' . esc_attr($field['id']) . '" type="text" name="' . $this->args['opt_name'] . '[' . esc_attr($field['id']) . ']" value="' . $data . '" />' . "\n"; break; case 'textarea': if (!empty($field['box-title'])) { $html .= '<h4>' . esc_attr($field['box-title']) . '</h4>'; } $html .= '<textarea class="large-text" id="' . esc_attr($field['id']) . '" rows="20" cols="50" name="' . $this->args['opt_name'] . '[' . esc_attr($field['id']) . ']" >' . stripslashes($data) . '</textarea>' . "\n"; break; case 'checkbox': if (!empty($field['box-title'])) { $html .= '<h4>' . esc_attr($field['box-title']) . '</h4>'; } $html .= '<label for="' . esc_attr($field['id']) . '"><input type="checkbox" id="' . esc_attr($field['id']) . '" name="' . $this->args['opt_name'] . '[' . esc_attr($field['id']) . ']" ' . checked('on', $data, false) . '/> ' . esc_attr($field['description']) . '</label>'; break; case 'select': $class = ''; if (!empty($field['box-title'])) { $html .= '<h4>' . esc_attr($field['box-title']) . '</h4>'; } if (!empty($field['class'])) { $class = esc_attr($field['class']); } $html .= '<select class="' . $class . '" name="' . $this->args['opt_name'] . '[' . esc_attr($field['id']) . ']" id="' . esc_attr($field['id']) . '">'; foreach ($field['options'] as $k => $v) { $selected = false; if ($k == $data) { $selected = true; } $html .= '<option ' . selected($selected, true, false) . ' value="' . esc_attr($k) . '">' . esc_attr($v) . '</option>'; } $html .= '</select> '; break; case 'button': $html .= '<input class="' . esc_attr($field['class']) . '" name="' . esc_attr($field['id']) . '" value="' . esc_attr($field['default']) . '" id="' . esc_attr($field['id']) . '" />'; break; case 'image': $html .= '<div class="box-image">'; if ($data != '') { $html .= '<div class="img-container">'; $image_attributes = wp_get_attachment_image_src($data, 'full'); if (!empty($image_attributes)) { $image_link = esc_url_raw($image_attributes[0]); } else { $image_link = $data; } $html .= '<img src="' . $image_link . '" alt="" />'; $html .= '</div> '; } $html .= '<input class="of-input" name="' . $this->args['opt_name'] . '[' . esc_attr($field['id']) . ']" id="' . esc_attr($field['id']) . '_upload" type="hidden" value="' . $data . '" />'; $html .= '<div class="upload_button_div">'; $image_type = isset($field['imagetype']) ? 'data-imagetype="' . $field['imagetype'] . '"' : ''; $html .= '<span ' . $image_type . ' class="button upload_btn" id="' . esc_attr($field['id']) . '">' . __('Upload Image', 'fruitful') . '</span>'; if (!empty($data)) { $none = ''; } else { $none = 'none'; } $html .= '<span class="button reset_btn ' . $none . '" id="reset_' . esc_attr($field['id']) . '" title="' . esc_attr($field['id']) . '">' . __('Remove', 'fruitful') . '</span>'; $html .= '</div>'; $html .= '</div>'; break; case 'color': if (!empty($field['box-title'])) { $html .= '<h4>' . esc_attr($field['box-title']) . '</h4>'; } $html .= '<input type="text" id="' . esc_attr($field['id']) . '" class="colorPicker" name="' . $this->args['opt_name'] . '[' . esc_attr($field['id']) . ']" value="' . esc_attr($data) . '" data-default-color="' . $field['default'] . '"/>'; break; case 'font': $html .= '<div class="text_fonts">'; $html .= '<div id="menu_sample_font" class="sample_text">' . __('Sample Font', 'fruitful') . '</div>'; $html .= '<select class="select-fonts" name="' . $this->args['opt_name'] . '[' . esc_attr($field['id']) . ']" id="options-' . esc_attr($field['id']) . '">'; foreach ($field['options'] as $k => $v) { $selected = false; if ($k == $data) { $selected = true; } $html .= '<option ' . selected($selected, true, false) . ' value="' . esc_attr($k) . '">' . esc_attr($v) . '</option>'; } $html .= '</select> '; $html .= '</div>'; break; case 'slides': fruitful_slider_images(); break; } if (!$echo) { return $html; } echo $html; }
<!--[if lt IE 9]><script src="<?php echo get_template_directory_uri(); ?> /js/html5.js" type="text/javascript"></script><![endif]--> <?php wp_head(); ?> </head> <body <?php body_class(); ?> > <div id="page-header" class="hfeed site"> <?php $theme_options = fruitful_get_theme_options(); $logo_pos = $menu_pos = ''; if (isset($theme_options['logo_position'])) { $logo_pos = esc_attr($theme_options['logo_position']); } if (isset($theme_options['menu_position'])) { $menu_pos = esc_attr($theme_options['menu_position']); } $logo_pos_class = fruitful_get_class_pos($logo_pos); $menu_pos_class = fruitful_get_class_pos($menu_pos); $responsive_menu_type = esc_attr($theme_options['menu_type_responsive']); $is_responsive = isset($theme_options['responsive']) && $theme_options['responsive'] == 'on'; if (isset($theme_options['menu_icon_color'])) { $menu_icon_color = $theme_options['menu_icon_color']; } if (!$is_responsive || $is_responsive && $responsive_menu_type == 'inside_content') {
public function register_settings($wp_customize) { global $fruitful_theme_options; $opt_name = $fruitful_theme_options->args['opt_name']; $theme_options = fruitful_get_theme_options(); $height = isset($theme_options['header_height']) ? $theme_options['header_height'] : 80; $wp_customize->add_panel($opt_name, array('priority' => 10, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => 'Fruitful Theme Options', 'description' => '')); $type = 'option'; if (is_array($this->sections)) { foreach ($this->sections as $option) { $priority = isset($option['priority']) ? $option['priority'] : 10; $id = isset($option['id']) ? $option['id'] : ''; $title = isset($option['title']) ? esc_attr($option['title']) : ''; $description = isset($option['description']) ? esc_attr($option['description']) : ''; $wp_customize->add_section(esc_attr($id), array('priority' => $priority, 'title' => $title, 'description' => $description, 'panel' => $opt_name)); foreach ($option['fields'] as $field) { $f_id = isset($field['id']) ? esc_attr($field['id']) : ''; $f_default = isset($field['default']) ? esc_attr($field['default']) : ''; $f_label = isset($field['label']) ? esc_attr($field['label']) : ''; $f_description = isset($field['description']) ? esc_attr($field['description']) : ''; $f_info = isset($field['info']) ? esc_attr($field['info']) : ''; $f_type = isset($field['type']) ? esc_attr($field['type']) : ''; $f_choices = isset($field['options']) ? $field['options'] : array(); $section = isset($option['id']) ? esc_attr($option['id']) : ''; if ($f_type == 'checkbox') { $sanitize = 'fruitful_theme_sanitize_checkbox'; } else { $sanitize = ''; } if (!empty($field['fields'])) { foreach ($field['fields'] as $key => $group) { $g_default = isset($group['default']) ? esc_attr($group['default']) : ''; $g_label = isset($group['label']) ? esc_attr($group['label']) : ''; $g_description = isset($group['description']) ? esc_attr($group['description']) : ''; $g_info = isset($group['info']) ? esc_attr($group['info']) : ''; $g_boxtitle = isset($group['box-title']) ? esc_attr($group['box-title']) : ''; $g_type = isset($group['type']) ? esc_attr($group['type']) : ''; $g_choices = isset($group['options']) ? $group['options'] : array(); $g_id = isset($group['id']) ? esc_attr($group['id']) : ''; if ($g_type == 'checkbox') { $sanitize = 'fruitful_theme_sanitize_checkbox'; } else { $sanitize = ''; } $id = $opt_name . '[' . $g_id . ']'; $wp_customize->add_setting(esc_attr($id), array('default' => $g_default, 'type' => $type, 'capability' => '', 'sanitize_callback' => $sanitize)); if ($key == 0) { $top_label = $field['label']; $top_info = $field['info']; } else { $top_label = ''; $top_info = ''; } switch ($g_type) { case 'checkbox': $wp_customize->add_control(new Fruitful_Customize_Checkbox_Control($wp_customize, esc_attr($id), array('type' => 'checkbox', 'priority' => $priority, 'section' => $section, 'label' => $g_label, 'description' => $g_description, 'info' => $g_info, 'top_label' => $top_label, 'top_info' => $top_info))); break; case 'text': $wp_customize->add_control(new Fruitful_Customize_Text_Control($wp_customize, esc_attr($id), array('type' => 'text', 'priority' => $priority, 'section' => $section, 'label' => $g_label, 'description' => $g_description, 'info' => $g_info, 'top_label' => $top_label, 'top_info' => $top_info, 'box_title' => $g_boxtitle))); break; case 'select': $wp_customize->add_control(new Fruitful_Customize_Select_Control($wp_customize, esc_attr($id), array('type' => 'select', 'priority' => $priority, 'section' => $section, 'label' => $g_label, 'description' => $f_description, 'choices' => $g_choices, 'info' => $g_info, 'top_label' => $top_label, 'top_info' => $top_info, 'box_title' => $g_boxtitle))); break; case 'image': if (class_exists('WP_Customize_Cropped_Image_Control') && $id == $opt_name . '[header_img]') { $wp_customize->add_control(new WP_Customize_Cropped_Image_Control($wp_customize, esc_attr($id), array('priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_info, 'flex_width' => true, 'flex_height' => false, 'width' => 1600, 'height' => $height))); } else { $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, esc_attr($id), array('priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_info))); } break; case 'color': $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, esc_attr($id), array('priority' => $priority, 'section' => $section, 'label' => $top_label, 'description' => $g_boxtitle, 'info' => $g_info))); break; case 'textarea': $wp_customize->add_control(new Fruitful_Customize_Textarea_Control($wp_customize, esc_attr($id), array('priority' => $priority, 'section' => $section, 'label' => $g_label, 'description' => $g_description, 'info' => $g_info))); break; } } } $id = $opt_name . '[' . $f_id . ']'; $wp_customize->add_setting(esc_attr($id), array('default' => $f_default, 'type' => $type, 'capability' => '', 'sanitize_callback' => $sanitize)); switch ($f_type) { case 'checkbox': $wp_customize->add_control(new Fruitful_Customize_Checkbox_Control($wp_customize, esc_attr($id), array('type' => 'checkbox', 'priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_description, 'info' => $f_info))); break; case 'text': $wp_customize->add_control(new Fruitful_Customize_Text_Control($wp_customize, esc_attr($id), array('type' => 'text', 'priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_description, 'info' => $f_info))); break; case 'select': $wp_customize->add_control(new Fruitful_Customize_Select_Control($wp_customize, esc_attr($id), array('type' => 'select', 'priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_description, 'choices' => $f_choices, 'info' => $f_info))); break; case 'font': $wp_customize->add_control(new Fruitful_Customize_Font_Control($wp_customize, esc_attr($id), array('type' => 'select', 'priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_description, 'choices' => $f_choices, 'info' => $f_info))); break; case 'image': $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, esc_attr($id), array('priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_info))); break; case 'color': $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, esc_attr($id), array('priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_info))); break; case 'textarea': $wp_customize->add_control(new Fruitful_Customize_Textarea_Control($wp_customize, esc_attr($id), array('priority' => $priority, 'section' => $section, 'label' => $f_label, 'description' => $f_description, 'info' => $f_info))); break; } } } } $wp_customize->remove_section('slider'); }
function go_woo_tabs_center() { $style_ = $back_style = $woo_style_ = ''; $theme_options = fruitful_get_theme_options(); $style_ .= '@media only screen and (min-width: 1024px) {body.woocommerce div.product .woocommerce-tabs, body.woocommerce-page div.product .woocommerce-tabs, body.woocommerce #content div.product .woocommerce-tabs, body.woocommerce-page #content div.product .woocommerce-tabs {max-width : 100%; margin-top: 20px;}}' . "\n"; wp_add_inline_style('main-style', fruitful_compress_code($style_)); if ($woo_style_ != '') { wp_add_inline_style('woo-style', fruitful_compress_code($woo_style_)); } }