最后,我将其解决如下:
add_action( \'admin_enqueue_scripts\', array($this, \'my_admin_scripts\') );
function my_admin_scripts($page) {
global $post;
if ($page == "post-new.php" OR $page == "post.php") {
wp_register_script( \'my-custom-admin-scripts\', plugins_url(\'/js/my-admin-post.js\',dirname(__FILE__)), array(\'jquery\', \'jquery-ui-sortable\' ) , null, true );
wp_enqueue_script( \'my-custom-admin-scripts\' );
}
}
并将JQuery所需的atribute放入下一个js代码(/js/my admin post.js):
// JavaScript Document
jQuery(document).ready(function($) {
$(\'#title\').attr(\'required\', true);
$(\'#content\').attr(\'required\', true);
$(\'#_my_custom_field\').attr(\'required\', true);
});