質問編集履歴
1
解決方法
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,3 +66,65 @@
|
|
66
66
|
```
|
67
67
|
|
68
68
|
どのようにすれば、エラーが解消できるかお力添えいただきたいです。
|
69
|
+
|
70
|
+
### 最終的に下記のコードで解決しました!
|
71
|
+
忘備録として記載します。
|
72
|
+
▼footer.php
|
73
|
+
```php
|
74
|
+
<?php
|
75
|
+
//カスタムフィールドで開始日と終了日を取得
|
76
|
+
$jsonString = json_encode($dataArray, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
|
77
|
+
$date_start = date_format(date_create(get_field('イベント開始日')), 'Y/m/d');
|
78
|
+
$date_end = date_format(date_create(get_field('イベント終了日')), 'Y/m/d');
|
79
|
+
if(get_field('イベント終了日')){
|
80
|
+
$ads_s = json_encode($date_start);
|
81
|
+
$ads_e = json_encode($date_end);
|
82
|
+
}else{
|
83
|
+
$ads_s = json_encode($date_start);
|
84
|
+
$ads_e = json_encode($date_start);
|
85
|
+
}
|
86
|
+
|
87
|
+
// スマートカスタムフィールドで除外日をデイトピッカーを使って記載したものを、新しい配列に格納する
|
88
|
+
$get_group = SCF::get('deleteDayArray');
|
89
|
+
$get_delete_day = [];
|
90
|
+
$i = 0;
|
91
|
+
foreach ($get_group as $fields) {
|
92
|
+
$event_time = esc_html($fields['deleteDay']);
|
93
|
+
$get_delete_day[$i] = date_format(date_create($event_time), 'Y/m/d');
|
94
|
+
$i++;
|
95
|
+
}
|
96
|
+
|
97
|
+
$today = date("Y/m/d");
|
98
|
+
//除外日の入力がないとき、今日の日付が自動的に入力されていたため本日の日付で分岐
|
99
|
+
if($get_delete_day[0] !== $today){
|
100
|
+
$get_delete_day_array = json_encode($get_delete_day);
|
101
|
+
}else{
|
102
|
+
//昨日以前の日付は選択に含めないため、除外日の入力がないときは昨日の日付を入れる
|
103
|
+
$get_delete_day_array[0] = date("Y/m/d",strtotime("yesterday"));
|
104
|
+
$get_delete_day_array = json_encode($get_delete_day);
|
105
|
+
}
|
106
|
+
?>
|
107
|
+
<?php if (is_singular("event")): ?>
|
108
|
+
<script>
|
109
|
+
$(function (){
|
110
|
+
var disableDates = JSON.parse('<?php echo $get_delete_day_array; ?>');
|
111
|
+
// ContactForm7のデイトピッカーにカスタムフィールドで設定した最大・最小日を設ける
|
112
|
+
$("#custom-datepicker").datepicker({
|
113
|
+
language: 'ja',
|
114
|
+
dateFormat: 'yy年mm月dd日(D)',
|
115
|
+
beforeShowDay : function(date) {
|
116
|
+
var disableDate = $.datepicker.formatDate('yy/mm/dd', date);
|
117
|
+
if (disableDates.indexOf(disableDate) !== -1) {
|
118
|
+
return [false, ''];
|
119
|
+
}else{
|
120
|
+
return [true, ''];
|
121
|
+
}
|
122
|
+
},
|
123
|
+
minDate: new Date(JSON.parse('<?php echo $ads_s; ?>')),
|
124
|
+
maxDate: new Date(JSON.parse('<?php echo $ads_e; ?>')),
|
125
|
+
});
|
126
|
+
});
|
127
|
+
</script>
|
128
|
+
<?php endif; ?>
|
129
|
+
|
130
|
+
```
|