如何从下面的代码验证wordpress nonce?

0ejtzxu1  于 2021-06-23  发布在  Mysql
关注(0)|答案(0)|浏览(282)

请检查blockquote代码。它不工作的标题。我认为这个条件不能接受从主体到标题的值。但是,有什么解决办法呢?

<?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();

如果(!wp\u verify\u nonce($delete\u nonce,'holiday\u nonce')){….}否则{….}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题