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
$post_callback,
[1500] Fix | Delete
array( &$inner_block, &$block, $next )
[1501] Fix | Delete
);
[1502] Fix | Delete
}
[1503] Fix | Delete
[1504] Fix | Delete
$block_content .= traverse_and_serialize_block( $inner_block, $pre_callback, $post_callback );
[1505] Fix | Delete
$block_content .= isset( $post_markup ) ? $post_markup : '';
[1506] Fix | Delete
[1507] Fix | Delete
++$block_index;
[1508] Fix | Delete
}
[1509] Fix | Delete
}
[1510] Fix | Delete
[1511] Fix | Delete
if ( ! is_array( $block['attrs'] ) ) {
[1512] Fix | Delete
$block['attrs'] = array();
[1513] Fix | Delete
}
[1514] Fix | Delete
[1515] Fix | Delete
return get_comment_delimited_block_content(
[1516] Fix | Delete
$block['blockName'],
[1517] Fix | Delete
$block['attrs'],
[1518] Fix | Delete
$block_content
[1519] Fix | Delete
);
[1520] Fix | Delete
}
[1521] Fix | Delete
[1522] Fix | Delete
/**
[1523] Fix | Delete
* Replaces patterns in a block tree with their content.
[1524] Fix | Delete
*
[1525] Fix | Delete
* @since 6.6.0
[1526] Fix | Delete
*
[1527] Fix | Delete
* @param array $blocks An array blocks.
[1528] Fix | Delete
*
[1529] Fix | Delete
* @return array An array of blocks with patterns replaced by their content.
[1530] Fix | Delete
*/
[1531] Fix | Delete
function resolve_pattern_blocks( $blocks ) {
[1532] Fix | Delete
static $inner_content;
[1533] Fix | Delete
// Keep track of seen references to avoid infinite loops.
[1534] Fix | Delete
static $seen_refs = array();
[1535] Fix | Delete
$i = 0;
[1536] Fix | Delete
while ( $i < count( $blocks ) ) {
[1537] Fix | Delete
if ( 'core/pattern' === $blocks[ $i ]['blockName'] ) {
[1538] Fix | Delete
$attrs = $blocks[ $i ]['attrs'];
[1539] Fix | Delete
[1540] Fix | Delete
if ( empty( $attrs['slug'] ) ) {
[1541] Fix | Delete
++$i;
[1542] Fix | Delete
continue;
[1543] Fix | Delete
}
[1544] Fix | Delete
[1545] Fix | Delete
$slug = $attrs['slug'];
[1546] Fix | Delete
[1547] Fix | Delete
if ( isset( $seen_refs[ $slug ] ) ) {
[1548] Fix | Delete
// Skip recursive patterns.
[1549] Fix | Delete
array_splice( $blocks, $i, 1 );
[1550] Fix | Delete
continue;
[1551] Fix | Delete
}
[1552] Fix | Delete
[1553] Fix | Delete
$registry = WP_Block_Patterns_Registry::get_instance();
[1554] Fix | Delete
$pattern = $registry->get_registered( $slug );
[1555] Fix | Delete
[1556] Fix | Delete
// Skip unknown patterns.
[1557] Fix | Delete
if ( ! $pattern ) {
[1558] Fix | Delete
++$i;
[1559] Fix | Delete
continue;
[1560] Fix | Delete
}
[1561] Fix | Delete
[1562] Fix | Delete
$blocks_to_insert = parse_blocks( $pattern['content'] );
[1563] Fix | Delete
$seen_refs[ $slug ] = true;
[1564] Fix | Delete
$prev_inner_content = $inner_content;
[1565] Fix | Delete
$inner_content = null;
[1566] Fix | Delete
$blocks_to_insert = resolve_pattern_blocks( $blocks_to_insert );
[1567] Fix | Delete
$inner_content = $prev_inner_content;
[1568] Fix | Delete
unset( $seen_refs[ $slug ] );
[1569] Fix | Delete
array_splice( $blocks, $i, 1, $blocks_to_insert );
[1570] Fix | Delete
[1571] Fix | Delete
// If we have inner content, we need to insert nulls in the
[1572] Fix | Delete
// inner content array, otherwise serialize_blocks will skip
[1573] Fix | Delete
// blocks.
[1574] Fix | Delete
if ( $inner_content ) {
[1575] Fix | Delete
$null_indices = array_keys( $inner_content, null, true );
[1576] Fix | Delete
$content_index = $null_indices[ $i ];
[1577] Fix | Delete
$nulls = array_fill( 0, count( $blocks_to_insert ), null );
[1578] Fix | Delete
array_splice( $inner_content, $content_index, 1, $nulls );
[1579] Fix | Delete
}
[1580] Fix | Delete
[1581] Fix | Delete
// Skip inserted blocks.
[1582] Fix | Delete
$i += count( $blocks_to_insert );
[1583] Fix | Delete
} else {
[1584] Fix | Delete
if ( ! empty( $blocks[ $i ]['innerBlocks'] ) ) {
[1585] Fix | Delete
$prev_inner_content = $inner_content;
[1586] Fix | Delete
$inner_content = $blocks[ $i ]['innerContent'];
[1587] Fix | Delete
$blocks[ $i ]['innerBlocks'] = resolve_pattern_blocks(
[1588] Fix | Delete
$blocks[ $i ]['innerBlocks']
[1589] Fix | Delete
);
[1590] Fix | Delete
$blocks[ $i ]['innerContent'] = $inner_content;
[1591] Fix | Delete
$inner_content = $prev_inner_content;
[1592] Fix | Delete
}
[1593] Fix | Delete
++$i;
[1594] Fix | Delete
}
[1595] Fix | Delete
}
[1596] Fix | Delete
return $blocks;
[1597] Fix | Delete
}
[1598] Fix | Delete
[1599] Fix | Delete
/**
[1600] Fix | Delete
* Given an array of parsed block trees, applies callbacks before and after serializing them and
[1601] Fix | Delete
* returns their concatenated output.
[1602] Fix | Delete
*
[1603] Fix | Delete
* Recursively traverses the blocks and their inner blocks and applies the two callbacks provided as
[1604] Fix | Delete
* arguments, the first one before serializing a block, and the second one after serializing.
[1605] Fix | Delete
* If either callback returns a string value, it will be prepended and appended to the serialized
[1606] Fix | Delete
* block markup, respectively.
[1607] Fix | Delete
*
[1608] Fix | Delete
* The callbacks will receive a reference to the current block as their first argument, so that they
[1609] Fix | Delete
* can also modify it, and the current block's parent block as second argument. Finally, the
[1610] Fix | Delete
* `$pre_callback` receives the previous block, whereas the `$post_callback` receives
[1611] Fix | Delete
* the next block as third argument.
[1612] Fix | Delete
*
[1613] Fix | Delete
* Serialized blocks are returned including comment delimiters, and with all attributes serialized.
[1614] Fix | Delete
*
[1615] Fix | Delete
* This function should be used when there is a need to modify the saved blocks, or to inject markup
[1616] Fix | Delete
* into the return value. Prefer `serialize_blocks` when preparing blocks to be saved to post content.
[1617] Fix | Delete
*
[1618] Fix | Delete
* This function is meant for internal use only.
[1619] Fix | Delete
*
[1620] Fix | Delete
* @since 6.4.0
[1621] Fix | Delete
* @access private
[1622] Fix | Delete
*
[1623] Fix | Delete
* @see serialize_blocks()
[1624] Fix | Delete
*
[1625] Fix | Delete
* @param array[] $blocks An array of parsed blocks. See WP_Block_Parser_Block.
[1626] Fix | Delete
* @param callable $pre_callback Callback to run on each block in the tree before it is traversed and serialized.
[1627] Fix | Delete
* It is called with the following arguments: &$block, $parent_block, $previous_block.
[1628] Fix | Delete
* Its string return value will be prepended to the serialized block markup.
[1629] Fix | Delete
* @param callable $post_callback Callback to run on each block in the tree after it is traversed and serialized.
[1630] Fix | Delete
* It is called with the following arguments: &$block, $parent_block, $next_block.
[1631] Fix | Delete
* Its string return value will be appended to the serialized block markup.
[1632] Fix | Delete
* @return string Serialized block markup.
[1633] Fix | Delete
*/
[1634] Fix | Delete
function traverse_and_serialize_blocks( $blocks, $pre_callback = null, $post_callback = null ) {
[1635] Fix | Delete
$result = '';
[1636] Fix | Delete
$parent_block = null; // At the top level, there is no parent block to pass to the callbacks; yet the callbacks expect a reference.
[1637] Fix | Delete
[1638] Fix | Delete
foreach ( $blocks as $index => $block ) {
[1639] Fix | Delete
if ( is_callable( $pre_callback ) ) {
[1640] Fix | Delete
$prev = 0 === $index
[1641] Fix | Delete
? null
[1642] Fix | Delete
: $blocks[ $index - 1 ];
[1643] Fix | Delete
[1644] Fix | Delete
$result .= call_user_func_array(
[1645] Fix | Delete
$pre_callback,
[1646] Fix | Delete
array( &$block, &$parent_block, $prev )
[1647] Fix | Delete
);
[1648] Fix | Delete
}
[1649] Fix | Delete
[1650] Fix | Delete
if ( is_callable( $post_callback ) ) {
[1651] Fix | Delete
$next = count( $blocks ) - 1 === $index
[1652] Fix | Delete
? null
[1653] Fix | Delete
: $blocks[ $index + 1 ];
[1654] Fix | Delete
[1655] Fix | Delete
$post_markup = call_user_func_array(
[1656] Fix | Delete
$post_callback,
[1657] Fix | Delete
array( &$block, &$parent_block, $next )
[1658] Fix | Delete
);
[1659] Fix | Delete
}
[1660] Fix | Delete
[1661] Fix | Delete
$result .= traverse_and_serialize_block( $block, $pre_callback, $post_callback );
[1662] Fix | Delete
$result .= isset( $post_markup ) ? $post_markup : '';
[1663] Fix | Delete
}
[1664] Fix | Delete
[1665] Fix | Delete
return $result;
[1666] Fix | Delete
}
[1667] Fix | Delete
[1668] Fix | Delete
/**
[1669] Fix | Delete
* Filters and sanitizes block content to remove non-allowable HTML
[1670] Fix | Delete
* from parsed block attribute values.
[1671] Fix | Delete
*
[1672] Fix | Delete
* @since 5.3.1
[1673] Fix | Delete
*
[1674] Fix | Delete
* @param string $text Text that may contain block content.
[1675] Fix | Delete
* @param array[]|string $allowed_html Optional. An array of allowed HTML elements and attributes,
[1676] Fix | Delete
* or a context name such as 'post'. See wp_kses_allowed_html()
[1677] Fix | Delete
* for the list of accepted context names. Default 'post'.
[1678] Fix | Delete
* @param string[] $allowed_protocols Optional. Array of allowed URL protocols.
[1679] Fix | Delete
* Defaults to the result of wp_allowed_protocols().
[1680] Fix | Delete
* @return string The filtered and sanitized content result.
[1681] Fix | Delete
*/
[1682] Fix | Delete
function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols = array() ) {
[1683] Fix | Delete
$result = '';
[1684] Fix | Delete
[1685] Fix | Delete
if ( str_contains( $text, '<!--' ) && str_contains( $text, '--->' ) ) {
[1686] Fix | Delete
$text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
[1687] Fix | Delete
}
[1688] Fix | Delete
[1689] Fix | Delete
$blocks = parse_blocks( $text );
[1690] Fix | Delete
foreach ( $blocks as $block ) {
[1691] Fix | Delete
$block = filter_block_kses( $block, $allowed_html, $allowed_protocols );
[1692] Fix | Delete
$result .= serialize_block( $block );
[1693] Fix | Delete
}
[1694] Fix | Delete
[1695] Fix | Delete
return $result;
[1696] Fix | Delete
}
[1697] Fix | Delete
[1698] Fix | Delete
/**
[1699] Fix | Delete
* Callback used for regular expression replacement in filter_block_content().
[1700] Fix | Delete
*
[1701] Fix | Delete
* @since 6.2.1
[1702] Fix | Delete
* @access private
[1703] Fix | Delete
*
[1704] Fix | Delete
* @param array $matches Array of preg_replace_callback matches.
[1705] Fix | Delete
* @return string Replacement string.
[1706] Fix | Delete
*/
[1707] Fix | Delete
function _filter_block_content_callback( $matches ) {
[1708] Fix | Delete
return '<!--' . rtrim( $matches[1], '-' ) . '-->';
[1709] Fix | Delete
}
[1710] Fix | Delete
[1711] Fix | Delete
/**
[1712] Fix | Delete
* Filters and sanitizes a parsed block to remove non-allowable HTML
[1713] Fix | Delete
* from block attribute values.
[1714] Fix | Delete
*
[1715] Fix | Delete
* @since 5.3.1
[1716] Fix | Delete
*
[1717] Fix | Delete
* @param WP_Block_Parser_Block $block The parsed block object.
[1718] Fix | Delete
* @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
[1719] Fix | Delete
* or a context name such as 'post'. See wp_kses_allowed_html()
[1720] Fix | Delete
* for the list of accepted context names.
[1721] Fix | Delete
* @param string[] $allowed_protocols Optional. Array of allowed URL protocols.
[1722] Fix | Delete
* Defaults to the result of wp_allowed_protocols().
[1723] Fix | Delete
* @return array The filtered and sanitized block object result.
[1724] Fix | Delete
*/
[1725] Fix | Delete
function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) {
[1726] Fix | Delete
$block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols, $block );
[1727] Fix | Delete
[1728] Fix | Delete
if ( is_array( $block['innerBlocks'] ) ) {
[1729] Fix | Delete
foreach ( $block['innerBlocks'] as $i => $inner_block ) {
[1730] Fix | Delete
$block['innerBlocks'][ $i ] = filter_block_kses( $inner_block, $allowed_html, $allowed_protocols );
[1731] Fix | Delete
}
[1732] Fix | Delete
}
[1733] Fix | Delete
[1734] Fix | Delete
return $block;
[1735] Fix | Delete
}
[1736] Fix | Delete
[1737] Fix | Delete
/**
[1738] Fix | Delete
* Filters and sanitizes a parsed block attribute value to remove
[1739] Fix | Delete
* non-allowable HTML.
[1740] Fix | Delete
*
[1741] Fix | Delete
* @since 5.3.1
[1742] Fix | Delete
* @since 6.5.5 Added the `$block_context` parameter.
[1743] Fix | Delete
*
[1744] Fix | Delete
* @param string[]|string $value The attribute value to filter.
[1745] Fix | Delete
* @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
[1746] Fix | Delete
* or a context name such as 'post'. See wp_kses_allowed_html()
[1747] Fix | Delete
* for the list of accepted context names.
[1748] Fix | Delete
* @param string[] $allowed_protocols Optional. Array of allowed URL protocols.
[1749] Fix | Delete
* Defaults to the result of wp_allowed_protocols().
[1750] Fix | Delete
* @param array $block_context Optional. The block the attribute belongs to, in parsed block array format.
[1751] Fix | Delete
* @return string[]|string The filtered and sanitized result.
[1752] Fix | Delete
*/
[1753] Fix | Delete
function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array(), $block_context = null ) {
[1754] Fix | Delete
if ( is_array( $value ) ) {
[1755] Fix | Delete
foreach ( $value as $key => $inner_value ) {
[1756] Fix | Delete
$filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols, $block_context );
[1757] Fix | Delete
$filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols, $block_context );
[1758] Fix | Delete
[1759] Fix | Delete
if ( isset( $block_context['blockName'] ) && 'core/template-part' === $block_context['blockName'] ) {
[1760] Fix | Delete
$filtered_value = filter_block_core_template_part_attributes( $filtered_value, $filtered_key, $allowed_html );
[1761] Fix | Delete
}
[1762] Fix | Delete
if ( $filtered_key !== $key ) {
[1763] Fix | Delete
unset( $value[ $key ] );
[1764] Fix | Delete
}
[1765] Fix | Delete
[1766] Fix | Delete
$value[ $filtered_key ] = $filtered_value;
[1767] Fix | Delete
}
[1768] Fix | Delete
} elseif ( is_string( $value ) ) {
[1769] Fix | Delete
return wp_kses( $value, $allowed_html, $allowed_protocols );
[1770] Fix | Delete
}
[1771] Fix | Delete
[1772] Fix | Delete
return $value;
[1773] Fix | Delete
}
[1774] Fix | Delete
[1775] Fix | Delete
/**
[1776] Fix | Delete
* Sanitizes the value of the Template Part block's `tagName` attribute.
[1777] Fix | Delete
*
[1778] Fix | Delete
* @since 6.5.5
[1779] Fix | Delete
*
[1780] Fix | Delete
* @param string $attribute_value The attribute value to filter.
[1781] Fix | Delete
* @param string $attribute_name The attribute name.
[1782] Fix | Delete
* @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
[1783] Fix | Delete
* or a context name such as 'post'. See wp_kses_allowed_html()
[1784] Fix | Delete
* for the list of accepted context names.
[1785] Fix | Delete
* @return string The sanitized attribute value.
[1786] Fix | Delete
*/
[1787] Fix | Delete
function filter_block_core_template_part_attributes( $attribute_value, $attribute_name, $allowed_html ) {
[1788] Fix | Delete
if ( empty( $attribute_value ) || 'tagName' !== $attribute_name ) {
[1789] Fix | Delete
return $attribute_value;
[1790] Fix | Delete
}
[1791] Fix | Delete
if ( ! is_array( $allowed_html ) ) {
[1792] Fix | Delete
$allowed_html = wp_kses_allowed_html( $allowed_html );
[1793] Fix | Delete
}
[1794] Fix | Delete
return isset( $allowed_html[ $attribute_value ] ) ? $attribute_value : '';
[1795] Fix | Delete
}
[1796] Fix | Delete
[1797] Fix | Delete
/**
[1798] Fix | Delete
* Parses blocks out of a content string, and renders those appropriate for the excerpt.
[1799] Fix | Delete
*
[1800] Fix | Delete
* As the excerpt should be a small string of text relevant to the full post content,
[1801] Fix | Delete
* this function renders the blocks that are most likely to contain such text.
[1802] Fix | Delete
*
[1803] Fix | Delete
* @since 5.0.0
[1804] Fix | Delete
*
[1805] Fix | Delete
* @param string $content The content to parse.
[1806] Fix | Delete
* @return string The parsed and filtered content.
[1807] Fix | Delete
*/
[1808] Fix | Delete
function excerpt_remove_blocks( $content ) {
[1809] Fix | Delete
if ( ! has_blocks( $content ) ) {
[1810] Fix | Delete
return $content;
[1811] Fix | Delete
}
[1812] Fix | Delete
[1813] Fix | Delete
$allowed_inner_blocks = array(
[1814] Fix | Delete
// Classic blocks have their blockName set to null.
[1815] Fix | Delete
null,
[1816] Fix | Delete
'core/freeform',
[1817] Fix | Delete
'core/heading',
[1818] Fix | Delete
'core/html',
[1819] Fix | Delete
'core/list',
[1820] Fix | Delete
'core/media-text',
[1821] Fix | Delete
'core/paragraph',
[1822] Fix | Delete
'core/preformatted',
[1823] Fix | Delete
'core/pullquote',
[1824] Fix | Delete
'core/quote',
[1825] Fix | Delete
'core/table',
[1826] Fix | Delete
'core/verse',
[1827] Fix | Delete
);
[1828] Fix | Delete
[1829] Fix | Delete
$allowed_wrapper_blocks = array(
[1830] Fix | Delete
'core/columns',
[1831] Fix | Delete
'core/column',
[1832] Fix | Delete
'core/group',
[1833] Fix | Delete
);
[1834] Fix | Delete
[1835] Fix | Delete
/**
[1836] Fix | Delete
* Filters the list of blocks that can be used as wrapper blocks, allowing
[1837] Fix | Delete
* excerpts to be generated from the `innerBlocks` of these wrappers.
[1838] Fix | Delete
*
[1839] Fix | Delete
* @since 5.8.0
[1840] Fix | Delete
*
[1841] Fix | Delete
* @param string[] $allowed_wrapper_blocks The list of names of allowed wrapper blocks.
[1842] Fix | Delete
*/
[1843] Fix | Delete
$allowed_wrapper_blocks = apply_filters( 'excerpt_allowed_wrapper_blocks', $allowed_wrapper_blocks );
[1844] Fix | Delete
[1845] Fix | Delete
$allowed_blocks = array_merge( $allowed_inner_blocks, $allowed_wrapper_blocks );
[1846] Fix | Delete
[1847] Fix | Delete
/**
[1848] Fix | Delete
* Filters the list of blocks that can contribute to the excerpt.
[1849] Fix | Delete
*
[1850] Fix | Delete
* If a dynamic block is added to this list, it must not generate another
[1851] Fix | Delete
* excerpt, as this will cause an infinite loop to occur.
[1852] Fix | Delete
*
[1853] Fix | Delete
* @since 5.0.0
[1854] Fix | Delete
*
[1855] Fix | Delete
* @param string[] $allowed_blocks The list of names of allowed blocks.
[1856] Fix | Delete
*/
[1857] Fix | Delete
$allowed_blocks = apply_filters( 'excerpt_allowed_blocks', $allowed_blocks );
[1858] Fix | Delete
$blocks = parse_blocks( $content );
[1859] Fix | Delete
$output = '';
[1860] Fix | Delete
[1861] Fix | Delete
foreach ( $blocks as $block ) {
[1862] Fix | Delete
if ( in_array( $block['blockName'], $allowed_blocks, true ) ) {
[1863] Fix | Delete
if ( ! empty( $block['innerBlocks'] ) ) {
[1864] Fix | Delete
if ( in_array( $block['blockName'], $allowed_wrapper_blocks, true ) ) {
[1865] Fix | Delete
$output .= _excerpt_render_inner_blocks( $block, $allowed_blocks );
[1866] Fix | Delete
continue;
[1867] Fix | Delete
}
[1868] Fix | Delete
[1869] Fix | Delete
// Skip the block if it has disallowed or nested inner blocks.
[1870] Fix | Delete
foreach ( $block['innerBlocks'] as $inner_block ) {
[1871] Fix | Delete
if (
[1872] Fix | Delete
! in_array( $inner_block['blockName'], $allowed_inner_blocks, true ) ||
[1873] Fix | Delete
! empty( $inner_block['innerBlocks'] )
[1874] Fix | Delete
) {
[1875] Fix | Delete
continue 2;
[1876] Fix | Delete
}
[1877] Fix | Delete
}
[1878] Fix | Delete
}
[1879] Fix | Delete
[1880] Fix | Delete
$output .= render_block( $block );
[1881] Fix | Delete
}
[1882] Fix | Delete
}
[1883] Fix | Delete
[1884] Fix | Delete
return $output;
[1885] Fix | Delete
}
[1886] Fix | Delete
[1887] Fix | Delete
/**
[1888] Fix | Delete
* Parses footnotes markup out of a content string,
[1889] Fix | Delete
* and renders those appropriate for the excerpt.
[1890] Fix | Delete
*
[1891] Fix | Delete
* @since 6.3.0
[1892] Fix | Delete
*
[1893] Fix | Delete
* @param string $content The content to parse.
[1894] Fix | Delete
* @return string The parsed and filtered content.
[1895] Fix | Delete
*/
[1896] Fix | Delete
function excerpt_remove_footnotes( $content ) {
[1897] Fix | Delete
if ( ! str_contains( $content, 'data-fn=' ) ) {
[1898] Fix | Delete
return $content;
[1899] Fix | Delete
}
[1900] Fix | Delete
[1901] Fix | Delete
return preg_replace(
[1902] Fix | Delete
'_<sup data-fn="[^"]+" class="[^"]+">\s*<a href="[^"]+" id="[^"]+">\d+</a>\s*</sup>_',
[1903] Fix | Delete
'',
[1904] Fix | Delete
$content
[1905] Fix | Delete
);
[1906] Fix | Delete
}
[1907] Fix | Delete
[1908] Fix | Delete
/**
[1909] Fix | Delete
* Renders inner blocks from the allowed wrapper blocks
[1910] Fix | Delete
* for generating an excerpt.
[1911] Fix | Delete
*
[1912] Fix | Delete
* @since 5.8.0
[1913] Fix | Delete
* @access private
[1914] Fix | Delete
*
[1915] Fix | Delete
* @param array $parsed_block The parsed block.
[1916] Fix | Delete
* @param array $allowed_blocks The list of allowed inner blocks.
[1917] Fix | Delete
* @return string The rendered inner blocks.
[1918] Fix | Delete
*/
[1919] Fix | Delete
function _excerpt_render_inner_blocks( $parsed_block, $allowed_blocks ) {
[1920] Fix | Delete
$output = '';
[1921] Fix | Delete
[1922] Fix | Delete
foreach ( $parsed_block['innerBlocks'] as $inner_block ) {
[1923] Fix | Delete
if ( ! in_array( $inner_block['blockName'], $allowed_blocks, true ) ) {
[1924] Fix | Delete
continue;
[1925] Fix | Delete
}
[1926] Fix | Delete
[1927] Fix | Delete
if ( empty( $inner_block['innerBlocks'] ) ) {
[1928] Fix | Delete
$output .= render_block( $inner_block );
[1929] Fix | Delete
} else {
[1930] Fix | Delete
$output .= _excerpt_render_inner_blocks( $inner_block, $allowed_blocks );
[1931] Fix | Delete
}
[1932] Fix | Delete
}
[1933] Fix | Delete
[1934] Fix | Delete
return $output;
[1935] Fix | Delete
}
[1936] Fix | Delete
[1937] Fix | Delete
/**
[1938] Fix | Delete
* Renders a single block into a HTML string.
[1939] Fix | Delete
*
[1940] Fix | Delete
* @since 5.0.0
[1941] Fix | Delete
*
[1942] Fix | Delete
* @global WP_Post $post The post to edit.
[1943] Fix | Delete
*
[1944] Fix | Delete
* @param array $parsed_block {
[1945] Fix | Delete
* A representative array of the block being rendered. See WP_Block_Parser_Block.
[1946] Fix | Delete
*
[1947] Fix | Delete
* @type string $blockName Name of block.
[1948] Fix | Delete
* @type array $attrs Attributes from block comment delimiters.
[1949] Fix | Delete
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
[1950] Fix | Delete
* have the same structure as this one.
[1951] Fix | Delete
* @type string $innerHTML HTML from inside block comment delimiters.
[1952] Fix | Delete
* @type array $innerContent List of string fragments and null markers where
[1953] Fix | Delete
* inner blocks were found.
[1954] Fix | Delete
* }
[1955] Fix | Delete
* @return string String of rendered HTML.
[1956] Fix | Delete
*/
[1957] Fix | Delete
function render_block( $parsed_block ) {
[1958] Fix | Delete
global $post;
[1959] Fix | Delete
$parent_block = null;
[1960] Fix | Delete
[1961] Fix | Delete
/**
[1962] Fix | Delete
* Allows render_block() to be short-circuited, by returning a non-null value.
[1963] Fix | Delete
*
[1964] Fix | Delete
* @since 5.1.0
[1965] Fix | Delete
* @since 5.9.0 The `$parent_block` parameter was added.
[1966] Fix | Delete
*
[1967] Fix | Delete
* @param string|null $pre_render The pre-rendered content. Default null.
[1968] Fix | Delete
* @param array $parsed_block {
[1969] Fix | Delete
* A representative array of the block being rendered. See WP_Block_Parser_Block.
[1970] Fix | Delete
*
[1971] Fix | Delete
* @type string $blockName Name of block.
[1972] Fix | Delete
* @type array $attrs Attributes from block comment delimiters.
[1973] Fix | Delete
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
[1974] Fix | Delete
* have the same structure as this one.
[1975] Fix | Delete
* @type string $innerHTML HTML from inside block comment delimiters.
[1976] Fix | Delete
* @type array $innerContent List of string fragments and null markers where
[1977] Fix | Delete
* inner blocks were found.
[1978] Fix | Delete
* }
[1979] Fix | Delete
* @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
[1980] Fix | Delete
*/
[1981] Fix | Delete
$pre_render = apply_filters( 'pre_render_block', null, $parsed_block, $parent_block );
[1982] Fix | Delete
if ( ! is_null( $pre_render ) ) {
[1983] Fix | Delete
return $pre_render;
[1984] Fix | Delete
}
[1985] Fix | Delete
[1986] Fix | Delete
$source_block = $parsed_block;
[1987] Fix | Delete
[1988] Fix | Delete
/**
[1989] Fix | Delete
* Filters the block being rendered in render_block(), before it's processed.
[1990] Fix | Delete
*
[1991] Fix | Delete
* @since 5.1.0
[1992] Fix | Delete
* @since 5.9.0 The `$parent_block` parameter was added.
[1993] Fix | Delete
*
[1994] Fix | Delete
* @param array $parsed_block {
[1995] Fix | Delete
* A representative array of the block being rendered. See WP_Block_Parser_Block.
[1996] Fix | Delete
*
[1997] Fix | Delete
* @type string $blockName Name of block.
[1998] Fix | Delete
* @type array $attrs Attributes from block comment delimiters.
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function