Skip to content

Commit

Permalink
Split up admin setting to hide phone and email info
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyReichert committed Feb 21, 2022
1 parent 24634c4 commit 843eb13
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
33 changes: 29 additions & 4 deletions src/simply-rets-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -266,10 +280,21 @@ public static function sr_admin_page() {
<td colspan="2">
<label>
<?php echo
'<input type="checkbox" id="sr_show_agent_contact" name="sr_show_agent_contact" value="1" '
. checked(1, get_option('sr_show_agent_contact'), false) . '/>'
'<input type="checkbox" id="sr_hide_agent_office_phone" name="sr_hide_agent_office_phone" value="1" '
. checked(1, get_option('sr_hide_agent_office_phone'), false) . '/>'
?>
Do not show agent/office phone numbers
</label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<?php echo
'<input type="checkbox" id="sr_hide_agent_office_email" name="sr_hide_agent_office_email" value="1" '
. checked(1, get_option('sr_hide_agent_office_email'), false) . '/>'
?>
Do not show Agent and Office phone number and email address (names are still shown).
Do not display agent/office email addresses
</label>
</td>
</tr>
Expand Down
14 changes: 9 additions & 5 deletions src/simply-rets-api-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = '';
Expand Down Expand Up @@ -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 = '';
}

/**
Expand Down
15 changes: 0 additions & 15 deletions src/simply-rets-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 843eb13

Please sign in to comment.