Skip to content

Commit

Permalink
fix: return 404 page when vendor store is not found (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
saimonh3 authored and sabbir1991 committed Jan 10, 2019
1 parent 6b63335 commit dd76714
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions classes/rewrites.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ function store_template( $template ) {
if ( ! empty( $store_name ) ) {
$store_user = get_user_by( 'slug', $store_name );

if ( ! $store_user ) {
return get_404_template();
}

// Bell out for Vendor Stuff extensions
if ( ! is_super_admin( $store_user->ID ) && user_can( $store_user->ID, 'vendor_staff' ) ) {
return get_404_template();
Expand Down Expand Up @@ -254,8 +258,13 @@ function store_query_filter( $query ) {
$author = get_query_var( $this->custom_store_url );

if ( ! is_admin() && $query->is_main_query() && ! empty( $author ) ) {
$seller_info = get_user_by( 'slug', $author );
$store_info = dokan_get_store_info( $seller_info->data->ID );
$seller_info = get_user_by( 'slug', $author );

if ( ! $seller_info ) {
return get_404_template();
}

$store_info = dokan_get_store_info( $seller_info->data->ID );
$post_per_page = isset( $store_info['store_ppp'] ) && ! empty( $store_info['store_ppp'] ) ? $store_info['store_ppp'] : 12;
set_query_var( 'posts_per_page', $post_per_page );
$query->set( 'post_type', 'product' );
Expand Down
5 changes: 5 additions & 0 deletions includes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ function wp_title( $title, $sep ) {
if ( dokan_is_store_page() ) {
$site_title = get_bloginfo( 'name' );
$store_user = get_userdata( get_query_var( 'author' ) );

if ( ! $store_user ) {
return $title;
}

$store_info = dokan_get_store_info( $store_user->ID );
$store_name = esc_html( $store_info['store_name'] );
$title = "$store_name $sep $site_title";
Expand Down

0 comments on commit dd76714

Please sign in to comment.