' . get_the_author() . ''; } elseif ( is_year() ) { $title = get_the_date( 'Y' ); } elseif ( is_month() ) { $title = get_the_date( 'F Y' ); } elseif ( is_day() ) { $title = get_the_date( get_option( 'date_format' ) ); } elseif ( is_tax( 'post_format' ) ) { if ( is_tax( 'post_format', 'post-format-aside' ) ) { $title = _x( 'Asides', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { $title = _x( 'Galleries', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { $title = _x( 'Images', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { $title = _x( 'Videos', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { $title = _x( 'Quotes', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { $title = _x( 'Links', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { $title = _x( 'Statuses', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { $title = _x( 'Audio', 'post format archive title', 'brunch-lite' ); } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { $title = _x( 'Chats', 'post format archive title', 'brunch-lite' ); } } elseif ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } elseif ( is_tax() ) { $title = single_term_title( '', false ); } else { $title = __( 'Archives', 'brunch-lite' ); } return $title; } add_filter( 'get_the_archive_title', 'joy_remove_archive_title_prefix' ); } function joy_convert_date( $orig_time ) { $time_arr = array( 'minutes' => 60, 'hours' => HOUR_IN_SECONDS, 'days' => DAY_IN_SECONDS, 'months' => YEAR_IN_SECONDS / 12, ); $opts = array( 'active' => array( 'date' => true, 'time' => true ), 'position' => 'after', 'time' => array( 'number' => '12', 'type' => 'months' ), 'ago_label' => '' ); $time = current_time( 'timestamp' ); $limit = (int)$opts['time']['number'] * $time_arr[$opts['time']['type']] ; global $post; $post_time = strtotime( $post->post_date ); if ( ( $time - $post_time ) <= $limit ) { $ago_label = !empty( $opts['ago_label'] ) ? $opts['ago_label'] : esc_html__( 'ago', 'brunch-lite' ); if ( $opts['position'] === 'after' ) { return human_time_diff( $post_time, $time ).' '.$ago_label; } else { return $ago_label.' '.human_time_diff( $post_time, $time ); } } return $orig_time; } function joy_grid_category() { if (joy_option('blog_show_categories', true) == true) { $categories = get_the_category(); if ( ! empty( $categories ) ) { echo ''; echo esc_html__('Posted in', 'brunch-lite') . ' ' . ''.esc_html( $categories[0]->name ).''; echo ''; } } } function joy_grid_additional_meta() { if (joy_option('blog_show_author', true) == true) { //echo ', '; echo sprintf( '', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); } if (joy_option('blog_show_posted', true) == true) { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); if (joy_option('time_ago', false) == true) { $time_string = joy_convert_date(get_the_time()); } echo ''; echo ''.esc_html__(',', 'brunch-lite').' '.$time_string.''; } if (joy_option('blog_recipe_meta', false) == true) { $recipe_data = array(); $recipe_data['totaltime'] = get_post_meta( get_the_ID(), 'pb_recipe_totaltime', true ); $recipe_data['yields'] = get_post_meta( get_the_ID(), 'pb_recipe_yields', true ); $recipe_data['cookingmethod'] = get_post_meta( get_the_ID(), 'pb_recipe_cooking_method', true ); $recipe_data['cuisine'] = get_post_meta( get_the_ID(), 'pb_recipe_cuisine', true ); if ($recipe_data['totaltime'] != '') { echo ''; echo ''.esc_html__(',', 'brunch-lite').' '.esc_html__('Ready in', 'brunch-lite').' '.joy_format_time($recipe_data['totaltime']).''; } if ($recipe_data['yields'] != '') { echo ''; echo ''.esc_html__(',', 'brunch-lite').' '.esc_html__('Yields:', 'brunch-lite').' '.($recipe_data['yields']).''; } } } function joy_single_entry_additional_meta() { if (joy_option('post_show_author', true) == true) { echo '•'; echo __( 'By', 'brunch-lite' ) . ' ' . sprintf( '%2$s', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); } if (joy_option('post_show_posted', true) == true) { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); if (joy_option('time_ago', false) == true) { $time_string = joy_convert_date(get_the_time()); } echo '•'; echo sprintf( '%2$s', esc_url( get_permalink() ), $time_string ); } if (joy_option('blog_show_time', true) == true) { $words_per_minute = joy_option('blog_show_time_words', '250'); $content = get_post_field( 'post_content', get_the_ID() ); $word_count = str_word_count( strip_tags( $content ) ); if ($words_per_minute != '') { $ttr = round($word_count / $words_per_minute); } else { $ttr = round($word_count / 250); } if ($ttr == 0 ){ $ttr = '1'; } echo '•'; echo ''.$ttr.' '.esc_html__('Min', 'brunch-lite').' ' . esc_html__('Read', 'brunch-lite'). ''; } } function joy_get_the_date() { $time_string = ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) ? get_the_modified_date() : get_the_date(); if (joy_option('time_ago', false) == true) { $time_string = joy_convert_date(get_the_time()); } return $time_string; } function joy_single_entry_categories() { if ( 'post' == get_post_type() ) { $categories_list = get_the_category_list( esc_html__( ' ', 'brunch-lite' ) ); if ( $categories_list ) { printf( '%1$s', $categories_list ); } } } function joy_get_prev_next_posts() { $prev = get_adjacent_post( true, '', false, 'category' ); $next = get_adjacent_post( true, '', true, 'category' ); return array( 'prev' => $prev, 'next' => $next ); } function joy_background_lazyload_class() { $class_name = ''; if (joy_option('image_lazyload', false) == true) { $class_name = 'background_lazy'; } if ($class_name != '') { echo $class_name; } } function joy_get_image_lazyload_class() { $class_name = ''; if (joy_option('image_lazyload', false) == true) { $class_name = 'image_lazy'; } return $class_name; } function joy_background_image($image_url) { if (joy_option('image_lazyload', false) == true) { echo 'data-background="'.esc_url($image_url).'"'; } else { echo 'style="background-image: url('.esc_url($image_url).');"'; } } function joy_get_background_image($image_url) { if (joy_option('image_lazyload', false) == true) { return 'data-background="'.esc_url($image_url).'"'; } else { return 'style="background-image: url('.esc_url($image_url).');"'; } } function joy_meta_value($id, $param) { $value = get_post_meta( $id, 'pb_'.$param, true ); return $value; } function joy_has_post_gallery($id, $param) { $values = get_post_meta($id); $has_gallery = false; return array('active' => $has_gallery, 'gallery' => $has_gallery ? $values['pb_'.$param] : array()); } function joy_get_sidebar_setup() { $settings_sidebar = joy_option('post_sidebar', 'no'); if (is_single()) { $post_sidebar = joy_meta_value(get_the_ID(), 'post_sidebar_pos'); if ($post_sidebar != '' && $post_sidebar != 'default') { $settings_sidebar = $post_sidebar; } } return $settings_sidebar; } function joy_page_title_setup() { $display = true; if (is_singular('page')) { if (joy_meta_value(get_the_ID(), 'page_title') == 'hide') { $display = false; } } return $display; } if (BRUNCH_DEMO_MODE) { add_action( 'pre_get_posts', 'joy_demo_posts_count', 1 ); function joy_demo_posts_count($query) { if ( is_admin() || ! $query->is_main_query() ) return; $joy_count = isset($_REQUEST['post_count']) ? $_REQUEST['post_count'] : ''; if ($joy_count != '' && intval($joy_count) != 0) { $query->set( 'posts_per_page', intval($joy_count) ); } } add_filter('BRUNCH_DEMO_MODE', 'BRUNCH_DEMO_MODE', 10, 2); function BRUNCH_DEMO_MODE($option, $value) { if (isset($_REQUEST[$option])) { $query_value = $_REQUEST[$option]; if ($query_value == 'true' || $query_value == 'false') { if ($query_value == 'true') { $value = true; } else { $value = false; } } else { $value = $query_value; } } return $value; } } function joy_set_dropcap($content) { if (!is_singular('post')) { return $content; } if ( preg_match( '#(^)(?:\s?)*(([A-Z]|[a-z]|[0-9]|[\p{L}])(.*\R)*(\R)*.*)#m', $content, $matches ) ) { $top_content = str_replace( $matches[2], '', $content ); $bottom_content = ltrim( $matches[2] ); $joy_first_letter_of_filtered_content = mb_substr( $bottom_content, 0, 1 ); if (joy_option('dropcap_style', 'style1') == 'style1' || joy_option('dropcap_style', 'style1') == 'style3') { if ( mb_substr( $bottom_content, 1, 1 ) === ' ' ) { $joy_remaining_letters_of_filtered_content = ' ' . mb_substr( $bottom_content, 2 ); } else { $joy_remaining_letters_of_filtered_content = mb_substr( $bottom_content, 1); } } else { $joy_remaining_letters_of_filtered_content = $content; } $joy_dropcapped_first_letter = '' . $joy_first_letter_of_filtered_content . ''; $bottom_content = $joy_dropcapped_first_letter . $joy_remaining_letters_of_filtered_content; return $top_content . $bottom_content; } return $content; } function joy_get_featured_posts() { if (joy_option('header_featured', false) == true && joy_option('header_featured_tag', '') != '') { $settings = array('tag_name' => joy_option('header_featured_tag', '')); $user_count = joy_option('header_featured_count', ''); if ($user_count != '' && intval($user_count) != 0) { $settings['max_posts'] = $user_count; } $settings['post_order'] = 'date'; JoyFeaturedContent::setup($settings); $joy_featured = JoyFeaturedContent::get_featured_posts(); return apply_filters( 'joy_get_featured_posts', $joy_featured ); } else { return apply_filters( 'joy_get_featured_posts', false ); } } function joy_format_time($minutes) { $minutes = intval($minutes); $output = array(); if ($minutes < 60) { $output['time'] = '00:'.sprintf("%02d", $minutes); } else { $hours = floor($minutes / 60); $minutes = $minutes - ($hours * 60); $output['time'] = sprintf("%02d", $hours).':'.sprintf("%02d", $minutes); } return $output['time']; } function joy_categories_filter( $type ) { if ($type == 'index') { $categories_list = get_categories( array( 'orderby' => 'name', 'order' => 'ASC' ) ); if ( ! empty( $categories_list ) && ! is_wp_error( $categories_list ) ) { $categories_list_display = '