1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
<?php
class orddd_shipping_days_settings {
public static function orddd_shipping_days_settings_section_callback() {
_e( '<b>Shipping Days</b> refers to the working days of your own company. <b>Delivery Days</b> refers to the working days of your shipping company to whom you submit your orders for deliveries. <br>Leave this unchanged if you handle delivery & shipping by yourself.', 'order-delivery-date' );
}
public static function orddd_enable_shipping_days_callback( $args ) {
$orddd_enable_shipping_days = '';
if ( get_option( 'orddd_enable_shipping_days' ) == 'on' ) {
$orddd_enable_shipping_days = 'checked';
}
echo '<input type="checkbox" name="orddd_enable_shipping_days" id="orddd_enable_shipping_days" class="day-checkbox" ' . $orddd_enable_shipping_days . '/>';
$html = '<label for="orddd_enable_shipping_days"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_shipping_day_0_save( $input ) {
$input = orddd_shipping_days_settings::return_orddd_shipping_day_input( 'orddd_shipping_day_0' );
return $input;
}
public static function orddd_shipping_day_1_save( $input ) {
$input = orddd_shipping_days_settings::return_orddd_shipping_day_input( 'orddd_shipping_day_1' );
return $input;
}
public static function orddd_shipping_day_2_save( $input ) {
$input = orddd_shipping_days_settings::return_orddd_shipping_day_input( 'orddd_shipping_day_2' );
return $input;
}
public static function orddd_shipping_day_3_save( $input ) {
$input = orddd_shipping_days_settings::return_orddd_shipping_day_input( 'orddd_shipping_day_3' );
return $input;
}
public static function orddd_shipping_day_4_save( $input ) {
$input = orddd_shipping_days_settings::return_orddd_shipping_day_input( 'orddd_shipping_day_4' );
return $input;
}
public static function orddd_shipping_day_5_save( $input ) {
$input = orddd_shipping_days_settings::return_orddd_shipping_day_input( 'orddd_shipping_day_5' );
return $input;
}
public static function orddd_shipping_day_6_save( $input ) {
$input = orddd_shipping_days_settings::return_orddd_shipping_day_input( 'orddd_shipping_day_6' );
return $input;
}
public static function return_orddd_shipping_day_input( $weekday ) {
global $orddd_shipping_days;
$input = '';
if( isset( $_POST[ 'orddd_shipping_days' ] ) ) {
$weekdays = $_POST[ 'orddd_shipping_days' ];
if( in_array( $weekday, $weekdays ) ) {
$input = 'checked';
}
}
return $input;
}
public static function orddd_shipping_days_callback( $args ) {
global $orddd_shipping_days;
echo '<select class="orddd_shipping_days" id="orddd_shipping_days" name="orddd_shipping_days[]" placeholder="Select Weekdays" multiple="multiple">';
foreach ( $orddd_shipping_days as $n => $day_name ) {
if( "checked" == get_option( $n ) ) {
print( '<option name="' . $n . '" value="' . $n . '" selected>' . $day_name . '</option>' );
} else {
print( '<option name="' . $n . '" value="' . $n . '">' . $day_name . '</option>' );
}
}
echo '</select>';
echo '<script>
jQuery( ".orddd_shipping_days" ).select2();
</script>';
$html = '<label for="orddd_shipping_days"> ' . $args[ 0 ] . '</label>';
echo $html;
}
}