我在WP REST API中弄脏了我的手。我已经阅读了一些教程,并对使用JavaScript创建新帖子提出了一个问题。
在里面this 教程,帖子var status = \'draft\';
(请参见代码)。So I am just worried that won\'t anyone able to hack that status?
jQuery( document ).ready( function ( $ ) {
$( \'#post-submission-form\' ).on( \'submit\', function(e) {
e.preventDefault();
var title = $( \'#post-submission-title\' ).val();
var excerpt = $( \'#post-submission-excerpt\' ).val();
var content = $( \'#post-submission-content\' ).val();
var status = \'draft\'; // this code
var data = {
title: title,
excerpt: excerpt,
content: content
};
$.ajax({
method: "POST",
url: POST_SUBMITTER.root + \'wp/v2/posts\',
data: data,
beforeSend: function ( xhr ) {
xhr.setRequestHeader( \'X-WP-Nonce\', POST_SUBMITTER.nonce );
},
success : function( response ) {
console.log( response );
alert( POST_SUBMITTER.success );
},
fail : function( response ) {
console.log( response );
alert( POST_SUBMITTER.failure );
}
});
});
} );