wp/wp-includes/blocks/query-pagination-previous.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    17 function render_block_core_query_pagination_previous( $attributes, $content, $block ) {
    17 function render_block_core_query_pagination_previous( $attributes, $content, $block ) {
    18 	$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
    18 	$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
    19 	$page     = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
    19 	$page     = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
    20 
    20 
    21 	$wrapper_attributes = get_block_wrapper_attributes();
    21 	$wrapper_attributes = get_block_wrapper_attributes();
    22 	$default_label      = __( '« Previous Page' );
    22 	$default_label      = __( 'Previous Page' );
    23 	$label              = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
    23 	$label              = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? esc_html( $attributes['label'] ) : $default_label;
    24 	$content            = '';
    24 	$pagination_arrow   = get_query_pagination_arrow( $block, false );
       
    25 	if ( $pagination_arrow ) {
       
    26 		$label = $pagination_arrow . $label;
       
    27 	}
       
    28 	$content = '';
    25 	// Check if the pagination is for Query that inherits the global context
    29 	// Check if the pagination is for Query that inherits the global context
    26 	// and handle appropriately.
    30 	// and handle appropriately.
    27 	if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
    31 	if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
    28 		$filter_link_attributes = function() use ( $wrapper_attributes ) {
    32 		$filter_link_attributes = function() use ( $wrapper_attributes ) {
    29 			return $wrapper_attributes;
    33 			return $wrapper_attributes;
    30 		};
    34 		};
       
    35 
    31 		add_filter( 'previous_posts_link_attributes', $filter_link_attributes );
    36 		add_filter( 'previous_posts_link_attributes', $filter_link_attributes );
    32 		$content = get_previous_posts_link( $label );
    37 		$content = get_previous_posts_link( $label );
    33 		remove_filter( 'previous_posts_link_attributes', $filter_link_attributes );
    38 		remove_filter( 'previous_posts_link_attributes', $filter_link_attributes );
    34 	} elseif ( 1 !== $page ) {
    39 	} elseif ( 1 !== $page ) {
    35 		$content = sprintf(
    40 		$content = sprintf(