You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to add a Bluesky button to pass along posts from my Wordpress site. There's some Bluesky documentation on what's needed here. Using the procedures in the Scriptless Social Sharing documentation I was able to produce a function that works. (The following code is operating now on my site.) For folk looking to adopt, adapt, or improve on this, I'm adding the following note.
The custom URL generated adds %20 in place of spaces in the post Title as well as between the Title and the post URL. Bluesky recognizes the URL as a URL but it doesn't seem to automatically separate the Title from the post URL in the Bluesky post without some manual typing. (I added a report on this in Bluesky's github discussion board here.) I added two spaces %20%20 between the post Title and post URL by creating a custom text, and I'm using a custom permalink to avoid transgressing the 300 character limit on posts with moderately long titles and long permalinks. To get the custom text to work, I had to increase the priority of my filter to override some other code that was resisting my filter under normal priority.
Here is the function I wrote and would love if this would be improved to the point that it might be integrated into Scriptless Social Sharing.
// Add Bluesky button to Scriptless Social Sharing plugin
add_filter( 'scriptlesssocialsharing_register', function( $buttons ) {
$buttons['bluesky'] = array(
'label' => 'Bluesky',
'url_base' => 'https://bsky.app/intent/compose',
'args' => array(
'query_args' => array(
'text' => '%%custom_text%%', // %% placeholders for the text to go into the Bluesky post.
),
'color' => '#3333cc', // Optional: Custom button color.
'icon' => '', // Optional: SVG icon for Bluesky.
),
);
return $buttons;
}, 20 ); // Higher priority ensures it overrides other filters.
add_filter( 'scriptlesssocialsharing_bluesky_query_args', function( $query_args, $id, $attributes, $setting ) {
global $post;
if ( ! $post instanceof WP_Post ) {
return $query_args;
}
$post_title = get_the_title( $post->ID );
$shortlink = site_url( '?p=' . $post->ID );
// Adding two spaces to separate the post Title from the URL.
$query_args['text'] = $post_title . ' ' . $shortlink;
return $query_args;
}, 20, 4 );
The text was updated successfully, but these errors were encountered:
I wanted to add a Bluesky button to pass along posts from my Wordpress site. There's some Bluesky documentation on what's needed here. Using the procedures in the Scriptless Social Sharing documentation I was able to produce a function that works. (The following code is operating now on my site.) For folk looking to adopt, adapt, or improve on this, I'm adding the following note.
The custom URL generated adds
%20
in place of spaces in the post Title as well as between the Title and the post URL. Bluesky recognizes the URL as a URL but it doesn't seem to automatically separate the Title from the post URL in the Bluesky post without some manual typing. (I added a report on this in Bluesky's github discussion board here.) I added two spaces%20%20
between the post Title and post URL by creating a custom text, and I'm using a custom permalink to avoid transgressing the 300 character limit on posts with moderately long titles and long permalinks. To get the custom text to work, I had to increase the priority of my filter to override some other code that was resisting my filter under normal priority.Here is the function I wrote and would love if this would be improved to the point that it might be integrated into Scriptless Social Sharing.
// Add Bluesky button to Scriptless Social Sharing plugin
add_filter( 'scriptlesssocialsharing_register', function( $buttons ) {
$buttons['bluesky'] = array(
'label' => 'Bluesky',
'url_base' => 'https://bsky.app/intent/compose',
'args' => array(
'query_args' => array(
'text' => '%%custom_text%%', // %% placeholders for the text to go into the Bluesky post.
),
'color' => '#3333cc', // Optional: Custom button color.
'icon' => '', // Optional: SVG icon for Bluesky.
),
);
return $buttons;
}, 20 ); // Higher priority ensures it overrides other filters.
add_filter( 'scriptlesssocialsharing_bluesky_query_args', function( $query_args, $id, $attributes, $setting ) {
global $post;
if ( ! $post instanceof WP_Post ) {
return $query_args;
}
$post_title = get_the_title( $post->ID );
$shortlink = site_url( '?p=' . $post->ID );
// Adding two spaces to separate the post Title from the URL.
$query_args['text'] = $post_title . ' ' . $shortlink;
return $query_args;
}, 20, 4 );
The text was updated successfully, but these errors were encountered: