Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions autodescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: The SEO Framework
* Plugin URI: https://theseoframework.com/
* Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for your WordPress website.
* Version: 5.1.3-dev-6
* Version: 5.1.3-dev-7
* Author: Sybre Waaijer
* Author URI: https://theseoframework.com/
* License: GPLv3
Expand Down Expand Up @@ -45,7 +45,7 @@
*
* @since 2.3.5
*/
define( 'THE_SEO_FRAMEWORK_VERSION', '5.1.2' );
define( 'THE_SEO_FRAMEWORK_VERSION', '5.1.3' );

/**
* The plugin Database version.
Expand All @@ -54,7 +54,7 @@
*
* @since 2.7.0
*/
define( 'THE_SEO_FRAMEWORK_DB_VERSION', '5100' );
define( 'THE_SEO_FRAMEWORK_DB_VERSION', '5130' );

/**
* The plugin file, absolute unix path.
Expand Down
14 changes: 13 additions & 1 deletion bootstrap/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function _upgrade( $previous_version ) {
'2701', '2802', '2900',
'3001', '3103', '3300',
'4051', '4103', '4110', '4200', '4270',
'5001', '5050', '5100',
'5001', '5050', '5100', '5130',
];
// phpcs:enable, WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine

Expand Down Expand Up @@ -967,3 +967,15 @@ function _do_upgrade_5100() {
Data\Plugin::update_option( 'homepage_redirect', '' );
}
}

/**
* Registers new option 'author_tags'.
*
* @since 5.1.3
*/
function _do_upgrade_5130() {

if ( \get_option( 'the_seo_framework_initial_db_version' ) < '5130' ) {
Data\Plugin::update_option( 'author_tags', 1 );
}
}
2 changes: 2 additions & 0 deletions inc/classes/data/filter/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public static function register_sanitizers_jit() {
'alter_archive_query_type' => 'alter_query_type',
'alter_search_query_type' => 'alter_query_type',
'alter_search_query' => 'checkbox',
'author_tags' => 'checkbox',
'author_noarchive' => 'checkbox',
'author_nofollow' => 'checkbox',
'author_noindex' => 'checkbox',
Expand Down Expand Up @@ -224,6 +225,7 @@ public static function register_sanitizers_jit() {
'og_tags' => 'checkbox',
'paged_noindex' => 'checkbox',
'pint_verification' => 'verification_code',
'post_author' => 'metadata_text',
'post_modify_time' => 'checkbox',
'post_publish_time' => 'checkbox',
'prev_next_archives' => 'checkbox',
Expand Down
4 changes: 4 additions & 0 deletions inc/classes/data/plugin/setup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ public static function get_default_options() {
'post_publish_time' => 1, // Article Published Time.
'post_modify_time' => 1, // Article Modified Time.

// Author.
'post_author' => '', // Author fallback name.

// Twitter.
'twitter_card' => 'summary_large_image', // Twitter Card layout. If no twitter:image image is found, it'll change to 'summary', radio
'twitter_site' => '', // Twitter business @username.
Expand All @@ -281,6 +284,7 @@ public static function get_default_options() {
'og_tags' => 1, // Output of Open Graph meta tags.
'facebook_tags' => 1, // Output the Facebook meta tags.
'twitter_tags' => 1, // Output the Twitter meta tags.
'author_tags' => 1, // Output author meta tags.
'oembed_scripts' => 1, // Enable WordPress's oEmbed scripts.

// Social title settings.
Expand Down
71 changes: 71 additions & 0 deletions inc/classes/front/meta/generator/author.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* @package The_SEO_Framework\Classes\Front\Front\Meta\Generator
* @subpackage The_SEO_Framework\Meta\Author
*/

namespace The_SEO_Framework\Front\Meta\Generator;

\defined( 'THE_SEO_FRAMEWORK_PRESENT' ) or die;

use The_SEO_Framework\{
Meta,
Data,
Helper\Query,
};

/**
* The SEO Framework plugin
* Copyright (C) 2025 Sybre Waaijer, CyberWire B.V. (https://cyberwire.nl/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Holds Author generators for meta tag output.
*
* @since 5.1.3
* @access private
*/
final class Author {

/**
* @since 5.1.3
* @var callable[] GENERATORS A list of autoloaded meta callbacks.
*/
public const GENERATORS = [
[ __CLASS__, 'generate_author' ],
];

/**
* Generates the author meta tag.
*
* @since 5.0.0
* @generator
*/
public static function generate_author() {

// Only output on singular posts/pages where an author is available
if ( ! Query::is_singular() ) return;

$author_name = Meta\Author::get_author_name();

if ( \strlen( $author_name ) )
yield 'author' => [
'attributes' => [
'name' => 'author',
'content' => $author_name,
],
];
}
}
5 changes: 5 additions & 0 deletions inc/classes/front/meta/head.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public static function print_tags() {
'Robots',
'URI',
'Description',
'Author',
'Theme_Color',
'Open_Graph',
'Facebook',
Expand Down Expand Up @@ -170,6 +171,10 @@ public static function print_tags() {
$remove_pools[] = 'Twitter';
}

// Remove Author generator if author meta is disabled
if ( ! Data\Plugin::get_option( 'author_tags' ) )
$remove_pools[] = 'Author';

/**
* @since 5.0.0
* @param string[] $generator_pools A list of tag pools requested for the current query.
Expand Down
52 changes: 52 additions & 0 deletions inc/classes/meta/author.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* @package The_SEO_Framework\Classes\Meta
* @subpackage The_SEO_Framework\Meta\Author
*/

namespace The_SEO_Framework\Meta;

\defined( 'THE_SEO_FRAMEWORK_PRESENT' ) or die;

use The_SEO_Framework\Data;

/**
* The SEO Framework plugin
* Copyright (C) 2025 Sybre Waaijer, CyberWire B.V. (https://cyberwire.nl/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Holds getters for meta tag output.
*
* @since 5.1.3
* @access protected
* Use tsf()->author() instead.
*/
class Author {

/**
* @since 5.1.3
*
* @return string The author name.
*/
public static function get_author_name() {

// Only output on single posts where an author is available
if ( ! Query::is_single() ) return;

return Title::get_user_title( Query::get_post_author_id() )
?: Data\Plugin::get_option( 'post_author' );
}
}
5 changes: 5 additions & 0 deletions inc/classes/meta/facebook.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static function get_author() {

if ( 'article' !== Open_Graph::get_type() ) return;

// Check if author tags are enabled
if ( ! Data\Plugin::get_option( 'author_tags' ) ) {
return Data\Plugin::get_option( 'facebook_author' );
}

return Data\Plugin\User::get_current_post_author_meta_item( 'facebook_page' )
?: Data\Plugin::get_option( 'facebook_author' );
}
Expand Down
2 changes: 1 addition & 1 deletion inc/classes/meta/schema/entities/author.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function build( $args = null ) {
$entity = [
'@type' => static::$type,
'@id' => static::get_id( [ 'uid' => $author_id ] ),
'name' => $user_data->display_name ?? '', // Yes, this could lead to an empty Author entity in a corner case.
'name' => Meta\Title::get_user_title( $author_id ), // Yes, this could lead to an empty Author entity in a corner case.
// Let's not; may invoke bad bots. Let's do this via sameas.
// 'url' => Meta\URI::get_bare_author_url( $author_id ),
];
Expand Down
2 changes: 1 addition & 1 deletion inc/classes/meta/title.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ public static function get_term_title( $term = null ) {
*/
public static function get_user_title( $user_id = 0 ) {
return Sanitize::metadata_content(
\get_userdata( $user_id ?: Query::get_the_real_id() )->display_name ?? ''
Data\User::get_userdata( $user_id ?: Query::get_the_real_id(), 'display_name' ) ?? ''
);
}

Expand Down
6 changes: 6 additions & 0 deletions inc/classes/meta/twitter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ public static function get_site() {
* @return string
*/
public static function get_creator() {

// Check if author tags are enabled
if ( ! Data\Plugin::get_option( 'author_tags' ) ) {
return Data\Plugin::get_option( 'twitter_creator' );
}

return Data\Plugin\User::get_current_post_author_meta_item( 'twitter_page' )
?: Data\Plugin::get_option( 'twitter_creator' );
}
Expand Down
19 changes: 19 additions & 0 deletions inc/classes/pool.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,25 @@ public static function utils() {
};
}

/**
* Returns the Author API class as instantiated object with deprecation capabilities.
* This allows for easy API access, and it allows us to silence fatal errors.
*
* @since 5.1.3
* @api Not used internally.
*
* @return \The_SEO_Framework\Meta\Author
*/
public static function author() {
return static::$pool['author'] ??= new class extends Meta\Author {
use Static_Deprecator;

private $colloquial_handle = 'tsf()->author()';
private $deprecated_methods = [];
private $deprecated_properties = [];
};
}

/**
* Returns the Breadcrumbs API class as instantiated object with deprecation capabilities.
* This allows for easy API access, and it allows us to silence fatal errors.
Expand Down
4 changes: 4 additions & 0 deletions inc/views/profile/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
],
];

// Only show authorial info if author_tags is enabled
if ( Data\Plugin::get_option( 'author_tags' ) ) :
?>
<h2><?php \esc_html_e( 'Authorial Info', 'autodescription' ); ?></h2>
<table class=form-table>
Expand All @@ -75,3 +77,5 @@ class="regular-text <?= \esc_attr( $labels['class'] ) ?>" />
?>
</table>
<?php
endif;
?>
Loading