我创建了一个新插件,可以帮助我在编辑器中插入新帖子。
add_action('media_buttons', 'jgames_button', 20);
function jgames_button()
{
$url = plugins_url().'/j_games_uploads/j_games_uploads.php?page=add&TB_iframe=true&height=500&width=640';
echo '<a href="'.$url.'" class="thickbox" title="Add new game"><img src="'.admin_url('images/media-button-other.gif').'" alt="Add new game"></a>';
}
if(isset($_GET['page']) && $_GET['page'] == 'add'){
?>
<div class="wrap">
<h2>Add new game:</h2>
<form method="post" action="j_games_uploads.php" enctype="multipart/form-data">
<p>
<label for="publisher">publisher:</labe>
<input type="text" name="publisher" />
</p>
...Here is more forms...
<p class="submit">
<input type="submit" name="submit" value="Save Changes" class="button-primary" />
</p>
</form>
</div>
<?php
} elseif (isset($_POST['submit'])){
print_r($_POST['submit']);
}
但是当我点击新按钮进入编辑器时,我看到弹出窗口出现错误“致命错误:调用未定义函数add_action()” 如何解决?
答案 0 :(得分:0)
你的错误在于表格行动。不要将表单发送到独立文件。而不是它你可以使用`
<form action="?action=j_games_uploads" enctype ...`
我希望我能解释一下。