PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
← All changes | includes/class-ph-install.php +204 -32 1.4.622.3.0 View file →
@@ -17,8 +17,25 @@
17 17 */
18 18 class PH_Install {
19 19
20 20 /**
21 + * DB updates and callbacks that need to be run per version.
22 + *
23 + * @var array
24 + */
25 + private static $db_updates = array(
26 + '1.4.68' => array(
27 + 'propertyhive_update_1468_on_market_change_dates',
28 + ),
29 + '2.0.0' => array(
30 + 'propertyhive_update_200_pre_pro_record_installed_plugins',
31 + ),
32 + '2.2.0' => array(
33 + 'propertyhive_deactivate_template_assistant', // different naming convention as needs to be run elsewhere too
34 + ),
35 + );
36 +
37 + /**
21 38 * Hook in tabs.
22 39 */
23 40 public function __construct() {
24 41 register_activation_hook( PH_PLUGIN_FILE, array( $this, 'install' ) );
@@ -69,8 +86,10 @@
69 86
70 87 $this->create_primary_office();
71 88 $this->create_cron_jobs();
72 89
90 + $this->update();
91 +
73 92 // Clear transient cache
74 93
75 94 // Queue upgrades
76 95 $current_version = get_option( 'propertyhive_version', null );
@@ -79,8 +98,9 @@
79 98 // No existing version set. This must be a new fresh install
80 99 if ( is_null( $current_version ) && is_null( $current_db_version ) )
81 100 {
82 101 $this->create_terms();
102 + $this->create_pages();
83 103 set_transient( '_ph_activation_redirect', 1, 30 );
84 104 }
85 105
86 106 update_option( 'propertyhive_db_version', PH()->version );
@@ -105,11 +125,22 @@
105 125 wp_clear_scheduled_hook( 'propertyhive_update_currency_exchange_rates' );
106 126 wp_clear_scheduled_hook( 'propertyhive_process_email_log' );
107 127 wp_clear_scheduled_hook( 'propertyhive_auto_email_match' );
108 128 wp_clear_scheduled_hook( 'propertyhive_check_licenses' );
129 + wp_clear_scheduled_hook( 'propertyhive_update_address_concatenated' );
130 + wp_clear_scheduled_hook( 'propertyhive_cleanup_search_analytics' );
109 131 }
110 132
111 133 /**
134 + * Get list of DB update callbacks.
135 + *
136 + * @return array
137 + */
138 + public static function get_db_update_callbacks() {
139 + return self::$db_updates;
140 + }
141 +
142 + /**
112 143 * Handle updates
113 144 */
114 145 public function update() {
115 146 // Do updates
@@ -114,19 +145,17 @@
114 145 public function update() {
115 146 // Do updates
116 147 $current_db_version = get_option( 'propertyhive_db_version' );
117 148
118 - /*if ( version_compare( $current_db_version, '1.4', '<' ) ) {
119 - include( 'updates/propertyhive-update-1.4.php' );
120 - update_option( 'propertyhive_db_version', '1.4' );
149 + foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) {
150 + if ( version_compare( $current_db_version, $version, '<' ) ) {
151 + foreach ( $update_callbacks as $update_callback ) {
152 + add_action('property_run_update_actions', $update_callback);
153 + }
154 + }
121 155 }
122 -
123 - if ( version_compare( $current_db_version, '2.1.0', '<' ) || PH_VERSION == '2.1-bleeding' ) {
124 - include( 'updates/propertyhive-update-2.1.php' );
125 - update_option( 'propertyhive_db_version', '2.1.0' );
126 - }*/
127 -
128 - update_option( 'propertyhive_db_version', PH()->version );
156 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Existing public Property Hive extension hook property_run_update_actions; changing the established name would detach installed callbacks.
157 + do_action('property_run_update_actions');
129 158 }
130 159
131 160 /**
132 161 * Create cron jobs (clear them first)
@@ -137,13 +166,13 @@
137 166 wp_clear_scheduled_hook( 'propertyhive_update_currency_exchange_rates' );
138 167 wp_clear_scheduled_hook( 'propertyhive_process_email_log' );
139 168 wp_clear_scheduled_hook( 'propertyhive_auto_email_match' );
140 169 wp_clear_scheduled_hook( 'propertyhive_check_licenses' );
170 + wp_clear_scheduled_hook( 'propertyhive_update_address_concatenated' );
171 + wp_clear_scheduled_hook( 'propertyhive_cleanup_search_analytics' );
141 172
142 - $ve = get_option( 'gmt_offset' ) > 0 ? '+' : '-';
143 -
144 173 // Schedule for midnight as it's likely traffic will be quieter at that time
145 - wp_schedule_event( strtotime( '00:00 tomorrow ' . $ve . get_option( 'gmt_offset' ) . ' HOURS' ), 'daily', 'propertyhive_update_currency_exchange_rates' );
174 + wp_schedule_event( strtotime( 'tomorrow' ) - ( (int)get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ), 'daily', 'propertyhive_update_currency_exchange_rates' );
146 175
147 176 wp_schedule_event( time(), 'every_fifteen_minutes', 'propertyhive_process_email_log' );
148 177
149 178 $auto_property_match_enabled = get_option( 'propertyhive_auto_property_match', '' );
@@ -149,14 +178,31 @@
149 178 $auto_property_match_enabled = get_option( 'propertyhive_auto_property_match', '' );
150 179
151 180 if ( $auto_property_match_enabled == 'yes' )
152 181 {
153 - wp_schedule_event( strtotime( '02:00 tomorrow ' . $ve . get_option( 'gmt_offset' ) . ' HOURS' ), 'daily', 'propertyhive_auto_email_match' );
182 + $recurrence = apply_filters( 'propertyhive_auto_email_match_cron_recurrence', 'daily' );
183 + if ( $recurrence != 'hourly' )
184 + {
185 + $timestamp = strtotime( 'tomorrow +2hours') - ( (int)get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
186 + }
187 + else
188 + {
189 + $timestamp = strtotime( '+1 hours' );
190 + }
191 + wp_schedule_event(
192 + apply_filters( 'propertyhive_auto_email_match_cron_timestamp', $timestamp ),
193 + $recurrence,
194 + 'propertyhive_auto_email_match'
195 + );
154 196 }
155 197
156 198 // Schedule for 1am as it's likely traffic will be quieter at that time
157 199 // 1am so it doesn't run at exactly the same time as the exchange rate cron
158 - wp_schedule_event( strtotime( '01:00 tomorrow ' . $ve . get_option( 'gmt_offset' ) . ' HOURS' ), 'daily', 'propertyhive_check_licenses' );
200 + wp_schedule_event( strtotime( 'tomorrow +1hours' ) - ( (int)get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ), 'daily', 'propertyhive_check_licenses' );
201 +
202 + wp_schedule_event( strtotime( 'tomorrow +3hours' ) - ( (int)get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ), 'daily', 'propertyhive_update_address_concatenated' );
203 +
204 + wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', 'propertyhive_cleanup_search_analytics' );
159 205 }
160 206
161 207 public function custom_cron_recurrence( $schedules )
162 208 {
@@ -161,9 +207,9 @@
161 207 public function custom_cron_recurrence( $schedules )
162 208 {
163 209 $schedules['every_fifteen_minutes'] = array(
164 210 'interval' => 900,
165 - 'display' => __( 'Every 15 Minutes', 'textdomain' )
211 + 'display' => __( 'Every 15 Minutes', 'propertyhive' )
166 212 );
167 213
168 214 return $schedules;
169 215 }
@@ -173,9 +219,9 @@
173 219 *
174 220 * @access public
175 221 * @return void
176 222 */
177 - public static function create_pages() {
223 + public function create_pages() {
178 224
179 225 // Create page object
180 226 $my_post = array(
181 227 'post_title' => __( 'Property Search', 'propertyhive' ),
@@ -186,11 +232,14 @@
186 232 'ping_status' => 'closed',
187 233 );
188 234
189 235 // Insert the post into the database
190 - $page_id = wp_insert_post( $my_post );
236 + $page_id = wp_insert_post( $my_post, true );
191 237
192 - update_option( 'propertyhive_search_results_page_id', $page_id );
238 + if ( !is_wp_error($page_id) )
239 + {
240 + update_option( 'propertyhive_search_results_page_id', $page_id );
241 + }
193 242 }
194 243
195 244 /**
196 245 * Add the default terms for PH taxonomies - property types, tenures etc. Modify this at your own risk.
@@ -284,9 +333,9 @@
284 333 'name' => 'Terraced Bungalow',
285 334 'child_of_previous' => true
286 335 ),
287 336 array(
288 - 'name' => 'End of Terrace House',
337 + 'name' => 'End of Terrace Bungalow',
289 338 'child_of_previous' => true
290 339 ),
291 340 // FLATS
292 341 array(
@@ -424,8 +473,14 @@
424 473 'name' => 'Freehold'
425 474 ),
426 475 array(
427 476 'name' => 'Leasehold'
477 + ),
478 + array(
479 + 'name' => 'Share of Freehold'
480 + ),
481 + array(
482 + 'name' => 'Commonhold'
428 483 )
429 484 ),
430 485 'commercial_tenure' => array(
431 486 array(
@@ -432,8 +487,14 @@
432 487 'name' => 'Freehold'
433 488 ),
434 489 array(
435 490 'name' => 'Leasehold'
491 + ),
492 + array(
493 + 'name' => 'Share of Freehold'
494 + ),
495 + array(
496 + 'name' => 'Commonhold'
436 497 )
437 498 ),
438 499 'furnished' => array(
439 500 array(
@@ -453,8 +514,25 @@
453 514 array(
454 515 'name' => 'Chain Free'
455 516 )
456 517 ),
518 + 'management_key_date_type' => array(
519 + array(
520 + 'name' => 'Initial Inventory',
521 + 'recurrence_type' => 'tenancy_management',
522 + 'recurrence_rule' => 'FREQ=ONCE',
523 + ),
524 + array(
525 + 'name' => 'Inspection',
526 + 'recurrence_type' => 'tenancy_management',
527 + 'recurrence_rule' => 'FREQ=MONTHLY;INTERVAL=3',
528 + ),
529 + array(
530 + 'name' => 'Gas Safety Check',
531 + 'recurrence_type' => 'property_management',
532 + 'recurrence_rule' => 'FREQ=YEARLY;INTERVAL=1',
533 + ),
534 + ),
457 535 );
458 536
459 537 $availability_departments = get_option( 'propertyhive_availability_departments', array() );
460 538 if ( !is_array($availability_departments) ) { $availability_departments = array(); }
@@ -486,8 +564,21 @@
486 564 if ( $taxonomy == 'availability' && is_array($term['departments']) && !empty($term['departments']) )
487 565 {
488 566 $availability_departments[$return['term_id']] = $term['departments'];
489 567 }
568 +
569 + if ( $taxonomy == 'management_key_date_type' && isset($term['recurrence_type']) && isset($term['recurrence_rule']) )
570 + {
571 + $options = get_option( 'propertyhive_key_date_type', array() );
572 + if ( !is_array($options) ) { $options = array(); }
573 +
574 + $options[$return['term_id']] = array(
575 + 'recurrence_rule' => $term['recurrence_rule'],
576 + 'recurrence_type' => $term['recurrence_type'],
577 + );
578 +
579 + update_option( 'propertyhive_key_date_type', $options );
580 + }
490 581 }
491 582 else
492 583 {
493 584 // Hmm... an error occurred
@@ -542,8 +633,11 @@
542 633 add_option( 'propertyhive_active_departments_sales', 'yes', '', 'yes' );
543 634 add_option( 'propertyhive_active_departments_lettings', 'yes', '', 'yes' );
544 635 add_option( 'propertyhive_primary_department', 'residential-sales', '', 'yes' );
545 636
637 + add_option( 'propertyhive_maps_provider', 'osm', '', 'no' );
638 + add_option( 'propertyhive_geocoding_provider', 'osm', '', 'no' );
639 +
546 640 add_option( 'propertyhive_default_country', 'GB', '', 'yes' );
547 641 add_option( 'propertyhive_countries', array('GB'), '', 'yes' );
548 642
549 643 add_option( 'propertyhive_applicant_match_price_range_percentage_lower', 20, '', 'no' );
@@ -548,22 +642,28 @@
548 642
549 643 add_option( 'propertyhive_applicant_match_price_range_percentage_lower', 20, '', 'no' );
550 644 add_option( 'propertyhive_applicant_match_price_range_percentage_higher', 5, '', 'no' );
551 645
646 + add_option( 'propertyhive_license_type', 'pro', '', 'yes' );
647 +
552 648 add_option( 'propertyhive_install_timestamp', time(), '', 'no' );
553 649 add_option( 'propertyhive_review_prompt_due_timestamp', strtotime('+30 days'), '', 'no' );
554 650
555 651 add_option( 'propertyhive_enquiry_auto_responder_email_subject', __( 'Thank you for your enquiry', 'propertyhive' ), '', 'no' );
556 - add_option( 'propertyhive_enquiry_auto_responder_email_body', __( "Thank you for your recent property enquiry about [property_address_hyperlinked]. A member of our team will be in touch shortly.
652 + add_option( 'propertyhive_enquiry_auto_responder_email_body', sprintf(
653 + /* translators: %s: blog name shown in the email sign-off */
654 + __( "Thank you for your recent property enquiry about [property_address_hyperlinked]. A member of our team will be in touch shortly.
557 655
558 656 Kind regards,
559 657
560 -" . get_bloginfo('name') . "
658 +%s
561 659
562 -[similar_properties]", 'propertyhive' ), '', 'no' );
660 +[similar_properties]", 'propertyhive' ),
661 + get_bloginfo('name')
662 + ), '', 'no' );
563 663
564 664 add_option( 'propertyhive_property_match_default_email_subject', __( 'We found [property_count] that might be of interest to you', 'propertyhive' ), '', 'no' );
565 - add_option( 'propertyhive_property_match_default_email_body', __( "Hi [contact_name],
665 + add_option( 'propertyhive_property_match_default_email_body', __( "Hi [contact_dear],
566 666
567 667 Based on your requirements, we've found [property_count] below that we believe might be suitable for you:
568 668
569 669 [properties]
@@ -571,28 +671,84 @@
571 671 If you have any questions or require more information about any of the properties shown above please let me know.
572 672
573 673 Kind regards,
574 674
575 -" . get_bloginfo('name'), 'propertyhive' ), '', 'no' );
675 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
576 676
577 - add_option( 'propertyhive_viewing_applicant_booking_confirmation_email_subject', 'Your Viewing On [property_address]', '', 'no' );
578 - add_option( 'propertyhive_viewing_applicant_booking_confirmation_email_body', "Dear [applicant_name],
677 + // Applicant Viewing Booking Confirmation
678 + add_option( 'propertyhive_viewing_applicant_booking_confirmation_email_subject', __( 'Your Viewing On [property_address]', 'propertyhive' ), '', 'no' );
679 + add_option( 'propertyhive_viewing_applicant_booking_confirmation_email_body', __( "Dear [applicant_dear],
579 680
580 681 This is confirmation that your viewing on [property_address] has been booked for [viewing_time] on [viewing_date].
581 682
582 683 Should you need to cancel or amend your booking please do not hesitate to contact us.
583 684
584 -" . get_bloginfo('name'), '', 'no' );
685 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
585 686
586 - add_option( 'propertyhive_viewing_owner_booking_confirmation_email_subject', 'Viewing Booked On [property_address]', '', 'no' );
587 - add_option( 'propertyhive_viewing_owner_booking_confirmation_email_body', "Dear [owner_name],
687 + // Applicant Viewing Cancellation Notification
688 + add_option( 'propertyhive_viewing_applicant_cancellation_notification_email_subject', __( 'Your Viewing On [property_address] Has Been Cancelled', 'propertyhive' ), '', 'no' );
689 + add_option( 'propertyhive_viewing_applicant_cancellation_notification_email_body', __( "Dear [applicant_dear],
588 690
691 +This is confirmation that a viewing on [property_address] that was booked for [viewing_time] on [viewing_date] has been cancelled. [cancelled_reason]
692 +
693 +Should you have any questions please do not hesitate to contact us.
694 +
695 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
696 +
697 + // Owner/Landlord Viewing Booking Confirmation
698 + add_option( 'propertyhive_viewing_owner_booking_confirmation_email_subject', __( 'Viewing Booked On [property_address]', 'propertyhive' ), '', 'no' );
699 + add_option( 'propertyhive_viewing_owner_booking_confirmation_email_body', __( "Dear [owner_dear],
700 +
589 701 This is confirmation that a viewing has been booked at your property, [property_address], for [viewing_time] on [viewing_date].
590 702
591 703 Should you need to cancel or amend this viewing please do not hesitate to contact us.
592 704
593 -" . get_bloginfo('name'), '', 'no' );
705 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
594 706
707 + // Owner/Landlord Viewing Cancellation Notification
708 + add_option( 'propertyhive_viewing_owner_cancellation_notification_email_subject', __( 'Viewing Cancelled On [property_address]', 'propertyhive' ), '', 'no' );
709 + add_option( 'propertyhive_viewing_owner_cancellation_notification_email_body', __( "Dear [owner_dear],
710 +
711 +This is confirmation that a viewing on [property_address] that was booked for [viewing_time] on [viewing_date] has been cancelled. [cancelled_reason]
712 +
713 +Should you have any questions please do not hesitate to contact us.
714 +
715 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
716 +
717 + // Attending Negotiator Viewing Booking Confirmation
718 + add_option( 'propertyhive_viewing_attending_negotiator_booking_confirmation_email_subject', __( 'Viewing Booked On [property_address]', 'propertyhive' ), '', 'no' );
719 + add_option( 'propertyhive_viewing_attending_negotiator_booking_confirmation_email_body', __( "This is confirmation you've been assigned to attend a viewing at property, [property_address], for [viewing_time] on [viewing_date].
720 +
721 +Applicant Details:
722 +[applicant_details]
723 +
724 +Owner Details:
725 +[owner_details]
726 +
727 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
728 +
729 + // Attending Negotiator Viewing Cancellation Notification
730 + add_option( 'propertyhive_viewing_attending_negotiator_cancellation_notification_email_subject', __( 'Viewing Cancelled On [property_address]', 'propertyhive' ), '', 'no' );
731 + add_option( 'propertyhive_viewing_attending_negotiator_cancellation_notification_email_body', __( "This is confirmation that a viewing you were assigned to carry out on [property_address] that was booked for [viewing_time] on [viewing_date] has been cancelled. [cancelled_reason]
732 +
733 +Applicant Details:
734 +[applicant_details]
735 +
736 +Owner Details:
737 +[owner_details]
738 +
739 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
740 +
741 + // Owner/Landlord Appraisal Booking Confirmation
742 + add_option( 'propertyhive_appraisal_owner_booking_confirmation_email_subject', __( 'Appraisal Booked On [property_address]', 'propertyhive' ), '', 'no' );
743 + add_option( 'propertyhive_appraisal_owner_booking_confirmation_email_body', __( "Dear [owner_dear],
744 +
745 +This is confirmation that an appraisal has been booked for your property, [property_address], for [appraisal_time] on [appraisal_date].
746 +
747 +Should you need to cancel or amend this appraisal, please do not hesitate to contact us.
748 +
749 +", 'propertyhive' ) . get_bloginfo('name'), '', 'no' );
750 +
595 751 }
596 752
597 753 /**
598 754 * Set up the database tables which the plugin needs to function.
@@ -622,12 +778,14 @@
622 778 contact_id bigint(20) unsigned NOT NULL,
623 779 property_ids text NOT NULL,
624 780 applicant_profile_id tinyint(3) unsigned NOT NULL,
625 781 to_email_address varchar(255) NOT NULL,
782 + cc_email_address varchar(255) NOT NULL,
783 + bcc_email_address varchar(255) NOT NULL,
626 784 from_name varchar(255) NOT NULL,
627 785 from_email_address varchar(255) NOT NULL,
628 786 subject varchar(255) NOT NULL,
629 - body longtext NOT NULL,
787 + body blob NOT NULL,
630 788 lock_id varchar(23) NOT NULL,
631 789 locked_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
632 790 status varchar(5) NOT NULL,
633 791 send_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -632,8 +790,22 @@
632 790 status varchar(5) NOT NULL,
633 791 send_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
634 792 sent_by bigint(20) unsigned NOT NULL,
635 793 PRIMARY KEY (email_id)
794 + ) $collate;";
795 +
796 + $tables .= "
797 + CREATE TABLE {$wpdb->prefix}ph_address_keyword_polygon (
798 + address_keyword varchar(255) NOT NULL,
799 + polygon_coordinates longtext NOT NULL
800 + ) $collate;";
801 +
802 + $tables .= "
803 + CREATE TABLE {$wpdb->prefix}ph_search_log (
804 + id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
805 + searched_at datetime NOT NULL,
806 + PRIMARY KEY (id),
807 + KEY searched_at (searched_at)
636 808 ) $collate;";
637 809
638 810 dbDelta( $tables );
639 811 }