normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
$taxonomy = 'availability';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$departments = ph_get_departments();
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Availability Option', 'propertyhive' ) : __( 'Edit Availability', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_availability_settings' ),
array(
'title' => __( 'Availability', 'propertyhive' ),
'id' => 'availability_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
);
$availability_departments = get_option( 'propertyhive_availability_departments', array() );
$i = 0;
foreach ( $departments as $key => $value )
{
if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' )
{
$args[] = array(
'title' => __( 'Applies To', 'propertyhive' ),
'name' => 'department[' . $key . ']',
'id' => 'department_' . $key,
//'default' => $term_name,
'value' => ( !isset($availability_departments[$current_id]) || in_array($key, $availability_departments[$current_id]) ? 'yes' : '' ),
'type' => 'checkbox',
'desc_tip' => false,
'desc' => $value,
'checkboxgroup' => ( $i == 0 ? 'start' : ( $i == count($departments)-1 ? 'end' : '' ) ),
);
++$i;
}
}
$args[] = array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
);
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_availability_settings' );
return apply_filters( 'propertyhive_custom_field_availability_settings', $args );
}
/**
* Show residential property type add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_property_type_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
$current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
$taxonomy = 'property_type';
$term_name = '';
$term_parent = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
$term_parent = $term->parent;
}
$existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')');
$args = array(
'hide_empty' => false,
'parent' => 0,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
'exclude' => array($current_id)
);
$terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_type' ) ) );
if ( !empty( $terms ) && !is_wp_error( $terms ) )
{
foreach ($terms as $term)
{
$existing_terms[$term->term_id] = $term->name;
}
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Property Type', 'propertyhive' ) : __( 'Edit Property Type', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_type_settings' ),
array(
'title' => __( 'Property Type', 'propertyhive' ),
'id' => 'property_type_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'title' => __( 'Parent', 'propertyhive' ),
'id' => 'parent_property_type_id',
'default' => $term_parent,
'options' => $existing_terms,
'type' => 'select',
'desc_tip' => false,
'desc' => ''
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_property_type_settings' )
);
return apply_filters( 'propertyhive_custom_field_property_type_settings', $args );
}
/**
* Show commercial property type add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_commercial_property_type_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
$current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
$taxonomy = 'commercial_property_type';
$term_name = '';
$term_parent = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
$term_parent = $term->parent;
}
$existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')');
$args = array(
'hide_empty' => false,
'parent' => 0,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
'exclude' => array($current_id)
);
$terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_property_type' ) ) );
if ( !empty( $terms ) && !is_wp_error( $terms ) )
{
foreach ($terms as $term)
{
$existing_terms[$term->term_id] = $term->name;
}
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Property Type', 'propertyhive' ) : __( 'Edit Property Type', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_property_type_settings' ),
array(
'title' => __( 'Property Type', 'propertyhive' ),
'id' => 'commercial_property_type_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'title' => __( 'Parent', 'propertyhive' ),
'id' => 'parent_commercial_property_type_id',
'default' => $term_parent,
'options' => $existing_terms,
'type' => 'select',
'desc_tip' => false,
'desc' => ''
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_commercial_property_type_settings' )
);
return apply_filters( 'propertyhive_custom_field_commercial_property_type_settings', $args );
}
/**
* Show location add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_location_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
$current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
$taxonomy = 'location';
$term_name = '';
$term_parent = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
$term_parent = $term->parent;
}
$existing_terms = array('' => '(' . __ ( 'no parent', 'propertyhive') . ')');
$args = array(
'hide_empty' => false,
'parent' => 0,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
'exclude' => array($current_id)
);
$terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => $taxonomy ) ) );
if ( !empty( $terms ) && !is_wp_error( $terms ) )
{
foreach ($terms as $term)
{
$existing_terms[$term->term_id] = '- '.$term->name;
$args = array(
'hide_empty' => false,
'parent' => $term->term_id,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
'exclude' => array($current_id)
);
$terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => $taxonomy ) ) );
if ( !empty( $terms ) && !is_wp_error( $terms ) )
{
foreach ($terms as $term)
{
$existing_terms[$term->term_id] = '- - '.$term->name;
}
}
}
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Location', 'propertyhive' ) : __( 'Edit Location', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_location_settings' ),
array(
'title' => __( 'Location', 'propertyhive' ),
'id' => 'location_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'title' => __( 'Parent', 'propertyhive' ),
'id' => 'parent_location_id',
'default' => $term_parent,
'options' => $existing_terms,
'type' => 'select',
'desc_tip' => false,
'desc' => ''
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_location_settings' )
);
return apply_filters( 'propertyhive_custom_field_location_settings', $args );
}
/**
* Show parking add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_parking_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
$current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
$taxonomy = 'parking';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Parking Option', 'propertyhive' ) : __( 'Edit Parking', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_parking_settings' ),
array(
'title' => __( 'Parking', 'propertyhive' ),
'id' => 'parking_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_parking_settings' )
);
return apply_filters( 'propertyhive_custom_field_parking_settings', $args );
}
/**
* Show outside space add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_outside_space_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
$current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
$taxonomy = 'outside_space';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Outside Space', 'propertyhive' ) : __( 'Edit Outside Space', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_outside_space_settings' ),
array(
'title' => __( 'Outside Space', 'propertyhive' ),
'id' => 'outside_space_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_outside_space_settings' )
);
return apply_filters( 'propertyhive_custom_field_outside_space_settings', $args );
}
/**
* Show custom field delete options
*
* @access public
* @return string
*/
public function get_custom_fields_delete($current_id, $taxonomy, $taxonomy_name)
{
global $save_button_text;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
$save_button_text = __( 'Delete', 'propertyhive' );
//$taxonomy = 'outside_space';
//$taxonomy_name = __( 'Outside Space', 'propertyhive' );
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- This branch only selects a read-only success view; the deletion mutation occurs in save() after the settings nonce and capability checks.
$confirm_removal = ( isset( $_POST['confirm_removal'] ) && is_string( $_POST['confirm_removal'] ) ) ? sanitize_text_field( wp_unslash( $_POST['confirm_removal'] ) ) : '';
if ( '1' === $confirm_removal )
{
// A term has just been deleted
global $hide_save_button, $show_cancel_button, $cancel_button_href;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
$hide_save_button = TRUE;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
$show_cancel_button = TRUE;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
$cancel_button_href = admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=' . str_replace("_", "-", $taxonomy) );
$args = array();
$args[] = array( 'title' => __( 'Successfully Deleted', 'propertyhive' ) . ' ' . $taxonomy_name, 'type' => 'title', 'desc' => '', 'id' => 'custom_field_' . $taxonomy . '_delete' );
$args[] = array(
'title' => __( 'Term Deleted', 'propertyhive' ),
'id' => '',
'html' => $taxonomy_name . __(' deleted successfully', 'propertyhive' ) . ' ' . __( 'Go Back', 'propertyhive' ) . '',
'type' => 'html',
'desc_tip' => false,
);
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_delete' );
}
else
{
$term_name = '';
if ($current_id == '')
{
die("ID not passed");
}
else
{
$term_ids = explode("-", $current_id);
$args = array();
foreach ( $term_ids as $current_id )
{
$term = get_term( $current_id, $taxonomy );
if ( is_null($term) || is_wp_error($term) )
{
die("Invalid term trying to be deleted");
}
else
{
$term_name = $term->name;
$args[] = array( 'title' => __( 'Delete', 'propertyhive' ) . ' ' . $taxonomy_name . ': ' . $term_name, 'type' => 'title', 'desc' => '', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' );
// Get number of properties assigned to this term
$query_args = array(
'post_type' => 'property',
'nopaging' => true,
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Term deletion/reassignment must locate all properties or key dates attached to this selected term before removing it.
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'id',
'terms' => $current_id,
),
),
);
$property_query = new WP_Query( $query_args );
$num_properties = $property_query->found_posts;
wp_reset_postdata();
// Get number of applicants assigned to this term
$num_applicants = 0;
if ( $taxonomy == 'property_type' || $taxonomy == 'commercial_property_type' || $taxonomy == 'location' )
{
$query_args = array(
'post_type' => 'contact',
'nopaging' => true,
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Applicant preferences are serialized profile metadata; deletion/reassignment must inspect every applicant profile to preserve its other selections.
'meta_query' => array(
array(
'key' => '_contact_types',
'value' => 'applicant',
'compare' => 'LIKE'
),
),
);
$applicant_query = new WP_Query( $query_args );
if ( $applicant_query->have_posts() )
{
while ( $applicant_query->have_posts() )
{
$applicant_query->the_post();
$applicant_has_taxonomy = false;
$num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE );
if ( $num_applicant_profiles == '' )
{
$num_applicant_profiles = 0;
}
if ( $num_applicant_profiles > 0 )
{
for ( $i = 0; $i < $num_applicant_profiles; ++$i )
{
$applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE );
if ( isset($applicant_profile[$taxonomy.'s']) && is_array($applicant_profile[$taxonomy.'s']) && !empty($applicant_profile[$taxonomy.'s']) )
{
if (in_array($current_id, $applicant_profile[$taxonomy.'s']))
{
$applicant_has_taxonomy = true;
}
}
}
}
if ( $applicant_has_taxonomy )
{
++$num_applicants;
}
}
}
wp_reset_postdata();
}
// Get number of key dates assigned to this term
$num_key_dates= 0;
if ( $taxonomy == 'management_key_date_type' )
{
$query_args = array(
'post_type' => 'key_date',
'nopaging' => true,
'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Term deletion/reassignment must locate all properties or key dates attached to this selected term before removing it.
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'id',
'terms' => $current_id,
),
),
);
$key_date_query = new WP_Query( $query_args );
$num_key_dates = $key_date_query->found_posts;
wp_reset_postdata();
}
if ($num_properties > 0 || $num_applicants > 0 || $num_key_dates > 0 )
{
$alternative_terms = array();
$alternative_terms['none'] = '-- ' . __( 'Don\'t Reassign', 'propertyhive' ) . ' --';
$term_args = array(
'hide_empty' => false,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- This is a get_terms argument excluding the terms being deleted from reassignment choices, not a posts exclusion query.
'exclude' => $term_ids,
'parent' => 0
);
$terms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) );
if ( !empty( $terms ) && !is_wp_error( $terms ) )
{
foreach ($terms as $term)
{
$alternative_terms[$term->term_id] = $term->name;
$term_args = array(
'hide_empty' => false,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- This is a get_terms argument excluding the terms being deleted from reassignment choices, not a posts exclusion query.
'exclude' => $term_ids,
'parent' => $term->term_id
);
$subterms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) );
if ( !empty( $subterms ) && !is_wp_error( $subterms ) )
{
foreach ($subterms as $term)
{
$alternative_terms[$term->term_id] = '- ' . $term->name;
$term_args = array(
'hide_empty' => false,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- This is a get_terms argument excluding the terms being deleted from reassignment choices, not a posts exclusion query.
'exclude' => $term_ids,
'parent' => $term->term_id
);
$subsubterms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) );
if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) )
{
foreach ($subsubterms as $term)
{
$alternative_terms[$term->term_id] = '- - ' . $term->name;
}
}
}
}
}
}
// There are properties assigned to this term
$args[] = array(
'title' => __( 'Re-assign to', 'propertyhive' ),
'id' => 'reassign_to_' . $current_id,
'default' => '',
'options' => $alternative_terms,
'type' => 'select',
'desc_tip' => false,
'desc' => __( 'There are properties, applicants or management dates that have this term assigned to them. Which, if any, term should they be reassigned to?' , 'propertyhive' )
);
}
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' );
}
}
$args[] = array( 'title' => __( 'Confirm Removal', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_confirm_delete' );
$args[] = array(
'title' => __( 'Confirm Removal?', 'propertyhive' ),
'id' => 'confirm_removal',
'type' => 'checkbox',
'desc_tip' => false,
);
$args[] = array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
);
$args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_confirm_delete' );
}
}
return apply_filters( 'propertyhive_custom_field_' . $taxonomy . '_delete', $args );
}
/**
* Show price qualifier add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_price_qualifier_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
$current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
$taxonomy = 'price_qualifier';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Price Qualifier', 'propertyhive' ) : __( 'Edit Price Qualifier', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_price_qualifier_settings' ),
array(
'title' => __( 'Price Qualifier', 'propertyhive' ),
'id' => 'price_qualifier_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_price_qualifier_settings' )
);
return apply_filters( 'propertyhive_custom_field_price_qualifier_settings', $args );
}
/**
* Show sale by add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_sale_by_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
$current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
$taxonomy = 'sale_by';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Sale By', 'propertyhive' ) : __( 'Edit Sale By', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_sale_by_settings' ),
array(
'title' => __( 'Sale By', 'propertyhive' ),
'id' => 'sale_by_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_sale_by_settings' )
);
return apply_filters( 'propertyhive_custom_field_sale_by_settings', $args );
}
/**
* Show tenure add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_tenure_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
$current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
$taxonomy = 'tenure';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Tenure', 'propertyhive' ) : __( 'Edit Tenure', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_tenure_settings' ),
array(
'title' => __( 'Tenure', 'propertyhive' ),
'id' => 'tenure_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_tenure_settings' )
);
return apply_filters( 'propertyhive_custom_field_tenure_settings', $args );
}
/**
* Show commercial tenure add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_commercial_tenure_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
$current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
$taxonomy = 'commercial_tenure';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Tenure', 'propertyhive' ) : __( 'Edit Tenure', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_tenure_settings' ),
array(
'title' => __( 'Tenure', 'propertyhive' ),
'id' => 'commercial_tenure_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_commercial_tenure_settings' )
);
return apply_filters( 'propertyhive_custom_field_commercial_tenure_settings', $args );
}
/**
* Show furnished add/edit options
*
* @access public
* @return string
*/
public function get_custom_fields_furnished_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
$current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
$taxonomy = 'furnished';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Furnished', 'propertyhive' ) : __( 'Edit Furnished', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_furnished_settings' ),
array(
'title' => __( 'Furnished', 'propertyhive' ),
'id' => 'furnished_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'type' => 'hidden',
'id' => 'taxonomy',
'default' => $taxonomy
),
array( 'type' => 'sectionend', 'id' => 'custom_field_furnished_settings' )
);
return apply_filters( 'propertyhive_custom_field_furnished_settings', $args );
}
/**
* Show key date add/edit options
*
* @return string
*/
public function get_custom_fields_management_key_date_type_setting()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
$current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
$taxonomy = 'management_key_date_type';
$term_name = '';
if ($current_id != '')
{
$term = get_term( $current_id, $taxonomy );
$term_name = $term->name;
}
$recurrence = get_option( 'propertyhive_key_date_type', array() );
if ( ! is_array($recurrence) )
{
$recurrence = array();
}
$recurrence_rule = isset($recurrence[$current_id]) ? $recurrence[$current_id]['recurrence_rule'] : '';
$recurrence_type = isset($recurrence[$current_id]) ? $recurrence[$current_id]['recurrence_type'] : '';
$recurrence = array(
'FREQ' => 'ONCE',
'INTERVAL' => '1',
);
if ( !empty($recurrence_rule) )
{
foreach (explode(';', $recurrence_rule) as $key_value_pair){
list($key, $value) = explode('=', $key_value_pair);
$recurrence[$key] = $value;
}
}
$interval_disabled = $recurrence['FREQ'] == 'ONCE' ? array('disabled' => 'disabled') : array();
$args = array(
array( 'title' => ( $current_id == '' ? __( 'Add New Management Date Type', 'propertyhive' ) : __( 'Edit Management Date Type', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_management_key_date_type_settings' ),
array(
'title' => __( 'Description', 'propertyhive' ),
'id' => 'management_key_date_type_name',
'default' => $term_name,
'type' => 'text',
'desc_tip' => false,
),
array(
'title' => __( 'Type', 'propertyhive' ),
'id' => 'management_key_date_type_recurrence_type',
'default' => $recurrence_type,
'type' => 'select',
'desc_tip' => false,
'options' => array(
'tenancy_management' => __( 'Tenancy Management', 'propertyhive' ),
'property_management' => __( 'Property Management', 'propertyhive' ),
),
),
array(
'title' => __( 'Frequency', 'propertyhive' ),
'id' => 'management_key_date_type_recurrence_freq',
'default' => $recurrence['FREQ'],
'type' => 'select',
'desc_tip' => false,
'options' => array(
'ONCE' => __( 'Once', 'propertyhive' ),
'DAILY' => __( 'Daily', 'propertyhive' ),
'WEEKLY' => __( 'Weekly', 'propertyhive' ),
'MONTHLY' => __( 'Monthly', 'propertyhive' ),
'YEARLY' => __( 'Yearly', 'propertyhive' ),
),
'custom_attributes' => array('onchange' => "
jQuery('#management_key_date_type_recurrence_interval').prop( 'disabled', this.value == 'ONCE');
"),
),
array(
'title' => __( 'Interval', 'propertyhive' ),
'id' => 'management_key_date_type_recurrence_interval',
'default' => $recurrence['INTERVAL'],
'type' => 'number',
'custom_attributes' => array_merge( array( 'min' => '1', 'required' => 'true'), $interval_disabled ),
'desc' => '
When setting a key date to Complete, these settings are used to calculate the date the next one should occur. For example, if a key date should happen every 3 months, set Frequency to "Monthly" and Interval to "3".