alleyinteractive / alleyinteractive/wp-seo
New `WP_SEO_Format_Page_Number` tag formatter
- Lenguaje dominante
- PHP
- Estrellas
- 45
- Forks
- 13
- Merge medio
- 12 d 16 h
- PR fusionados (30 d)
- 5
Descripción
### Description
Introduce a new `#page_number#` formatter:
```php
/**
* Add #page_number# to WP SEO Formatting Options
*/
class WP_SEO_Format_Page_Number extends WP_SEO_Formatting_Tag {
/**
* The name of the tag.
*
* @var string
*/
public $tag = '#page_number#';
/**
* The description of the tag.
*
* @return string
*/
public function get_description(): string {
return __( 'Replaced with page number for archive pages.', 'wp-seo' );
}
/**
* The replacement value for the tag.
*
* @return string
*/
public function get_value(): string {
if ( is_archive() ) {
global $wp_query;
$page = 1;
if ( $wp_query->is_paged() ) {
$page = $wp_query->query_vars['paged'];
}
if ( $page > 1 ) {
/* translators: Page Number */
return sprintf( esc_html__( 'Page %s |', 'wp-seo' ), absint( $page ) );
}
}
return '';
}
}
```
### Use Case
A new `#page_number#` formatter to be used in archive pages.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.