Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save propertyhive/30da236791df1990498e9a0664947ec4 to your computer and use it in GitHub Desktop.
Save propertyhive/30da236791df1990498e9a0664947ec4 to your computer and use it in GitHub Desktop.
Custom property import frequency
add_filter( 'propertyhive_property_import_frequencies', 'add_custom_import_frequency' );
function add_custom_import_frequency($frequencies)
{
$new_frequencies = array('every_five_minutes' => 'Every Five Minutes');
// if anything other than 'every_five_minutes' a custom cron schedule will need to be added
// 'every_five_minutes' is already an established schedule setup by the import add on
// https://developer.wordpress.org/reference/hooks/cron_schedules/
return array_merge( $new_frequencies, $frequencies );
}
add_filter( 'propertyhive_property_import_next_due', 'get_next_due', 10, 3 );
function get_next_due( $got_next_due, $next_due, $last_start_date )
{
if ( ( ($next_due - $last_start_date) / 60 / 60 ) >= 0.083333 ) // 0.083333 = a twelth (i.e. five minutes) of an hour
{
$got_next_due = $next_due;
}
return $got_next_due;
}
add_filter( 'propertyhive_property_ok_to_run_import', 'check_ok_to_run_import', 10, 2 );
function check_ok_to_run_import( $ok_to_run_import, $diff_secs )
{
if (($diff_secs / 60 / 60) < 0.083333) // 0.083333 = a twelth (i.e. five minutes) of an hour
{
$ok_to_run_import = false;
}
return $ok_to_run_import;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment