Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack
File: functions.opengraph.php
) {
[500] Fix | Delete
$image_id = jetpack_get_site_logo( 'id' );
[501] Fix | Delete
$logo = wp_get_attachment_image_src( $image_id, 'full' );
[502] Fix | Delete
if (
[503] Fix | Delete
isset( $logo[0] ) && isset( $logo[1] ) && isset( $logo[2] )
[504] Fix | Delete
&& ( _jetpack_og_get_image_validate_size( $logo[1], $logo[2], $width, $height ) )
[505] Fix | Delete
) {
[506] Fix | Delete
return array(
[507] Fix | Delete
'src' => $logo[0],
[508] Fix | Delete
'width' => $logo[1],
[509] Fix | Delete
'height' => $logo[2],
[510] Fix | Delete
'type' => 'site_logo',
[511] Fix | Delete
);
[512] Fix | Delete
}
[513] Fix | Delete
}
[514] Fix | Delete
[515] Fix | Delete
// Third fall back, Core's site logo.
[516] Fix | Delete
if ( has_custom_logo() ) {
[517] Fix | Delete
$custom_logo_id = get_theme_mod( 'custom_logo' );
[518] Fix | Delete
$sl_details = wp_get_attachment_image_src(
[519] Fix | Delete
$custom_logo_id,
[520] Fix | Delete
'full'
[521] Fix | Delete
);
[522] Fix | Delete
if (
[523] Fix | Delete
isset( $sl_details[0] ) && isset( $sl_details[1] ) && isset( $sl_details[2] )
[524] Fix | Delete
&& ( _jetpack_og_get_image_validate_size( $sl_details[1], $sl_details[2], $width, $height ) )
[525] Fix | Delete
) {
[526] Fix | Delete
return array(
[527] Fix | Delete
'src' => $sl_details[0],
[528] Fix | Delete
'width' => $sl_details[1],
[529] Fix | Delete
'height' => $sl_details[2],
[530] Fix | Delete
'alt_text' => Images::get_alt_text( $custom_logo_id ),
[531] Fix | Delete
);
[532] Fix | Delete
}
[533] Fix | Delete
}
[534] Fix | Delete
[535] Fix | Delete
// Fourth fall back, Core Site Icon, if valid in size.
[536] Fix | Delete
if ( has_site_icon() ) {
[537] Fix | Delete
$image_id = get_option( 'site_icon' );
[538] Fix | Delete
$icon = wp_get_attachment_image_src( $image_id, 'full' );
[539] Fix | Delete
if (
[540] Fix | Delete
isset( $icon[0] ) && isset( $icon[1] ) && isset( $icon[2] )
[541] Fix | Delete
&& ( _jetpack_og_get_image_validate_size( $icon[1], $icon[2], $width, $height ) )
[542] Fix | Delete
) {
[543] Fix | Delete
return array(
[544] Fix | Delete
'src' => $icon[0],
[545] Fix | Delete
'width' => $icon[1],
[546] Fix | Delete
'height' => $icon[2],
[547] Fix | Delete
'type' => 'site_icon',
[548] Fix | Delete
);
[549] Fix | Delete
}
[550] Fix | Delete
}
[551] Fix | Delete
[552] Fix | Delete
return array(
[553] Fix | Delete
'src' => '',
[554] Fix | Delete
'width' => $width,
[555] Fix | Delete
'height' => $height,
[556] Fix | Delete
'type' => 'blank',
[557] Fix | Delete
);
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
/**
[561] Fix | Delete
* Get the site's fallback image.
[562] Fix | Delete
*
[563] Fix | Delete
* @since 14.9
[564] Fix | Delete
*
[565] Fix | Delete
* @return string
[566] Fix | Delete
*/
[567] Fix | Delete
function jetpack_og_get_site_fallback_blank_image() {
[568] Fix | Delete
/**
[569] Fix | Delete
* Filter the default Open Graph Image tag, used when no Image can be found in a post.
[570] Fix | Delete
*
[571] Fix | Delete
* @since 3.0.0
[572] Fix | Delete
*
[573] Fix | Delete
* @param string $str Default Image URL.
[574] Fix | Delete
*/
[575] Fix | Delete
return apply_filters( 'jetpack_open_graph_image_default', 'https://s0.wp.com/i/blank.jpg' );
[576] Fix | Delete
}
[577] Fix | Delete
[578] Fix | Delete
/**
[579] Fix | Delete
* Get available templates for Social Image Generator.
[580] Fix | Delete
*
[581] Fix | Delete
* @since 14.9
[582] Fix | Delete
*
[583] Fix | Delete
* @return array The available templates.
[584] Fix | Delete
*/
[585] Fix | Delete
function jetpack_og_get_available_templates() {
[586] Fix | Delete
if ( ! class_exists( '\Automattic\Jetpack\Publicize\Social_Image_Generator\Templates' ) ) {
[587] Fix | Delete
return array();
[588] Fix | Delete
}
[589] Fix | Delete
[590] Fix | Delete
return \Automattic\Jetpack\Publicize\Social_Image_Generator\Templates::TEMPLATES;
[591] Fix | Delete
}
[592] Fix | Delete
[593] Fix | Delete
/**
[594] Fix | Delete
* Get a social image token from Social Image Generator.
[595] Fix | Delete
*
[596] Fix | Delete
* @since 14.9
[597] Fix | Delete
*
[598] Fix | Delete
* @param string $site_title The site title.
[599] Fix | Delete
* @param string $image_url The image URL.
[600] Fix | Delete
* @param string $template The template to use.
[601] Fix | Delete
*
[602] Fix | Delete
* @return string|WP_Error The social image token, or a WP_Error if the token could not be generated.
[603] Fix | Delete
*/
[604] Fix | Delete
function jetpack_og_get_social_image_token( $site_title, $image_url, $template ) {
[605] Fix | Delete
// Let's check if we have a cached token.
[606] Fix | Delete
$cache_key = wp_hash( $site_title . $image_url . $template );
[607] Fix | Delete
$transient_name = 'jetpack_og_social_image_token_' . $cache_key;
[608] Fix | Delete
$cached_token = get_transient( $transient_name );
[609] Fix | Delete
[610] Fix | Delete
if ( ! empty( $cached_token ) ) {
[611] Fix | Delete
return $cached_token;
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
/**
[615] Fix | Delete
* Filter the social image token for testing purposes.
[616] Fix | Delete
*
[617] Fix | Delete
* @since 14.9
[618] Fix | Delete
*
[619] Fix | Delete
* @param string|WP_Error|null $token The token to return, or null to use default behavior.
[620] Fix | Delete
*/
[621] Fix | Delete
$token = apply_filters( 'jetpack_og_get_social_image_token', null );
[622] Fix | Delete
if ( null !== $token ) {
[623] Fix | Delete
return $token;
[624] Fix | Delete
}
[625] Fix | Delete
[626] Fix | Delete
if ( ! function_exists( '\Automattic\Jetpack\Publicize\Social_Image_Generator\fetch_token' ) ) {
[627] Fix | Delete
return new WP_Error( 'jetpack_og_get_social_image_token_error', __( 'Social Image Generator is not available.', 'jetpack' ) );
[628] Fix | Delete
}
[629] Fix | Delete
[630] Fix | Delete
$token = \Automattic\Jetpack\Publicize\Social_Image_Generator\fetch_token( $site_title, $image_url, $template );
[631] Fix | Delete
[632] Fix | Delete
/*
[633] Fix | Delete
* We want to cache 2 types of responses:
[634] Fix | Delete
* - Successful responses with a token.
[635] Fix | Delete
* - WP_Error responses that denote a WordPress.com connection issue.
[636] Fix | Delete
*/
[637] Fix | Delete
if (
[638] Fix | Delete
! is_wp_error( $token )
[639] Fix | Delete
|| (
[640] Fix | Delete
is_wp_error( $token )
[641] Fix | Delete
&& 'invalid_user_permission_publicize' === $token->get_error_code()
[642] Fix | Delete
)
[643] Fix | Delete
) {
[644] Fix | Delete
set_transient( $transient_name, $token, DAY_IN_SECONDS );
[645] Fix | Delete
}
[646] Fix | Delete
[647] Fix | Delete
return $token;
[648] Fix | Delete
}
[649] Fix | Delete
[650] Fix | Delete
/**
[651] Fix | Delete
* Generate and create a fallback social image.
[652] Fix | Delete
*
[653] Fix | Delete
* @since 14.9
[654] Fix | Delete
*
[655] Fix | Delete
* @param array $representative_image The representative image of the site.
[656] Fix | Delete
* @param string $template The template to use.
[657] Fix | Delete
*
[658] Fix | Delete
* @return array The source ('src'), 'width', and 'height' of the image.
[659] Fix | Delete
*/
[660] Fix | Delete
function jetpack_og_generate_fallback_social_image( $representative_image, $template ) {
[661] Fix | Delete
$site_title = get_bloginfo( 'name' );
[662] Fix | Delete
$fallback_image = array(
[663] Fix | Delete
'src' => $representative_image['src'],
[664] Fix | Delete
'width' => $representative_image['width'],
[665] Fix | Delete
'height' => $representative_image['height'],
[666] Fix | Delete
);
[667] Fix | Delete
[668] Fix | Delete
// Ensure that we use a valid template.
[669] Fix | Delete
if (
[670] Fix | Delete
! in_array(
[671] Fix | Delete
$template,
[672] Fix | Delete
jetpack_og_get_available_templates(),
[673] Fix | Delete
true
[674] Fix | Delete
)
[675] Fix | Delete
) {
[676] Fix | Delete
$template = 'edge';
[677] Fix | Delete
}
[678] Fix | Delete
[679] Fix | Delete
// Let's generate the token matching the image..
[680] Fix | Delete
$token = jetpack_og_get_social_image_token( $site_title, $representative_image['src'], $template );
[681] Fix | Delete
[682] Fix | Delete
if ( is_wp_error( $token ) ) {
[683] Fix | Delete
return $fallback_image;
[684] Fix | Delete
}
[685] Fix | Delete
[686] Fix | Delete
// Build the image URL and return it.
[687] Fix | Delete
return array(
[688] Fix | Delete
'src' => sprintf(
[689] Fix | Delete
'https://s0.wp.com/_si/?t=%s',
[690] Fix | Delete
$token
[691] Fix | Delete
),
[692] Fix | Delete
'width' => 1200,
[693] Fix | Delete
'height' => 630,
[694] Fix | Delete
);
[695] Fix | Delete
}
[696] Fix | Delete
[697] Fix | Delete
/**
[698] Fix | Delete
* Validate the width and height against required width and height
[699] Fix | Delete
*
[700] Fix | Delete
* @param int $width Width of the image.
[701] Fix | Delete
* @param int $height Height of the image.
[702] Fix | Delete
* @param int $req_width Required width to pass validation.
[703] Fix | Delete
* @param int $req_height Required height to pass validation.
[704] Fix | Delete
*
[705] Fix | Delete
* @return bool - True if the image passed the required size validation
[706] Fix | Delete
*/
[707] Fix | Delete
function _jetpack_og_get_image_validate_size( $width, $height, $req_width, $req_height ) {
[708] Fix | Delete
if ( ! $width || ! $height ) {
[709] Fix | Delete
return false;
[710] Fix | Delete
}
[711] Fix | Delete
[712] Fix | Delete
$valid_width = ( $width >= $req_width );
[713] Fix | Delete
$valid_height = ( $height >= $req_height );
[714] Fix | Delete
$is_image_acceptable = $valid_width && $valid_height;
[715] Fix | Delete
[716] Fix | Delete
return $is_image_acceptable;
[717] Fix | Delete
}
[718] Fix | Delete
[719] Fix | Delete
/**
[720] Fix | Delete
* Gets a gravatar URL of the specified size.
[721] Fix | Delete
*
[722] Fix | Delete
* @param string $email E-mail address to get gravatar for.
[723] Fix | Delete
* @param int $width Size of returned gravatar.
[724] Fix | Delete
* @return array|bool|mixed|string
[725] Fix | Delete
*/
[726] Fix | Delete
function jetpack_og_get_image_gravatar( $email, $width ) {
[727] Fix | Delete
return get_avatar_url(
[728] Fix | Delete
$email,
[729] Fix | Delete
array(
[730] Fix | Delete
'size' => $width,
[731] Fix | Delete
)
[732] Fix | Delete
);
[733] Fix | Delete
}
[734] Fix | Delete
[735] Fix | Delete
/**
[736] Fix | Delete
* Clean up text meant to be used as Description Open Graph tag.
[737] Fix | Delete
*
[738] Fix | Delete
* There should be:
[739] Fix | Delete
* - no links
[740] Fix | Delete
* - no shortcodes
[741] Fix | Delete
* - no html tags or their contents
[742] Fix | Delete
* - no content within wp:query blocks
[743] Fix | Delete
* - not too many words.
[744] Fix | Delete
*
[745] Fix | Delete
* @param string $description Text coming from WordPress (autogenerated or manually generated by author).
[746] Fix | Delete
* @param WP_Post|null $data Information about our post.
[747] Fix | Delete
*
[748] Fix | Delete
* @return string $description Cleaned up description string.
[749] Fix | Delete
*/
[750] Fix | Delete
function jetpack_og_get_description( $description = '', $data = null ) {
[751] Fix | Delete
// Remove content within wp:query blocks.
[752] Fix | Delete
$description = jetpack_og_remove_query_blocks( $description );
[753] Fix | Delete
[754] Fix | Delete
// Remove tags such as <style or <script.
[755] Fix | Delete
$description = wp_strip_all_tags( $description );
[756] Fix | Delete
[757] Fix | Delete
/*
[758] Fix | Delete
* Clean up any plain text entities left into formatted entities.
[759] Fix | Delete
* Intentionally not using a filter to prevent pollution.
[760] Fix | Delete
* @see https://github.com/Automattic/jetpack/pull/2899#issuecomment-151957382
[761] Fix | Delete
*/
[762] Fix | Delete
$description = wp_kses(
[763] Fix | Delete
trim(
[764] Fix | Delete
convert_chars(
[765] Fix | Delete
wptexturize( $description )
[766] Fix | Delete
)
[767] Fix | Delete
),
[768] Fix | Delete
array()
[769] Fix | Delete
);
[770] Fix | Delete
[771] Fix | Delete
// Remove shortcodes.
[772] Fix | Delete
$description = strip_shortcodes( $description );
[773] Fix | Delete
[774] Fix | Delete
// Remove links.
[775] Fix | Delete
$description = preg_replace(
[776] Fix | Delete
'@https?://[\S]+@',
[777] Fix | Delete
'',
[778] Fix | Delete
$description
[779] Fix | Delete
);
[780] Fix | Delete
[781] Fix | Delete
/*
[782] Fix | Delete
* Limit things to a small text blurb.
[783] Fix | Delete
* There isn't a hard limit set by Facebook, so let's rely on WP's own limit.
[784] Fix | Delete
* (55 words or the localized equivalent).
[785] Fix | Delete
* This limit can be customized with the wp_trim_words filter.
[786] Fix | Delete
*/
[787] Fix | Delete
$description = wp_trim_words( $description );
[788] Fix | Delete
[789] Fix | Delete
// Let's set a default if we have no text by now.
[790] Fix | Delete
if ( empty( $description ) ) {
[791] Fix | Delete
/**
[792] Fix | Delete
* Filter the fallback `og:description` used when no excerpt information is provided.
[793] Fix | Delete
*
[794] Fix | Delete
* @module sharedaddy, publicize
[795] Fix | Delete
*
[796] Fix | Delete
* @since 3.9.0
[797] Fix | Delete
*
[798] Fix | Delete
* @param string $var Fallback og:description. Default is translated `Visit the post for more'.
[799] Fix | Delete
* @param object $data Post object for the current post.
[800] Fix | Delete
*/
[801] Fix | Delete
$description = apply_filters(
[802] Fix | Delete
'jetpack_open_graph_fallback_description',
[803] Fix | Delete
__( 'Visit the post for more.', 'jetpack' ),
[804] Fix | Delete
$data
[805] Fix | Delete
);
[806] Fix | Delete
}
[807] Fix | Delete
[808] Fix | Delete
return $description;
[809] Fix | Delete
}
[810] Fix | Delete
[811] Fix | Delete
/**
[812] Fix | Delete
* Remove content within wp:query blocks from the description.
[813] Fix | Delete
*
[814] Fix | Delete
* @since 14.9
[815] Fix | Delete
*
[816] Fix | Delete
* @param string $description The description text that may contain block markup.
[817] Fix | Delete
* @return string The description with wp:query blocks removed.
[818] Fix | Delete
*/
[819] Fix | Delete
function jetpack_og_remove_query_blocks( $description ) {
[820] Fix | Delete
// Handle non-string input
[821] Fix | Delete
if ( ! is_string( $description ) ) {
[822] Fix | Delete
return '';
[823] Fix | Delete
}
[824] Fix | Delete
[825] Fix | Delete
$output = '';
[826] Fix | Delete
$offset = 0;
[827] Fix | Delete
$depth = 0;
[828] Fix | Delete
$in_query_block = false;
[829] Fix | Delete
[830] Fix | Delete
$scanner = Block_Scanner::create( $description );
[831] Fix | Delete
if ( ! $scanner ) {
[832] Fix | Delete
return $description;
[833] Fix | Delete
}
[834] Fix | Delete
[835] Fix | Delete
while ( $scanner->next_delimiter() ) {
[836] Fix | Delete
$span = $scanner->get_span();
[837] Fix | Delete
$match_at = $span->start;
[838] Fix | Delete
$length = $span->length;
[839] Fix | Delete
[840] Fix | Delete
// Check if this is a query block.
[841] Fix | Delete
if ( $scanner->is_block_type( 'query' ) ) {
[842] Fix | Delete
switch ( $scanner->get_delimiter_type() ) {
[843] Fix | Delete
case Block_Scanner::OPENER:
[844] Fix | Delete
if ( ! $in_query_block ) {
[845] Fix | Delete
// Copy content before the query block.
[846] Fix | Delete
$output .= substr( $description, $offset, $match_at - $offset );
[847] Fix | Delete
$in_query_block = true;
[848] Fix | Delete
}
[849] Fix | Delete
++$depth;
[850] Fix | Delete
break;
[851] Fix | Delete
[852] Fix | Delete
case Block_Scanner::CLOSER:
[853] Fix | Delete
--$depth;
[854] Fix | Delete
if ( $in_query_block && $depth === 0 ) {
[855] Fix | Delete
// We've exited the query block, continue from after it.
[856] Fix | Delete
$in_query_block = false;
[857] Fix | Delete
$offset = $match_at + $length;
[858] Fix | Delete
[859] Fix | Delete
// Remove extra newline if present
[860] Fix | Delete
if (
[861] Fix | Delete
str_starts_with( substr( $description, $offset ), "\n" )
[862] Fix | Delete
&& str_ends_with( $output, "\n" )
[863] Fix | Delete
) {
[864] Fix | Delete
++$offset;
[865] Fix | Delete
}
[866] Fix | Delete
}
[867] Fix | Delete
break;
[868] Fix | Delete
[869] Fix | Delete
case Block_Scanner::VOID:
[870] Fix | Delete
// Void query blocks should be removed entirely.
[871] Fix | Delete
if ( ! $in_query_block ) {
[872] Fix | Delete
$output .= substr( $description, $offset, $match_at - $offset );
[873] Fix | Delete
$offset = $match_at + $length;
[874] Fix | Delete
// Remove extra newline if present
[875] Fix | Delete
if (
[876] Fix | Delete
str_starts_with( substr( $description, $offset ), "\n" )
[877] Fix | Delete
&& str_ends_with( $output, "\n" )
[878] Fix | Delete
) {
[879] Fix | Delete
++$offset;
[880] Fix | Delete
}
[881] Fix | Delete
}
[882] Fix | Delete
break;
[883] Fix | Delete
}
[884] Fix | Delete
} elseif ( ! $in_query_block ) {
[885] Fix | Delete
// Not a query block, copy content including the delimiter if we're not inside a query block.
[886] Fix | Delete
$output .= substr( $description, $offset, $match_at - $offset + $length );
[887] Fix | Delete
$offset = $match_at + $length;
[888] Fix | Delete
}
[889] Fix | Delete
}
[890] Fix | Delete
[891] Fix | Delete
// Add any remaining content after the last delimiter.
[892] Fix | Delete
if ( ! $in_query_block ) {
[893] Fix | Delete
$output .= substr( $description, $offset );
[894] Fix | Delete
}
[895] Fix | Delete
[896] Fix | Delete
return $output;
[897] Fix | Delete
}
[898] Fix | Delete
[899] Fix | Delete
/**
[900] Fix | Delete
* Display a Fediverse actor Open Graph tag when the post author has a Mastodon connection.
[901] Fix | Delete
*
[902] Fix | Delete
* @see https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/
[903] Fix | Delete
*
[904] Fix | Delete
* @since 13.8
[905] Fix | Delete
*
[906] Fix | Delete
* @param array $tags Current tags.
[907] Fix | Delete
*
[908] Fix | Delete
* @return array
[909] Fix | Delete
*/
[910] Fix | Delete
function jetpack_add_fediverse_creator_open_graph_tag( $tags ) {
[911] Fix | Delete
/*
[912] Fix | Delete
* Let's not do this on WordPress.com Simple for now,
[913] Fix | Delete
* because of its performance impact.
[914] Fix | Delete
* See p1723574138779019/1723572983.803009-slack-C01U2KGS2PQ
[915] Fix | Delete
*/
[916] Fix | Delete
if ( ( new Host() )->is_wpcom_simple() ) {
[917] Fix | Delete
return $tags;
[918] Fix | Delete
}
[919] Fix | Delete
[920] Fix | Delete
// Let's not add any tags when the ActivityPub plugin already adds its own.
[921] Fix | Delete
$is_activitypub_opengraph_integration_active = get_option( 'activitypub_use_opengraph' );
[922] Fix | Delete
if ( $is_activitypub_opengraph_integration_active ) {
[923] Fix | Delete
return $tags;
[924] Fix | Delete
}
[925] Fix | Delete
[926] Fix | Delete
// We pull the Mastodon connection data from Publicize.
[927] Fix | Delete
if ( ! function_exists( 'publicize_init' ) ) {
[928] Fix | Delete
return $tags;
[929] Fix | Delete
}
[930] Fix | Delete
$publicize = publicize_init();
[931] Fix | Delete
[932] Fix | Delete
global $post;
[933] Fix | Delete
if (
[934] Fix | Delete
! is_singular()
[935] Fix | Delete
|| ! $post instanceof WP_Post
[936] Fix | Delete
|| ! isset( $post->ID )
[937] Fix | Delete
|| empty( $post->post_author )
[938] Fix | Delete
) {
[939] Fix | Delete
return $tags;
[940] Fix | Delete
}
[941] Fix | Delete
[942] Fix | Delete
$post_mastodon_connections = array();
[943] Fix | Delete
[944] Fix | Delete
// Loop through active connections.
[945] Fix | Delete
foreach ( (array) $publicize->get_services( 'connected' ) as $service_name => $connections ) {
[946] Fix | Delete
if ( 'mastodon' !== $service_name ) {
[947] Fix | Delete
continue;
[948] Fix | Delete
}
[949] Fix | Delete
[950] Fix | Delete
// services can have multiple connections. Store them all in our array.
[951] Fix | Delete
foreach ( $connections as $connection ) {
[952] Fix | Delete
$connection_id = $publicize->get_connection_id( $connection );
[953] Fix | Delete
$connection_meta = $publicize->get_connection_meta( $connection );
[954] Fix | Delete
[955] Fix | Delete
$connection_data = $connection_meta['connection_data'] ?? array();
[956] Fix | Delete
$mastodon_handle = $connection_meta['external_display'] ?? '';
[957] Fix | Delete
$connection_user_id = $connection_data['user_id'] ?? 0;
[958] Fix | Delete
[959] Fix | Delete
if ( empty( $mastodon_handle ) ) {
[960] Fix | Delete
continue;
[961] Fix | Delete
}
[962] Fix | Delete
[963] Fix | Delete
// Did we skip this connection for this post?
[964] Fix | Delete
if ( get_post_meta( $post->ID, $publicize->POST_SKIP_PUBLICIZE . $connection_id, true ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
[965] Fix | Delete
continue;
[966] Fix | Delete
}
[967] Fix | Delete
[968] Fix | Delete
$post_mastodon_connections[] = array(
[969] Fix | Delete
'user_id' => (int) $connection_user_id,
[970] Fix | Delete
'connection_id' => (int) $connection_id,
[971] Fix | Delete
'handle' => $mastodon_handle,
[972] Fix | Delete
'global' => 0 === (int) $connection_user_id,
[973] Fix | Delete
);
[974] Fix | Delete
}
[975] Fix | Delete
}
[976] Fix | Delete
[977] Fix | Delete
// If we have no Mastodon connections, skip.
[978] Fix | Delete
if ( empty( $post_mastodon_connections ) ) {
[979] Fix | Delete
return $tags;
[980] Fix | Delete
}
[981] Fix | Delete
[982] Fix | Delete
/*
[983] Fix | Delete
* Select a single Mastodon connection to use.
[984] Fix | Delete
* It should be either the first connection belonging to the post author,
[985] Fix | Delete
* or the first global connection.
[986] Fix | Delete
*/
[987] Fix | Delete
foreach ( $post_mastodon_connections as $mastodon_connection ) {
[988] Fix | Delete
if ( (int) $post->post_author === $mastodon_connection['user_id'] ) {
[989] Fix | Delete
$tags['fediverse:creator'] = esc_attr( $mastodon_connection['handle'] );
[990] Fix | Delete
break;
[991] Fix | Delete
}
[992] Fix | Delete
[993] Fix | Delete
if ( $mastodon_connection['global'] ) {
[994] Fix | Delete
$tags['fediverse:creator'] = esc_attr( $mastodon_connection['handle'] );
[995] Fix | Delete
break;
[996] Fix | Delete
}
[997] Fix | Delete
}
[998] Fix | Delete
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function