function _mp_products_html_grid($custom_query) { global $mp, $post; $html = ''; $current_post = $post; //get image width if ($mp->get_setting('list_img_size') == 'custom') { $width = $mp->get_setting('list_img_width'); } else { $size = $mp->get_setting('list_img_size'); $width = get_option($size . "_size_w"); } $inline_style = !($mp->get_setting('store_theme') == 'none' || current_theme_supports('mp_style')); while ($custom_query->have_posts()) { $custom_query->the_post(); $img = mp_product_image(false, 'list', $post->ID); $excerpt = $mp->get_setting('show_excerpt') ? '<p class="mp_excerpt">' . $mp->product_excerpt($post->post_excerpt, $post->post_content, $post->ID, '') . '</p>' : ''; $mp_product_list_content = apply_filters('mp_product_list_content', $excerpt, $post->ID); $pinit = mp_pinit_button($post->ID, 'all_view'); $class = array(); $class[] = strlen($img) > 0 ? 'mp_thumbnail' : ''; $class[] = strlen($excerpt) > 0 ? 'mp_excerpt' : ''; $class[] = mp_has_variations($post->ID) ? 'mp_price_variations' : ''; $html .= ' <div itemscope itemtype="http://schema.org/Product" class="hentry mp_one_tile ' . implode($class, ' ') . '"> <div class="mp_one_product"' . ($inline_style ? ' style="width: ' . $width . 'px;"' : '') . '> <div class="mp_product_detail"' . ($inline_style ? ' style="width: ' . $width . 'px;"' : '') . '> ' . $img . ' ' . $pinit . ' <h3 class="mp_product_name entry-title" itemprop="name"> <a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a> </h3> <div>' . $mp_product_list_content . '</div> </div> <div class="mp_price_buy"' . ($inline_style ? ' style="width: ' . $width . 'px;"' : '') . '> ' . mp_product_price(false, $post->ID) . ' ' . mp_buy_button(false, 'list', $post->ID) . ' ' . apply_filters('mp_product_list_meta', '', $post->ID) . ' </div> <div style="display:none" > <span class="entry-title">' . get_the_title() . '</span> was last modified: <time class="updated">' . get_the_time('Y-m-d\\TG:i') . '</time> by <span class="author vcard"><span class="fn">' . get_the_author_meta('display_name') . '</span></span> </div> </div> </div>'; } $html .= $custom_query->found_posts > 0 ? '<div class="clear"></div>' : ''; $post = $current_post; //wp_reset_postdata() doesn't work here for some reason return apply_filters('_mp_products_html_grid', $html, $custom_query); }
function _mp_global_products_html_grid($results, $args) { global $mp, $post; $html = ''; $inline_style = !($mp->get_setting('store_theme') == 'none' || current_theme_supports('mp_style')); $current_blog_id = get_current_blog_id(); $current_post = $post; //thumbnail width $width = (double) $args['thumbnail_size']; foreach ($results as $index => $result) { switch_to_blog($result->blog_id); $post = get_post($result->post_id); setup_postdata($post); $img = mp_product_image(false, 'list', $post->ID, $args['thumbnail_size']); $excerpt = ''; if ($args['text'] == 'excerpt') { $excerpt = '<p class="mp_excerpt">' . $mp->product_excerpt($post->post_excerpt, $post->post_content, $post->ID, '') . '</p>'; } elseif ($args['text'] == 'content') { $excerpt = get_the_content(); } $mp_product_list_content = apply_filters('mp_product_list_content', $excerpt, $post->ID); $pinit = mp_pinit_button($post->ID, 'all_view'); $class = array(); $class[] = strlen($img) > 0 ? 'mp_thumbnail' : ''; $class[] = strlen($excerpt) > 0 ? 'mp_excerpt' : ''; $class[] = mp_has_variations($post->ID) ? 'mp_price_variations' : ''; $html .= ' <div itemscope itemtype="http://schema.org/Product" class="hentry mp_one_tile ' . implode($class, ' ') . '"> <div class="mp_one_product"' . ($inline_style ? ' style="width: ' . $width . 'px;"' : '') . '> <div class="mp_product_detail"' . ($inline_style ? ' style="width: ' . $width . 'px;"' : '') . '> ' . $img . ' ' . $pinit . ' <h3 class="mp_product_name entry-title"> <a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a> </h3> <div>' . $mp_product_list_content . '</div> </div> <div class="mp_price_buy"' . ($inline_style ? ' style="width: ' . $width . 'px;"' : '') . '> ' . ($args['show_price'] ? mp_product_price(false, $post->ID) : '') . ' <a class="mp_link_buynow" href="' . get_permalink($post->ID) . '">' . __('Buy Now »', 'mp') . '</a> ' . apply_filters('mp_product_list_meta', '', $post->ID) . ' </div> <div style="display:none" > <span class="entry-title">' . get_the_title() . '</span> was last modified: <time class="updated">' . get_the_time('Y-m-d\\TG:i') . '</time> by <span class="author vcard"><span class="fn">' . get_the_author_meta('display_name') . '</span></span> </div> </div> </div>'; } $html .= count($results) > 0 ? '<div class="clear"></div>' : ''; $post = $current_post; //wp_reset_postdata() doesn't work here switch_to_blog($current_blog_id); return apply_filters('_mp_global_products_html_grid', $html, $results); }