Commit realizado el 12:13:52 08-04-2024

This commit is contained in:
Pagina Web Monito
2024-04-08 12:13:55 -04:00
commit 0c33094de9
7815 changed files with 1365694 additions and 0 deletions

View File

@@ -0,0 +1 @@
(()=>{"use strict";const e=wp.hooks,o=wp.i18n,n=wp.element,t=wp.compose,a=wp.data,r=wp.components;const l=(0,t.compose)((0,a.withSelect)((function(e){return{robots:e("rank-math-pro").getNewsRobots()}})),(0,a.withDispatch)((function(e){return{updateNewsRobots:function(o){e("rank-math-pro").updateNewsRobots(o)}}})))((function(e){return wp.element.createElement(n.Fragment,null,wp.element.createElement(r.PanelBody,{initialOpen:!0},wp.element.createElement(r.RadioControl,{label:(0,o.__)("Googlebot-News index","rank-math-pro"),help:(0,o.__)('Using an "Index" or "NoIndex" option allows you to control what Google News Bot (not to be confused with Google Search Bot) can include or not include in the Google News Index.',"rank-math-pro"),selected:e.robots,options:[{value:"index",label:(0,o.__)("Index","rank-math-pro")},{value:"noindex",label:(0,o.__)("No Index","rank-math-pro")}],onChange:e.updateNewsRobots})))}));(0,e.addAction)("rank_math_loaded","rank-math-pro",(function(){(0,e.addFilter)("rankMath.advanced.newsSitemap","rank-math-pro",(function(){return l}))}))})();

View File

@@ -0,0 +1,118 @@
<?php
/**
* The News Sitemap Metabox.
*
* @since 1.0.0
* @package RankMath
* @subpackage RankMathPro
* @author MyThemeShop <admin@mythemeshop.com>
*/
namespace RankMathPro\Sitemap;
use RankMath\Helper;
use RankMath\Traits\Hooker;
use RankMath\Admin\Admin_Helper;
use RankMath\Sitemap\Cache_Watcher;
use MyThemeShop\Helpers\Param;
use MyThemeShop\Helpers\WordPress;
defined( 'ABSPATH' ) || exit;
/**
* News_Metabox class.
*/
class News_Metabox {
use Hooker;
/**
* The Constructor.
*/
public function __construct() {
if ( ! Helper::has_cap( 'sitemap' ) ) {
return;
}
$this->action( 'save_post', 'save_post' );
$this->action( 'rank_math/admin/editor_scripts', 'enqueue_news_sitemap', 11 );
$this->filter( 'rank_math/metabox/post/values', 'add_metadata', 10, 2 );
}
/**
* Enqueue scripts for the metabox.
*/
public function enqueue_news_sitemap() {
if ( ! $this->can_add_tab() ) {
return;
}
wp_enqueue_script(
'rank-math-pro-news',
RANK_MATH_PRO_URL . 'includes/modules/news-sitemap/assets/js/news-sitemap.js',
[ 'rank-math-pro-editor' ],
rank_math_pro()->version,
true
);
}
/**
* Add meta data to use in gutenberg.
*
* @param array $values Aray of tabs.
* @param Screen $screen Sceen object.
*
* @return array
*/
public function add_metadata( $values, $screen ) {
$object_id = $screen->get_object_id();
$object_type = $screen->get_object_type();
$robots = $screen->get_meta( $object_type, $object_id, 'rank_math_news_sitemap_robots' );
$values['newsSitemap'] = [
'robots' => $robots ? $robots : 'index',
];
return $values;
}
/**
* Check for relevant post type before invalidation.
*
* @copyright Copyright (C) 2008-2019, Yoast BV
* The following code is a derivative work of the code from the Yoast(https://github.com/Yoast/wordpress-seo/), which is licensed under GPL v3.
*
* @param int $post_id Post ID to possibly invalidate for.
*/
public function save_post( $post_id ) {
if (
wp_is_post_revision( $post_id ) ||
! $this->can_add_tab( get_post_type( $post_id ) ) ||
false === Helper::is_post_indexable( $post_id )
) {
return false;
}
Cache_Watcher::invalidate( 'news' );
}
/**
* Show field check callback.
*
* @param string $post_type Current Post Type.
*
* @return boolean
*/
private function can_add_tab( $post_type = false ) {
if ( Admin_Helper::is_term_profile_page() || Admin_Helper::is_posts_page() ) {
return false;
}
$post_type = $post_type ? $post_type : WordPress::get_post_type();
return in_array(
$post_type,
(array) Helper::get_settings( 'sitemap.news_sitemap_post_type' ),
true
);
}
}

View File

@@ -0,0 +1,300 @@
<?php
/**
* The Sitemap Module
*
* @since 1.0.0
* @package RankMath
* @subpackage RankMathPro
* @author MyThemeShop <admin@mythemeshop.com>
*/
namespace RankMathPro\Sitemap;
use RankMath\Helper;
use RankMath\Sitemap\Router;
use RankMath\Sitemap\Providers\Post_Type;
defined( 'ABSPATH' ) || exit;
/**
* News_Provider class.
*/
class News_Provider extends Post_Type {
/**
* Indicate that this provider should show an empty sitemap instead of a 404.
*
* @var boolean
*/
public $should_show_empty = true;
/**
* Check if provider supports given item type.
*
* @param string $type Type string to check for.
* @return boolean
*/
public function handles_type( $type ) {
return 'news' === $type;
}
/**
* Get set of sitemaps index link data.
*
* @param int $max_entries Entries per sitemap.
* @return array
*/
public function get_index_links( $max_entries ) { // phpcs:ignore
global $wpdb;
$index = [];
$post_types = Helper::get_settings( 'sitemap.news_sitemap_post_type' );
$posts = $this->get_posts( $post_types, 1, 0 );
if ( empty( $posts ) ) {
return $index;
}
$item = $this->do_filter(
'sitemap/index/entry',
[
'loc' => Router::get_base_url( 'news-sitemap.xml' ),
'lastmod' => get_lastpostdate( 'gmt' ),
],
'news',
);
if ( $item ) {
$index[] = $item;
}
return $index;
}
/**
* Get set of sitemap link data.
*
* @param string $type Sitemap type.
* @param int $max_entries Entries per sitemap.
* @param int $current_page Current page of the sitemap.
* @return array
*/
public function get_sitemap_links( $type, $max_entries, $current_page ) { // phpcs:ignore
$links = [];
$post_types = Helper::get_settings( 'sitemap.news_sitemap_post_type' );
$posts = $this->get_posts( $post_types, 1000, 0 );
if ( empty( $posts ) ) {
return $links;
}
foreach ( $posts as $post ) {
if ( ! Helper::is_post_indexable( $post->ID ) ) {
continue;
}
if ( ! News_Sitemap::is_post_indexable( $post->ID ) ) {
continue;
}
$url = $this->get_url( $post );
if ( ! isset( $url['loc'] ) ) {
continue;
}
/**
* Filter URL entry before it gets added to the sitemap.
*
* @param array $url Array of URL parts.
* @param string $type URL type.
* @param object $user Data object for the URL.
*/
$url = $this->do_filter( 'sitemap/entry', $url, 'post', $post );
if ( empty( $url ) ) {
continue;
}
if ( (int) $post->ID === $this->get_page_for_posts_id() || (int) $post->ID === $this->get_page_on_front_id() ) {
array_unshift( $links, $url );
continue;
}
$links[] = $url;
}
return $links;
}
/**
* Retrieve set of posts with optimized query routine.
*
* @param array $post_types Post type to retrieve.
* @param int $count Count of posts to retrieve.
* @param int $offset Starting offset.
*
* @return object[]
*/
protected function get_posts( $post_types, $count, $offset ) { // phpcs:ignore
global $wpdb;
if ( empty( $post_types ) ) {
return [];
}
if ( ! is_array( $post_types ) ) {
$post_types = [ $post_types ];
}
/**
* Get posts for the last two days only.
*/
$sql = "
SELECT *
FROM {$wpdb->posts}
WHERE post_status='publish'
AND ( TIMESTAMPDIFF( MINUTE, post_date_gmt, UTC_TIMESTAMP() ) <= ( 48 * 60 ) )
AND post_type IN ( '" . join( "', '", esc_sql( $post_types ) ) . "' )
";
$terms_query = '';
foreach ( $post_types as $post_type ) {
$terms = current( Helper::get_settings( "sitemap.news_sitemap_exclude_{$post_type}_terms", [] ) );
if ( empty( $terms ) ) {
continue;
}
array_map(
function ( $key ) use ( $terms, &$terms_query, $wpdb ) {
$placeholders = implode( ', ', array_fill( 0, count( $terms[ $key ] ), '%d' ) );
$terms_sql = "
{$wpdb->posts}.ID NOT IN (
SELECT object_id
FROM {$wpdb->term_relationships}
WHERE term_taxonomy_id IN ($placeholders)
)
AND";
$terms_query .= $wpdb->prepare( $terms_sql, $terms[ $key ] ); // phpcs:ignore
},
array_keys( $terms )
);
}
// Remove the last AND, no way to tell the last items.
if ( $terms_query ) {
$terms_query = preg_replace( '/(AND)$/i', '', $terms_query );
$terms_query = "( {$terms_query} )";
$sql .= 'AND ' . $terms_query;
}
$sql .= "
AND post_password = ''
ORDER BY post_date_gmt DESC
LIMIT 0, %d
";
$count = max( 1, min( 1000, $count ) );
return $wpdb->get_results( $wpdb->prepare( $sql, $count ) ); // phpcs:ignore
}
/**
* Produce array of URL parts for given post object.
*
* @param object $post Post object to get URL parts for.
* @return array|boolean
*/
protected function get_url( $post ) {
$url = [];
/**
* Filter the URL Rank Math SEO uses in the XML sitemap.
*
* Note that only absolute local URLs are allowed as the check after this removes external URLs.
*
* @param string $url URL to use in the XML sitemap
* @param object $post Post object for the URL.
*/
$url['loc'] = $this->do_filter( 'sitemap/xml_post_url', get_permalink( $post ), $post );
/**
* Do not include external URLs.
*
* @see https://wordpress.org/plugins/page-links-to/ can rewrite permalinks to external URLs.
*/
if ( 'external' === $this->get_classifier()->classify( $url['loc'] ) ) {
return false;
}
$canonical = Helper::get_post_meta( 'canonical', $post->ID );
if ( '' !== $canonical && $canonical !== $url['loc'] ) {
/*
* Let's assume that if a canonical is set for this page and it's different from
* the URL of this post, that page is either already in the XML sitemap OR is on
* an external site, either way, we shouldn't include it here.
*/
return false;
}
rank_math()->variables->setup();
$url['title'] = $this->get_title( $post );
$url['publication_date'] = $post->post_date_gmt;
return $url;
}
/**
* Get Post Title.
*
* @param WP_Post $post Post Object.
*
* @return string
*/
private function get_title( $post ) {
$title = Helper::get_post_meta( 'title', $post->ID );
return $title ? $title : $post->post_title;
}
/**
* Filter Posts by excluded terms.
*
* @param object $posts News Sitemap Posts.
*
* @return object[]
*/
private function filter_posts_by_terms( $posts ) {
if ( empty( $posts ) ) {
return $posts;
}
foreach ( $posts as $key => $post ) {
$exclude_terms = current( Helper::get_settings( "sitemap.news_sitemap_exclude_{$post->post_type}_terms", [] ) );
if ( empty( $exclude_terms ) ) {
continue;
}
$exclude_terms = array_merge( ...array_values( $exclude_terms ) );
$taxonomies = get_object_taxonomies( $post->post_type, 'names' );
if ( empty( $taxonomies ) ) {
continue;
}
$terms = wp_get_object_terms(
$post->ID,
$taxonomies,
[
'fields' => 'ids',
]
);
if ( ! empty( array_intersect( $terms, $exclude_terms ) ) ) {
unset( $posts[ $key ] );
}
}
return $posts;
}
}

View File

@@ -0,0 +1,323 @@
<?php
/**
* The News Sitemap Module
*
* @since 1.0.0
* @package RankMath
* @subpackage RankMathPro
* @author MyThemeShop <admin@mythemeshop.com>
*/
namespace RankMathPro\Sitemap;
use RankMath\KB;
use RankMath\Helper;
use RankMath\Helpers\Locale;
use RankMath\Sitemap\Cache_Watcher;
use RankMath\Traits\Hooker;
use RankMath\Sitemap\Router;
use MyThemeShop\Helpers\Param;
defined( 'ABSPATH' ) || exit;
/**
* News_Sitemap class.
*/
class News_Sitemap {
use Hooker;
/**
* NEWS Publication.
*
* @var string
*/
protected $news_publication = null;
/**
* The Constructor.
*/
public function __construct() {
if ( is_admin() ) {
$this->filter( 'rank_math/settings/sitemap', 'add_settings', 11 );
}
new News_Metabox();
$this->action( 'rank_math/head', 'robots', 10 );
$this->filter( 'rank_math/sitemap/providers', 'add_provider' );
$this->filter( 'rank_math/sitemap/news_urlset', 'xml_urlset' );
$this->filter( 'rank_math/sitemap/xsl_news', 'sitemap_xsl' );
$this->filter( 'rank_math/sitemap/news_stylesheet_url', 'stylesheet_url' );
$this->filter( 'rank_math/sitemap/news_sitemap_url', 'sitemap_url', 10, 2 );
$this->filter( 'rank_math/schema/default_type', 'change_default_schema_type', 10, 3 );
$this->filter( 'rank_math/snippet/rich_snippet_article_entity', 'add_copyrights_data' );
$this->action( 'admin_post_rank-math-options-sitemap', 'save_exclude_terms_data', 9 );
$this->action( 'transition_post_status', 'status_transition', 10, 3 );
}
/**
* Function to pass empty array to exclude terms data when term is not selected for a Post type.
* This code is needed to save empty group value since CMB2 doesn't allow it.
*
* @since 2.8.1
* @return void
*/
public function save_exclude_terms_data() {
$post_types = Helper::get_settings( 'sitemap.news_sitemap_post_type', [] );
if ( empty( $post_types ) ) {
return;
}
foreach ( $post_types as $post_type ) {
if ( ! isset( $_POST["news_sitemap_exclude_{$post_type}_terms"] ) ) { //phpcs:ignore
$_POST["news_sitemap_exclude_{$post_type}_terms"] = []; //phpcs:ignore
}
}
}
/**
* Output the meta robots tag.
*/
public function robots() {
if ( ! is_singular() ) {
return;
}
$post = get_post();
/**
* Filter: 'rank_math/sitemap/news/noindex' - Allow preventing of outputting noindex tag.
*
* @api string $meta_robots The noindex tag.
*
* @param object $post The post.
*/
if ( ! $this->do_filter( 'sitemap/news/noindex', true, $post ) || self::is_post_indexable( $post->ID ) ) {
return;
}
echo '<meta name="Googlebot-News" content="noindex" />' . "\n";
}
/**
* Check if post is indexable.
*
* @param int $post_id Post ID to check.
*
* @return boolean
*/
public static function is_post_indexable( $post_id ) {
$robots = get_post_meta( $post_id, 'rank_math_news_sitemap_robots', true );
if ( ! empty( $robots ) && 'noindex' === $robots ) {
return false;
}
return true;
}
/**
* Add module settings into general optional panel.
*
* @param array $tabs Array of option panel tabs.
*
* @return array
*/
public function add_settings( $tabs ) {
$sitemap_url = Router::get_base_url( 'news-sitemap.xml' );
$tabs['news-sitemap'] = [
'icon' => 'fa fa-newspaper-o',
'title' => esc_html__( 'News Sitemap', 'rank-math-pro' ),
'icon' => 'rm-icon rm-icon-post',
'desc' => wp_kses_post( sprintf( __( 'News Sitemaps allow you to control which content you submit to Google News. More information: <a href="%s" target="_blank">News Sitemaps overview</a>', 'rank-math-pro' ), KB::get( 'news-sitemap', 'Options Panel Sitemap News Tab' ) ) ),
'file' => dirname( __FILE__ ) . '/settings-news.php',
/* translators: News Sitemap Url */
'after_row' => '<div class="notice notice-alt notice-info info inline rank-math-notice"><p>' . sprintf( esc_html__( 'Your News Sitemap index can be found here: : %s', 'rank-math-pro' ), '<a href="' . $sitemap_url . '" target="_blank">' . $sitemap_url . '</a>' ) . '</p></div>',
];
return $tabs;
}
/**
* Add news sitemap provider.
*
* @param array $providers Sitemap provider registry.
*/
public function add_provider( $providers ) {
$providers[] = new \RankMathPro\Sitemap\News_Provider();
return $providers;
}
/**
* Produce XML output for google news urlset.
*
* @return string
*/
public function xml_urlset() {
return '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
. 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd '
. 'http://www.google.com/schemas/sitemap-news/0.9 http://www.google.com/schemas/sitemap-news/0.9/sitemap-news.xsd" '
. 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
. 'xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">' . "\n";
}
/**
* Stylesheet Url for google news.
*
* @param string $url Current stylesheet url.
* @return string
*/
public function stylesheet_url( $url ) { // phpcs:ignore
$stylesheet_url = preg_replace( '/(^http[s]?:)/', '', Router::get_base_url( 'news-sitemap.xsl' ) );
return '<?xml-stylesheet type="text/xsl" href="' . $stylesheet_url . '"?>';
}
/**
* Stylesheet for google news.
*
* @param string $title Title for stylesheet.
*/
public function sitemap_xsl( $title ) { // phpcs:ignore
require_once 'sitemap-xsl.php';
}
/**
* Build the `<url>` tag for a given URL.
*
* @param array $url Array of parts that make up this entry.
* @param Renderer $renderer Sitemap renderer class object.
* @return string
*/
public function sitemap_url( $url, $renderer ) {
$date = null;
if ( ! empty( $url['publication_date'] ) ) {
// Create a DateTime object date in the correct timezone.
$date = $renderer->timezone->format_date( $url['publication_date'] );
}
$output = $renderer->newline( '<url>', 1 );
$output .= $renderer->newline( '<loc>' . $renderer->encode_url_rfc3986( htmlspecialchars( $url['loc'] ) ) . '</loc>', 2 );
$output .= $renderer->newline( '<news:news>', 2 );
$output .= $this->get_news_publication( $renderer );
$output .= empty( $date ) ? '' : $renderer->newline( '<news:publication_date>' . htmlspecialchars( $date ) . '</news:publication_date>', 3 );
$output .= $renderer->add_cdata( $url['title'], 'news:title', 3 );
$output .= $renderer->newline( '</news:news>', 2 );
$output .= $renderer->newline( '</url>', 1 );
/**
* Filters the output for the sitemap url tag.
*
* @param string $output The output for the sitemap url tag.
* @param array $url The sitemap url array on which the output is based.
*/
return $this->do_filter( 'sitemap_url', $output, $url );
}
/**
* Get News Pub Tags.
*
* @param Renderer $renderer Sitemap renderer class object.
* @return string
*/
private function get_news_publication( $renderer ) {
if ( is_null( $this->news_publication ) ) {
$lang = Locale::get_site_language();
$name = Helper::get_settings( 'sitemap.news_sitemap_publication_name' );
$name = $name ? $name : get_bloginfo( 'name' );
$this->news_publication = '';
$this->news_publication .= $renderer->newline( '<news:publication>', 3 );
$this->news_publication .= $renderer->newline( '<news:name>' . esc_html( $name ) . '</news:name>', 4 );
$this->news_publication .= $renderer->newline( '<news:language>' . $lang . '</news:language>', 4 );
$this->news_publication .= $renderer->newline( '</news:publication>', 3 );
}
return $this->news_publication;
}
/**
* Change default schema type on News Posts.
*
* @param string $schema Default schema type.
* @param string $post_type Current Post Type.
* @param int $post_id Current Post ID.
*
* @return string
*/
public function change_default_schema_type( $schema, $post_type, $post_id ) {
$news_post_types = (array) Helper::get_settings( 'sitemap.news_sitemap_post_type' );
if ( ! in_array( $post_type, $news_post_types, true ) ) {
return $schema;
}
$exclude_terms = (array) Helper::get_settings( "sitemap.news_sitemap_exclude_{$post_type}_terms" );
if ( empty( $exclude_terms[0] ) ) {
return 'NewsArticle';
}
$has_excluded_term = false;
foreach ( $exclude_terms[0] as $taxonomy => $terms ) {
if ( has_term( $terms, $taxonomy, $post_id ) ) {
$has_excluded_term = true;
break;
}
}
return $has_excluded_term ? $schema : 'NewsArticle';
}
/**
* Filter to add Copyrights data in Article Schema on News Posts.
*
* @param array $entity Snippet Data.
* @return array
*/
public function add_copyrights_data( $entity ) {
global $post;
if ( is_null( $post ) ) {
return $entity;
}
$news_post_types = (array) Helper::get_settings( 'sitemap.news_sitemap_post_type' );
if ( ! in_array( $post->post_type, $news_post_types, true ) ) {
return $entity;
}
$entity['copyrightYear'] = get_the_modified_date( 'Y', $post );
if ( ! empty( $entity['publisher'] ) ) {
$entity['copyrightHolder'] = $entity['publisher'];
}
return $entity;
}
/**
* Invalidate News Sitemap cache when a scheduled post is published.
*
* @param string $new_status New Status.
* @param string $old_status Old Status.
* @param object $post Post Object.
*/
public function status_transition( $new_status, $old_status, $post ) {
if ( $old_status === $new_status || 'publish' !== $new_status ) {
return;
}
$news_post_types = (array) Helper::get_settings( 'sitemap.news_sitemap_post_type', [] );
if ( ! in_array( $post->post_type, $news_post_types, true ) ) {
return;
}
if ( false === Helper::is_post_indexable( $post->ID ) ) {
return;
}
Cache_Watcher::invalidate( 'news' );
}
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* Sitemap - News
*
* @since 1.0.0
* @package RankMath
* @subpackage RankMathPro
* @author MyThemeShop <admin@mythemeshop.com>
*/
use RankMath\Helper;
defined( 'ABSPATH' ) || exit;
$cmb->add_field(
[
'id' => 'news_sitemap_publication_name',
'type' => 'text',
'name' => esc_html__( 'Google News Publication Name', 'rank-math-pro' ),
'desc' => wp_kses_post( __( 'The name of the news publication. It must match the name exactly as it appears on your articles in news.google.com, omitting any trailing parentheticals. <a href="https://support.google.com/news/publisher-center/answer/9606710" target="_blank">More information at support.google.com</a>', 'rank-math-pro' ) ),
]
);
$post_types = Helper::choices_post_types();
if ( isset( $post_types['attachment'] ) && Helper::get_settings( 'general.attachment_redirect_urls', true ) ) {
unset( $post_types['attachment'] );
}
$cmb->add_field(
[
'id' => 'news_sitemap_post_type',
'type' => 'multicheck_inline',
'name' => esc_html__( 'News Post Type', 'rank-math-pro' ),
'desc' => esc_html__( 'Select the post type you use for News articles.', 'rank-math-pro' ),
'options' => $post_types,
]
);
$post_types = Helper::get_settings( 'sitemap.news_sitemap_post_type', [] );
if ( empty( $post_types ) ) {
return;
}
foreach ( $post_types as $post_type ) {
$taxonomies = Helper::get_object_taxonomies( $post_type, 'objects' );
if ( empty( $taxonomies ) ) {
continue;
}
$post_type_obj = get_post_type_object( $post_type );
$post_type_label = $post_type_obj->labels->singular_name;
$group_field_id = '';
foreach ( $taxonomies as $taxonomy => $data ) {
if ( empty( $data->show_ui ) ) {
continue;
}
$terms = get_terms(
[
'taxonomy' => $taxonomy,
'show_ui' => true,
'fields' => 'id=>name',
'update_term_meta_cache' => false,
]
);
if ( 0 === count( $terms ) ) {
continue;
}
if ( ! $group_field_id ) {
$group_field_id = $cmb->add_field(
[
'id' => "news_sitemap_exclude_{$post_type}_terms",
'type' => 'group',
/* translators: Post Type */
'name' => sprintf( __( 'Exclude %s Terms ', 'rank-math-pro' ), $post_type_label ),
'classes' => 'news-sitemap-exclude-terms cmb-group-text-only',
'repeatable' => false,
]
);
}
$cmb->add_group_field(
$group_field_id,
[
'name' => '',
'id' => $taxonomy,
'type' => 'multicheck_inline',
'options' => $terms,
'classes' => 'cmb-field-list',
/* translators: 1. Taxonomy Name 2. Post Type */
'desc' => sprintf( esc_html__( '%1$s to exclude for %2$s.', 'rank-math-pro' ), $data->label, $post_type_label ),
]
);
}
}

View File

@@ -0,0 +1,184 @@
<?php
/**
* Sitemap stylesheet.
*
* @package RankMath
* @subpackage RankMath\Sitemap
*/
use RankMath\KB;
use RankMath\Sitemap\Router;
use RankMath\Sitemap\Sitemap;
defined( 'ABSPATH' ) || exit;
// Echo so opening tag doesn't get confused for PHP.
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo esc_html( $title ); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
font-size: 14px;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
margin: 0;
color: #545353;
}
a {
color: #05809e;
text-decoration: none;
}
h1 {
font-size: 24px;
font-family: Verdana,Geneva,sans-serif;
font-weight: normal;
margin: 0;
}
#description {
background-color: #4275f4;
padding: 20px 40px;
color: #fff;
padding: 30px 30px 20px;
}
#description h1,
#description p,
#description a {
color: #fff;
margin: 0;
font-size: 1.1em;
}
#description h1 {
font-size: 2em;
margin-bottom: 1em;
}
#description p {
margin-top: 5px;
}
#content {
padding: 20px 30px;
background: #fff;
max-width: 75%;
margin: 0 auto;
}
table {
border: none;
border-collapse: collapse;
font-size: .9em;
width: 100%;
}
th {
background-color: #4275f4;
color: #fff;
text-align: left;
padding: 15px;
font-size: 14px;
cursor: pointer;
}
td {
padding: 10px;
border-bottom: 1px solid #ddd;
}
tbody tr:nth-child(even) {
background-color: #f7f7f7;
}
table td a {
display: block;
}
table td a img {
max-height: 30px;
margin: 6px 3px;
}
</style>
</head>
<body>
<div id="description">
<h1><?php esc_html_e( 'XML Sitemap', 'rank-math-pro' ); ?></h1>
<?php if ( false === $this->do_filter( 'sitemap/remove_credit', false ) ) : ?>
<p>
<?php
printf(
wp_kses_post(
/* translators: link to rankmath.com */
__( 'This XML Sitemap is generated by <a href="%s" target="_blank">Rank Math WordPress SEO Plugin</a>. It is what search engines like Google use to crawl and re-crawl posts/pages/products/images/archives on your website.', 'rank-math-pro' )
),
KB::get( 'seo-suite' )
);
?>
</p>
<?php endif; ?>
<p>
<?php
printf(
wp_kses_post(
/* translators: link to rankmath.com */
__( 'Learn more about <a href="%s" target="_blank">XML Sitemaps</a>.', 'rank-math-pro' )
),
'http://sitemaps.org'
);
?>
</p>
</div>
<div id="content">
<p>
<?php
printf(
/* translators: xsl value count */
__( 'This XML Sitemap contains <strong>%s</strong> URLs.', 'rank-math-pro' ),
'<xsl:value-of select="count(sitemap:urlset/sitemap:url)"/>'
);
?>
</p>
<p class="expl">
<?php
printf(
/* translators: xsl value count */
__( '<a href="%s">&#8592; Sitemap Index</a>', 'rank-math-pro' ),
esc_url( Router::get_base_url( Sitemap::get_sitemap_index_slug() . '.xml' ) )
);
?>
</p>
<table id="sitemap" cellpadding="3">
<thead>
<tr>
<th width="40%">Title</th>
<th width="15%"><?php esc_html_e( 'Publication Date', 'rank-math-pro' ); ?></th>
</tr>
</thead>
<tbody>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<tr>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="news:news/news:title"/>
</a>
</td>
<td>
<xsl:value-of select="concat(substring(news:news/news:publication_date,0,11),concat(' ', substring(news:news/news:publication_date,12,8)),concat(' ', substring(news:news/news:publication_date,20,6)))"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>