get_queried_object_id();
$pagebg = alanah_meta_field( $page_id, 'page_bg' );
if( $pagebg ) :
echo 'style="background: '.$pagebg.'"';
endif;
}
/**
* Setup Admin favicon
*/
add_action( 'admin_head', 'alanah_admin_favicon', 10 );
function alanah_admin_favicon() {
if( alanah_get_option( 'favicon' ) && alanah_get_option( 'favicon' ) !== '' ) : ?>
for posts and comments.
add_theme_support( 'automatic-feed-links' );
// Switches default core markup for search form, comment form, and comments
// to output valid HTML5.
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'custom-background');
//Add woocommerce support to theme
add_theme_support( 'woocommerce' );
//Theme based image size
add_image_size( 'alanah-catalog', 300, 300, true );
add_image_size( 'alanah-lightbox', 400, 400, true );
add_image_size( 'alanah-categories', 400, 400, true );
// Set content-width.
global $content_width;
if ( ! isset( $content_width ) ) {
$content_width = 1190;
}
}
/**
* Prag replace
*/
function ct_prag_replace( $str='' ) {
return trim( preg_replace( "/('|\"|\r?\n)/", '', $str ) );
}
/**
* Limit title characters
*/
function al_limit_title( $title ) {
$max = 40;
if( strlen( $title ) > $max ) $title = substr( $title, 0, $max ) . '…';
return $title;
}
/**
* Get Post category list
*/
function alanah_get_the_category_list( $separator = '', $parents='', $post_id = false ){
global $wp_rewrite;
$categories = get_the_category( $post_id );
if ( !is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) )
return apply_filters( 'the_category', '', $separator, $parents );
if ( empty( $categories ) )
return apply_filters( 'the_category', __( 'Uncategorized', 'alanah-free' ), $separator, $parents );
$rel = '';
$thelist = '';
if ( '' == $separator ) :
$thelist .= '
';
foreach ( $categories as $category ) {
$thelist .= "\n\t";
switch ( strtolower( $parents ) ) {
case 'multiple':
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, true, $separator );
$thelist .= '' . $category->name . ' ';
break;
case 'single':
$thelist .= '';
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, false, $separator );
$thelist .= $category->name . ' ';
break;
case '':
default:
$thelist .= '' . $category->name . ' ';
}
}
$thelist .= ' ';
else :
$i = 0;
foreach ( $categories as $category ) {
if ( 0 < $i )
$thelist .= $separator;
switch ( strtolower( $parents ) ) {
case 'multiple':
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, true, $separator );
$thelist .= '' . $category->name . ' ';
break;
case 'single':
$thelist .= '';
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, false, $separator );
$thelist .= "$category->name ";
break;
case '':
default:
$thelist .= '' . $category->name . ' ';
}
++$i;
}
endif;
return apply_filters( 'the_category', $thelist, $separator, $parents );
} //alanah_get_the_category_list
/**
* Add jQuery translations
*/
function alanah_jQuery_translate() {
return array(
'success_msg' => __( 'was successfully added to your shopping cart. ', 'alanah-free' ),
'ok' => __( 'Ok', 'alanah-free' ),
'go_cart' => __( 'Go to cart', 'alanah-free' )
);
}
/**
* Admin jQuery translations
*/
function alanah_admin_jQuery_translate() {
return array(
'media' => __( 'Select Media', 'alanah-free' ),
'clickimg' => __( 'Click the image to edit or update', 'alanah-free' ),
'remove' => __( 'Remove hover image', 'alanah-free' ),
'yousure' => __( 'Are you sure?', 'alanah-free' ),
'delerror' => __( 'Error while deleting', 'alanah-free' )
);
}
/**
* For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
*/
add_filter( 'wp_page_menu_args', 'alanah_page_menu_args' );
function alanah_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
/**
* Sets the post excerpt length to 40 characters.
*
* To override this length in a child theme, remove the filter and add your own
* function tied to the excerpt_length filter hook.
*
*/
add_filter( 'excerpt_length', 'alanah_excerpt_length' );
function alanah_excerpt_length( $length ) {
return 40;
}
/**
* Returns a "Continue Reading" link for excerpts
*
* @return string "Continue Reading" link
*/
function alanah_continue_reading_link() {
return ' ' . __( 'Continue reading → ', 'alanah-free' ) . ' ';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and alanah_continue_reading_link().
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*
* @return string An ellipsis
*/
add_filter( 'excerpt_more', 'alanah_auto_excerpt_more' );
function alanah_auto_excerpt_more( $more ) {
return ' …' . alanah_continue_reading_link();
}
/**
* Adds a pretty "Continue Reading" link to custom post excerpts.
*
* To override this link in a child theme, remove the filter and add your own
* function tied to the get_the_excerpt filter hook.
*
* @return string Excerpt with a pretty "Continue Reading" link
*/
add_filter( 'get_the_excerpt', 'alanah_custom_excerpt_more' );
function alanah_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= alanah_continue_reading_link();
}
return $output;
}
/**
* Remove inline styles printed when the gallery shortcode is used.
*
* Galleries are styled by the theme in Twenty Ten's style.css. This is just
* a simple filter call that tells WordPress to not use the default styles.
*
*/
add_filter( 'use_default_gallery_style', '__return_false' );
/**
* Comments for Alanah posts
*
*/
if ( ! function_exists( 'alanah_comment' ) ) :
function alanah_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'comment' :
?>
id="li-comment-">
%2$s', 'alanah-free' ),
'meta-prep meta-prep-author',
sprintf( '%3$s ',
get_permalink(),
esc_attr( get_the_time() ),
get_the_date()
)
);
}
endif;
/**
* Setup Posts meta data
*/
if ( ! function_exists( 'alanah_posted_by' ) ) :
function alanah_posted_by() {
printf( __( 'Posted by %2$s', 'alanah-free' ),
'meta-author',
sprintf( '%3$s ',
get_author_posts_url( get_the_author_meta( 'ID' ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'alanah-free' ), get_the_author() ) ),
get_the_author()
)
);
}
endif;
/**
* Setup Posts meta data
*/
if ( ! function_exists( 'alanah_posted_in' ) ) :
function alanah_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the permalink .', 'alanah-free' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = __( 'This entry was posted in %1$s. Bookmark the permalink .', 'alanah-free' );
} else {
$posted_in = __( 'Bookmark the permalink .', 'alanah-free' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
alanah_get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;
/**
* Post Read more link
*/
add_filter( 'excerpt_more', 'alanah_excerpt_more' );
function alanah_excerpt_more($more) {
global $post;
return ''.__( 'Read More','alanah-free' ).'
';
}
/**
* Archives pages pagination
*/
function alanah_archive_pagination() {
if( is_singular() ) return;
global $wp_query;
// Stop execution if there's only 1 page
if( $wp_query->max_num_pages <= 1 ) return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
// Add current page to the array
if ( $paged >= 1 )
$links[] = $paged;
// Add the pages around the current page to the array
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '' . "\n";
// Previous Post Link
if ( get_previous_posts_link() )
printf( '%s ' . "\n", get_previous_posts_link( '«' ) );
// Link to first page, plus ellipses if necessary
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '%s ' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '… ';
}
// Link to current page, plus 2 pages in either direction if necessary
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '%s ' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
// Link to last page, plus ellipses if necessary
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '… ' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '%s ' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
// Next Post Link
if ( get_next_posts_link() )
printf( '%s ' . "\n", get_next_posts_link( '»' ) );
echo ' ' . "\n";
}
/**
* Post Search Form
*/
function alanah_product_search() {
get_template_part( 'html/alanah-product', 'search' );
}
/**
* Alanah breadcrumb
*/
function alanah_breadcrumb() {
echo '' . __( 'Home', 'alanah-free' ) . ' ';
if ( is_category() || is_single() ) :
echo " » ";
the_category(' • ');
if ( is_single() ) :
echo " » ";
the_title();
endif;
elseif ( is_archive() ) :
echo " » ";
if ( is_day() ) {
printf( __( '%s', 'alanah-free' ), get_the_date() );
} elseif ( is_month() ) {
printf( __( '%s', 'alanah-free' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'alanah-free' ) ) );
} elseif ( is_year() ) {
printf( __( '%s', 'alanah-free' ), get_the_date( _x( 'Y', 'yearly archives date format', 'alanah-free' ) ) );
} else {
_e( 'Blog Archives', 'alanah-free' );
}
elseif ( is_home() ) :
echo " » ";
echo get_the_title( get_option( 'page_for_posts', true ) );
elseif ( is_page() ) :
echo " » ";
echo the_title();
elseif ( is_search() ) :
echo " » " . __( 'Search Results for...', 'alanah-free' );
echo '"';
echo the_search_query();
echo ' "';
endif;
}
/**
* Load google fonts in site
*/
function alanah_load_google_fonts() {
global $al_core;
$heading_font = alanah_get_option( 'heading_font' );
$body_font = alanah_get_option( 'body_font' );
$menu_font = alanah_get_option( 'menu_font' );
$al_core->alanah_load_google_fonts( $heading_font, $body_font, $menu_font );
}
/**
* Posts Grid
*/
function alanah_posts_grid( $args, $title, $column, $ID = '', $class = '' ) {
global $al_core;
$al_core->alanah_wc_post_grid( $args, $title, $column, $ID, $class );
}
/**
* Posts Slider
*/
function alanah_posts_slider( $args, $slider_cols, $direction, $scroll, $autoplay, $title, $ID = '', $class = '' ) {
global $al_core;
$al_core->alanah_wc_post_slider( $args, $slider_cols, $direction, $scroll, $autoplay, $title, $ID, $class );
}
/**
* Page templte based classes in inner container
*/
add_filter( 'alanah_inner_classes', 'alanah_template_based_classes' );
function alanah_template_based_classes( $classes ) {
global $template;
$class = preg_replace( "/\.[^.]+$/", "", basename( $template ) );
$classes .= ' ' . $class;
return $classes;
}
- $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
comment_approved == '0' ) : ?>