我有一个插件,我正在设计一个管理页面,当我点击提交时,我会得到一个没有任何错误或文本的白色页面。
这是我的密码
add_action( \'admin_init\', \'linc_plugin_settings\' );
add_action(\'admin_menu\', \'linc_plugin_menu\');
function linc_plugin_settings() {
$id = 1;
$url;
$input_value = $_POST[\'urlfield\'];
if(isset($_POST["urlfield"]) && is_array($_POST["urlfield"])){
foreach ($input_value as $url) {
register_setting( \'linc-post-url-\' . $id++, $url );
}
}
}
function linc_plugin_menu() {
add_menu_page(\'Linc Post Settings\', \'Import Settings\', \'administrator\', \'linc-post-import-settings\', \'linc_plugin_settings_page\', \'dashicons-hammer\');
}
function linc_plugin_settings_page() {
?>
<div id="content">
<h2 id="header-text" align=\'center\'> Linc Post Importer </h2>
<h3 id=\'instructions\' align=\'center\'> Enter the URL of the Linc City Site that you wish to import posts from. <br /> Use the import button to run the import function for the newly added URL\'s</h3>
<h2> Enter URL Below <br /> ex. http://www.linccity.com/</h2>
<form id="url-list">
<input id="url-field-1" name="urlfield[]" type="text">
<button class="button" id="add-url"> + </button>
<script>
jQuery(document).ready(function ($) {
$("#add-url").click(function(){
$( "#submit" ).before( "<br /><input id=\'url-field-1\' name=\'urlfield[]\' type=\'text\'><br />" );
});
});
</script>
<?php submit_button(); ?>
</form>
</div>
<?php
}
我试图在提交表单时为每个包含url的框添加一个设置。
最合适的回答,由SO网友:Bikash Waiba 整理而成
您的按钮正在提交表单使用此脚本
<script>
jQuery(document).ready(function ($) {
$("#add-url").click(function(e){
e.preventDefault();
$( "#submit" ).before( "<br /><input id=\'url-field-1\' name=\'urlfield[]\' type=\'text\'><br />" );
});
});
</script>