请检查块引用代码。它对标题不起作用。我认为从主体到标题时,此条件不能接受值。但是,有什么解决方案呢?
<?php
/**
* Template Name: Manage Days
*/
if ( isset($_GET['remove_date']) && isset($_GET['_wpnonce']) ) {
$delete_date = $_GET['remove_date'];
$delete_nonce = $_GET['_wpnonce'];
if ( ! wp_verify_nonce( $delete_nonce, 'holiday_nonce' ) ) {
die( 'Failed security check' );
} else {
$delete_holiday = $wpdb->delete(
$wpdb->prefix . 'ab_holidays',
[ 'staff_id' => $staff_id, 'date' => $delete_date ],
[ '%d', '%s' ] );
}
}
get_header(); ?>
<?php
$disable_dates = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}ab_holidays WHERE staff_id = '$staff_id'");
foreach ( $disable_dates as $disable_date ) {
$originalDate = $disable_date->date;
$newDate = date("F j, Y", strtotime($originalDate));
$nonce = wp_create_nonce( 'holiday_nonce' . $originalDate );
echo '<a href="' . get_permalink() . '?remove_date=' . $originalDate . '&_wpnonce=' . $nonce . '" class="delete-holiday"><i class="fa fa-times-circle"></i></a>' . $newDate . '<br />';
}
?>
<?php
get_footer();
if(!wp_verify_nonce($ delete_nonce,'holiday_nonce')){.... } else {.....}