-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Bluesky to the profile fields (#2413)
- Loading branch information
1 parent
ad87037
commit 6651f67
Showing
4 changed files
with
69 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
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
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,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' ); | ||
} | ||
} |
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,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; | ||
} | ||
); | ||
} | ||
} |