Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: blocks.php
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
[2000] Fix | Delete
* have the same structure as this one.
[2001] Fix | Delete
* @type string $innerHTML HTML from inside block comment delimiters.
[2002] Fix | Delete
* @type array $innerContent List of string fragments and null markers where
[2003] Fix | Delete
* inner blocks were found.
[2004] Fix | Delete
* }
[2005] Fix | Delete
* @param array $source_block {
[2006] Fix | Delete
* An un-modified copy of `$parsed_block`, as it appeared in the source content.
[2007] Fix | Delete
* See WP_Block_Parser_Block.
[2008] Fix | Delete
*
[2009] Fix | Delete
* @type string $blockName Name of block.
[2010] Fix | Delete
* @type array $attrs Attributes from block comment delimiters.
[2011] Fix | Delete
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
[2012] Fix | Delete
* have the same structure as this one.
[2013] Fix | Delete
* @type string $innerHTML HTML from inside block comment delimiters.
[2014] Fix | Delete
* @type array $innerContent List of string fragments and null markers where
[2015] Fix | Delete
* inner blocks were found.
[2016] Fix | Delete
* }
[2017] Fix | Delete
* @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
[2018] Fix | Delete
*/
[2019] Fix | Delete
$parsed_block = apply_filters( 'render_block_data', $parsed_block, $source_block, $parent_block );
[2020] Fix | Delete
[2021] Fix | Delete
$context = array();
[2022] Fix | Delete
[2023] Fix | Delete
if ( $post instanceof WP_Post ) {
[2024] Fix | Delete
$context['postId'] = $post->ID;
[2025] Fix | Delete
[2026] Fix | Delete
/*
[2027] Fix | Delete
* The `postType` context is largely unnecessary server-side, since the ID
[2028] Fix | Delete
* is usually sufficient on its own. That being said, since a block's
[2029] Fix | Delete
* manifest is expected to be shared between the server and the client,
[2030] Fix | Delete
* it should be included to consistently fulfill the expectation.
[2031] Fix | Delete
*/
[2032] Fix | Delete
$context['postType'] = $post->post_type;
[2033] Fix | Delete
}
[2034] Fix | Delete
[2035] Fix | Delete
/**
[2036] Fix | Delete
* Filters the default context provided to a rendered block.
[2037] Fix | Delete
*
[2038] Fix | Delete
* @since 5.5.0
[2039] Fix | Delete
* @since 5.9.0 The `$parent_block` parameter was added.
[2040] Fix | Delete
*
[2041] Fix | Delete
* @param array $context Default context.
[2042] Fix | Delete
* @param array $parsed_block {
[2043] Fix | Delete
* A representative array of the block being rendered. See WP_Block_Parser_Block.
[2044] Fix | Delete
*
[2045] Fix | Delete
* @type string $blockName Name of block.
[2046] Fix | Delete
* @type array $attrs Attributes from block comment delimiters.
[2047] Fix | Delete
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
[2048] Fix | Delete
* have the same structure as this one.
[2049] Fix | Delete
* @type string $innerHTML HTML from inside block comment delimiters.
[2050] Fix | Delete
* @type array $innerContent List of string fragments and null markers where
[2051] Fix | Delete
* inner blocks were found.
[2052] Fix | Delete
* }
[2053] Fix | Delete
* @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
[2054] Fix | Delete
*/
[2055] Fix | Delete
$context = apply_filters( 'render_block_context', $context, $parsed_block, $parent_block );
[2056] Fix | Delete
[2057] Fix | Delete
$block = new WP_Block( $parsed_block, $context );
[2058] Fix | Delete
[2059] Fix | Delete
return $block->render();
[2060] Fix | Delete
}
[2061] Fix | Delete
[2062] Fix | Delete
/**
[2063] Fix | Delete
* Parses blocks out of a content string.
[2064] Fix | Delete
*
[2065] Fix | Delete
* @since 5.0.0
[2066] Fix | Delete
*
[2067] Fix | Delete
* @param string $content Post content.
[2068] Fix | Delete
* @return array[] {
[2069] Fix | Delete
* Array of block structures.
[2070] Fix | Delete
*
[2071] Fix | Delete
* @type array ...$0 {
[2072] Fix | Delete
* A representative array of a single parsed block object. See WP_Block_Parser_Block.
[2073] Fix | Delete
*
[2074] Fix | Delete
* @type string $blockName Name of block.
[2075] Fix | Delete
* @type array $attrs Attributes from block comment delimiters.
[2076] Fix | Delete
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
[2077] Fix | Delete
* have the same structure as this one.
[2078] Fix | Delete
* @type string $innerHTML HTML from inside block comment delimiters.
[2079] Fix | Delete
* @type array $innerContent List of string fragments and null markers where
[2080] Fix | Delete
* inner blocks were found.
[2081] Fix | Delete
* }
[2082] Fix | Delete
* }
[2083] Fix | Delete
*/
[2084] Fix | Delete
function parse_blocks( $content ) {
[2085] Fix | Delete
/**
[2086] Fix | Delete
* Filter to allow plugins to replace the server-side block parser.
[2087] Fix | Delete
*
[2088] Fix | Delete
* @since 5.0.0
[2089] Fix | Delete
*
[2090] Fix | Delete
* @param string $parser_class Name of block parser class.
[2091] Fix | Delete
*/
[2092] Fix | Delete
$parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' );
[2093] Fix | Delete
[2094] Fix | Delete
$parser = new $parser_class();
[2095] Fix | Delete
return $parser->parse( $content );
[2096] Fix | Delete
}
[2097] Fix | Delete
[2098] Fix | Delete
/**
[2099] Fix | Delete
* Parses dynamic blocks out of `post_content` and re-renders them.
[2100] Fix | Delete
*
[2101] Fix | Delete
* @since 5.0.0
[2102] Fix | Delete
*
[2103] Fix | Delete
* @param string $content Post content.
[2104] Fix | Delete
* @return string Updated post content.
[2105] Fix | Delete
*/
[2106] Fix | Delete
function do_blocks( $content ) {
[2107] Fix | Delete
$blocks = parse_blocks( $content );
[2108] Fix | Delete
$output = '';
[2109] Fix | Delete
[2110] Fix | Delete
foreach ( $blocks as $block ) {
[2111] Fix | Delete
$output .= render_block( $block );
[2112] Fix | Delete
}
[2113] Fix | Delete
[2114] Fix | Delete
// If there are blocks in this content, we shouldn't run wpautop() on it later.
[2115] Fix | Delete
$priority = has_filter( 'the_content', 'wpautop' );
[2116] Fix | Delete
if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) {
[2117] Fix | Delete
remove_filter( 'the_content', 'wpautop', $priority );
[2118] Fix | Delete
add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 );
[2119] Fix | Delete
}
[2120] Fix | Delete
[2121] Fix | Delete
return $output;
[2122] Fix | Delete
}
[2123] Fix | Delete
[2124] Fix | Delete
/**
[2125] Fix | Delete
* If do_blocks() needs to remove wpautop() from the `the_content` filter, this re-adds it afterwards,
[2126] Fix | Delete
* for subsequent `the_content` usage.
[2127] Fix | Delete
*
[2128] Fix | Delete
* @since 5.0.0
[2129] Fix | Delete
* @access private
[2130] Fix | Delete
*
[2131] Fix | Delete
* @param string $content The post content running through this filter.
[2132] Fix | Delete
* @return string The unmodified content.
[2133] Fix | Delete
*/
[2134] Fix | Delete
function _restore_wpautop_hook( $content ) {
[2135] Fix | Delete
$current_priority = has_filter( 'the_content', '_restore_wpautop_hook' );
[2136] Fix | Delete
[2137] Fix | Delete
add_filter( 'the_content', 'wpautop', $current_priority - 1 );
[2138] Fix | Delete
remove_filter( 'the_content', '_restore_wpautop_hook', $current_priority );
[2139] Fix | Delete
[2140] Fix | Delete
return $content;
[2141] Fix | Delete
}
[2142] Fix | Delete
[2143] Fix | Delete
/**
[2144] Fix | Delete
* Returns the current version of the block format that the content string is using.
[2145] Fix | Delete
*
[2146] Fix | Delete
* If the string doesn't contain blocks, it returns 0.
[2147] Fix | Delete
*
[2148] Fix | Delete
* @since 5.0.0
[2149] Fix | Delete
*
[2150] Fix | Delete
* @param string $content Content to test.
[2151] Fix | Delete
* @return int The block format version is 1 if the content contains one or more blocks, 0 otherwise.
[2152] Fix | Delete
*/
[2153] Fix | Delete
function block_version( $content ) {
[2154] Fix | Delete
return has_blocks( $content ) ? 1 : 0;
[2155] Fix | Delete
}
[2156] Fix | Delete
[2157] Fix | Delete
/**
[2158] Fix | Delete
* Registers a new block style.
[2159] Fix | Delete
*
[2160] Fix | Delete
* @since 5.3.0
[2161] Fix | Delete
* @since 6.6.0 Added support for registering styles for multiple block types.
[2162] Fix | Delete
*
[2163] Fix | Delete
* @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/
[2164] Fix | Delete
*
[2165] Fix | Delete
* @param string|string[] $block_name Block type name including namespace or array of namespaced block type names.
[2166] Fix | Delete
* @param array $style_properties Array containing the properties of the style name, label,
[2167] Fix | Delete
* style_handle (name of the stylesheet to be enqueued),
[2168] Fix | Delete
* inline_style (string containing the CSS to be added),
[2169] Fix | Delete
* style_data (theme.json-like array to generate CSS from).
[2170] Fix | Delete
* See WP_Block_Styles_Registry::register().
[2171] Fix | Delete
* @return bool True if the block style was registered with success and false otherwise.
[2172] Fix | Delete
*/
[2173] Fix | Delete
function register_block_style( $block_name, $style_properties ) {
[2174] Fix | Delete
return WP_Block_Styles_Registry::get_instance()->register( $block_name, $style_properties );
[2175] Fix | Delete
}
[2176] Fix | Delete
[2177] Fix | Delete
/**
[2178] Fix | Delete
* Unregisters a block style.
[2179] Fix | Delete
*
[2180] Fix | Delete
* @since 5.3.0
[2181] Fix | Delete
*
[2182] Fix | Delete
* @param string $block_name Block type name including namespace.
[2183] Fix | Delete
* @param string $block_style_name Block style name.
[2184] Fix | Delete
* @return bool True if the block style was unregistered with success and false otherwise.
[2185] Fix | Delete
*/
[2186] Fix | Delete
function unregister_block_style( $block_name, $block_style_name ) {
[2187] Fix | Delete
return WP_Block_Styles_Registry::get_instance()->unregister( $block_name, $block_style_name );
[2188] Fix | Delete
}
[2189] Fix | Delete
[2190] Fix | Delete
/**
[2191] Fix | Delete
* Checks whether the current block type supports the feature requested.
[2192] Fix | Delete
*
[2193] Fix | Delete
* @since 5.8.0
[2194] Fix | Delete
* @since 6.4.0 The `$feature` parameter now supports a string.
[2195] Fix | Delete
*
[2196] Fix | Delete
* @param WP_Block_Type $block_type Block type to check for support.
[2197] Fix | Delete
* @param string|array $feature Feature slug, or path to a specific feature to check support for.
[2198] Fix | Delete
* @param mixed $default_value Optional. Fallback value for feature support. Default false.
[2199] Fix | Delete
* @return bool Whether the feature is supported.
[2200] Fix | Delete
*/
[2201] Fix | Delete
function block_has_support( $block_type, $feature, $default_value = false ) {
[2202] Fix | Delete
$block_support = $default_value;
[2203] Fix | Delete
if ( $block_type instanceof WP_Block_Type ) {
[2204] Fix | Delete
if ( is_array( $feature ) && count( $feature ) === 1 ) {
[2205] Fix | Delete
$feature = $feature[0];
[2206] Fix | Delete
}
[2207] Fix | Delete
[2208] Fix | Delete
if ( is_array( $feature ) ) {
[2209] Fix | Delete
$block_support = _wp_array_get( $block_type->supports, $feature, $default_value );
[2210] Fix | Delete
} elseif ( isset( $block_type->supports[ $feature ] ) ) {
[2211] Fix | Delete
$block_support = $block_type->supports[ $feature ];
[2212] Fix | Delete
}
[2213] Fix | Delete
}
[2214] Fix | Delete
[2215] Fix | Delete
return true === $block_support || is_array( $block_support );
[2216] Fix | Delete
}
[2217] Fix | Delete
[2218] Fix | Delete
/**
[2219] Fix | Delete
* Converts typography keys declared under `supports.*` to `supports.typography.*`.
[2220] Fix | Delete
*
[2221] Fix | Delete
* Displays a `_doing_it_wrong()` notice when a block using the older format is detected.
[2222] Fix | Delete
*
[2223] Fix | Delete
* @since 5.8.0
[2224] Fix | Delete
*
[2225] Fix | Delete
* @param array $metadata Metadata for registering a block type.
[2226] Fix | Delete
* @return array Filtered metadata for registering a block type.
[2227] Fix | Delete
*/
[2228] Fix | Delete
function wp_migrate_old_typography_shape( $metadata ) {
[2229] Fix | Delete
if ( ! isset( $metadata['supports'] ) ) {
[2230] Fix | Delete
return $metadata;
[2231] Fix | Delete
}
[2232] Fix | Delete
[2233] Fix | Delete
$typography_keys = array(
[2234] Fix | Delete
'__experimentalFontFamily',
[2235] Fix | Delete
'__experimentalFontStyle',
[2236] Fix | Delete
'__experimentalFontWeight',
[2237] Fix | Delete
'__experimentalLetterSpacing',
[2238] Fix | Delete
'__experimentalTextDecoration',
[2239] Fix | Delete
'__experimentalTextTransform',
[2240] Fix | Delete
'fontSize',
[2241] Fix | Delete
'lineHeight',
[2242] Fix | Delete
);
[2243] Fix | Delete
[2244] Fix | Delete
foreach ( $typography_keys as $typography_key ) {
[2245] Fix | Delete
$support_for_key = isset( $metadata['supports'][ $typography_key ] ) ? $metadata['supports'][ $typography_key ] : null;
[2246] Fix | Delete
[2247] Fix | Delete
if ( null !== $support_for_key ) {
[2248] Fix | Delete
_doing_it_wrong(
[2249] Fix | Delete
'register_block_type_from_metadata()',
[2250] Fix | Delete
sprintf(
[2251] Fix | Delete
/* translators: 1: Block type, 2: Typography supports key, e.g: fontSize, lineHeight, etc. 3: block.json, 4: Old metadata key, 5: New metadata key. */
[2252] Fix | Delete
__( 'Block "%1$s" is declaring %2$s support in %3$s file under %4$s. %2$s support is now declared under %5$s.' ),
[2253] Fix | Delete
$metadata['name'],
[2254] Fix | Delete
"<code>$typography_key</code>",
[2255] Fix | Delete
'<code>block.json</code>',
[2256] Fix | Delete
"<code>supports.$typography_key</code>",
[2257] Fix | Delete
"<code>supports.typography.$typography_key</code>"
[2258] Fix | Delete
),
[2259] Fix | Delete
'5.8.0'
[2260] Fix | Delete
);
[2261] Fix | Delete
[2262] Fix | Delete
_wp_array_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key );
[2263] Fix | Delete
unset( $metadata['supports'][ $typography_key ] );
[2264] Fix | Delete
}
[2265] Fix | Delete
}
[2266] Fix | Delete
[2267] Fix | Delete
return $metadata;
[2268] Fix | Delete
}
[2269] Fix | Delete
[2270] Fix | Delete
/**
[2271] Fix | Delete
* Helper function that constructs a WP_Query args array from
[2272] Fix | Delete
* a `Query` block properties.
[2273] Fix | Delete
*
[2274] Fix | Delete
* It's used in Query Loop, Query Pagination Numbers and Query Pagination Next blocks.
[2275] Fix | Delete
*
[2276] Fix | Delete
* @since 5.8.0
[2277] Fix | Delete
* @since 6.1.0 Added `query_loop_block_query_vars` filter and `parents` support in query.
[2278] Fix | Delete
*
[2279] Fix | Delete
* @param WP_Block $block Block instance.
[2280] Fix | Delete
* @param int $page Current query's page.
[2281] Fix | Delete
*
[2282] Fix | Delete
* @return array Returns the constructed WP_Query arguments.
[2283] Fix | Delete
*/
[2284] Fix | Delete
function build_query_vars_from_query_block( $block, $page ) {
[2285] Fix | Delete
$query = array(
[2286] Fix | Delete
'post_type' => 'post',
[2287] Fix | Delete
'order' => 'DESC',
[2288] Fix | Delete
'orderby' => 'date',
[2289] Fix | Delete
'post__not_in' => array(),
[2290] Fix | Delete
);
[2291] Fix | Delete
[2292] Fix | Delete
if ( isset( $block->context['query'] ) ) {
[2293] Fix | Delete
if ( ! empty( $block->context['query']['postType'] ) ) {
[2294] Fix | Delete
$post_type_param = $block->context['query']['postType'];
[2295] Fix | Delete
if ( is_post_type_viewable( $post_type_param ) ) {
[2296] Fix | Delete
$query['post_type'] = $post_type_param;
[2297] Fix | Delete
}
[2298] Fix | Delete
}
[2299] Fix | Delete
if ( isset( $block->context['query']['sticky'] ) && ! empty( $block->context['query']['sticky'] ) ) {
[2300] Fix | Delete
$sticky = get_option( 'sticky_posts' );
[2301] Fix | Delete
if ( 'only' === $block->context['query']['sticky'] ) {
[2302] Fix | Delete
/*
[2303] Fix | Delete
* Passing an empty array to post__in will return have_posts() as true (and all posts will be returned).
[2304] Fix | Delete
* Logic should be used before hand to determine if WP_Query should be used in the event that the array
[2305] Fix | Delete
* being passed to post__in is empty.
[2306] Fix | Delete
*
[2307] Fix | Delete
* @see https://core.trac.wordpress.org/ticket/28099
[2308] Fix | Delete
*/
[2309] Fix | Delete
$query['post__in'] = ! empty( $sticky ) ? $sticky : array( 0 );
[2310] Fix | Delete
$query['ignore_sticky_posts'] = 1;
[2311] Fix | Delete
} else {
[2312] Fix | Delete
$query['post__not_in'] = array_merge( $query['post__not_in'], $sticky );
[2313] Fix | Delete
}
[2314] Fix | Delete
}
[2315] Fix | Delete
if ( ! empty( $block->context['query']['exclude'] ) ) {
[2316] Fix | Delete
$excluded_post_ids = array_map( 'intval', $block->context['query']['exclude'] );
[2317] Fix | Delete
$excluded_post_ids = array_filter( $excluded_post_ids );
[2318] Fix | Delete
$query['post__not_in'] = array_merge( $query['post__not_in'], $excluded_post_ids );
[2319] Fix | Delete
}
[2320] Fix | Delete
if (
[2321] Fix | Delete
isset( $block->context['query']['perPage'] ) &&
[2322] Fix | Delete
is_numeric( $block->context['query']['perPage'] )
[2323] Fix | Delete
) {
[2324] Fix | Delete
$per_page = absint( $block->context['query']['perPage'] );
[2325] Fix | Delete
$offset = 0;
[2326] Fix | Delete
[2327] Fix | Delete
if (
[2328] Fix | Delete
isset( $block->context['query']['offset'] ) &&
[2329] Fix | Delete
is_numeric( $block->context['query']['offset'] )
[2330] Fix | Delete
) {
[2331] Fix | Delete
$offset = absint( $block->context['query']['offset'] );
[2332] Fix | Delete
}
[2333] Fix | Delete
[2334] Fix | Delete
$query['offset'] = ( $per_page * ( $page - 1 ) ) + $offset;
[2335] Fix | Delete
$query['posts_per_page'] = $per_page;
[2336] Fix | Delete
}
[2337] Fix | Delete
// Migrate `categoryIds` and `tagIds` to `tax_query` for backwards compatibility.
[2338] Fix | Delete
if ( ! empty( $block->context['query']['categoryIds'] ) || ! empty( $block->context['query']['tagIds'] ) ) {
[2339] Fix | Delete
$tax_query = array();
[2340] Fix | Delete
if ( ! empty( $block->context['query']['categoryIds'] ) ) {
[2341] Fix | Delete
$tax_query[] = array(
[2342] Fix | Delete
'taxonomy' => 'category',
[2343] Fix | Delete
'terms' => array_filter( array_map( 'intval', $block->context['query']['categoryIds'] ) ),
[2344] Fix | Delete
'include_children' => false,
[2345] Fix | Delete
);
[2346] Fix | Delete
}
[2347] Fix | Delete
if ( ! empty( $block->context['query']['tagIds'] ) ) {
[2348] Fix | Delete
$tax_query[] = array(
[2349] Fix | Delete
'taxonomy' => 'post_tag',
[2350] Fix | Delete
'terms' => array_filter( array_map( 'intval', $block->context['query']['tagIds'] ) ),
[2351] Fix | Delete
'include_children' => false,
[2352] Fix | Delete
);
[2353] Fix | Delete
}
[2354] Fix | Delete
$query['tax_query'] = $tax_query;
[2355] Fix | Delete
}
[2356] Fix | Delete
if ( ! empty( $block->context['query']['taxQuery'] ) ) {
[2357] Fix | Delete
$query['tax_query'] = array();
[2358] Fix | Delete
foreach ( $block->context['query']['taxQuery'] as $taxonomy => $terms ) {
[2359] Fix | Delete
if ( is_taxonomy_viewable( $taxonomy ) && ! empty( $terms ) ) {
[2360] Fix | Delete
$query['tax_query'][] = array(
[2361] Fix | Delete
'taxonomy' => $taxonomy,
[2362] Fix | Delete
'terms' => array_filter( array_map( 'intval', $terms ) ),
[2363] Fix | Delete
'include_children' => false,
[2364] Fix | Delete
);
[2365] Fix | Delete
}
[2366] Fix | Delete
}
[2367] Fix | Delete
}
[2368] Fix | Delete
if (
[2369] Fix | Delete
isset( $block->context['query']['order'] ) &&
[2370] Fix | Delete
in_array( strtoupper( $block->context['query']['order'] ), array( 'ASC', 'DESC' ), true )
[2371] Fix | Delete
) {
[2372] Fix | Delete
$query['order'] = strtoupper( $block->context['query']['order'] );
[2373] Fix | Delete
}
[2374] Fix | Delete
if ( isset( $block->context['query']['orderBy'] ) ) {
[2375] Fix | Delete
$query['orderby'] = $block->context['query']['orderBy'];
[2376] Fix | Delete
}
[2377] Fix | Delete
if (
[2378] Fix | Delete
isset( $block->context['query']['author'] )
[2379] Fix | Delete
) {
[2380] Fix | Delete
if ( is_array( $block->context['query']['author'] ) ) {
[2381] Fix | Delete
$query['author__in'] = array_filter( array_map( 'intval', $block->context['query']['author'] ) );
[2382] Fix | Delete
} elseif ( is_string( $block->context['query']['author'] ) ) {
[2383] Fix | Delete
$query['author__in'] = array_filter( array_map( 'intval', explode( ',', $block->context['query']['author'] ) ) );
[2384] Fix | Delete
} elseif ( is_int( $block->context['query']['author'] ) && $block->context['query']['author'] > 0 ) {
[2385] Fix | Delete
$query['author'] = $block->context['query']['author'];
[2386] Fix | Delete
}
[2387] Fix | Delete
}
[2388] Fix | Delete
if ( ! empty( $block->context['query']['search'] ) ) {
[2389] Fix | Delete
$query['s'] = $block->context['query']['search'];
[2390] Fix | Delete
}
[2391] Fix | Delete
if ( ! empty( $block->context['query']['parents'] ) && is_post_type_hierarchical( $query['post_type'] ) ) {
[2392] Fix | Delete
$query['post_parent__in'] = array_filter( array_map( 'intval', $block->context['query']['parents'] ) );
[2393] Fix | Delete
}
[2394] Fix | Delete
}
[2395] Fix | Delete
[2396] Fix | Delete
/**
[2397] Fix | Delete
* Filters the arguments which will be passed to `WP_Query` for the Query Loop Block.
[2398] Fix | Delete
*
[2399] Fix | Delete
* Anything to this filter should be compatible with the `WP_Query` API to form
[2400] Fix | Delete
* the query context which will be passed down to the Query Loop Block's children.
[2401] Fix | Delete
* This can help, for example, to include additional settings or meta queries not
[2402] Fix | Delete
* directly supported by the core Query Loop Block, and extend its capabilities.
[2403] Fix | Delete
*
[2404] Fix | Delete
* Please note that this will only influence the query that will be rendered on the
[2405] Fix | Delete
* front-end. The editor preview is not affected by this filter. Also, worth noting
[2406] Fix | Delete
* that the editor preview uses the REST API, so, ideally, one should aim to provide
[2407] Fix | Delete
* attributes which are also compatible with the REST API, in order to be able to
[2408] Fix | Delete
* implement identical queries on both sides.
[2409] Fix | Delete
*
[2410] Fix | Delete
* @since 6.1.0
[2411] Fix | Delete
*
[2412] Fix | Delete
* @param array $query Array containing parameters for `WP_Query` as parsed by the block context.
[2413] Fix | Delete
* @param WP_Block $block Block instance.
[2414] Fix | Delete
* @param int $page Current query's page.
[2415] Fix | Delete
*/
[2416] Fix | Delete
return apply_filters( 'query_loop_block_query_vars', $query, $block, $page );
[2417] Fix | Delete
}
[2418] Fix | Delete
[2419] Fix | Delete
/**
[2420] Fix | Delete
* Helper function that returns the proper pagination arrow HTML for
[2421] Fix | Delete
* `QueryPaginationNext` and `QueryPaginationPrevious` blocks based
[2422] Fix | Delete
* on the provided `paginationArrow` from `QueryPagination` context.
[2423] Fix | Delete
*
[2424] Fix | Delete
* It's used in QueryPaginationNext and QueryPaginationPrevious blocks.
[2425] Fix | Delete
*
[2426] Fix | Delete
* @since 5.9.0
[2427] Fix | Delete
*
[2428] Fix | Delete
* @param WP_Block $block Block instance.
[2429] Fix | Delete
* @param bool $is_next Flag for handling `next/previous` blocks.
[2430] Fix | Delete
* @return string|null The pagination arrow HTML or null if there is none.
[2431] Fix | Delete
*/
[2432] Fix | Delete
function get_query_pagination_arrow( $block, $is_next ) {
[2433] Fix | Delete
$arrow_map = array(
[2434] Fix | Delete
'none' => '',
[2435] Fix | Delete
'arrow' => array(
[2436] Fix | Delete
'next' => '→',
[2437] Fix | Delete
'previous' => '←',
[2438] Fix | Delete
),
[2439] Fix | Delete
'chevron' => array(
[2440] Fix | Delete
'next' => '»',
[2441] Fix | Delete
'previous' => '«',
[2442] Fix | Delete
),
[2443] Fix | Delete
);
[2444] Fix | Delete
if ( ! empty( $block->context['paginationArrow'] ) && array_key_exists( $block->context['paginationArrow'], $arrow_map ) && ! empty( $arrow_map[ $block->context['paginationArrow'] ] ) ) {
[2445] Fix | Delete
$pagination_type = $is_next ? 'next' : 'previous';
[2446] Fix | Delete
$arrow_attribute = $block->context['paginationArrow'];
[2447] Fix | Delete
$arrow = $arrow_map[ $block->context['paginationArrow'] ][ $pagination_type ];
[2448] Fix | Delete
$arrow_classes = "wp-block-query-pagination-$pagination_type-arrow is-arrow-$arrow_attribute";
[2449] Fix | Delete
return "<span class='$arrow_classes' aria-hidden='true'>$arrow</span>";
[2450] Fix | Delete
}
[2451] Fix | Delete
return null;
[2452] Fix | Delete
}
[2453] Fix | Delete
[2454] Fix | Delete
/**
[2455] Fix | Delete
* Helper function that constructs a comment query vars array from the passed
[2456] Fix | Delete
* block properties.
[2457] Fix | Delete
*
[2458] Fix | Delete
* It's used with the Comment Query Loop inner blocks.
[2459] Fix | Delete
*
[2460] Fix | Delete
* @since 6.0.0
[2461] Fix | Delete
*
[2462] Fix | Delete
* @param WP_Block $block Block instance.
[2463] Fix | Delete
* @return array Returns the comment query parameters to use with the
[2464] Fix | Delete
* WP_Comment_Query constructor.
[2465] Fix | Delete
*/
[2466] Fix | Delete
function build_comment_query_vars_from_block( $block ) {
[2467] Fix | Delete
[2468] Fix | Delete
$comment_args = array(
[2469] Fix | Delete
'orderby' => 'comment_date_gmt',
[2470] Fix | Delete
'order' => 'ASC',
[2471] Fix | Delete
'status' => 'approve',
[2472] Fix | Delete
'no_found_rows' => false,
[2473] Fix | Delete
);
[2474] Fix | Delete
[2475] Fix | Delete
if ( is_user_logged_in() ) {
[2476] Fix | Delete
$comment_args['include_unapproved'] = array( get_current_user_id() );
[2477] Fix | Delete
} else {
[2478] Fix | Delete
$unapproved_email = wp_get_unapproved_comment_author_email();
[2479] Fix | Delete
[2480] Fix | Delete
if ( $unapproved_email ) {
[2481] Fix | Delete
$comment_args['include_unapproved'] = array( $unapproved_email );
[2482] Fix | Delete
}
[2483] Fix | Delete
}
[2484] Fix | Delete
[2485] Fix | Delete
if ( ! empty( $block->context['postId'] ) ) {
[2486] Fix | Delete
$comment_args['post_id'] = (int) $block->context['postId'];
[2487] Fix | Delete
}
[2488] Fix | Delete
[2489] Fix | Delete
if ( get_option( 'thread_comments' ) ) {
[2490] Fix | Delete
$comment_args['hierarchical'] = 'threaded';
[2491] Fix | Delete
} else {
[2492] Fix | Delete
$comment_args['hierarchical'] = false;
[2493] Fix | Delete
}
[2494] Fix | Delete
[2495] Fix | Delete
if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) {
[2496] Fix | Delete
$per_page = get_option( 'comments_per_page' );
[2497] Fix | Delete
$default_page = get_option( 'default_comments_page' );
[2498] Fix | Delete
if ( $per_page > 0 ) {
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function