Skip to content

Commit

Permalink
fix: product and author object existence and proper data type validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mralaminahamed committed Nov 28, 2024
1 parent f6b2f86 commit 1bafca9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions includes/wc-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@ function dokan_seller_product_tab( $tabs ) {
* Prints seller info in product single page
*
* @global WC_Product $product
* @param type $val
*/
function dokan_product_seller_tab( $val ) {
function dokan_product_seller_tab() {
global $product;

if ( ! $product instanceof WC_Product ) {
return;
}

$author_id = get_post_field( 'post_author', $product->get_id() );
$author = get_user_by( 'id', $author_id );

if ( ! $author instanceof WP_User ) {
return;
}

$store_info = dokan_get_store_info( $author->ID );

dokan_get_template_part(
Expand Down
3 changes: 3 additions & 0 deletions templates/global/product-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* @since 2.4
*
* @package dokan
*
* @var WP_User $author Vendor user object
* @var array $store_info Vendor store data
*/
?>

Expand Down

0 comments on commit 1bafca9

Please sign in to comment.