我目前正在使用新功能更新系统。我加入了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
目录