1 && get_option('page_comments')) : ?> "%s"', 'maia'), get_the_title() ), '', '' ); } endif; if (! function_exists('maia_tbay_entry_meta')) : /** * Prints HTML with meta information for the categories, tags. * * @since Maia 1.0 */ function maia_tbay_entry_meta() { if (is_sticky() && is_home() && ! is_paged()) { printf('%s', esc_html__('Featured', 'maia')); } $format = get_post_format(); if (current_theme_supports('post-formats', $format)) { printf( '%1$s%3$s', sprintf('%s ', _x('Format', 'Used before post format.', 'maia')), esc_url(get_post_format_link($format)), get_post_format_string($format) ); } if (in_array(get_post_type(), array( 'post', 'attachment' ))) { $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')), get_the_date(), esc_attr(get_the_modified_date('c')), get_the_modified_date() ); printf( '%1$s %3$s', _x('Posted on', 'Used before publish date.', 'maia'), esc_url(get_permalink()), $time_string ); } if ('post' == get_post_type()) { if (is_singular() || is_multi_author()) { printf( '%1$s %3$s', _x('Author', 'Used before post author name.', 'maia'), esc_url(get_author_posts_url(get_the_author_meta('ID'))), get_the_author() ); } $categories_list = get_the_category_list(_x(', ', 'Used between list items, there is a space after the comma.', 'maia')); if ($categories_list && maia_tbay_categorized_blog()) { printf( '%1$s %2$s', _x('Categories', 'Used before category names.', 'maia'), $categories_list ); } $tags_list = get_the_tag_list('', _x(', ', 'Used between list items, there is a space after the comma.', 'maia')); if ($tags_list) { printf( '%1$s %2$s', _x('Tags', 'Used before tag names.', 'maia'), $tags_list ); } } if (is_attachment() && wp_attachment_is_image()) { // Retrieve attachment metadata. $metadata = wp_get_attachment_metadata(); printf( '%1$s %3$s × %4$s', _x('Full size', 'Used before full size attachment link.', 'maia'), esc_url(wp_get_attachment_url()), $metadata['width'], $metadata['height'] ); } if (! is_single() && ! post_password_required() && (comments_open() || get_comments_number())) { echo ''; /* translators: %s: post title */ comments_popup_link(sprintf(esc_html__('Leave a comment on %s', 'maia'), get_the_title())); echo ''; } } endif; /** * Determine whether blog/site has more than one category. * * @since Maia 1.0 * * @return bool True of there is more than one category, false otherwise. */ function maia_tbay_categorized_blog() { if (false === ($all_the_cool_cats = get_transient('maia_tbay_categories'))) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories(array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, )); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count($all_the_cool_cats); set_transient('maia_tbay_categories', $all_the_cool_cats); } if ($all_the_cool_cats > 1) { // This blog has more than 1 category so maia_tbay_categorized_blog should return true. return true; } else { // This blog has only 1 category so maia_tbay_categorized_blog should return false. return false; } } /** * Flush out the transients used in {@see maia_tbay_categorized_blog()}. * * @since Maia 1.0 */ function maia_tbay_category_transient_flusher() { // Like, beat it. Dig? delete_transient('maia_tbay_categories'); } add_action('edit_category', 'maia_tbay_category_transient_flusher'); add_action('save_post', 'maia_tbay_category_transient_flusher'); if (! function_exists('maia_tbay_post_thumbnail')) { function maia_tbay_post_thumbnail() { if (post_password_required() || is_attachment() || ! has_post_thumbnail()) { return; } if (is_singular()) : ?>
ID); $k = count($cat); foreach ($cat as $c) { $categories = get_category($c); $k -= 1; if ($k == 0) { echo '' . esc_html($categories->name) . ''; } else { echo '' . esc_html($categories->name) . ', '; } } } } if (! function_exists('maia_tbay_short_top_meta')) { function maia_tbay_short_top_meta($post) { ?>
%2$s', esc_url(get_permalink(get_the_ID())), /* translators: %s: Name of current post */ sprintf(esc_html__('Continue reading %s', 'maia'), '' . get_the_title(get_the_ID()) . '') ); return ' … ' . $link; } add_filter('excerpt_more', 'maia_tbay_excerpt_more'); endif; /** * ------------------------------------------------------------------------------------------------ * Display meta information for a specific post * ------------------------------------------------------------------------------------------------ */ if (! function_exists('maia_post_meta')) { function maia_post_meta($atts = array()) { $text_domain = esc_html__(' comments', 'maia'); if (get_comments_number() == 1) { $text_domain = esc_html__(' comment', 'maia'); } extract(shortcode_atts(array( 'date' => 1, 'author' => 0, 'author_img' => 0, 'comments' => 0, 'comments_text' => 0, 'tags' => 0, 'edit' => 1, ), $atts)); ?>

query_vars['search_terms'])) { global $wpdb; $q = $wp_query->query_vars; $n = ! empty($q['exact']) ? '' : '%'; $search = array(); foreach (( array ) $q['search_terms'] as $term) { $search[] = $wpdb->prepare("$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like($term) . $n); } if (! is_user_logged_in()) { $search[] = "$wpdb->posts.post_password = ''"; } $search = ' AND ' . implode(' AND ', $search); } return $search; } } /** * ------------------------------------------------------------------------------------------------ * Ajax search * ------------------------------------------------------------------------------------------------ */ if ( ! function_exists( 'maia_init_product_search' ) ) { function maia_init_product_search() { if( maia_woocommerce_activated() ) { if ( apply_filters( 'maia_search_query_in', maia_tbay_get_config('search_query_in', 'title') === 'all' ) ) { add_filter( 'posts_search', 'maia_product_search_sku', 9 ); } else { add_filter('posts_search', 'maia_product_search_title', 20, 2); } } } add_action( 'init', 'maia_init_product_search', 10 ); } if ( ! function_exists( 'maia_product_search_sku' ) ) { function maia_product_search_sku( $where ) { if ( !maia_redux_framework_activated() ) return $where; global $wp; if ( ( is_admin() ) //if ((is_admin() && 'edit.php' != $pagenow) || !is_search() || !isset( $wp->query_vars['s'] ) //post_types can also be arrays.. || (isset( $wp->query_vars['post_type'] ) && 'product' != $wp->query_vars['post_type'] ) || (isset( $wp->query_vars['post_type'] ) && is_array( $wp->query_vars['post_type'] ) && !in_array( 'product', $wp->query_vars['post_type'] ) ) ) { return $where; } $s = $wp->query_vars['s']; return maia_sku_search_query( $where, $s ); } } if ( ! function_exists( 'maia_sku_search_query' ) ) { function maia_sku_search_query( $where, $s ) { global $wpdb; $search_ids = array(); $terms = explode( ',', $s ); foreach ( $terms as $term ) { //Include the search by id if admin area. if ( is_admin() && is_numeric( $term ) ) { $search_ids[] = $term; } // search for variations with a matching sku and return the parent. $sku_to_parent_id = $wpdb->get_col( $wpdb->prepare( "SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->wc_product_meta_lookup} ml on p.ID = ml.product_id and ml.sku LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean( $term ) ) ); //Search for a regular product that matches the sku. $clean_term = wc_clean( $term ); $sku_to_id = $wpdb->get_results( "SELECT product_id FROM {$wpdb->wc_product_meta_lookup} WHERE sku LIKE '%{$clean_term}%';", ARRAY_N ); $sku_to_id_results = array(); if ( is_array( $sku_to_id ) ) { foreach ( $sku_to_id as $id ) { $sku_to_id_results[] = $id[0]; } } $search_ids = array_merge( $search_ids, $sku_to_id_results, $sku_to_parent_id ); } $search_ids = array_filter( array_map( 'absint', $search_ids ) ); if ( sizeof( $search_ids ) > 0 ) { $where = str_replace( ')))', ")) OR ( {$wpdb->posts}.ID IN (" . implode( ',', $search_ids ) . ")))", $where ); } return $where; } } if (! function_exists('maia_product_search_title')) { function maia_product_search_title($where, $wp_query) { if ( !maia_redux_framework_activated() ) return $where; $where = maia_search_title_query($where, $wp_query); return $where; } } if (! function_exists('wp_body_open')) : /** * Fire the wp_body_open action. * * Added for backwards compatibility to support pre 5.2.0 WordPress versions. * * @since Maia 1.5 */ function wp_body_open() { /** * Triggered after the opening tag. * * @since Maia 1.5 */ do_action('wp_body_open'); } endif; if (! function_exists('maia_time_link')) : /** * Gets a nicely formatted string for the published date. */ function maia_time_link() { $time_string = ''; $time_string = sprintf( $time_string, get_the_date(DATE_W3C), get_the_date(), get_the_modified_date(DATE_W3C), get_the_modified_date() ); // Wrap the time string in a link, and preface it with 'Posted on'. return sprintf( /* translators: %s: post date */ __('%sPosted on%s %s', 'maia'), '', '', '' . trim($time_string) . '' ); } endif;