Changeset 3489190
- Timestamp:
- 03/23/2026 03:54:20 PM (6 days ago)
- Location:
- social-integration-for-bluesky
- Files:
-
- 14 edited
- 1 copied
-
tags/2.2.1 (copied) (copied from social-integration-for-bluesky/trunk)
-
tags/2.2.1/assets/css/bluesky-social-posts.css (modified) (1 diff)
-
tags/2.2.1/classes/BlueSky_Account_Manager.php (modified) (1 diff)
-
tags/2.2.1/classes/BlueSky_Plugin_Setup.php (modified) (1 diff)
-
tags/2.2.1/classes/BlueSky_Syndication_Service.php (modified) (4 diffs)
-
tags/2.2.1/readme.txt (modified) (2 diffs)
-
tags/2.2.1/social-integration-for-bluesky.php (modified) (2 diffs)
-
tags/2.2.1/templates/frontend/posts-list.php (modified) (1 diff)
-
trunk/assets/css/bluesky-social-posts.css (modified) (1 diff)
-
trunk/classes/BlueSky_Account_Manager.php (modified) (1 diff)
-
trunk/classes/BlueSky_Plugin_Setup.php (modified) (1 diff)
-
trunk/classes/BlueSky_Syndication_Service.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/social-integration-for-bluesky.php (modified) (2 diffs)
-
trunk/templates/frontend/posts-list.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
social-integration-for-bluesky/tags/2.2.1/assets/css/bluesky-social-posts.css
r3488902 r3489190 124 124 18px 125 125 ) !important; 126 } 127 128 /* File attachment layout (PDF, DOC, ZIP…) */ 129 .bluesky-social-integration-embedded-record.is-file { 130 padding: var(--padding-block, 16px) var(--padding-inline, 8px); 131 } 132 133 .bluesky-social-integration-embedded-record.is-file 134 .bluesky-social-integration-external-content-title { 135 display: flex !important; 136 align-items: center; 137 gap: 0.4em; 138 font-size: var( 139 --bluesky-posts-custom-external-content-title-fs, 140 15px 141 ) !important; 142 word-break: break-all; 143 } 144 145 .bluesky-social-integration-embedded-record.is-file 146 .bluesky-social-integration-external-content-title svg { 147 flex-shrink: 0; 148 width: 1.25em !important; 149 height: 1.25em !important; 150 fill: none !important; 126 151 } 127 152 -
social-integration-for-bluesky/tags/2.2.1/classes/BlueSky_Account_Manager.php
r3488902 r3489190 487 487 } 488 488 489 // If rules are set but post has no categories, don't syndicate 490 if (empty($post_category_ids)) { 491 return false; 492 } 493 489 494 // Check exclude rules first (higher priority) 490 495 if (!empty($exclude_rules)) { -
social-integration-for-bluesky/tags/2.2.1/classes/BlueSky_Plugin_Setup.php
r3468869 r3489190 169 169 ); 170 170 171 // REST API (Gutenberg) syndication — fires after handle_terms() so categories are correct 172 add_action( 173 "rest_after_insert_post", 174 [$this->syndication, "syndicate_post_rest_after_insert"], 175 10, 176 3, 177 ); 178 171 179 // Messaging & Noticing 172 180 add_action("admin_notices", [$this->settings, "display_bluesky_logout_message"]); -
social-integration-for-bluesky/tags/2.2.1/classes/BlueSky_Syndication_Service.php
r3468869 r3489190 90 90 } 91 91 92 // Multi-account branching 92 // In REST API (Gutenberg) context, transition_post_status fires before 93 // handle_terms() and update_additional_fields_for_response() run, so both 94 // post terms and post meta are not yet saved. Defer everything to 95 // rest_after_insert_post which fires after all data is persisted. 96 if (defined('REST_REQUEST') && REST_REQUEST) { 97 return; 98 } 99 100 // Classic editor: terms and meta are already saved at this point. 93 101 $account_manager = new BlueSky_Account_Manager(); 94 102 … … 98 106 } 99 107 100 // Single-account syndication ( existing code unchanged)108 // Single-account syndication (classic editor — terms already saved) 101 109 $permalink = get_permalink($post_id); 102 110 … … 131 139 } 132 140 141 // Check category rules 142 if (!$account_manager->should_syndicate_to_account($post_id, 'default')) { 143 return; 144 } 145 133 146 // Get post excerpt 134 147 $excerpt = ""; … … 419 432 } 420 433 } 434 435 /** 436 * Handle single-account syndication for REST API (Gutenberg) posts. 437 * 438 * transition_post_status fires before WordPress's handle_terms() saves categories 439 * in REST API context, so get_the_category() returns empty there. This hook fires 440 * after handle_terms(), so category rules are evaluated against the correct terms. 441 * 442 * @param WP_Post $post Fully saved post object 443 * @param WP_REST_Request $request REST request 444 * @param bool $creating True if creating, false if updating 445 */ 446 public function syndicate_post_rest_after_insert($post, $_request, $_creating) { 447 if ('post' !== $post->post_type || 'publish' !== $post->post_status) { 448 return; 449 } 450 451 $post_id = $post->ID; 452 453 $options = get_option(BLUESKY_PLUGIN_OPTIONS, []); 454 if (!empty($options['global_pause'])) { 455 return; 456 } 457 458 if (!current_user_can('edit_post', $post_id)) { 459 return; 460 } 461 462 $account_manager = new BlueSky_Account_Manager(); 463 464 // Multi-account: meta and terms are both saved at this point, so the selected 465 // accounts and category rules will be read correctly. 466 if ($account_manager->is_multi_account_enabled()) { 467 $this->syndicate_post_multi_account($post_id, $post); 468 return; 469 } 470 471 // Single-account path 472 do_action('bluesky_before_syndicating_post', $post_id); 473 474 $dont_syndicate = get_post_meta($post_id, '_bluesky_dont_syndicate', true); 475 if ($dont_syndicate) { 476 return; 477 } 478 479 // Prevent double-syndication (e.g. if classic editor path already ran) 480 $is_syndicated = get_post_meta($post_id, '_bluesky_syndicated', true); 481 if ($is_syndicated) { 482 return; 483 } 484 485 // Category rules — terms are saved at this point 486 if (!$account_manager->should_syndicate_to_account($post_id, 'default')) { 487 return; 488 } 489 490 $permalink = get_permalink($post_id); 491 $excerpt = !empty($post->post_excerpt) 492 ? $post->post_excerpt 493 : wp_trim_words($post->post_content, 30, '...'); 494 $image_url = ''; 495 496 if (has_post_thumbnail($post_id)) { 497 $image_url = get_the_post_thumbnail_url($post_id, 'large'); 498 } 499 if (empty($image_url)) { 500 preg_match('/<img[^>]+src=[\'"]([^\'"]+)[\'"][^>]*>/i', $post->post_content, $matches); 501 if (!empty($matches[1])) { 502 $image_url = $matches[1]; 503 } 504 } 505 506 $custom_text = get_post_meta($post_id, '_bluesky_syndication_text', true); 507 $post_title_for_bluesky = !empty($custom_text) ? $custom_text : $post->post_title; 508 509 $bluesky_post_info = $this->api_handler->syndicate_post_to_bluesky( 510 $post_title_for_bluesky, 511 $permalink, 512 $excerpt, 513 $image_url 514 ); 515 516 $post_meta = add_post_meta($post_id, '_bluesky_syndicated', true, true); 517 518 if ($bluesky_post_info !== false && is_array($bluesky_post_info)) { 519 update_post_meta($post_id, '_bluesky_syndication_bs_post_info', wp_json_encode($bluesky_post_info)); 520 } 521 522 do_action('bluesky_after_syndicating_post', $post_id, $post_meta); 523 } 421 524 } -
social-integration-for-bluesky/tags/2.2.1/readme.txt
r3488902 r3489190 6 6 Tested up to: 6.9.1 7 7 Requires PHP: 7.4 8 Stable tag: 2.2. 08 Stable tag: 2.2.1 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 157 157 == Changelog == 158 158 159 = 2.2.1 = 160 * **Bug fix** 161 * Multi-account VS Simple account set up were not managing Category Rules the same way. 162 * Improve the embedded "external-media" aspect of the media box in the Post Feed. (PDF, XLS, or any document shared in a BlueSky post) 163 159 164 = 2.2.0 = 160 165 * **New Feature** -
social-integration-for-bluesky/tags/2.2.1/social-integration-for-bluesky.php
r3488902 r3489190 3 3 Plugin Name: Social Integration for BlueSky 4 4 Description: BlueSky social features into WordPress supporting multi-account: Post New Articles on BlueSky, Profile Card Block, Last Post feed block, and widgets. 5 Version: 2.2. 05 Version: 2.2.1 6 6 Requires at least: 5.0 7 7 Requires PHP: 7.4 … … 19 19 } 20 20 21 define("BLUESKY_PLUGIN_VERSION", "2.2. 0");21 define("BLUESKY_PLUGIN_VERSION", "2.2.1"); 22 22 define("BLUESKY_PLUGIN_FILE", __FILE__); 23 23 define("BLUESKY_PLUGIN_BASENAME", plugin_basename(__FILE__)); -
social-integration-for-bluesky/tags/2.2.1/templates/frontend/posts-list.php
r3488902 r3489190 191 191 $display_embeds 192 192 ): 193 if ( 194 isset($post["external_media"]["uri"]) && 195 strpos( 196 $post["external_media"]["uri"], 197 "youtu", 198 ) 199 ): 200 $helpers = new BlueSky_Helpers(); 201 $youtube_id = $helpers->get_youtube_id( 202 $post["external_media"]["uri"], 203 ); 204 205 if ($youtube_id): 206 $post["external_media"]["thumb"] = 207 "https://i.ytimg.com/vi/" . 208 $youtube_id . 209 "/maxresdefault.jpg"; 210 endif; 211 endif; ?> 212 213 <?php echo isset($post["external_media"]["uri"]) 214 ? '<a href="' . 215 esc_url($post["external_media"]["uri"]) . 216 '" class="bluesky-social-integration-embedded-record is-external_media' . 217 (!empty($post["external_media"]["thumb"]) 218 ? " has-image" 219 : "") . 220 '">' 221 : ""; ?> 193 $ext_uri = $post["external_media"]["uri"] ?? ""; 194 $ext_thumb = $post["external_media"]["thumb"] ?? ""; 195 $ext_title = $post["external_media"]["title"] ?? ""; 196 $ext_desc = $post["external_media"]["description"] ?? ""; 197 198 // YouTube: override thumb with maxres image 199 if ($ext_uri && strpos($ext_uri, "youtu") !== false) { 200 $helpers = new BlueSky_Helpers(); 201 $youtube_id = $helpers->get_youtube_id($ext_uri); 202 if ($youtube_id) { 203 $ext_thumb = "https://i.ytimg.com/vi/" . $youtube_id . "/maxresdefault.jpg"; 204 } 205 } 206 207 // Detect file attachments (PDF, Office docs, archives…) 208 $uri_path = parse_url($ext_uri, PHP_URL_PATH) ?? ""; 209 $file_ext = strtolower(pathinfo($uri_path, PATHINFO_EXTENSION)); 210 $file_ext_list = ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "zip", "rar"]; 211 $is_file = in_array($file_ext, $file_ext_list, true); 212 $filename = $is_file ? basename($uri_path) : ""; 213 214 $record_classes = "bluesky-social-integration-embedded-record is-external_media"; 215 if ($is_file) { 216 $record_classes .= " is-file"; 217 } elseif (!empty($ext_thumb)) { 218 $record_classes .= " has-image"; 219 } 220 ?> 221 <?php if ($ext_uri): ?> 222 <a href="<?php echo esc_url($ext_uri); ?>" class="<?php echo esc_attr($record_classes); ?>"> 223 <?php endif; ?> 222 224 <div class="bluesky-social-integration-last-post-content"> 223 225 <?php if ($is_file): ?> 226 <div class="bluesky-social-integration-external-content"> 227 <p class="bluesky-social-integration-external-content-title"> 228 <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="20" height="20" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg> 229 <?php echo esc_html($filename ?: $ext_title); ?> 230 </p> 231 </div> 232 <?php else: ?> 233 <?php if (!empty($ext_thumb)): ?> 224 234 <div class="bluesky-social-integration-external-image"> 225 <?php 226 // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage 227 ?> 228 <?php echo isset( 229 $post["external_media"]["thumb"], 230 ) 231 ? '<img src="' . 232 esc_url( 233 $post["external_media"][ 234 "thumb" 235 ], 236 ) . 237 '" loading="lazy" alt="' . esc_attr( 238 $post["external_media"]["title"] ?? "" 239 ) . '">' 240 : ""; ?> 241 </div> 235 <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?> 236 <img src="<?php echo esc_url($ext_thumb); ?>" loading="lazy" alt="<?php echo esc_attr($ext_title); ?>"> 237 </div> 238 <?php endif; ?> 242 239 <div class="bluesky-social-integration-external-content"> 243 <?php echo isset( 244 $post["external_media"]["title"], 245 ) 246 ? '<p class="bluesky-social-integration-external-content-title">' . 247 esc_html( 248 $post["external_media"][ 249 "title" 250 ], 251 ) . 252 "</p>" 253 : ""; ?> 254 <?php echo isset( 255 $post["external_media"]["description"], 256 ) 257 ? '<p class="bluesky-social-integration-external-content-description">' . 258 esc_html( 259 $post["external_media"][ 260 "description" 261 ], 262 ) . 263 "</p>" 264 : ""; ?> 265 <?php echo isset( 266 $post["external_media"]["uri"], 267 ) 268 ? '<p class="bluesky-social-integration-external-content-url"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="16" height="16" stroke-width="2"><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0"></path><path d="M3.6 9h16.8"></path><path d="M3.6 15h16.8"></path><path d="M11.5 3a17 17 0 0 0 0 18"></path><path d="M12.5 3a17 17 0 0 1 0 18"></path></svg>' . 269 esc_html( 270 explode( 271 "/", 272 $post["external_media"][ 273 "uri" 274 ], 275 )[2], 276 ) . 277 "</p>" 278 : ""; ?> 279 </div> 240 <?php if (!empty($ext_title)): ?> 241 <p class="bluesky-social-integration-external-content-title"><?php echo esc_html($ext_title); ?></p> 242 <?php endif; ?> 243 <?php if (!empty($ext_desc)): ?> 244 <p class="bluesky-social-integration-external-content-description"><?php echo esc_html($ext_desc); ?></p> 245 <?php endif; ?> 246 <?php if ($ext_uri): ?> 247 <p class="bluesky-social-integration-external-content-url"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="16" height="16" stroke-width="2"><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0"></path><path d="M3.6 9h16.8"></path><path d="M3.6 15h16.8"></path><path d="M11.5 3a17 17 0 0 0 0 18"></path><path d="M12.5 3a17 17 0 0 1 0 18"></path></svg><?php echo esc_html(parse_url($ext_uri, PHP_URL_HOST) ?? ""); ?></p> 248 <?php endif; ?> 249 </div> 250 <?php endif; ?> 280 251 </div> 281 <?php echo isset($post["external_media"]["uri"])282 ? "</a>"283 : "";284 endif;252 <?php if ($ext_uri): ?> 253 </a> 254 <?php endif; ?> 255 <?php endif; 285 256 286 257 // displays potential embeds -
social-integration-for-bluesky/trunk/assets/css/bluesky-social-posts.css
r3488902 r3489190 124 124 18px 125 125 ) !important; 126 } 127 128 /* File attachment layout (PDF, DOC, ZIP…) */ 129 .bluesky-social-integration-embedded-record.is-file { 130 padding: var(--padding-block, 16px) var(--padding-inline, 8px); 131 } 132 133 .bluesky-social-integration-embedded-record.is-file 134 .bluesky-social-integration-external-content-title { 135 display: flex !important; 136 align-items: center; 137 gap: 0.4em; 138 font-size: var( 139 --bluesky-posts-custom-external-content-title-fs, 140 15px 141 ) !important; 142 word-break: break-all; 143 } 144 145 .bluesky-social-integration-embedded-record.is-file 146 .bluesky-social-integration-external-content-title svg { 147 flex-shrink: 0; 148 width: 1.25em !important; 149 height: 1.25em !important; 150 fill: none !important; 126 151 } 127 152 -
social-integration-for-bluesky/trunk/classes/BlueSky_Account_Manager.php
r3488902 r3489190 487 487 } 488 488 489 // If rules are set but post has no categories, don't syndicate 490 if (empty($post_category_ids)) { 491 return false; 492 } 493 489 494 // Check exclude rules first (higher priority) 490 495 if (!empty($exclude_rules)) { -
social-integration-for-bluesky/trunk/classes/BlueSky_Plugin_Setup.php
r3468869 r3489190 169 169 ); 170 170 171 // REST API (Gutenberg) syndication — fires after handle_terms() so categories are correct 172 add_action( 173 "rest_after_insert_post", 174 [$this->syndication, "syndicate_post_rest_after_insert"], 175 10, 176 3, 177 ); 178 171 179 // Messaging & Noticing 172 180 add_action("admin_notices", [$this->settings, "display_bluesky_logout_message"]); -
social-integration-for-bluesky/trunk/classes/BlueSky_Syndication_Service.php
r3468869 r3489190 90 90 } 91 91 92 // Multi-account branching 92 // In REST API (Gutenberg) context, transition_post_status fires before 93 // handle_terms() and update_additional_fields_for_response() run, so both 94 // post terms and post meta are not yet saved. Defer everything to 95 // rest_after_insert_post which fires after all data is persisted. 96 if (defined('REST_REQUEST') && REST_REQUEST) { 97 return; 98 } 99 100 // Classic editor: terms and meta are already saved at this point. 93 101 $account_manager = new BlueSky_Account_Manager(); 94 102 … … 98 106 } 99 107 100 // Single-account syndication ( existing code unchanged)108 // Single-account syndication (classic editor — terms already saved) 101 109 $permalink = get_permalink($post_id); 102 110 … … 131 139 } 132 140 141 // Check category rules 142 if (!$account_manager->should_syndicate_to_account($post_id, 'default')) { 143 return; 144 } 145 133 146 // Get post excerpt 134 147 $excerpt = ""; … … 419 432 } 420 433 } 434 435 /** 436 * Handle single-account syndication for REST API (Gutenberg) posts. 437 * 438 * transition_post_status fires before WordPress's handle_terms() saves categories 439 * in REST API context, so get_the_category() returns empty there. This hook fires 440 * after handle_terms(), so category rules are evaluated against the correct terms. 441 * 442 * @param WP_Post $post Fully saved post object 443 * @param WP_REST_Request $request REST request 444 * @param bool $creating True if creating, false if updating 445 */ 446 public function syndicate_post_rest_after_insert($post, $_request, $_creating) { 447 if ('post' !== $post->post_type || 'publish' !== $post->post_status) { 448 return; 449 } 450 451 $post_id = $post->ID; 452 453 $options = get_option(BLUESKY_PLUGIN_OPTIONS, []); 454 if (!empty($options['global_pause'])) { 455 return; 456 } 457 458 if (!current_user_can('edit_post', $post_id)) { 459 return; 460 } 461 462 $account_manager = new BlueSky_Account_Manager(); 463 464 // Multi-account: meta and terms are both saved at this point, so the selected 465 // accounts and category rules will be read correctly. 466 if ($account_manager->is_multi_account_enabled()) { 467 $this->syndicate_post_multi_account($post_id, $post); 468 return; 469 } 470 471 // Single-account path 472 do_action('bluesky_before_syndicating_post', $post_id); 473 474 $dont_syndicate = get_post_meta($post_id, '_bluesky_dont_syndicate', true); 475 if ($dont_syndicate) { 476 return; 477 } 478 479 // Prevent double-syndication (e.g. if classic editor path already ran) 480 $is_syndicated = get_post_meta($post_id, '_bluesky_syndicated', true); 481 if ($is_syndicated) { 482 return; 483 } 484 485 // Category rules — terms are saved at this point 486 if (!$account_manager->should_syndicate_to_account($post_id, 'default')) { 487 return; 488 } 489 490 $permalink = get_permalink($post_id); 491 $excerpt = !empty($post->post_excerpt) 492 ? $post->post_excerpt 493 : wp_trim_words($post->post_content, 30, '...'); 494 $image_url = ''; 495 496 if (has_post_thumbnail($post_id)) { 497 $image_url = get_the_post_thumbnail_url($post_id, 'large'); 498 } 499 if (empty($image_url)) { 500 preg_match('/<img[^>]+src=[\'"]([^\'"]+)[\'"][^>]*>/i', $post->post_content, $matches); 501 if (!empty($matches[1])) { 502 $image_url = $matches[1]; 503 } 504 } 505 506 $custom_text = get_post_meta($post_id, '_bluesky_syndication_text', true); 507 $post_title_for_bluesky = !empty($custom_text) ? $custom_text : $post->post_title; 508 509 $bluesky_post_info = $this->api_handler->syndicate_post_to_bluesky( 510 $post_title_for_bluesky, 511 $permalink, 512 $excerpt, 513 $image_url 514 ); 515 516 $post_meta = add_post_meta($post_id, '_bluesky_syndicated', true, true); 517 518 if ($bluesky_post_info !== false && is_array($bluesky_post_info)) { 519 update_post_meta($post_id, '_bluesky_syndication_bs_post_info', wp_json_encode($bluesky_post_info)); 520 } 521 522 do_action('bluesky_after_syndicating_post', $post_id, $post_meta); 523 } 421 524 } -
social-integration-for-bluesky/trunk/readme.txt
r3488902 r3489190 6 6 Tested up to: 6.9.1 7 7 Requires PHP: 7.4 8 Stable tag: 2.2. 08 Stable tag: 2.2.1 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 157 157 == Changelog == 158 158 159 = 2.2.1 = 160 * **Bug fix** 161 * Multi-account VS Simple account set up were not managing Category Rules the same way. 162 * Improve the embedded "external-media" aspect of the media box in the Post Feed. (PDF, XLS, or any document shared in a BlueSky post) 163 159 164 = 2.2.0 = 160 165 * **New Feature** -
social-integration-for-bluesky/trunk/social-integration-for-bluesky.php
r3488902 r3489190 3 3 Plugin Name: Social Integration for BlueSky 4 4 Description: BlueSky social features into WordPress supporting multi-account: Post New Articles on BlueSky, Profile Card Block, Last Post feed block, and widgets. 5 Version: 2.2. 05 Version: 2.2.1 6 6 Requires at least: 5.0 7 7 Requires PHP: 7.4 … … 19 19 } 20 20 21 define("BLUESKY_PLUGIN_VERSION", "2.2. 0");21 define("BLUESKY_PLUGIN_VERSION", "2.2.1"); 22 22 define("BLUESKY_PLUGIN_FILE", __FILE__); 23 23 define("BLUESKY_PLUGIN_BASENAME", plugin_basename(__FILE__)); -
social-integration-for-bluesky/trunk/templates/frontend/posts-list.php
r3488902 r3489190 191 191 $display_embeds 192 192 ): 193 if ( 194 isset($post["external_media"]["uri"]) && 195 strpos( 196 $post["external_media"]["uri"], 197 "youtu", 198 ) 199 ): 200 $helpers = new BlueSky_Helpers(); 201 $youtube_id = $helpers->get_youtube_id( 202 $post["external_media"]["uri"], 203 ); 204 205 if ($youtube_id): 206 $post["external_media"]["thumb"] = 207 "https://i.ytimg.com/vi/" . 208 $youtube_id . 209 "/maxresdefault.jpg"; 210 endif; 211 endif; ?> 212 213 <?php echo isset($post["external_media"]["uri"]) 214 ? '<a href="' . 215 esc_url($post["external_media"]["uri"]) . 216 '" class="bluesky-social-integration-embedded-record is-external_media' . 217 (!empty($post["external_media"]["thumb"]) 218 ? " has-image" 219 : "") . 220 '">' 221 : ""; ?> 193 $ext_uri = $post["external_media"]["uri"] ?? ""; 194 $ext_thumb = $post["external_media"]["thumb"] ?? ""; 195 $ext_title = $post["external_media"]["title"] ?? ""; 196 $ext_desc = $post["external_media"]["description"] ?? ""; 197 198 // YouTube: override thumb with maxres image 199 if ($ext_uri && strpos($ext_uri, "youtu") !== false) { 200 $helpers = new BlueSky_Helpers(); 201 $youtube_id = $helpers->get_youtube_id($ext_uri); 202 if ($youtube_id) { 203 $ext_thumb = "https://i.ytimg.com/vi/" . $youtube_id . "/maxresdefault.jpg"; 204 } 205 } 206 207 // Detect file attachments (PDF, Office docs, archives…) 208 $uri_path = parse_url($ext_uri, PHP_URL_PATH) ?? ""; 209 $file_ext = strtolower(pathinfo($uri_path, PATHINFO_EXTENSION)); 210 $file_ext_list = ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "zip", "rar"]; 211 $is_file = in_array($file_ext, $file_ext_list, true); 212 $filename = $is_file ? basename($uri_path) : ""; 213 214 $record_classes = "bluesky-social-integration-embedded-record is-external_media"; 215 if ($is_file) { 216 $record_classes .= " is-file"; 217 } elseif (!empty($ext_thumb)) { 218 $record_classes .= " has-image"; 219 } 220 ?> 221 <?php if ($ext_uri): ?> 222 <a href="<?php echo esc_url($ext_uri); ?>" class="<?php echo esc_attr($record_classes); ?>"> 223 <?php endif; ?> 222 224 <div class="bluesky-social-integration-last-post-content"> 223 225 <?php if ($is_file): ?> 226 <div class="bluesky-social-integration-external-content"> 227 <p class="bluesky-social-integration-external-content-title"> 228 <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="20" height="20" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg> 229 <?php echo esc_html($filename ?: $ext_title); ?> 230 </p> 231 </div> 232 <?php else: ?> 233 <?php if (!empty($ext_thumb)): ?> 224 234 <div class="bluesky-social-integration-external-image"> 225 <?php 226 // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage 227 ?> 228 <?php echo isset( 229 $post["external_media"]["thumb"], 230 ) 231 ? '<img src="' . 232 esc_url( 233 $post["external_media"][ 234 "thumb" 235 ], 236 ) . 237 '" loading="lazy" alt="' . esc_attr( 238 $post["external_media"]["title"] ?? "" 239 ) . '">' 240 : ""; ?> 241 </div> 235 <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?> 236 <img src="<?php echo esc_url($ext_thumb); ?>" loading="lazy" alt="<?php echo esc_attr($ext_title); ?>"> 237 </div> 238 <?php endif; ?> 242 239 <div class="bluesky-social-integration-external-content"> 243 <?php echo isset( 244 $post["external_media"]["title"], 245 ) 246 ? '<p class="bluesky-social-integration-external-content-title">' . 247 esc_html( 248 $post["external_media"][ 249 "title" 250 ], 251 ) . 252 "</p>" 253 : ""; ?> 254 <?php echo isset( 255 $post["external_media"]["description"], 256 ) 257 ? '<p class="bluesky-social-integration-external-content-description">' . 258 esc_html( 259 $post["external_media"][ 260 "description" 261 ], 262 ) . 263 "</p>" 264 : ""; ?> 265 <?php echo isset( 266 $post["external_media"]["uri"], 267 ) 268 ? '<p class="bluesky-social-integration-external-content-url"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="16" height="16" stroke-width="2"><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0"></path><path d="M3.6 9h16.8"></path><path d="M3.6 15h16.8"></path><path d="M11.5 3a17 17 0 0 0 0 18"></path><path d="M12.5 3a17 17 0 0 1 0 18"></path></svg>' . 269 esc_html( 270 explode( 271 "/", 272 $post["external_media"][ 273 "uri" 274 ], 275 )[2], 276 ) . 277 "</p>" 278 : ""; ?> 279 </div> 240 <?php if (!empty($ext_title)): ?> 241 <p class="bluesky-social-integration-external-content-title"><?php echo esc_html($ext_title); ?></p> 242 <?php endif; ?> 243 <?php if (!empty($ext_desc)): ?> 244 <p class="bluesky-social-integration-external-content-description"><?php echo esc_html($ext_desc); ?></p> 245 <?php endif; ?> 246 <?php if ($ext_uri): ?> 247 <p class="bluesky-social-integration-external-content-url"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="16" height="16" stroke-width="2"><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0"></path><path d="M3.6 9h16.8"></path><path d="M3.6 15h16.8"></path><path d="M11.5 3a17 17 0 0 0 0 18"></path><path d="M12.5 3a17 17 0 0 1 0 18"></path></svg><?php echo esc_html(parse_url($ext_uri, PHP_URL_HOST) ?? ""); ?></p> 248 <?php endif; ?> 249 </div> 250 <?php endif; ?> 280 251 </div> 281 <?php echo isset($post["external_media"]["uri"])282 ? "</a>"283 : "";284 endif;252 <?php if ($ext_uri): ?> 253 </a> 254 <?php endif; ?> 255 <?php endif; 285 256 286 257 // displays potential embeds
Note: See TracChangeset
for help on using the changeset viewer.