所以我的 index.php 上有以下代码:
<?php
define('WP_USE_THEMES', false); // Don't use WP themes
require('../wp-load.php'); // Allows the use of WP functions
?>
<?php // Check if the user is logged in. If not, show the login form
global $user_ID, $user_identity; get_currentuserinfo(); if (!$user_ID) { ?>
<script type="text/javascript">window.location.href='login.php';</script>
<?php } else { // If the user is logged in
include('header.php'); ?>
<div id="content">
<!-- Full Width Start -->
<div class="full-width">
<span class="full-width-red-left"></span>
<div class="full-width-red-wrapper">Department Chooser</div>
<span class="full-width-red-right"></span>
<div class="full-width-content">
<div id="panel-icons">
<?php // Display the menu for each department the user is a member of.
if(is_eventsStaff()){ eventsPanelIcon(); }
if(is_helpDeskStaff()){ helpPanelIcon(); }
if(is_hxlStaff()){ livePanelIcon(); }
if(is_newsStaff()){ newsPanelIcon(); }
if(is_raresStaff()){ raresPanelIcon(); }
if(is_panelAdmin()){ adminPanelIcon();} ?>
</div>
<div id="uploader-icon-wrapper">
<div class="panel-horizontal-split"></div>
<a href="#" id="upload-panel-icon"></a>
</div>
</div>
<div class="full-width-footer"></div>
</div>
<!-- Full Width End -->
</div>
</div>
<?php } else { echo "Test"; } }?>
然后是 header.php:
<link rel='stylesheet' href='CSS/build.css' type='text/css'/>
<title>Habbox Staff Panel</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<?php include_once('functions.php'); // Include staff panel functions ?>
<!-- Preload Image Hovers Start -->
<img src="images/topbar_home_hover.png" class="preload" />
<img src="images/topbar_admin_hover.png" class="preload" />
<img src="images/topbar_events_hover.png" class="preload" />
<!-- Preload Image Hovers End -->
<?php if(has_Roles()) { ?>
<!-- TopBar Start -->
<div id="topbar-wrapper">
<div id="topbar-inner-wrapper">
<span class="topbar-radio-text">Welcome <span class="bold red"><?php echo $user_login; ?></span></span>
<div class="topbar-divider"></div>
<a href="<?php echo $siteURL;?>/index.php" class="topbar-home"></a>
<?php
if (isset($_COOKIE['timezone'])) { date_default_timezone_set($_COOKIE['timezone']); } else { date_default_timezone_set('Europe/London'); }
if(is_eventsStaff()){
echo '<a href="'.$siteURL.'/Events/index.php" class="topbar-events"></a>';
}
// Check if the user is an admin
if(is_panelAdmin()){
echo '<a href="'.$siteURL.'/Admin/users.php" class="topbar-admin"></a>';
}
?>
<div id="topbar-logout">
<form>
<div class="darkbutton"><span class="darkbutton-left"></span><a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Log Out</a><span class="darkbutton-right"></span>
</div>
<input type="hidden" name="redirect_to" value="/Staff">
</form>
</div>
</div>
</div>
<!-- TopBar End -->
<div id="page-wrapper">
但它给了我以下错误:
解析错误:语法错误,第 43 行 index.php 中的意外 T_ELSE
但我不明白为什么。如果我将 header.php 的内容复制到 index.php 中,它似乎工作正常,但当我使用包含时却不行。