Ich kann nicht die wp_verify_nonce Methode im WordPress-Plugin verwenden.Wordpress: Aufruf zu undefinierter Funktion wp_verify_nonce() in benutzerdefinierten Plugin
Ich bekomme den fatalen Fehler: Call to undefined function wp_verify_nonce()
.
Ich versuchte veröffentlichen die Methode ohne private function submit_form()
Erfolg
<?php
/*
* Frontend class.
*
* Method and property for frontend section.
*
* @since 1.0
*
*/
namespace Simplestform;
class Frontend extends \Simplestform\Base {
/**
* Our constructor.
*
*
*/
public function __construct($base_dir = null) {
parent::__construct();
if (!is_null ($base_dir)) {
/*
* Call Base function to set the base dir
*/
$this->set_base_dir($base_dir);
}
/*
*
* Register shortcode
*
*/
$this->add_shortcode();
$this->submit_form();
}
/**
* Register the shortcode
*
* @since 1.0
*/
private function add_shortcode() {
add_shortcode($this->get_shortcode_tag() , array ($this , 'render_contact_form'));
}
public function render_contact_form() {
include_once ($this->get_base_dir().'/views/frontend/basic-form.php');
}
private function submit_form() {
if (isset ($_POST['_wpnonce'])) {
$nonce = $_POST['_wpnonce'];
wp_verify_nonce ($nonce , 'test_nonce_field');
echo '<pre>';
var_dump ($_POST);
echo '</pre>';
}
}
}
Check [diese Antwort] (https://wordpress.stackexchange.com/questions/21014/cant-access-some-worpress-function-from-my- Plugin) – Picard