ID;
if ( ! $post_id ) return;
}
global $graphene_settings;
// Get the local setting
$show_addthis_local = graphene_get_post_meta( $post_id, 'show_addthis' );
$show_addthis_global = $graphene_settings['show_addthis'];
$show_addthis_page = $graphene_settings['show_addthis_page'];
// Determine whether we should show AddThis or not
if ( $show_addthis_local == 'show' )
$show_addthis = true;
elseif ( $show_addthis_local == 'hide' )
$show_addthis = false;
elseif ( $show_addthis_local == '' ){
if ( ( $show_addthis_global && get_post_type() != 'page' ) || ( $show_addthis_global && $show_addthis_page ) )
$show_addthis = true;
else
$show_addthis = false;
} else
$show_addthis = false;
// Show the AddThis button
if ( $show_addthis) {
echo '';
$html = stripslashes( $graphene_settings['addthis_code'] );
$html = str_replace( '[#post-url]', esc_attr( get_permalink( $post_id ) ), $html );
$html = str_replace( '[#post-title]', esc_attr( get_the_title( $post_id ) ), $html );
$html = str_replace( '[#post-excerpt]', esc_attr( get_the_excerpt() ), $html );
echo $html;
echo '
';
do_action( 'graphene_show_addthis' );
}
do_action( 'graphene_addthis' );
}
endif;
if ( ! function_exists( 'graphene_continue_reading_link' ) ) :
/**
* Returns a "Continue Reading" link for excerpts
* Based on the function from the Twenty Ten theme
*
* @since Graphene 1.0.8
* @return string "Continue Reading" link
*/
function graphene_continue_reading_link() {
global $graphene_in_slider;
if ( ! is_page() && ! $graphene_in_slider ) {
$more_link_text = __( 'Continue reading »', 'graphene' );
return '' . $more_link_text . '';
}
}
endif;
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and graphene_continue_reading_link().
* Based on the function from Twenty Ten theme.
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*
* @since Graphene 1.0.8
* @return string An ellipsis
*/
function graphene_auto_excerpt_more( $more ) {
return apply_filters( 'graphene_auto_excerpt_more', ' … ' . graphene_continue_reading_link() );
}
add_filter( 'excerpt_more', 'graphene_auto_excerpt_more' );
/**
* Add the Read More link to manual excerpts.
*
* @since Graphene 1.1.3
*/
function graphene_manual_excerpt_more( $text ){
global $post, $graphene_settings, $graphene_in_slider;
if ( $graphene_in_slider ) return $text;
$has_excerpt = has_excerpt();
if ( $has_excerpt && ! $graphene_settings['show_excerpt_more'] ) return $text;
$has_more = preg_match( '//', $post->post_content, $matches );
if ( ! $has_excerpt && ! $has_more ) return $text;
if ( $has_more ) {
if ( $text != graphene_truncate_words( $text, $graphene_settings['excerpt_length'], '' ) ) return $text;
}
$text = explode( '
', $text );
$text[count( $text )-2] .= graphene_continue_reading_link();
$text = implode( '', $text );
return $text;
}
add_action( 'the_excerpt', 'graphene_manual_excerpt_more' );
if ( ! function_exists( 'graphene_posts_nav' ) ) :
/**
* Generates the posts navigation links
*/
function graphene_posts_nav(){
global $graphene_settings;
$query = $GLOBALS['wp_query'];
if ( function_exists( 'wp_pagenavi' ) ) : ?>
max_num_pages > 1 ) : ?>
max_num_pages > 1 ) && $graphene_settings['inf_scroll_enable'] && $graphene_settings['inf_scroll_click'] ) : ?>
'« %link',
'format_next' => '%link »',
'link' => '%title',
'in_same_cat' => false,
'excluded_cats' => '',
);
if ( $graphene_settings['slider_type'] == 'categories' )
if ( $graphene_settings['slider_exclude_categories'] == 'everywhere' )
$args['excluded_cats'] = $graphene_settings['slider_specific_categories'];
$args = apply_filters( 'graphene_post_nav_args', $args );
?>
tag, with height and width attributes.
* The function returns the thumbnail of the original image, linked to the post's
* permalink. Returns FALSE if the current post has no image.
*
* This function requires the post ID to get the image from to be supplied as the
* argument. If no post ID is supplied, it outputs an error message. An optional argument
* size can be used to determine the size of the image to be used.
*
* Based on code snippets by John Crenshaw
* (http://www.rlmseo.com/blog/get-images-attached-to-post/)
*
* @package Graphene
* @since Graphene 1.1
*/
function graphene_get_post_image( $post_id = NULL, $size = 'thumbnail', $context = '', $urlonly = false ){
/* Don't do anything if no post ID is supplied */
if ( $post_id == NULL ) return;
/* Get the images */
$images = get_children( array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post_id,
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => 1,
), ARRAY_A );
$html = '';
/* Returns generic image if there is no image to show */
if ( empty( $images ) && $context != 'excerpt' && ! $urlonly ) {
$html .= apply_filters( 'graphene_generic_slider_img', '' ); // For backward compatibility
$html .= apply_filters( 'graphene_generic_post_img', '' );
}
/* Build the
tag if there is an image */
foreach ( $images as $image ){
if (!$urlonly) {
if ( $context == 'excerpt' ) {$html .= '';};
} else {
$html = wp_get_attachment_image_src( $image['ID'], $size);
}
}
/* Returns the image HTMl */
return $html;
}
endif;
/**
* Improves the WordPress default excerpt output. This function will retain HTML tags inside the excerpt.
* Based on codes by Aaron Russell at http://www.aaronrussell.co.uk/blog/improving-wordpress-the_excerpt/
*/
function graphene_improved_excerpt( $text ){
global $graphene_settings, $post;
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content( '' );
$text = strip_shortcodes( $text );
$text = apply_filters( 'the_content', $text);
$text = str_replace( ']]>', ']]>', $text);
/* Remove unwanted JS code */
$text = preg_replace( '@@si', '', $text);
/* Strip HTML tags, but allow certain tags */
$text = strip_tags( $text, $graphene_settings['excerpt_html_tags'] );
$excerpt_length = apply_filters( 'excerpt_length', 55);
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[...]' );
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if ( count( $words) > $excerpt_length ) {
array_pop( $words);
$text = implode( ' ', $words);
$text = $text . $excerpt_more;
} else {
$text = implode( ' ', $words);
}
}
// Try to balance the HTML tags
$text = force_balance_tags( $text );
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt);
}
/**
* Only use the custom excerpt trimming function if user decides to retain html tags.
*/
if ( $graphene_settings['excerpt_html_tags'] ) {
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
add_filter( 'get_the_excerpt', 'graphene_improved_excerpt' );
}
/**
* Determine if date should be displayed. Returns true if it should, or false otherwise.
*/
if ( ! function_exists( 'graphene_should_show_date' ) ) :
function graphene_should_show_date(){
// Check post type
$allowed_posttypes = apply_filters( 'graphene_date_display_posttype', array( 'post' ) );
if ( ! in_array( get_post_type(), $allowed_posttypes ) )
return false;
// Check per-post settings
global $post;
$post_setting = graphene_get_post_meta( $post->ID, 'post_date_display' );
if ( $post_setting == 'hidden' )
return false;
elseif ( $post_setting != '' )
return true;
// Check global setting
global $graphene_settings;
if ( $graphene_settings['post_date_display'] == 'hidden' )
return false;
return true;
}
endif;
/**
* This functions adds additional classes to the post element. The additional classes
* are added by filtering the WordPress post_class() function.
*/
function graphene_post_class( $classes ){
global $post;
if ( in_array( graphene_post_date_setting( $post->ID ), array( 'hidden', 'text' ) ) || ! graphene_should_show_date() ) {
$classes[] = 'nodate';
}
// $classes = array_merge( $classes, graphene_get_grid( '', 16, 11, 8, true ) );
// Prints the body class
return $classes;
}
add_filter( 'post_class', 'graphene_post_class' );
/**
* Allows post queries to sort the results by the order specified in the post__in parameter.
* Just set the orderby parameter to post__in!
*
* Based on the Sort Query by Post In plugin by Jake Goldman (http://www.get10up.com)
*/
function graphene_sort_query_by_post_in( $sortby, $thequery ) {
global $wpdb;
if ( ! empty( $thequery->query['post__in'] ) && isset( $thequery->query['orderby'] ) && $thequery->query['orderby'] == 'post__in' )
$sortby = "find_in_set(" . $wpdb->prefix . "posts.ID, '" . implode( ',', $thequery->query['post__in'] ) . "')";
return $sortby;
}
add_filter( 'posts_orderby', 'graphene_sort_query_by_post_in', 9999, 2 );
if ( ! function_exists( 'graphene_post_date' ) ) :
/**
* Displays the date. Must be used inside the loop.
*/
function graphene_post_date( $id = '' ){
if ( ! $id ) {
global $post;
$id = $post->ID;
}
if ( ! graphene_should_show_date() ) return;
global $graphene_settings;
$style = graphene_post_date_setting( $id, 'post_date_display' );
if ( stristr( $style, 'icon' ) ) :
?>
labels->singular_name ); ?>
element in a text block
*
* @param string $text A text block
* @return string $text The text block with the .first-p class added to the first element
*
* @package Graphene
* @since 1.6
*/
function graphene_first_p( $text ){
$text = preg_replace('/
]+)?>/', '
', $text , 1 );
return apply_filters( 'graphene_first_p', $text );
}
/**
* Display a link to return to the parent page for child pages
*
* @param object $post The post object of the current page
*/
if ( ! function_exists( 'graphene_parent_return_link' ) ) :
function graphene_parent_return_link( $post = '' ){
if ( function_exists( 'bcn_display' ) ) return;
if ( empty( $post ) ) return;
if ( ! $post->post_parent ) return;
$title = get_the_title( $post->post_parent );
$permalink = get_permalink( $post->post_parent );
?>
queried_object ){
$term = $wp_query->queried_object;
$tax = $term->taxonomy;
} else {
$tax = $wp_query->tax_query->queries[0]['taxonomy'];
$term = $wp_query->tax_query->queries[0]['terms'][0];
$term = get_term_by( 'slug', $term, $tax );
}
if ( ! $term ) return;
if ( $term->description ) :
?>
description; ?>
is_home() && $query->is_main_query() ) ) return;
global $graphene_settings;
if ( empty( $graphene_settings['frontpage_posts_cats'] ) || in_array( 'disabled', $graphene_settings['frontpage_posts_cats'] ) ) return;
$cats = $graphene_settings['frontpage_posts_cats'];
$query->set( 'category__in', graphene_object_id( $cats, 'category' ) );
}
add_action( 'pre_get_posts', 'graphene_filter_posts_category', 5 );
/**
* Get the post date display type for each post
*
* @package Graphene
* @since 1.8.3
*/
function graphene_post_date_setting( $id ){
$post_setting = graphene_get_post_meta( $id, 'post_date_display' );
if ( $post_setting ) return $post_setting;
global $graphene_settings;
return $graphene_settings['post_date_display'];
}