Exemple #1
0
/**
 * Adds custom classes to the array of body classes.
 *
 * @since 1.0
 * @param array $classes Classes for the body element.
 * @return array
 */
function onehost_body_classes($classes)
{
    // Adds a class of group-blog to blogs with more than 1 published author.
    if (is_multi_author()) {
        $classes[] = 'group-blog';
    }
    // Add a class of layout
    $classes[] = onehost_get_layout();
    // Add a class when choose no animation
    if (onehost_theme_option('no_animation')) {
        $classes[] = 'no-animation';
    }
    // Add a class when choose no animation
    $classes[] = onehost_theme_option('site_style') . '-version';
    // Add a class for color scheme
    if (onehost_theme_option('custom_color_scheme') && onehost_theme_option('custom_color_1')) {
        $classes[] = 'custom-color-scheme';
    } else {
        $classes[] = onehost_theme_option('color_scheme');
    }
    if (onehost_get_meta('hide_singular_title')) {
        $classes[] = 'hide-singular-title';
    }
    return $classes;
}
Exemple #2
0
/**
 * Get layout base on current page
 *
 * @return string
 */
function onehost_get_layout()
{
    $layout = onehost_theme_option('default_layout');
    $custom_layout = onehost_get_meta('layout');
    if (is_page()) {
        if (onehost_get_meta('custom_layout') && $custom_layout) {
            $layout = $custom_layout;
        } else {
            $layout = onehost_theme_option('page_layout');
        }
    } elseif (is_singular('post')) {
        if (onehost_get_meta('custom_layout') && $custom_layout) {
            $layout = $custom_layout;
        } else {
            $layout = onehost_theme_option('single_layout');
        }
    } elseif (is_404()) {
        $layout = 'full-content';
    }
    return $layout;
}
<?php

/**
 * @package OneHost
 */
?>

<article id="post-<?php 
the_ID();
?>
" <?php 
post_class();
?>
>
	<?php 
if (!onehost_get_meta('hide_singular_title')) {
    ?>
		<header class="entry-header clearfix">
			<?php 
    onehost_entry_thumbnail();
    ?>

			<h2 class="entry-title"><a href="<?php 
    the_permalink();
    ?>
" title="<?php 
    the_title_attribute();
    ?>
" rel="bookmark"><?php 
    the_title();
    ?>
Exemple #4
0
/**
 * Custom scripts and styles on header
 *
 * @since  1.0
 */
function onehost_header_scripts()
{
    $inline_css = '';
    // Logo
    $logo_size_width = intval(onehost_theme_option('logo_size_width'));
    $logo_css = $logo_size_width ? 'width:' . $logo_size_width . 'px; ' : '';
    $logo_size_height = intval(onehost_theme_option('logo_size_height'));
    $logo_css .= $logo_size_height ? 'height:' . $logo_size_height . 'px; ' : '';
    $logo_margin_top = intval(onehost_theme_option('logo_margin_top'));
    $logo_css .= $logo_margin_top ? 'margin-top:' . $logo_margin_top . 'px;' : '';
    $logo_margin_right = intval(onehost_theme_option('logo_margin_right'));
    $logo_css .= $logo_margin_right ? 'margin-right:' . $logo_margin_right . 'px;' : '';
    $logo_margin_bottom = intval(onehost_theme_option('logo_margin_bottom'));
    $logo_css .= $logo_margin_bottom ? 'margin-bottom:' . $logo_margin_bottom . 'px;' : '';
    $logo_margin_left = intval(onehost_theme_option('logo_margin_left'));
    $logo_css .= $logo_margin_left ? 'margin-left:' . $logo_margin_bottom . 'px;' : '';
    if (!empty($logo_css)) {
        $inline_css .= '#site-header .site-branding .site-logo img ' . ' {' . $logo_css . '}';
    }
    // Featured Title Area
    $image = onehost_get_meta('singular_title_area_bg');
    if ($image) {
        $image = wp_get_attachment_image_src($image, 'full');
        $image = $image ? $image[0] : '';
    }
    if (!$image) {
        $image = onehost_theme_option('title_area_bg');
    }
    $featured_css = $image ? "background-image: url({$image})" : '';
    if (!empty($featured_css)) {
        $inline_css .= '#title-area {' . $featured_css . '}';
    }
    // Custom CSS
    $css_custom = onehost_get_meta('custom_css') . onehost_theme_option('custom_css');
    if (!empty($css_custom)) {
        $inline_css .= $css_custom;
    }
    if (!empty($inline_css)) {
        $inline_css = '<style type="text/css">' . $inline_css . '</style>';
    }
    // Custom javascript
    $js_custom = onehost_get_meta('custom_js') . onehost_theme_option('header_scripts');
    if (!empty($js_custom)) {
        $js_custom = '<script type="text/javascript">' . $js_custom . '</script>';
    }
    $inline_css .= $inline_css . $js_custom;
    if ($inline_css) {
        echo $inline_css;
    }
}
<?php

/**
 * The template part for displaying title area
 *
 * @package OneHost
 */
if (is_page_template('one-page.php') || is_singular() && onehost_get_meta('hide_singular_title_area')) {
    return;
}
?>

<div id="title-area" class="title-area">
	<div class="container">
		<?php 
the_archive_title('<h1 class="page-title">', '</h1>');
?>
	</div>
</div><!-- .page-header -->
 /**
  * Testimonial shortcode
  *
  * @param array  $atts
  * @param string $content
  *
  * @return string
  */
 function testimonial($atts, $content)
 {
     $atts = shortcode_atts(array('style' => 'short', 'slider' => '', 'number' => 'all', 'single' => '', 'speed' => '700', 'navigation' => '', 'pagination' => '', 'class_name' => '', 'autoplay' => '', 'animation' => '', 'duration' => '', 'delay' => ''), $atts);
     $size = 'widget-thumb';
     $item_class = '';
     $data_animation = '';
     $css_class = array();
     $css_class[] = 'testimonial-list';
     $id = '';
     if ($atts['slider']) {
         $speed = intval($atts['speed']);
         $id = uniqid('testimonial-slider-');
         $this->l10n['testimonial'][$id] = array('speed' => $speed, 'navigation' => $atts['navigation'] ? $atts['navigation'] : 'false', 'pagination' => $atts['pagination'] ? $atts['pagination'] : 'false', 'single' => $atts['single'] ? $atts['single'] : 'false', 'autoplay' => $atts['autoplay'] ? $atts['autoplay'] : 'false');
         $id = 'id="' . $id . '"';
     } else {
         if ($atts['style'] == 'full') {
             $size = 'testimonial-thumb';
             $item_class = 'col-sm-6 col-md-6';
             $css_class[] = 'row';
         } elseif ($atts['style'] == 'medium') {
             $item_class = 'col-sm-4 col-md-4';
             $css_class[] = 'row';
         }
     }
     if ($atts['animation']) {
         $css_class[] = 'wow';
         $css_class[] = esc_attr($atts['animation']);
         if ($atts['duration']) {
             $data_animation .= ' data-wow-duration="' . esc_attr($atts['duration']) . 'ms"';
         }
         if ($atts['delay']) {
             $data_animation .= ' data-wow-delay="' . esc_attr($atts['delay']) . 'ms"';
         }
     }
     $css_class[] = isset($atts['class_name']) ? esc_attr($atts['class_name']) : '';
     $css_class[] = 'testimonial-' . esc_attr($atts['style']);
     $number = -1;
     if (strtolower($atts['number']) != 'all') {
         $number = intval($atts['number']);
     }
     $index = 0;
     $output = array();
     $args = array('post_type' => 'testimonial', 'posts_per_page' => $number);
     $the_query = new WP_Query($args);
     while ($the_query->have_posts()) {
         $the_query->the_post();
         $args = array('size' => $size, 'echo' => false, 'format' => 'src');
         $image_src = onehost_get_image($args);
         $cats = wp_get_post_terms(get_the_ID(), 'testimonial_category');
         $cat_name = $cats ? $cats[0]->name : '';
         if (!$atts['slider']) {
             if ($atts['style'] == 'full') {
                 if ($index % 2 == 0 && $index != 0) {
                     $output[] = '<div class="clearfix"></div>';
                 }
                 $index++;
             } elseif ($atts['style'] == 'medium') {
                 if ($index % 3 == 0 && $index != 0) {
                     $output[] = '<div class="clearfix"></div>';
                 }
                 $index++;
             }
         }
         $output[] = sprintf('<div class="testi-item %s">', $item_class);
         $star = onehost_get_meta('star');
         if ($star && $star != '0') {
             $output[] = '<div class="testi-star">';
             $star = explode('.', $star);
             $num = intval($star[0]);
             if ($num) {
                 if ($num > 0) {
                     for ($i = 0; $i < $num; $i++) {
                         $output[] = '<i class="fa fa-star fa-md"></i>';
                     }
                 }
             }
             if (isset($star[1])) {
                 $output[] = '<i class="fa fa-star-half-empty fa-md"></i>';
             } else {
                 $num = 5 - $num;
                 if ($num > 0) {
                     for ($i = 0; $i < $num; $i++) {
                         $output[] = '<i class="fa fa-star-o fa-md"></i>';
                     }
                 }
             }
             $output[] = '</div>';
         }
         $output[] = sprintf('<div class="testi-desc">%s</div>', get_the_excerpt());
         $output[] = sprintf('<div class="testi-author"><img src="%s" alt="%s" class="testi-pic"><div class="testi-company"><strong>%s</strong><span>, %s</span></div></div>', esc_url($image_src), the_title_attribute('echo=0'), get_the_title(), $cat_name);
         $output[] = '</div>';
     }
     wp_reset_postdata();
     return sprintf('<div %s class="%s" %s>%s</div>', $id, implode(' ', $css_class), $data_animation, implode('', $output));
 }
Exemple #7
0
/**
 * Show entry thumbnail base on its format
 *
 * @since  1.0
 */
function onehost_entry_thumbnail($size = 'blog-thumb')
{
    $html = '';
    $css_class = '';
    if ('full-content' == onehost_get_layout()) {
        $size = 'blog-full-thumb';
    }
    $size = apply_filters('onehost_post_format_thumbnail_size', $size);
    switch (get_post_format()) {
        case 'image':
            $image = onehost_get_image(array('size' => $size, 'format' => 'src', 'meta_key' => 'image', 'echo' => false));
            if (!$image) {
                break;
            }
            $html = sprintf('<a class="entry-image" href="%1$s" title="%2$s"><img src="%3$s" alt="%2$s"></a>', get_permalink(), the_title_attribute('echo=0'), $image);
            break;
        case 'gallery':
            $images = onehost_get_meta('images', "type=image&size={$size}");
            if (empty($images)) {
                break;
            }
            $gallery = array();
            foreach ($images as $image) {
                $gallery[] = '<div class="entry-item">' . '<img src="' . $image['url'] . '" alt="' . the_title_attribute('echo=0') . '">' . '</div>';
            }
            $html .= '<div class="flexslider entry-image"><div class="slides">' . implode('', $gallery) . '</div></div>';
            break;
        case 'audio':
            $thumb = get_the_post_thumbnail(get_the_ID(), $size);
            if (!empty($thumb)) {
                $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>';
            }
            $audio = onehost_get_meta('audio');
            if (!$audio) {
                break;
            }
            // If URL: show oEmbed HTML or jPlayer
            if (filter_var($audio, FILTER_VALIDATE_URL)) {
                // Try oEmbed first
                if ($oembed = @wp_oembed_get($audio)) {
                    $html .= $oembed;
                } else {
                    $html .= '<div class="audio-player">' . wp_audio_shortcode(array('src' => $audio)) . '</div>';
                }
            } else {
                $html .= $audio;
            }
            break;
        case 'video':
            if (!empty($thumb)) {
                $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>';
            }
            $video = onehost_get_meta('video');
            if (!$video) {
                break;
            }
            // If URL: show oEmbed HTML
            if (filter_var($video, FILTER_VALIDATE_URL)) {
                if ($oembed = @wp_oembed_get($video)) {
                    $html .= $oembed;
                } else {
                    $atts = array('src' => $video, 'width' => 848);
                    if (has_post_thumbnail()) {
                        $atts['poster'] = onehost_get_image('format=src&echo=0&size=full');
                    }
                    $html .= wp_video_shortcode($atts);
                }
            } else {
                $html .= $video;
            }
            break;
        case 'link':
            if (!empty($thumb)) {
                $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>';
            }
            $link = onehost_get_meta('url');
            $text = onehost_get_meta('url_text');
            if (!$link) {
                break;
            }
            $html .= sprintf('<a href="%s" class="link-block">%s</a>', esc_url($link), $text ? $text : $link);
            break;
        case 'quote':
            if (!empty($thumb)) {
                $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>';
            }
            $quote = onehost_get_meta('quote');
            $author = onehost_get_meta('quote_author');
            $author_url = onehost_get_meta('author_url');
            if (!$quote) {
                break;
            }
            $html .= sprintf('<blockquote>%s<cite>%s</cite></blockquote>', esc_html($quote), empty($author_url) ? $author : "<a href='{$author_url}'> - {$author}</a>");
            break;
        default:
            $thumb = onehost_get_image(array('size' => $size, 'meta_key' => 'image', 'echo' => false));
            if (empty($thumb)) {
                break;
            }
            $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>';
            break;
    }
    if ($html = apply_filters(__FUNCTION__, $html, get_post_format())) {
        echo "<div class='entry-format'>{$html}</div>";
    }
}