Skip to content

Commit

Permalink
feat: add Bluesky to the profile fields (#2413)
Browse files Browse the repository at this point in the history
  • Loading branch information
leogermani authored Nov 21, 2024
1 parent ad87037 commit 6651f67
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
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;
}
);
}
}

0 comments on commit 6651f67

Please sign in to comment.