-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yoast
committed
Apr 24, 2024
1 parent
f1c55ad
commit 5f870bb
Showing
173 changed files
with
7,994 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
[![Coverage Status](https://coveralls.io/repos/github/Yoast/wpseo-news/badge.svg?branch=trunk)](https://coveralls.io/github/Yoast/wpseo-news?branch=trunk) | ||
|
||
Yoast News SEO for Yoast SEO | ||
========================== | ||
Requires at least: 6.3 | ||
Tested up to: 6.4 | ||
Stable tag: 13.2 | ||
Requires PHP: 7.2.5 | ||
Depends: Yoast SEO | ||
|
||
Yoast News SEO module for the Yoast SEO plugin. | ||
|
||
This repository uses [the Yoast grunt tasks plugin](https://github.com/Yoast/plugin-grunt-tasks). | ||
|
||
Installation | ||
============ | ||
|
||
1. Go to Plugins -> Add New. | ||
2. Click "Upload" right underneath "Install Plugins". | ||
3. Upload the zip file that this readme was contained in. | ||
4. Activate the plugin. | ||
5. Go to SEO -> Extensions -> Licenses, enter your license key and Save. | ||
6. Your license key will be validated. | ||
7. You can now use Yoast News SEO. See also https://kb.yoast.com/kb/configuration-guide-for-news-seo/ | ||
|
||
Frequently Asked Questions | ||
-------------------------- | ||
|
||
You can find the [Yoast News SEO FAQ](https://kb.yoast.com/kb/category/news-seo/) in our knowledge base. | ||
|
||
Changelog | ||
========= | ||
|
||
## 13.2 | ||
|
||
Release date: 2024-03-05 | ||
|
||
#### Enhancements | ||
|
||
* Adds a `wpseo_news_sitemap_content` filter to append custom content to the XML sitemap. Props to @wccoder. | ||
* This PR introduces a new way of retrieving translations for Yoast News SEO, by utilizing the TranslationPress service. Instead of having to ship all translations with every release, we can now load the translations on a per-install basis, tailored to the user's setup. This means smaller plugin releases and less bloat on the user's server. | ||
|
||
#### Bugfixes | ||
|
||
* Fixes a bug where a warning would be thrown on activation. | ||
* Fixes a bug where using the `&` character in the publication name would break the XML sitemap. | ||
|
||
#### Other | ||
|
||
* Drops compatibility with PHP 5.6, 7.0 and 7.1. | ||
* Improves discoverability of security policy. | ||
* Sets the minimum required Yoast SEO version to 22.2. | ||
* Sets the minimum supported WordPress version to 6.3. | ||
* Sets the WordPress tested up to version to 6.4. | ||
* The plugin has no known incompatibilities with PHP 8.3. | ||
* Users requiring this package via [WP]Packagist can now use the `composer/installers` v2. | ||
|
||
## 13.1 | ||
|
||
Release date: 2021-11-16 | ||
|
||
#### Enhancements | ||
|
||
* Huge performance improvement: moves the XML News sitemap to be based on our Indexables architecture. | ||
* Removes images from the XML News sitemap as they serve no purpose here and this further improves performance. | ||
|
||
#### Other | ||
|
||
* Excludes attachments and non-indexed post types from the possible post types to include in the News Sitemap. | ||
|
||
### Earlier versions | ||
For the changelog of earlier versions, please refer to [the changelog on yoast.com](https://yoa.st/news-seo-changelog). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
// Nothing to see here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="2.0" | ||
xmlns:html="http://www.w3.org/TR/REC-html40" | ||
xmlns:s="http://www.sitemaps.org/schemas/sitemap/0.9" | ||
xmlns:n="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>XML News Sitemap</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<style type="text/css"> | ||
body { | ||
font-family: Helvetica, Arial, sans-serif; | ||
font-size: 13px; | ||
color: #545353; | ||
} | ||
table { | ||
width: 100%; | ||
border: none; | ||
border-collapse: collapse; | ||
} | ||
#sitemap tbody tr:nth-child( odd ) { | ||
background-color: #eee; | ||
} | ||
#sitemap tbody tr:hover { | ||
background-color: #ccc; | ||
} | ||
#sitemap tbody tr:hover td, #sitemap tbody tr:hover td a { | ||
color: #000; | ||
} | ||
#content { | ||
margin: 0 auto; | ||
width: 1000px; | ||
} | ||
p.expl { | ||
margin: 10px 3px; | ||
line-height: 1.3em; | ||
} | ||
.expl a, .expl a:visited { | ||
color: #da3114; | ||
font-weight: bold; | ||
} | ||
a { | ||
color: #000; | ||
text-decoration: none; | ||
} | ||
a:visited { | ||
color: #777; | ||
} | ||
a:hover { | ||
text-decoration: underline; | ||
} | ||
td { | ||
font-size:11px; | ||
} | ||
th { | ||
text-align:left; | ||
padding-right:30px; | ||
font-size:11px; | ||
} | ||
thead th { | ||
border-bottom: 1px solid #000; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="content"> | ||
<h1>XML News Sitemap</h1> | ||
<p class="expl"> | ||
Generated by <a href="https://yoa.st/1y5">Yoast</a>'s <a href="https://yoa.st/1y6">SEO plugin</a> and its <a href="https://yoa.st/4hj">Google News SEO module</a>, this is an XML News Sitemap, meant for consumption by Google News. | ||
</p> | ||
<p class="expl"> | ||
<a href="https://developers.google.com/search/docs/advanced/sitemaps/news-sitemap">Read more information about XML News sitemaps</a>. | ||
</p> | ||
<p class="expl"> | ||
This sitemap contains <xsl:value-of select="count(s:urlset/s:url)"/> URLs. | ||
</p> | ||
<table id="sitemap" cellpadding="3"> | ||
<thead> | ||
<tr> | ||
<th width="75%">Title</th> | ||
<th width="25%">Publication date</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<xsl:for-each select="s:urlset/s:url"> | ||
<tr> | ||
<td> | ||
<xsl:variable name="itemURL"> | ||
<xsl:value-of select="s:loc"/> | ||
</xsl:variable> | ||
<a href="{$itemURL}"> | ||
<xsl:value-of select="n:news/n:title"/> | ||
</a> | ||
</td> | ||
<td> | ||
<xsl:value-of select="n:news/n:publication_date"/> | ||
</td> | ||
</tr> | ||
</xsl:for-each> | ||
</tbody> | ||
</table> | ||
</div> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<?php | ||
/** | ||
* Yoast SEO: News plugin file. | ||
* | ||
* @package WPSEO_News\Admin | ||
*/ | ||
|
||
/** | ||
* Represents the admin page. | ||
*/ | ||
class WPSEO_News_Admin_Page { | ||
|
||
/** | ||
* Display admin page. | ||
* | ||
* @return void | ||
*/ | ||
public function display() { | ||
// Admin header. | ||
Yoast_Form::get_instance()->admin_header( true, 'wpseo_news' ); | ||
|
||
// Introduction. | ||
echo '<div id="wpseo-news-genre-removal-alert" style="max-width: 600px;"></div>'; | ||
echo '<p>', esc_html__( 'You will generally only need a News Sitemap when your website is included in Google News.', 'wordpress-seo-news' ), '</p>'; | ||
echo '<p>'; | ||
printf( | ||
/* translators: %1$s opening tag of the link to the News Sitemap, %2$s closing tag for the link. */ | ||
esc_html__( '%1$sView your News Sitemap%2$s.', 'wordpress-seo-news' ), | ||
'<a target="_blank" href="' . esc_url( WPSEO_News_Sitemap::get_sitemap_name() ) . '">', | ||
'</a>' | ||
); | ||
echo '</p>'; | ||
|
||
echo '<h2>', esc_html__( 'General settings', 'wordpress-seo-news' ), '</h2>'; | ||
|
||
/* translators: Hidden accessibility text. */ | ||
echo '<fieldset><legend class="screen-reader-text">', esc_html__( 'News Sitemap settings', 'wordpress-seo-news' ), '</legend>'; | ||
|
||
// Google News Publication Name. | ||
Yoast_Form::get_instance()->textinput( 'news_sitemap_name', __( 'Google News Publication Name', 'wordpress-seo-news' ) ); | ||
|
||
echo '</fieldset>'; | ||
|
||
// Post Types to include in News Sitemap. | ||
$this->include_post_types(); | ||
|
||
// Post categories to exclude. | ||
$this->excluded_post_type_taxonomies(); | ||
|
||
// Admin footer. | ||
Yoast_Form::get_instance()->admin_footer( true, false ); | ||
} | ||
|
||
/** | ||
* Generates the HTML for the post types which should be included in the sitemap. | ||
* | ||
* @return void | ||
*/ | ||
private function include_post_types() { | ||
$post_type_helper = YoastSEO()->helpers->post_type; | ||
|
||
// Post Types to include in News Sitemap. | ||
echo '<h2>' . esc_html__( 'Post Types to include in News Sitemap', 'wordpress-seo-news' ) . '</h2>'; | ||
/* translators: Hidden accessibility text. */ | ||
echo '<fieldset><legend class="screen-reader-text">', esc_html__( 'Post Types to include:', 'wordpress-seo-news' ), '</legend>'; | ||
|
||
$post_types = get_post_types( [ 'public' => true ], 'objects' ); | ||
$post_types_list = []; | ||
foreach ( $post_types as $post_type ) { | ||
if ( ! $post_type_helper->is_excluded( $post_type->name ) && $post_type->name !== 'attachment' ) { | ||
$post_types_list[ $post_type->name ] = $post_type->labels->name . ' (' . $post_type->name . ')'; | ||
} | ||
} | ||
|
||
Yoast_Form::get_instance()->checkbox_list( 'news_sitemap_include_post_types', $post_types_list ); | ||
|
||
echo '</fieldset><br>'; | ||
} | ||
|
||
/** | ||
* Generates the HTML for excluding post categories. | ||
* | ||
* @return void | ||
*/ | ||
private function excluded_post_type_taxonomies() { | ||
$post_types = get_post_types( [ 'public' => true ], 'objects' ); | ||
$post_types = array_filter( $post_types, [ $this, 'filter_included_post_type' ] ); | ||
|
||
array_walk( $post_types, [ $this, 'excluded_post_type_taxonomies_output' ] ); | ||
} | ||
|
||
/** | ||
* Filter function used to determine what post times should be included in the new sitemap. | ||
* | ||
* @param WP_Post_Type $post_type The post type. | ||
* | ||
* @return bool Whether or not the post type should be included in the sitemap. | ||
*/ | ||
protected function filter_included_post_type( $post_type ) { | ||
static $included_post_types; | ||
if ( ! $included_post_types ) { | ||
$included_post_types = (array) WPSEO_Options::get( 'news_sitemap_include_post_types', [] ); | ||
} | ||
|
||
return array_key_exists( $post_type->name, $included_post_types ); | ||
} | ||
|
||
/** | ||
* Creates an array of objects containing taxonomies and the list of terms that are eligible for exclusion in the | ||
* sitemap. | ||
* | ||
* @param WP_Post_Type $post_type Post type for which to exclude taxonomies. | ||
* | ||
* @return array Returns an array containing terms and taxonomies. Can be empty. | ||
*/ | ||
private function get_excluded_post_type_taxonomies( $post_type ) { | ||
$excludable_taxonomies = new WPSEO_News_Excludable_Taxonomies( $post_type->name ); | ||
|
||
return $excludable_taxonomies->get_terms(); | ||
} | ||
|
||
/** | ||
* Echoes the sub heading + checkboxes to exclude terms within each of the post type's taxonomies. | ||
* | ||
* @param WP_Post_Type $post_type The post type. | ||
* | ||
* @return void | ||
*/ | ||
private function excluded_post_type_taxonomies_output( $post_type ) { | ||
$terms_per_taxonomy = $this->get_excluded_post_type_taxonomies( $post_type ); | ||
|
||
if ( $terms_per_taxonomy === [] ) { | ||
return; | ||
} | ||
|
||
/* translators: %1%s expands to the post type name. */ | ||
echo '<h2>' . esc_html( sprintf( __( 'Terms to exclude for %1$s', 'wordpress-seo-news' ), $post_type->labels->name ) ) . '</h2>'; | ||
|
||
foreach ( $terms_per_taxonomy as $data ) { | ||
$taxonomy = $data['taxonomy']; | ||
$terms = $data['terms']; | ||
|
||
/* translators: %1%s expands to the taxonomy name name. */ | ||
echo '<h3>' . esc_html( sprintf( __( '%1$s to exclude', 'wordpress-seo-news' ), $taxonomy->labels->name ) ) . '</h3>'; | ||
|
||
$taxonomies_list = []; | ||
foreach ( $terms as $term ) { | ||
$taxonomies_list[ $term->term_id . '_for_' . $post_type->name ] = $term->name; | ||
} | ||
|
||
Yoast_Form::get_instance()->checkbox_list( 'news_sitemap_exclude_terms', $taxonomies_list ); | ||
} | ||
} | ||
|
||
/** | ||
* Checks if the current page is a news seo plugin page. | ||
* | ||
* @param string $page The page to check. | ||
* | ||
* @return bool True when currently on a new page. | ||
*/ | ||
protected function is_news_page( $page ) { | ||
$news_pages = [ 'wpseo_news' ]; | ||
|
||
return in_array( $page, $news_pages, true ); | ||
} | ||
} |
Oops, something went wrong.