Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Bluesky to the profile fields #2413

Merged
merged 1 commit into from
Nov 21, 2024
Merged
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
7 changes: 7 additions & 0 deletions newspack-theme/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1362,3 +1362,10 @@ function newspack_dequeue_mediaelement() {
* Woo Templates cache handling
*/
require get_template_directory() . '/woocommerce/templates.php';

/**
* Yoast customizations
*/
if ( class_exists( 'WPSEO_Options' ) ) {
require get_template_directory() . '/inc/yoast.php';
}
1 change: 1 addition & 0 deletions newspack-theme/inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function newspack_author_get_social_links( $author_id, $size = 24 ) {
'tumblr',
'youtube',
'wikipedia',
'bluesky',
);

// Create empty string for links.
Expand Down
27 changes: 27 additions & 0 deletions newspack-theme/inc/yoast-bluesky-contact-method.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php // phpcs:disable

use Yoast\WP\SEO\User_Meta\Domain\Additional_Contactmethod_Interface;

/**
* The Facebook contactmethod.
*/
class Newspack_Theme_Bluesky implements Additional_Contactmethod_Interface {

/**
* Returns the key of the Bluesky contactmethod.
*
* @return string The key of the Bluesky contactmethod.
*/
public function get_key(): string {
return 'bluesky';
}

/**
* Returns the label of the Bluesky field.
*
* @return string The label of the Bluesky field.
*/
public function get_label(): string {
return \__( 'Bluesky profile URL', 'newspack-theme' );
}
}
34 changes: 34 additions & 0 deletions newspack-theme/inc/yoast.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Newspack Theme: Yoast customizations.
*
* @package Newspack
*/

add_action( 'after_setup_theme', 'newspack_theme_yoast_init', 20 );

/**
* Add support for the Bluesky contact method while Yoast doesn't.
*
* @return void
*/
function newspack_theme_yoast_init() {

if ( class_exists( 'Yoast\WP\SEO\User_Meta\Framework\Additional_Contactmethods\Facebook' ) ) {
require_once get_template_directory() . '/inc/yoast-bluesky-contact-method.php';
add_filter(
'wpseo_additional_contactmethods',
function( $contact_methods ) {

// Bail if the Bluesky contact method is already registered.
foreach ( $contact_methods as $contact_method ) {
if ( 'bluesky' === $contact_method->get_key() ) {
return $contact_methods;
}
}
$contact_methods[] = new Newspack_Theme_Bluesky();
return $contact_methods;
}
);
}
}