我制作了新插件,可以帮助我将新帖子插入编辑器。
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()”如何解决?