1

我正在使用 wordpress,我一直在学习一些非常好的教程并通读 codex,但我遇到了一个问题,我似乎无法在其他任何地方找到答案。最终我的计划是为我的主题的用户创建一个界面,允许他们更改模板中某些元素的颜色、宽度、定位等。基本上它将是一个 php 文件,它将生成一个 css 文档。现在,尽管它所做的只是回显一个句子。我不确定这在技术上是否是一个“插件”,但是当我尝试将它放在插件文件夹中时,我最终会遇到 404 错误。我知道文件在那里,并且我已经三次检查了路径。我也尝试直接在 url 中导航到 php 文件,但仍然出现 404 错误。我也尝试过使用插件模板。当我在插件管理器中单击“激活”时,它会呼应这句话,但是从 functions.php 文件中调用它时它根本不起作用。任何帮助是极大的赞赏。

这是我放在functions.php末尾的代码:

//begin template specific*******************************************************

//------the function below styles the wordpress admin menus.-------

function custom_style() {
    echo '<style type="text/css">#adminmenu .wp-menu-image img {padding: 0px !important; margin-left: -3px;}</style>';
}

add_action('admin_menu', 'register_custom_menu_page');
add_action('admin_menu', 'custom_style');

//------this function adds the template specific menu item.---------

function register_custom_menu_page() {
    add_menu_page('Epsilon', 'Epsilon', 'add_users', plugins_url('epsilon/eps-manage.php', eps-manage.php ), '',   content_url('themes/epsilon/images/eps-icon.png'), 6);
}   // this function creates the correct path as far as I can tell, but when I click the link button in the admin menu, I get the 404.

//------this function hides the editor option under the appearance menu ----------

function remove_editor_menu() {
    remove_action('admin_menu', '_add_themes_utility_last', 101);
}

add_action('_admin_menu', 'remove_editor_menu', 1);

为什么我会收到此 404 错误,是否有更正确的方法来执行此操作?

4

1 回答 1

2

您正在尝试合并插件和主题。plugins_url 只会加载已注册和激活(不确定是否激活 100%)插件的文件,当您正在开发主题时,最好将管理文件与主题文件夹相关联,但老实说这种类型因为你是一个初学者,所以我会把所有的东西都保存在functions.php中,并使用函数作为你菜单的回调。

于 2012-08-28T19:05:35.887 回答