将我的插件页面分成不同文件的问题

时间:2016-06-20 作者:K.Briggs

由于我的上一个(第一个)插件在一个文件中有6个管理页面,因此有点难以管理,我决定将它们拆分为这一个,但这样做只会带来问题。

在我的插件函数文件(LoadPressFunctions.php)中,我有以下内容:

add_action( \'admin_menu\', \'my_plugin_menu\' );

function my_plugin_menu() {
    add_menu_page( \'LoadPress\', \'LoadPress\', \'manage_options\', \'LoadPressPlugin\', \'LoadPress_Plugin\', \'dashicons-download\', 99  );
}

function LoadPress_Plugin() {
    if ( !current_user_can( \'manage_options\' ) )  {
        wp_die( __( \'You do not have sufficient permissions to access this page.\' ) );
    }
    include \'LoadPressOptions-Home.php\';
}
在我的加载中,按Options Home。php文件我有:

<?php
echo \'<style>
    h1 {
        letter-spacing: 8px;
    }
    .sectionHeader {
        background-color: #E5E5E5;
        padding: 1px 10px 1px 10px;
        margin: 10px 0px 0px 0px;
        border-left: 4px solid #2A333E;
    }
    .sectionNotification {
        background-color: #E5E5E5;
        padding: 1px 10px 1px 10px;
        margin: 5px 0px 0px 0px;
        border-left: 4px solid #ffce1f;
    }
    ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu>li.current>a.current:after {
        border-right-color: #12171C;
    }
  </style>\';

    echo \'<div class="wrap">\';
    echo \'<h1>LoadPress</h1>\';
    echo \'<p class="description" id="tagline-description">Simplify Brilliance, Simplify Life.</p>\';
    ?>
    <h2 class="nav-tab-wrapper">
            <a class="nav-tab nav-tab-active" href="<?php echo admin_url() ?>admin.php?page=LoadPressPlugin">Home</a>
            <!--<a class="nav-tab" href="<?php echo admin_url() ?>admin.php?page=LoadPressPlugin-Settings">Settings</a>-->
            <a class="nav-tab" href="<?php echo admin_url() ?>admin.php?page=LoadPressPlugin-About">About/Credits</a>
            <a class="nav-tab" style="background-color: red;">Settings (Not available in Alpha)</a>
            <a class="nav-tab" href="<?php echo admin_url() ?>admin.php?page=LoadPressPlugin-Docs">Documentation</a>
            <a class="nav-tab" style="background-color: red;">Email Editor (Coming Soon)</a>
        </h2>
        <?php
//Options
    echo \'<div>\';
    ?>
    <img src="<?php echo get_site_url() ?>/wp-content/plugins/LoadPress/LoadPressLogo-Banner.png" style="margin-top: 10px;"/>
<?php
    echo \'</div>\';
?>
    <div class="sectionNotification">
    <h3>Thank You for choosing LoadPress</h3>
    </div>

    <div class="sectionHeader">
    <h3>What is LoadPress?</h3>
    <p>LoadPress is a professional plugin that allows site community members to post downloadable files, such as modifications, save files and other community applicable files.</p>
    <p>This plugin was developed for use primarily with modding communities for video games, and other video game related products, and uses a simplistic yet robust setup with several different fallbacks in case of mistakes.</p>
    <p>At the time of writing this, LoadPress is primarily used for in-house projects developed by Kyle Briggs & Don Briggs Ltd.</p>
    </div>

    <div class="sectionHeader">
    <h3>Why LoadPress?</h3>
    <p>LoadPress is an excellent choice for targeted community functionality as it offers several things other plugins do not:</p>
    <ol>
        <li>It allows users to upload files in any format (settable by editing the plugin).</li>
        <li>It allows total administrative control over all files, but only gives regular users access to their own.</li>
        <li>It simplifies the Media section to only display a regular user\'s own media (admins can see all).</li>
        <li>It is the ONLY plugin currently available for Wordpress that offers this functionality tailored specifically to file-sharing, and works seamlessly with any SEO package.</li>
        <li>At the core, it runs on Wordpress\' own API so the custom post type can be edited to your needs easily.</li>
    </ol>
    </div>

    </div>
    <?php
但现在我得到了一个空白页,因为我已经将此内容从主文件移动到了自己的文件,没有从中加载内容。

如果我将文件内容替换为:

<?php
echo \'<h1>Hi</h1>\';
一切正常,但我看不到Home有任何语法错误。php内容,因为它是直接复制和粘贴出来的功能(并添加了任何想法?

1 个回复
SO网友:Steve

您是否已在wordpress中启用调试?

打开wp config。php,并更改此行:

define(\'WP_DEBUG\', false);

define(\'WP_DEBUG\', true);
然后,PHP错误将输出到屏幕。