[英]Form Submit on Custom Admin Page (Wordpress)
我編寫了一個產品插件,該插件具有用於存儲的自定義數據庫表和用於管理的單個頁面。 在該屏幕上,管理員將能夠插入新條目並刪除現有條目。
考慮到這一點,“創建”和“刪除”按鈕都將發布到同一頁面,在這里我將分別處理它們並處理數據庫交互。 我的問題是,由於它不是實際的獨立頁面,而是wp-admin/admin.php?page=my-test-plugin
,我如何實現POST到Self?
<table class="apl_product_table">
<thead>
<tr>
<th>Product Tag</th>
<th>Product Name</th>
<th>Product ID</th>
<th>Product Price</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<form method="POST" action="<?php echo admin_url( 'admin.php' ); ?>">
<td><input type="text" name="product_tag" placeholder="Shortcode ID" required></td>
<td><input type="text" name="product_name" placeholder="Link Display Text" required></td>
<td><input type="text" name="product_id" placeholder="Amazon Product ID" required></td>
<td><input type="text" name="product_price" placeholder="Default Product Price" required></td>
<td><input type="submit" value="Create"></td>
</form>
</tr>
</tbody>
</table>
如果您希望自己提交HTML表單,只需刪除action屬性即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.