0

我制作了新插件,可以帮助我将新帖子插入编辑器。

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()”如何解决?

4

1 回答 1

0

你的错误在于形式行动。不要将表单帖子发送到独立文件。取而代之的是,您可以使用 `

<form action="?action=j_games_uploads" enctype ...`

我希望我能解释一下。

于 2012-05-01T11:20:12.230 回答