block->context['query']['author'] ) && $block->context['query']['author'] > 0 ) {
$query['author'] = $block->context['query']['author'];
}
}
if ( ! empty( $block->context['query']['search'] ) ) {
$query['s'] = $block->context['query']['search'];
}
if ( ! empty( $block->context['query']['parents'] ) && is_post_type_hierarchical( $query['post_type'] ) ) {
$query['post_parent__in'] = array_unique( array_map( 'intval', $block->context['query']['parents'] ) );
}
}
/**
* Filters the arguments which will be passed to `WP_Query` for the Query Loop Block.
*
* Anything to this filter should be compatible with the `WP_Query` API to form
* the query context which will be passed down to the Query Loop Block's children.
* This can help, for example, to include additional settings or meta queries not
* directly supported by the core Query Loop Block, and extend its capabilities.
*
* Please note that this will only influence the query that will be rendered on the
* front-end. The editor preview is not affected by this filter. Also, worth noting
* that the editor preview uses the REST API, so, ideally, one should aim to provide
* attributes which are also compatible with the REST API, in order to be able to
* implement identical queries on both sides.
*
* @since 6.1.0
*
* @param array $query Array containing parameters for `WP_Query` as parsed by the block context.
* @param WP_Block $block Block instance.
* @param int $page Current query's page.
*/
return apply_filters( 'query_loop_block_query_vars', $query, $block, $page );
}
/**
* Helper function that returns the proper pagination arrow HTML for
* `QueryPaginationNext` and `QueryPaginationPrevious` blocks based
* on the provided `paginationArrow` from `QueryPagination` context.
*
* It's used in QueryPaginationNext and QueryPaginationPrevious blocks.
*
* @since 5.9.0
*
* @param WP_Block $block Block instance.
* @param bool $is_next Flag for handling `next/previous` blocks.
* @return string|null The pagination arrow HTML or null if there is none.
*/
function get_query_pagination_arrow( $block, $is_next ) {
$arrow_map = array(
'none' => '',
'arrow' => array(
'next' => '→',
'previous' => '←',
),
'chevron' => array(
'next' => '»',
'previous' => '«',
),
);
if ( ! empty( $block->context['paginationArrow'] ) && array_key_exists( $block->context['paginationArrow'], $arrow_map ) && ! empty( $arrow_map[ $block->context['paginationArrow'] ] ) ) {
$pagination_type = $is_next ? 'next' : 'previous';
$arrow_attribute = $block->context['paginationArrow'];
$arrow = $arrow_map[ $block->context['paginationArrow'] ][ $pagination_type ];
$arrow_classes = "wp-block-query-pagination-$pagination_type-arrow is-arrow-$arrow_attribute";
return "$arrow";
}
return null;
}
/**
* Helper function that constructs a comment query vars array from the passed
* block properties.
*
* It's used with the Comment Query Loop inner blocks.
*
* @since 6.0.0
*
* @param WP_Block $block Block instance.
* @return array Returns the comment query parameters to use with the
* WP_Comment_Query constructor.
*/
function build_comment_query_vars_from_block( $block ) {
$comment_args = array(
'orderby' => 'comment_date_gmt',
'order' => 'ASC',
'status' => 'approve',
'no_found_rows' => false,
);
if ( is_user_logged_in() ) {
$comment_args['include_unapproved'] = array( get_current_user_id() );
} else {
$unapproved_email = wp_get_unapproved_comment_author_email();
if ( $unapproved_email ) {
$comment_args['include_unapproved'] = array( $unapproved_email );
}
}
if ( ! empty( $block->context['postId'] ) ) {
$comment_args['post_id'] = (int) $block->context['postId'];
}
if ( get_option( 'thread_comments' ) ) {
$comment_args['hierarchical'] = 'threaded';
} else {
$comment_args['hierarchical'] = false;
}
if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) {
$per_page = get_option( 'comments_per_page' );
$default_page = get_option( 'default_comments_page' );
if ( $per_page > 0 ) {
$comment_args['number'] = $per_page;
$page = (int) get_query_var( 'cpage' );
if ( $page ) {
$comment_args['paged'] = $page;
} elseif ( 'oldest' === $default_page ) {
$comment_args['paged'] = 1;
} elseif ( 'newest' === $default_page ) {
$max_num_pages = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
if ( 0 !== $max_num_pages ) {
$comment_args['paged'] = $max_num_pages;
}
}
}
}
return $comment_args;
}
/**
* Helper function that returns the proper pagination arrow HTML for
* `CommentsPaginationNext` and `CommentsPaginationPrevious` blocks based on the
* provided `paginationArrow` from `CommentsPagination` context.
*
* It's used in CommentsPaginationNext and CommentsPaginationPrevious blocks.
*
* @since 6.0.0
*
* @param WP_Block $block Block instance.
* @param string $pagination_type Optional. Type of the arrow we will be rendering.
* Accepts 'next' or 'previous'. Default 'next'.
* @return string|null The pagination arrow HTML or null if there is none.
*/
function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) {
$arrow_map = array(
'none' => '',
'arrow' => array(
'next' => '→',
'previous' => '←',
),
'chevron' => array(
'next' => '»',
'previous' => '«',
),
);
if ( ! empty( $block->context['comments/paginationArrow'] ) && ! empty( $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ] ) ) {
$arrow_attribute = $block->context['comments/paginationArrow'];
$arrow = $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ];
$arrow_classes = "wp-block-comments-pagination-$pagination_type-arrow is-arrow-$arrow_attribute";
return "$arrow";
}
return null;
}
/**
* Strips all HTML from the content of footnotes, and sanitizes the ID.
*
* This function expects slashed data on the footnotes content.
*
* @access private
* @since 6.3.2
*
* @param string $footnotes JSON-encoded string of an array containing the content and ID of each footnote.
* @return string Filtered content without any HTML on the footnote content and with the sanitized ID.
*/
function _wp_filter_post_meta_footnotes( $footnotes ) {
$footnotes_decoded = json_decode( $footnotes, true );
if ( ! is_array( $footnotes_decoded ) ) {
return '';
}
$footnotes_sanitized = array();
foreach ( $footnotes_decoded as $footnote ) {
if ( ! empty( $footnote['content'] ) && ! empty( $footnote['id'] ) ) {
$footnotes_sanitized[] = array(
'id' => sanitize_key( $footnote['id'] ),
'content' => wp_unslash( wp_filter_post_kses( wp_slash( $footnote['content'] ) ) ),
);
}
}
return wp_json_encode( $footnotes_sanitized );
}
/**
* Adds the filters for footnotes meta field.
*
* @access private
* @since 6.3.2
*/
function _wp_footnotes_kses_init_filters() {
add_filter( 'sanitize_post_meta_footnotes', '_wp_filter_post_meta_footnotes' );
}
/**
* Removes the filters for footnotes meta field.
*
* @access private
* @since 6.3.2
*/
function _wp_footnotes_remove_filters() {
remove_filter( 'sanitize_post_meta_footnotes', '_wp_filter_post_meta_footnotes' );
}
/**
* Registers the filter of footnotes meta field if the user does not have `unfiltered_html` capability.
*
* @access private
* @since 6.3.2
*/
function _wp_footnotes_kses_init() {
_wp_footnotes_remove_filters();
if ( ! current_user_can( 'unfiltered_html' ) ) {
_wp_footnotes_kses_init_filters();
}
}
/**
* Initializes the filters for footnotes meta field when imported data should be filtered.
*
* This filter is the last one being executed on {@see 'force_filtered_html_on_import'}.
* If the input of the filter is true, it means we are in an import situation and should
* enable kses, independently of the user capabilities. So in that case we call
* _wp_footnotes_kses_init_filters().
*
* @access private
* @since 6.3.2
*
* @param string $arg Input argument of the filter.
* @return string Input argument of the filter.
*/
function _wp_footnotes_force_filtered_html_on_import_filter( $arg ) {
// If `force_filtered_html_on_import` is true, we need to init the global styles kses filters.
if ( $arg ) {
_wp_footnotes_kses_init_filters();
}
return $arg;
}
/**
* Exposes blocks with autoRegister flag for ServerSideRender in the editor.
*
* Detects blocks that have the autoRegister flag set in their supports
* and passes them to JavaScript for auto-registration with ServerSideRender.
*
* @access private
* @since 7.0.0
*/
function _wp_enqueue_auto_register_blocks() {
$auto_register_blocks = array();
$registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
foreach ( $registered_blocks as $block_name => $block_type ) {
if ( ! empty( $block_type->supports['autoRegister'] ) && ! empty( $block_type->render_callback ) ) {
$auto_register_blocks[] = $block_name;
}
}
if ( ! empty( $auto_register_blocks ) ) {
wp_add_inline_script(
'wp-block-library',
sprintf( 'window.__unstableAutoRegisterBlocks = %s;', wp_json_encode( $auto_register_blocks ) ),
'before'
);
}
}
'Ocelli\/',
'Octopus',
'oegp',
'Offline Explorer',
'Offline Navigator',
'odin\.com',
'OgScrper',
'okhttp',
'omgili',
'OMSC',
'Online Domain Tools',
'Open Source RSS',
'OpenCalaisSemanticProxy',
'Openfind',
'OpenLinkProfiler',
'Openstat\/',
'OpenVAS',
'OPPO A33',
'Optimizer',
'Orbiter',
'OrgProbe\/',
'orion-semantics',
'Outlook-Express',
'Outlook-iOS',
'Owler',
'Owlin',
'ownCloud News',
'ow\.ly',
'OxfordCloudService',
'page scorer',
'Page Valet',
'page2rss',
'PageFreezer',
'PageGrabber',
'PagePeeker',
'PageScorer',
'Pagespeed\/',
'PageThing',
'page_verifier',
'Panopta',
'panscient',
'Papa Foto',
'parsijoo',
'Pavuk',
'PayPal IPN',
'pcBrowser',
'Pcore-HTTP',
'PDF24 URL To PDF',
'Pearltrees',
'PECL::HTTP',
'peerindex',
'Peew',
'PeoplePal',
'Perlu -',
'PhantomJS Screenshoter',
'PhantomJS\/',
'Photon\/',
'php-requests',
'phpservermon',
'Pi-Monster',
'Picscout',
'Picsearch',
'PictureFinder',
'Pimonster',
'Pingability',
'PingAdmin\.Ru',
'Pingdom',
'Pingoscope',
'PingSpot',
'ping\.blo\.gs',
'pinterest\.com',
'Pixray',
'Pizilla',
'Plagger\/',
'Pleroma ',
'Ploetz \+ Zeller',
'Plukkie',
'plumanalytics',
'PocketImageCache',
'PocketParser',
'Pockey',
'PodcastAddict\/',
'POE-Component-Client-HTTP',
'Polymail\/',
'Pompos',
'Porkbun',
'Port Monitor',
'postano',
'postfix-mta-sts-resolver',
'PostmanRuntime',
'postplanner\.com',
'PostPost',
'postrank',
'PowerPoint\/',
'Prebid',
'Prerender',
'Priceonomics Analysis Engine',
'PrintFriendly',
'PritTorrent',
'Prlog',
'probely\.com',
'probethenet',
'Project ?25499',
'Project-Resonance',
'prospectb2b',
'Protopage',
'ProWebWalker',
'proximic',
'PRTG Network Monitor',
'pshtt, https scanning',
'PTST ',
'PTST\/[0-9]+',
'pulsetic\.com',
'Pump',
'Python-httplib2',
'python-httpx',
'python-requests',
'Python-urllib',
'Qirina Hurdler',
'QQDownload',
'QrafterPro',
'Qseero',
'Qualidator',
'QueryN Metasearch',
'queuedriver',
'quic-go-HTTP\/',
'QuiteRSS',
'Quora Link Preview',
'Qwantify',
'Radian6',
'RadioPublicImageResizer',
'Railgun\/',
'RankActive',
'RankFlex',
'RankSonicSiteAuditor',
'RapidLoad\/',
'Re-re Studio',
'ReactorNetty',
'Readability',
'RealDownload',
'RealPlayer%20Downloader',
'RebelMouse',
'Recorder',
'RecurPost\/',
'redback\/',
'ReederForMac',
'Reeder\/',
'ReGet',
'RepoMonkey',
'request\.js',
'reqwest\/',
'ResponseCodeTest',
'RestSharp',
'Riddler',
'Rival IQ',
'Robosourcer',
'Robozilla',
'ROI Hunter',
'RPT-HTTPClient',
'RSSMix\/',
'RSSOwl',
'RuxitSynthetic',
'RyowlEngine',
'safe-agent-scanner',
'SalesIntelligent',
'Saleslift',
'SAP NetWeaver Application Server',
'SauceNAO',
'SBIder',
'sc-downloader',
'scalaj-http',
'Scamadviser-Frontend',
'ScanAlert',
'scan\.lol',
'Scoop',
'scooter',
'ScopeContentAG-HTTP-Client',
'ScoutJet',
'ScoutURLMonitor',
'ScrapeBox Page Scanner',
'Scrapy',
'Screaming',
'ScreenShotService',
'Scrubby',
'Scrutiny\/',
'Search37',
'searchenginepromotionhelp',
'Searchestate',
'SearchExpress',
'SearchSight',
'SearchWP',
'search\.thunderstone',
'Seeker',
'semanticdiscovery',
'semanticjuice',
'Semiocast HTTP client',
'Semrush',
'Sendsay\.Ru',
'sentry\/',
'SEO Browser',
'Seo Servis',
'seo-nastroj\.cz',
'seo4ajax',
'Seobility',
'SEOCentro',
'SeoCheck',
'seocompany',
'SEOkicks',
'SEOlizer',
'Seomoz',
'SEOprofiler',
'seoscanners',
'SEOsearch',
'seositecheckup',
'SEOstats',
'servernfo',
'sexsearcher',
'Seznam',
'Shelob',
'Shodan',
'Shoppimon',
'ShopWiki',
'ShortLinkTranslate',
'shortURL lengthener',
'shrinktheweb',
'Sideqik',
'Siege',
'SimplePie',
'SimplyFast',
'Siphon',
'SISTRIX',
'Site Sucker',
'Site-Shot\/',
'Site24x7',
'SiteBar',
'Sitebeam',
'Sitebulb\/',
'SiteCondor',
'SiteExplorer',
'SiteGuardian',
'Siteimprove',
'SiteIndexed',
'Sitemap(s)? Generator',
'SitemapGenerator',
'SiteMonitor',
'Siteshooter B0t',
'SiteSnagger',
'SiteSucker',
'SiteTruth',
'Sitevigil',
'sitexy\.com',
'SkypeUriPreview',
'Slack\/',
'sli-systems\.com',
'slider\.com',
'slurp',
'SlySearch',
'SmartDownload',
'SMRF URL Expander',
'SMUrlExpander',
'Snake',
'Snappy',
'SnapSearch',
'Snarfer\/',
'SniffRSS',
'sniptracker',
'Snoopy',
'SnowHaze Search',
'sogou web',
'SortSite',
'Sottopop',
'sovereign\.ai',
'SpaceBison',
'SpamExperts',
'Spammen',
'Spanner',
'Spawning-AI',
'spaziodati',
'SPDYCheck',
'Specificfeeds',
'SpeedKit',
'speedy',
'SPEng',
'Spinn3r',
'spray-can',
'Sprinklr ',
'spyonweb',
'sqlmap',
'Sqlworm',
'Sqworm',
'SSL Labs',
'ssl-tools',
'StackRambler',
'Statastico\/',
'Statically-',
'StatusCake',
'Steeler',
'Stratagems Kumo',
'Stripe\/',
'Stroke\.cz',
'StudioFACA',
'StumbleUpon',
'suchen',
'Sucuri',
'summify',
'SuperHTTP',
'Surphace Scout',
'Suzuran',
'swcd ',
'Symfony BrowserKit',
'Symfony2 BrowserKit',
'Synapse\/',
'Syndirella\/',
'SynHttpClient-Built',
'Sysomos',
'sysscan',
'Szukacz',
'T0PHackTeam',
'tAkeOut',
'Tarantula\/',
'Taringa UGC',
'TarmotGezgin',
'tchelebi\.io',
'techiaith\.cymru',
'Teleport',
'Telesoft',
'Telesphoreo',
'Telesphorep',
'Tenon\.io',
'teoma',
'terrainformatica',
'Test Certificate Info',
'testuri',
'Tetrahedron',
'TextRazor Downloader',
'The Drop Reaper',
'The Expert HTML Source Viewer',
'The Intraformant',
'The Knowledge AI',
'theinternetrules',
'TheNomad',
'Thinklab',
'Thumbor',
'Thumbshots',
'ThumbSniper',
'timewe\.net',
'TinEye',
'Tiny Tiny RSS',
'TLSProbe\/',
'Toata',
'topster',
'touche\.com',
'Traackr\.com',
'tracemyfile',
'Trackuity',
'TrapitAgent',
'Trendiction',
'Trendsmap',
'trendspottr',
'truwoGPS',
'TryJsoup',
'TulipChain',
'Turingos',
'Turnitin',
'tweetedtimes',
'Tweetminster',
'Tweezler\/',
'twibble',
'Twice',
'Twikle',
'Twingly',
'Twisted PageGetter',
'Typhoeus',
'ubermetrics-technologies',
'uclassify',
'UdmSearch',
'ultimate_sitemap_parser',
'unchaos',
'unirest-java',
'UniversalFeedParser',
'unshortenit',
'Unshorten\.It',
'Untiny',
'UnwindFetchor',
'updated',
'updown\.io daemon',
'Upflow',
'Uptimia',
'URL Verifier',
'Urlcheckr',
'URLitor',
'urlresolver',
'Urlstat',
'URLTester',
'UrlTrends Ranking Updater',
'URLy Warning',
'URLy\.Warning',
'URL\/Emacs',
'Vacuum',
'Vagabondo',
'VB Project',
'vBSEO',
'VCI',
'Verity',
'via ggpht\.com GoogleImageProxy',
'Virusdie',
'visionutils',
'Visual Rights Group',
'vkShare',
'VoidEYE',
'Voil',
'voltron',
'voyager\/',
'VSAgent\/',
'VSB-TUO\/',
'Vulnbusters Meter',
'VYU2',
'w3af\.org',
'W3C-checklink',
'W3C-mobileOK',
'W3C_Unicorn',
'WAC-OFU',
'WakeletLinkExpander',
'WallpapersHD',
'Wallpapers\/[0-9]+',
'wangling',
'Wappalyzer',
'WatchMouse',
'WbSrch\/',
'WDT\.io',
'Web Auto',
'Web Collage',
'Web Enhancer',
'Web Fetch',
'Web Fuck',
'Web Pix',
'Web Sauger',
'Web spyder',
'Web Sucker',
'web-capture\.net',
'Web-sniffer',
'Webalta',
'Webauskunft',
'WebAuto',
'WebCapture',
'WebClient\/',
'webcollage',
'WebCookies',
'WebCopier',
'WebCorp',
'WebDataStats',
'WebDoc',
'WebEnhancer',
'WebFetch',
'WebFuck',
'WebGazer',
'WebGo IS',
'WebImageCollector',
'WebImages',
'WebIndex',
'webkit2png',
'WebLeacher',
'webmastercoffee',
'webmon ',
'WebPix',
'WebReaper',
'WebSauger',
'webscreenie',
'Webshag',
'Webshot',
'Website Quester',
'websitepulse agent',
'WebsiteQuester',
'Websnapr',
'WebSniffer',
'Webster',
'WebStripper',
'WebSucker',
'webtech\/',
'WebThumbnail',
'Webthumb\/',
'WebWhacker',
'WebZIP',
'WeLikeLinks',
'WEPA',
'WeSEE',
'wf84',
'Wfuzz\/',
'wget',
'WhatCMS',
'WhatsApp',
'WhatsMyIP',
'WhatWeb',
'WhereGoes\?',
'Whibse',
'WhoAPI\/',
'WhoRunsCoinHive',
'Whynder Magnet',
'Windows-RSS-Platform',
'WinHttp-Autoproxy-Service',
'WinHTTP\/',
'WinPodder',
'wkhtmlto',
'wmtips',
'Woko',
'Wolfram HTTPClient',
'woorankreview',
'WordPress\/',
'WordupinfoSearch',
'Word\/',
'worldping-api',
'wotbox',
'WP Engine Install Performance API',
'WP Rocket',
'wpif',
'wprecon\.com survey',
'WPScan',
'wscheck',
'Wtrace',
'WWW-Collector-E',
'WWW-Mechanize',
'WWW::Document',
'WWW::Mechanize',
'WWWOFFLE',
'www\.monitor\.us',
'x09Mozilla',
'x22Mozilla',
'XaxisSemanticsClassifier',
'XenForo\/',
'Xenu Link Sleuth',
'XING-contenttabreceiver',
'xpymep([0-9]?)\.exe',
'Y!J-[A-Z][A-Z][A-Z]',
'Yaanb',
'yacy',
'Yahoo Link Preview',
'YahooCacheSystem',
'YahooMailProxy',
'YahooYSMcm',
'YandeG',
'Yandex(?!Search)',
'yanga',
'yeti',
'Yo-yo',
'Yoleo Consumer',
'yomins\.com',
'yoogliFetchAgent',
'YottaaMonitor',
'Your-Website-Sucks',
'yourls\.org',
'YoYs\.net',
'YP\.PL',
'Zabbix',
'Zade',
'Zao',
'Zapier',
'Zauba',
'Zemanta Aggregator',
'Zend\\\\Http\\\\Client',
'Zend_Http_Client',
'Zermelo',
'Zeus ',
'zgrab',
'ZnajdzFoto',
'ZnHTTP',
'Zombie\.js',
'Zoom\.Mac',
'ZoteroTranslationServer',
'ZyBorg',
'[a-z0-9\-_]*(bot|crawl|headless|archiver|transcoder|spider|uptime|validator|fetcher|cron|checker|reader|extractor|monitoring|analyzer|scraper)',
];
}