Skip to content

Instantly share code, notes, and snippets.

@rajeshsingh520
Created January 19, 2026 10:01
Show Gist options
  • Select an option

  • Save rajeshsingh520/db495a979edfaf64fa5b83ff00eb9a14 to your computer and use it in GitHub Desktop.

Select an option

Save rajeshsingh520/db495a979edfaf64fa5b83ff00eb9a14 to your computer and use it in GitHub Desktop.
class pisol_custom_code_20260119{
static $instance = null;
static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
function __construct() {
add_filter('pisol_dtt_date_sort', [$this, 'dates'], PHP_INT_MAX);
}
function dates($dates) {
$dates = self::removeNonWorkingDays($dates);
return $dates;
}
static function removeNonWorkingDays($dates){
$type = pi_dtt_delivery_type::getType();
$var_name = 'pi_'.$type.'_days';
$allowed_days = pisol_dtt_get_setting($var_name, array());
if(empty($allowed_days)) return $dates;
foreach($dates as $key => $date){
$day_of_week = date('w', strtotime($date));
if(!in_array((string)$day_of_week, $allowed_days)){
unset($dates[$key]);
}
}
return $dates;
}
}
pisol_custom_code_20260119::get_instance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment