/**
* Server-side rendering of the `core/post-navigation-link` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-navigation-link` block on the server.
*
* @since 5.9.0
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
*
* @return string Returns the next or previous post link that is adjacent to the current post.
*/
function render_block_core_post_navigation_link( $attributes, $content ) {
if ( ! is_singular() ) {
return '';
}
// Get the navigation type to show the proper link. Available options are `next|previous`.
$navigation_type = isset( $attributes['type'] ) ? $attributes['type'] : 'next';
// Allow only `next` and `previous` in `$navigation_type`.
if ( ! in_array( $navigation_type, array( 'next', 'previous' ), true ) ) {
return '';
}
$classes = "post-navigation-link-$navigation_type";
if ( isset( $attributes['textAlign'] ) ) {
$classes .= " has-text-align-{$attributes['textAlign']}";
}
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => $classes,
)
);
// Set default values.
$format = '%link';
$link = 'next' === $navigation_type ? _x( 'Next', 'label for next post link' ) : _x( 'Previous', 'label for previous post link' );
$label = '';
// Only use hardcoded values here, otherwise we need to add escaping where these values are used.
$arrow_map = array(
'none' => '',
'arrow' => array(
'next' => '→',
'previous' => '←',
),
'chevron' => array(
'next' => '»',
'previous' => '«',
),
);
// If a custom label is provided, make this a link.
// `$label` is used to prepend the provided label, if we want to show the page title as well.
if ( isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ) {
$label = "{$attributes['label']}";
$link = $label;
}
// If we want to also show the page title, make the page title a link and prepend the label.
if ( isset( $attributes['showTitle'] ) && $attributes['showTitle'] ) {
/*
* If the label link option is not enabled but there is a custom label,
* display the custom label as text before the linked title.
*/
if ( ! $attributes['linkLabel'] ) {
if ( $label ) {
$format = '' . wp_kses_post( $label ) . ' %link';
}
$link = '%title';
} elseif ( isset( $attributes['linkLabel'] ) && $attributes['linkLabel'] ) {
// If the label link option is enabled and there is a custom label, display it before the title.
if ( $label ) {
$link = '' . wp_kses_post( $label ) . '%title';
} else {
/*
* If the label link option is enabled and there is no custom label,
* add a colon between the label and the post title.
*/
$label = 'next' === $navigation_type ? _x( 'Next:', 'label before the title of the next post' ) : _x( 'Previous:', 'label before the title of the previous post' );
$link = sprintf(
'%1$s%2$s',
wp_kses_post( $label ),
'%title'
);
}
}
}
// Display arrows.
if ( isset( $attributes['arrow'] ) && 'none' !== $attributes['arrow'] && isset( $arrow_map[ $attributes['arrow'] ] ) ) {
$arrow = $arrow_map[ $attributes['arrow'] ][ $navigation_type ];
if ( 'next' === $navigation_type ) {
$format = '%link' . $arrow . '';
} else {
$format = '' . $arrow . '%link';
}
}
/*
* The dynamic portion of the function name, `$navigation_type`,
* Refers to the type of adjacency, 'next' or 'previous'.
*
* @see https://developer.wordpress.org/reference/functions/get_previous_post_link/
* @see https://developer.wordpress.org/reference/functions/get_next_post_link/
*/
$get_link_function = "get_{$navigation_type}_post_link";
if ( ! empty( $attributes['taxonomy'] ) ) {
$content = $get_link_function( $format, $link, true, '', $attributes['taxonomy'] );
} else {
$content = $get_link_function( $format, $link );
}
return sprintf(
'
%2$s
',
$wrapper_attributes,
$content
);
}
/**
* Registers the `core/post-navigation-link` block on the server.
*
* @since 5.9.0
*/
function register_block_core_post_navigation_link() {
register_block_type_from_metadata(
__DIR__ . '/post-navigation-link',
array(
'render_callback' => 'render_block_core_post_navigation_link',
)
);
}
add_action( 'init', 'register_block_core_post_navigation_link' );
yash – webinar
Exactly what set Crazy Gambling establishment apart are the broadening collection away from creative games. Navigating this site is a breeze, enabling you to see your preferred game quickly and you may to make secure money. The biggest user experience and you will progressive user interface enable it to be a new player favourite. According to our team’s inside the-depth get criteria, these types of casinos try imperative. (more…)
Elevate Your Gameplay: Seamless aviator game login & Experience the Thrill of Instant Wins.Understanding the Aviator Game MechanicsThe Importance of a Smooth aviator game loginTroubleshooting Common Login IssuesSecurity Measures for…
Пьянящий азарт и роскошь: онлайн-казино с атмосферой водки и больших выигрышей.Атмосфера роскоши и эксклюзивности в онлайн-казиноБонусы и акции с тематикой водки: больше, чем просто подаркиVIP-программы и эксклюзивные предложенияСпециальные предложения и…
Seguridad En Exchanges De CriptomonedasLos exchanges de criptomonedas se han convertido en el punto de entrada principal para millones de usuarios que desean operar con Bitcoin, Ethereum y otros activos…
Unlocking the World of Mr Punter Casino: A Comprehensive Guide to Login Procedures Welcome to the ultimate guide where we delve deep into the intricacies of Mr Punter Casino Login.…
Spielerlebnis neu definiert: Mit morospin zu mehr Spannung und Gewinnen im Online-Casino.Die Vielfalt der Spiele bei morospinBeliebte Spielautomaten bei morospinDie Bedeutung von verantwortungsvollem SpielenBoni und Aktionen bei morospinDie Bedeutung der…
The Thrilling Journey to Gamdom Win Welcome to the vibrant world of Gamdom, where the thrill of possibility meets the excitement of online gaming. Whether you are a seasoned player…
Plume et Vertige : Chicken Road avis, un défi palpitant où chaque pas augmente les gains, oserez-vous défier le destin jusquau bout ?Le Concept Unique de Chicken Road : Une…
Fortune Favors the Bold: Test your luck guiding a chicken along the perilous chickenroad, multiplying your winnings with each step – but know when to collect before disaster strikes.Understanding the…
La compra de esteroides en línea se ha vuelto cada vez más común entre atletas y culturistas que buscan mejorar su rendimiento o aumentar su masa muscular. Sin embargo, esta…