From 2b1ddd4eb8731abbc797eb4dcd4c2ba04841b182 Mon Sep 17 00:00:00 2001 From: Saimon Sajjad Date: Thu, 10 Jan 2019 10:36:09 +0600 Subject: [PATCH] feat: add dokan_get_permalink function to retrieve dokan pages url (#517) * feat: add dokan_get_permalink function to retrieve dokan pages url * feat: add dokan_is_store_listing function --- includes/functions.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index 4ccb87202f..bdfaeabb29 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -3351,3 +3351,43 @@ function dokan_get_variable_product_earning( $product_id, $seller_id, $formated return $earning; } + +/** + * Get page permalink of dokan pages by page id + * + * @since DOKAN_SINCE + * + * @param string $page_id + * + * @return string + */ +function dokan_get_permalink( $page_id ) { + if ( ! $page_id ) { + return false; + } + + $pages = get_option( 'dokan_pages' ); + + return isset( $pages[$page_id] ) ? get_permalink( $pages[$page_id] ) : false; +} + +/** + * Check if it's store listing page + * + * @since DOKAN_SINCE + * + * @return boolean + */ +function dokan_is_store_listing() { + $page_id = dokan_get_option( 'store_listing', 'dokan_pages' ); + + if ( ! $page_id ) { + return false; + } + + if ( $page_id === get_the_ID() ) { + return true; + } + + return false; +}