我目前正在使用新功能更新系統。我加入了show_user_profile
和edit_user_profile
行動,以自定義的數據添加到用戶視圖:WordPress使用/wp-admin/admin.php註銷
<script type="text/javascript">
function bindRemoveButton() {
jQuery(function($) {
$('table.available-users button.remove').on('click', function() {
$(this).parent().parent().remove();
});
});
}
bindRemoveButton();
</script>
<table class="form-table available-users">
<tbody>
<tr>
<th>
<label for="accounts"><?php print __('Assigned accounts', ZVA_I18N); ?></label>
<br />
<br />
<a href="<?php bloginfo('template_directory'); ?>/templates/admin/user_add_box.php#TB_iframe=true&width=600&height=550" title="<?php print __('Add User', ZVA_I18N); ?>" class="thickbox button button-primary"><?php print __('Add', ZVA_I18N); ?></button>
</th>
<td>
<table class="wp-list-table widefat fixed users">
<thead>
<tr>
<th scope="col" class="manage-colum" style="padding-left: 20px;"><span><?php print __('Username', ZVA_I18N); ?></span></th>
<th scope="col" class="manage-colum"><span><?php print __('Date From', ZVA_I18N); ?></span></th>
<th scope="col" class="manage-colum"><span><?php print __('Date To', ZVA_I18N); ?></span></th>
<th scope="col" class="manage-colum"><span><?php print __('Action', ZVA_I18N); ?></span></th>
</tr>
</thead>
<tbody>
<?php
foreach($user_available AS $aindex => $available_user) {
$user = new WP_User($available_user['user_id']);
?>
<tr>
<td><?php print $user->user_login; ?> (<?php print $user->display_name; ?>)</td>
<td>
<input type="text" name="jumper_day_from[<?php print $user->ID; ?>]" size="2" value="<?php print date('d', $available_user['from']); ?>" placeholder="DD" />.
<input type="text" name="jumper_month_from[<?php print $user->ID; ?>]" size="2" value="<?php print date('m', $available_user['from']); ?>" placeholder="MM" />.
<input type="text" name="jumper_year_from[<?php print $user->ID; ?>]" size="4" value="<?php print date('Y', $available_user['from']); ?>" placeholder="YYYY" />
</td>
<td>
<input type="text" name="jumper_day_to[<?php print $user->ID; ?>]" size="2" value="<?php print date('d', $available_user['to']); ?>" placeholder="DD" />.
<input type="text" name="jumper_month_to[<?php print $user->ID; ?>]" size="2" value="<?php print date('m', $available_user['to']); ?>" placeholder="MM" />.
<input type="text" name="jumper_year_to[<?php print $user->ID; ?>]" size="4" value="<?php print date('Y', $available_user['to']); ?>" placeholder="YYYY" />
</td>
<td>
<button type="button" class="remove button button-primary"><?php print __('Remove', ZVA_I18N); ?></button>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
好了,沒有問題。在我的代碼上查看Line 19,在這裏我添加一個鏈接/按鈕來打開一個帶有額外內容的新Thickbox。當我點擊鏈接時,一個厚盒子彈出並顯示文件/wp-content/themes/MyTheme/templates/admin/user_add_box.php
中的內容。
使用WordPress自身的功能(如$wpdb
或其他),IM包括admin.php
在user_add_box.php
- 是的,目前這只是這些線路上的文件:
<?php
define('WP_ADMIN', true);
/* Nativate to /wp-admin/ directory */
require_once(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/wp-admin/admin.php');
?>
,當我打開tickbox,登錄將顯示 - 好奇。之後,我完成從WordPress註銷。
我用WordPress工作很長時間,從來沒有這樣的問題。特別是因爲我也開發了多年WordPress的主題和插件。
你能告訴我,我做錯了什麼?爲什麼系統將我註銷?
感謝您的幫助。
編輯
看到核心文件後,我知道我必須這樣定義define('WP_ADMIN', true);
常量,但那是不解決問題。
if ($secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin'))
如果沒有,系統會自然而然重定向到wp-login.php
:如果該文件來自wp-admin
目錄