diff --git a/src/simply-rets-admin.php b/src/simply-rets-admin.php index 6e2f3de..d3d41ea 100644 --- a/src/simply-rets-admin.php +++ b/src/simply-rets-admin.php @@ -29,7 +29,6 @@ public static function register_admin_settings() { register_setting('sr_admin_settings', 'sr_contact_page'); register_setting('sr_admin_settings', 'sr_show_listingmeta'); register_setting('sr_admin_settings', 'sr_show_listing_remarks'); - register_setting('sr_admin_settings', 'sr_show_agent_contact'); register_setting('sr_admin_settings', 'sr_listing_gallery'); register_setting('sr_admin_settings', 'sr_show_leadcapture'); register_setting('sr_admin_settings', 'sr_leadcapture_recipient'); @@ -61,6 +60,21 @@ public static function register_admin_settings() { register_setting('sr_admin_settings', 'sr_listing_force_image_https', array( "default" => false )); + + register_setting('sr_admin_settings', 'sr_show_agent_contact'); + $show_contact_default = get_option('sr_show_agent_contact', false); + + register_setting( + 'sr_admin_settings', + 'sr_hide_agent_office_phone', + $show_contact_default + ); + + register_setting( + 'sr_admin_settings', + 'sr_hide_agent_office_email', + $show_contact_default + ); } public static $timezones = array( @@ -266,10 +280,21 @@ public static function sr_admin_page() { + + + + + diff --git a/src/simply-rets-api-helper.php b/src/simply-rets-api-helper.php index 2157fa4..5216ad4 100644 --- a/src/simply-rets-api-helper.php +++ b/src/simply-rets-api-helper.php @@ -1000,7 +1000,8 @@ public static function srResidentialDetailsGenerator( $listing ) { /////////////////////////////////////////////////////// - $show_contact_info = SrUtils::showAgentContact(); + $hide_contact_phone = get_option("sr_hide_agent_office_phone", false); + $hide_contact_email = get_option("sr_hide_agent_office_email", false); // agent data $listing_agent_id = $listing->agent->id; @@ -1010,7 +1011,7 @@ public static function srResidentialDetailsGenerator( $listing ) { $has_agent_contact_info = !empty($listing->agent->contact) AND !empty($listing->agent->contact->email); - if($show_contact_info AND $has_agent_contact_info) { + if(!$hide_contact_email AND $has_agent_contact_info) { $listing_agent_email = $listing->agent->contact->email; } else { $listing_agent_email = ''; @@ -1046,11 +1047,14 @@ public static function srResidentialDetailsGenerator( $listing ) { $listing_office_email = $has_office_contact_info ? $listing->office->contact->email : ''; $officeEmail = SimplyRetsApiHelper::srDetailsTable($listing_office_email, "Listing Office Email"); - /* If show_contact_info is false, stub these fields */ - if(!$show_contact_info) { + /* Hide contact info if settings are enabled */ + if($hide_contact_email) { + $officeEmail = ''; + } + + if($hide_contact_phone) { $agent_phone = ''; $officePhone = ''; - $officeEmail = ''; } /** diff --git a/src/simply-rets-utils.php b/src/simply-rets-utils.php index 1e45672..19c689f 100644 --- a/src/simply-rets-utils.php +++ b/src/simply-rets-utils.php @@ -34,21 +34,6 @@ public static function srShowListingMeta() { return $show_listing_meta; } - /** - * The naming for the database option is backwards. - * If it's 'checked', we _don't_ show data. - */ - public static function showAgentContact() { - - if( get_option('sr_show_agent_contact') ) { - $show = false; - } else { - $show = true; - } - - return $show; - } - /** * Normalize a property type abbreviation into the full text. */