Skip to content

Instantly share code, notes, and snippets.

@AnnaCrumina
Last active August 29, 2015 14:13
Show Gist options
  • Save AnnaCrumina/26c76fb0a1ca264dff30 to your computer and use it in GitHub Desktop.
Save AnnaCrumina/26c76fb0a1ca264dff30 to your computer and use it in GitHub Desktop.
Shortcode in stunning header [Atlantis]
<?php
/* -------------------------------------------------------
You can add your custom functions below
-------------------------------------------------------- */
function custom_stunning_header() {
global $crum_theme_option;
$custom_st_header = get_post_meta(get_the_ID(),'single_post_st_header',true);
if ( isset( $crum_theme_option['st_header'] ) && $crum_theme_option['st_header'] && !is_page_template('page-templates/no-stunning.php') && ($custom_st_header !='disable') || ($custom_st_header =='enable') ) {
$height = isset( $crum_theme_option['st-header-height'] ) ? $crum_theme_option['st-header-height'] : '';
$style = isset( $crum_theme_option['st-header-style'] ) ? $crum_theme_option['st-header-style'] : '';
$st_header_image = isset( $crum_theme_option['st-header-bg-image'] ) ? $crum_theme_option['st-header-bg-image']['url'] : '';
$st_header_bg = isset( $crum_theme_option['st-header-bg-color'] ) ? $crum_theme_option['st-header-bg-color'] : '';
$st_text_color = isset( $crum_theme_option['st-header-text-color'] ) ? $crum_theme_option['st-header-text-color'] : '';
$breadcrumbs = isset( $crum_theme_option['breadcrumbs'] ) ? $crum_theme_option['breadcrumbs'] : false;
//custom post settings
$custom_st_header_image = get_post_meta(get_the_ID(),'single_post_header_bg',true);
$custom_st_header_color = get_post_meta(get_the_ID(),'single_post_color_bg',true);
$custom_st_header_font = get_post_meta(get_the_ID(),'single_post_color_font',true);
$custom_st_header_height = get_post_meta(get_the_ID(),'single_post_header_height',true);
$custom_st_header_style = get_post_meta(get_the_ID(),'single_post_header_style',true);
$header_style = '';
if (! empty ($custom_st_header_image)){
$header_style = 'background: url('. $custom_st_header_image.');';
}elseif(!empty ($custom_st_header_color)){
$header_style = 'background-color:'. $custom_st_header_color.';';
}elseif(!empty ($custom_page_st_header_image)){
$header_style = 'background: url('. $custom_page_st_header_image.');';
}elseif(!empty ($custom_page_st_header_color)){
$header_style = 'background-color:'. $custom_page_st_header_color.';';
}elseif(! empty($st_header_image)){
$header_style = 'background: url('. $st_header_image.');';
}elseif(! empty($st_header_bg)){
$header_style = 'background-color:'. $st_header_bg.';';
}
if (! empty ($custom_st_header_font)){
$st_text_color = $custom_st_header_font;
}
if (! empty ($custom_st_header_height)){
$height = $custom_st_header_height;
}
if (! empty ($custom_st_header_style) && !($custom_st_header_style == '')){
$style = $custom_st_header_style;
}
?>
<div id="stunning-header" style="<?php echo $header_style; ?> background-position:50%;background-repeat:no-repeat;background-size: cover;">
<div class="row" style="<?php if ( $st_text_color ): echo 'color:' . $st_text_color . ';'; endif; ?>">
<div class="<?php reactor_columns( 12 ) ?>">
<header <?php if ( $height ) { ?> style="height: <?php echo $height; ?>px;"<?php } ?>>
<div class="st-wrap <?php echo $style ?>">
<?php if (is_single() && is_singular('post')) {
global $post;
$category = get_the_category($post->ID);
echo '<h2 class="header-title">' . $category[0]->name .'</h2>';
}elseif(is_single() && is_singular('portfolio')) {
$terms = get_the_terms( get_the_ID(), 'portfolio-category' );
if ( $terms && ! is_wp_error( $terms ) ) :
$cat_names = array();
foreach ( $terms as $term ) { $cat_names[] = $term->name; }
$cat_show = $cat_names[0];
echo '<h2 class="header-title">' . $cat_show . '</h2>';
else:
echo '<h2 class="header-title">' . __('Portfolio','crum') . '</h2>';
endif;
}elseif (is_home()){
echo '<h2 class="header-title">';
printf( __( 'Latest posts', 'crum' ));
echo '</h2>';
}
elseif ( is_tag() ) {
echo '<h2 class="header-title">';
printf( __( 'Tag: %s', 'crum' ), single_tag_title( '', false ) );
echo '</h2>';
}
elseif ( is_category() ) {
echo '<h2 class="header-title">';
printf( __( 'Category: %s', 'crum' ), single_cat_title( '', false ) );
echo '</h2>';
}
elseif ( is_author() ) {
echo '<h2 class="header-title">';
printf( __( 'Author: %s', 'crum' ), get_the_author() );
echo '</h2>';
}
elseif ( is_tax('portfolio-tag') ) {
echo '<h2 class="header-title">';
printf( __( 'Tag: %s', 'crum' ), get_queried_object()->name );
echo '</h2>';
}
elseif ( is_search() ) {
echo '<h2 class="header-title">';
printf( __( 'You search: %s', 'crum' ), get_search_query() );
echo '</h2>';
}
elseif ( is_tax('portfolio-category') ) {
echo '<h2 class="header-title">';
printf( __( 'Category: %s', 'crum' ), get_queried_object()->name );
echo '</h2>';
}
elseif ( is_archive() ) {
if ( is_day() ) {
echo '<h2 class="header-title">';
printf( __( 'Daily Archives: %s', 'crum' ), '<span>' . get_the_date() . '</span>' );
echo '</h2>';
}
elseif ( is_month() ) {
echo '<h2 class="header-title">';
printf( __( 'Monthly Archives: %s', 'crum' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'crum' ) ) . '</span>' );
echo '</h2>';
}
elseif ( is_year() ) {
echo '<h2 class="header-title">';
printf( __( 'Yearly Archives: %s', 'crum' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'crum' ) ) . '</span>' );
echo '</h2>';
}
elseif ( is_post_type_archive( 'product' ) ) {
echo '<h2 class="header-title">';
_e( 'Shop', 'crum' );
echo '</h2>';
}
else {
echo '<h2 class="header-title">';
_e( 'Archives', 'crum' );
echo '</h2>';
}
} elseif ((function_exists('is_woocommerce')) && ( is_woocommerce() || is_page('store') || is_shop() || is_product_category() || is_product() || is_cart() || is_checkout() )){ ?>
<h1 class="header-title"><?php woocommerce_page_title(); ?></h1>
<?php } else {
echo '<h1 class="header-title">' . get_the_title() . '</h1>';
} ?>
<?php echo do_shortcode('custom shortcode'); /*PASTE YOUR SHOTCODE INTO BRACKETS do_shortcode('') */ ?>
<?php if ( $breadcrumbs ): reactor_breadcrumbs(); endif; ?>
</div>
</header>
</div>
</div>
</div>
<?php
}
}
function crum_replace_stunning_header(){
remove_action('reactor_header_after', 'crumina_stunning_header', 1);
add_action('reactor_header_after', 'custom_stunning_header', 1);
}
add_action('init', 'crum_replace_stunning_header', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment