Advertisement
palsushobhan

wcfm-store-review-shortcode

May 9th, 2023
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. add_shortcode('wcfm_store_reviews', function($attr) {
  2.     global $WCFMmp, $post;
  3.     if ( ! empty( $attr['id'] ) && absint( $attr['id'] ) ) {
  4.         $vendor_id = absint( $attr['id'] );
  5.     }elseif (  wcfm_is_store_page() ) {
  6.         $wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
  7.         $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
  8.         if ( !empty( $store_name ) ) {
  9.             $store_user = get_user_by( 'slug', $store_name );
  10.             $vendor_id = $store_user->ID;
  11.         }
  12.     }elseif( is_product() ) {
  13.         $vendor_id = $post->post_author;
  14.     }
  15.     if( !$vendor_id && is_single() && $post && is_object( $post ) && wcfm_is_vendor( $post->post_author ) ) {
  16.         $vendor_id = $post->post_author;
  17.     }
  18.     if(!$vendor_id || !wcfm_is_vendor($vendor_id) ) return '';
  19.     $store_user = wcfmmp_get_store( $vendor_id );
  20.     $store_info        = $store_user->get_shop_info();
  21.     ob_start();
  22.     $WCFMmp->template->get_template( 'store/wcfmmp-view-store-reviews.php', array( 'store_user' => $store_user, 'store_info' => $store_info ) );
  23.     return ob_get_clean();
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement