From ae1462a6e67691d2108e9725a99ffe3d42005e00 Mon Sep 17 00:00:00 2001 From: Saimon Sajjad Date: Mon, 11 May 2020 16:32:23 +0600 Subject: [PATCH] feat: hide vendor info if admin wants to (#829) --- includes/Admin/Settings.php | 15 +++++++++++++++ includes/REST/Manager.php | 10 +++++++++- includes/functions.php | 19 +++++++++++++++++++ templates/global/product-tab.php | 2 +- templates/store-header.php | 6 +++--- templates/store-lists-loop.php | 4 ++-- 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index f98ffa6ee2..07dd32c0a3 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -515,6 +515,21 @@ public function get_settings_fields() { 'type' => 'checkbox', 'default' => 'off' ), + 'hide_vendor_info' => array( + 'name' => 'hide_vendor_info', + 'label' => __( 'Hide Vendor Info', 'dokan' ), + 'type' => 'multicheck', + 'default' => array( + 'email' => '', + 'phone' => '', + 'address' => '', + ), + 'options' => array( + 'email' => __( 'Email Address', 'dokan' ), + 'phone' => __( 'Phone Number', 'dokan' ), + 'address' => __( 'Store Address', 'dokan' ), + ) + ), ), 'dokan_privacy' => array( 'enable_privacy' => array( diff --git a/includes/REST/Manager.php b/includes/REST/Manager.php index 702129eb85..c8df478154 100644 --- a/includes/REST/Manager.php +++ b/includes/REST/Manager.php @@ -105,7 +105,15 @@ public function filter_store_open_close_option( $data ) { return $data; } - if ( empty( $data['show_email'] ) ) { + if ( dokan_is_vendor_info_hidden( 'address' ) ) { + unset( $data['address'] ); + } + + if ( dokan_is_vendor_info_hidden( 'phone' ) ) { + unset( $data['phone'] ); + } + + if ( dokan_is_vendor_info_hidden( 'email' ) || empty( $data['show_email'] ) ) { unset( $data['email'] ); } diff --git a/includes/functions.php b/includes/functions.php index a5a4fcec9d..b10917b3cf 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -3830,3 +3830,22 @@ function dokan_clear_product_caches( $product ) { $method->setAccessible( true ); $method->invokeArgs( $class, [ &$product ] ); } + +/** + * Check which vendor info should be hidden + * + * @since DOKAN_LITE_SINCE + * + * @param string $option + * + * @return bool|array if no param is passed + */ +function dokan_is_vendor_info_hidden( $option = null ) { + $options = dokan_get_option( 'hide_vendor_info', 'dokan_appearance' ); + + if ( is_null( $option ) ) { + return $options; + } + + return ! empty( $options[ $option ] ); +} \ No newline at end of file diff --git a/templates/global/product-tab.php b/templates/global/product-tab.php index 5cbfdc68bb..a7db2b554b 100644 --- a/templates/global/product-tab.php +++ b/templates/global/product-tab.php @@ -31,7 +31,7 @@ %s', esc_url( dokan_get_store_url( $author->ID ) ), esc_attr( $author->display_name ) ); ?> - +
  • diff --git a/templates/store-header.php b/templates/store-header.php index b9821dfa39..63953a9668 100644 --- a/templates/store-header.php +++ b/templates/store-header.php @@ -66,20 +66,20 @@ class="profile-info-img">
      - +
    • - get_phone() ) ) { ?> + get_phone() ) ) { ?>
    • get_phone() ); ?>
    • - show_email() == 'yes' ) { ?> + show_email() == 'yes' ) { ?>
    • get_email() ) ); ?> diff --git a/templates/store-lists-loop.php b/templates/store-lists-loop.php index 0beea4ec68..8bfa17b2eb 100644 --- a/templates/store-lists-loop.php +++ b/templates/store-lists-loop.php @@ -48,7 +48,7 @@ - + array( @@ -60,7 +60,7 @@

      - +