private static function get_edge_textnode( callable $get_textnode, \DOMNode $node = null, $recursive = false, $reverse = false ) {
		if ( ! isset( $node ) ) {
			return null;
		}

		if ( $node instanceof \DOMText ) {
			return $node;
		} elseif ( ! $node instanceof \DOMElement || $recursive && self::is_block_tag( $node ) ) {
			// Return null if $node is neither \DOMText nor \DOMElement or
			// when we are recursing and already at the block level.
			return null;
		}

		$edge_textnode = null;

		if ( $node->hasChildNodes() ) {
			$children    = $node->childNodes;
			$max         = $children->length;
			$index       = $reverse ? $max - 1 : 0;
			$incrementor = $reverse ? -1 : +1;

			while ( $index >= 0 && $index < $max && null === $edge_textnode ) {
				$edge_textnode = $get_textnode( $children->item( $index ), true );
				$index        += $incrementor;
			}
		}

		return $edge_textnode;
	}
private static function get_edge_textnode( callable $get_textnode, \DOMNode $node = null, $recursive = false, $reverse = false ) {
		if ( ! isset( $node ) ) {
			return null;
		}

		if ( $node instanceof \DOMText ) {
			return $node;
		} elseif ( ! $node instanceof \DOMElement || $recursive && self::is_block_tag( $node ) ) {
			// Return null if $node is neither \DOMText nor \DOMElement or
			// when we are recursing and already at the block level.
			return null;
		}

		$edge_textnode = null;

		if ( $node->hasChildNodes() ) {
			$children    = $node->childNodes;
			$max         = $children->length;
			$index       = $reverse ? $max - 1 : 0;
			$incrementor = $reverse ? -1 : +1;

			while ( $index >= 0 && $index < $max && null === $edge_textnode ) {
				$edge_textnode = $get_textnode( $children->item( $index ), true );
				$index        += $incrementor;
			}
		}

		return $edge_textnode;
	}
private static function get_edge_textnode ( callable $ get_textnode , \ DOMNode $ node = null , $ recursive = false , $ reverse = false ) { if ( ! isset ( $ node ) ) { return null ; } if ( $ node instanceof \ DOMText ) { return $ node ; } elseif ( ! $ node instanceof \ DOMElement || $ recursive && self :: is_block_tag ( $ node ) ) { // Return null if $node is neither \DOMText nor \DOMElement or // when we are recursing and already at the block level. return null ; } $ edge_textnode = null ; if ( $ node -> hasChildNodes ( ) ) { $ children = $ node -> childNodes ; $ max = $ children -> length ; $ index = $ reverse ? $ max - 1 : 0 ; $ incrementor = $ reverse ? - 1 : + 1 ; while ( $ index >= 0 && $ index < $ max && null === $ edge_textnode ) { $ edge_textnode = $ get_textnode ( $ children -> item ( $ index ) , true ) ; $ index += $ incrementor ; } } return $ edge_textnode ; }
Retrieves an edge \DOMText child of the element specified by the callable.
Block-level child elements are ignored.

@since 5.0.0

@param callable      $get_textnode Takes two parameters, a \DOMNode and a boolean flag for recursive calls.
@param \DOMNode|null $node         Optional. Default null.
@param bool          $recursive    Should be set to true on recursive calls. Optional. Default false.
@param bool          $reverse      Whether to iterate forward or backward. Optional. Default false.

@return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null.
Retrieves an edge \ DOMText child of the element specified by the callable . Block - level child elements are ignored .