Changeset 3328844
- Timestamp:
- 07/16/2025 09:06:47 AM (9 months ago)
- Location:
- share-on-mastodon
- Files:
-
- 10 edited
- 1 copied
-
tags/0.19.3 (copied) (copied from share-on-mastodon/trunk)
-
tags/0.19.3/includes/class-image-handler.php (modified) (3 diffs)
-
tags/0.19.3/includes/class-share-on-mastodon.php (modified) (1 diff)
-
tags/0.19.3/includes/functions.php (modified) (3 diffs)
-
tags/0.19.3/readme.txt (modified) (3 diffs)
-
tags/0.19.3/share-on-mastodon.php (modified) (1 diff)
-
trunk/includes/class-image-handler.php (modified) (3 diffs)
-
trunk/includes/class-share-on-mastodon.php (modified) (1 diff)
-
trunk/includes/functions.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/share-on-mastodon.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
share-on-mastodon/tags/0.19.3/includes/class-image-handler.php
r3125002 r3328844 33 33 } 34 34 35 // Always parse post content for images and alt text.36 $referenced_images = static::get_referenced_images( $post );37 38 35 // Alright, let's get started. 39 36 $media_ids = array(); … … 42 39 // Include featured image. 43 40 $media_ids[] = get_post_thumbnail_id( $post->ID ); 44 }45 46 if ( $enable_referenced_images && ! empty( $referenced_images ) ) {47 // Add in-post images.48 $media_ids = array_merge( $media_ids, array_keys( $referenced_images ) ); // We're interested only in the IDs, for now.49 41 } 50 42 … … 58 50 } 59 51 } 52 } 53 54 $referenced_images = array(); 55 56 if ( $enable_referenced_images || ! empty( $media_ids ) ) { 57 // Parse post content for images and alt text. 58 $referenced_images = static::get_referenced_images( $post ); 59 } 60 61 if ( $enable_referenced_images && ! empty( $referenced_images ) ) { 62 // Actually add any in-post images. 63 $media_ids = array_merge( $media_ids, array_keys( $referenced_images ) ); // We're interested only in the IDs, for now. 60 64 } 61 65 -
share-on-mastodon/tags/0.19.3/includes/class-share-on-mastodon.php
r3317007 r3328844 10 10 */ 11 11 class Share_On_Mastodon { 12 const PLUGIN_VERSION = '0.19. 2';12 const PLUGIN_VERSION = '0.19.3'; 13 13 const DB_VERSION = '1'; 14 14 -
share-on-mastodon/tags/0.19.3/includes/functions.php
r3317007 r3328844 48 48 */ 49 49 function attachment_url_to_postid( $url ) { 50 if ( str_starts_with( $url, 'data:' ) ) { 51 // Nothing to do. 52 return 0; 53 } 54 55 if ( strlen( $url ) > ( 2 * 2084 ) ) { 56 // 2,084 is sometimes seen as a practical maximum URL length, so anything over *twice* that is likely not a URL. 57 return 0; 58 } 59 50 60 global $wpdb; 51 61 … … 65 75 } 66 76 67 $filename = pathinfo( $path, PATHINFO_FILENAME ); // The bit before the (last) file extension (if any). 77 $extension = pathinfo( $path, PATHINFO_EXTENSION ); 78 $path_sans_extension = ! empty( $extension ) 79 ? preg_replace( "~\.{$extension}$~", '', $path ) 80 : $path; 68 81 69 82 $sql = $wpdb->prepare( 70 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value REGEXP %s", 71 str_replace( $filename, "$filename(-scaled)*", $path ) // This is really the only change here. 83 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND (meta_value = %s OR meta_value = %s OR meta_value = %s) LIMIT 1", 84 $path, 85 "{$path_sans_extension}-scaled" . ( ! empty( $extension ) ? ".{$extension}" : '' ), 86 "{$path_sans_extension}-rotated" . ( ! empty( $extension ) ? ".{$extension}" : '' ) 72 87 ); 73 88 74 89 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared 75 90 $results = $wpdb->get_results( $sql ); 76 $post_id = null;91 $post_id = 0; 77 92 78 93 if ( $results ) { 79 // Use the first available result, but prefer a case-sensitive match, if exists.80 94 $post_id = reset( $results )->post_id; 81 95 … … 83 97 foreach ( $results as $result ) { 84 98 if ( $path === $result->meta_value ) { 99 // If a case-sensitive match exists, use that instead. 85 100 $post_id = $result->post_id; 86 101 break; -
share-on-mastodon/tags/0.19.3/readme.txt
r3317007 r3328844 3 3 Tags: mastodon, social, fediverse, syndication, posse 4 4 Tested up to: 6.8 5 Stable tag: 0.19. 25 Stable tag: 0.19.3 6 6 License: GNU General Public License v3.0 7 7 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 29 29 30 30 == Changelog == 31 = 0.19.3 = 32 Improved detection of "in-post images." 33 31 34 = 0.19.2 = 32 35 Address potential conflict with other plugins' (or core WordPress') classic meta boxes. Prevent double ellipses in autogenerated excerpts. … … 52 55 = 0.17.0 = 53 56 Introduce Gutenberg sidebar panel. 54 55 = 0.16.1 =56 Deprecate `share_on_mastodon_cutoff` filter. Minor improvements.57 58 = 0.16.0 =59 Improved alt text discovery.60 61 = 0.15.0 =62 Better custom status messages: template tags, default template. Address odd Gutenberg behavior.63 64 = 0.14.0 =65 A very first implementation of optional custom status messages.66 67 = 0.13.1 =68 Improve Syndication Links compatibility.69 70 = 0.13.0 =71 Prevent accidental sharing of (very) old posts.72 73 = 0.12.2 =74 Custom field fix.75 76 = 0.12.1 =77 Filterable media array.78 79 = 0.12.0 =80 Configurable debug logging.81 82 = 0.11.0 =83 More flexible/robust instance URL handling. Overhauled plugin options. Syndication Links compatibility. -
share-on-mastodon/tags/0.19.3/share-on-mastodon.php
r3317007 r3328844 9 9 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 * Text Domain: share-on-mastodon 11 * Version: 0.19. 211 * Version: 0.19.3 12 12 * Requires at least: 5.9 13 13 * Requires PHP: 7.2 -
share-on-mastodon/trunk/includes/class-image-handler.php
r3125002 r3328844 33 33 } 34 34 35 // Always parse post content for images and alt text.36 $referenced_images = static::get_referenced_images( $post );37 38 35 // Alright, let's get started. 39 36 $media_ids = array(); … … 42 39 // Include featured image. 43 40 $media_ids[] = get_post_thumbnail_id( $post->ID ); 44 }45 46 if ( $enable_referenced_images && ! empty( $referenced_images ) ) {47 // Add in-post images.48 $media_ids = array_merge( $media_ids, array_keys( $referenced_images ) ); // We're interested only in the IDs, for now.49 41 } 50 42 … … 58 50 } 59 51 } 52 } 53 54 $referenced_images = array(); 55 56 if ( $enable_referenced_images || ! empty( $media_ids ) ) { 57 // Parse post content for images and alt text. 58 $referenced_images = static::get_referenced_images( $post ); 59 } 60 61 if ( $enable_referenced_images && ! empty( $referenced_images ) ) { 62 // Actually add any in-post images. 63 $media_ids = array_merge( $media_ids, array_keys( $referenced_images ) ); // We're interested only in the IDs, for now. 60 64 } 61 65 -
share-on-mastodon/trunk/includes/class-share-on-mastodon.php
r3317007 r3328844 10 10 */ 11 11 class Share_On_Mastodon { 12 const PLUGIN_VERSION = '0.19. 2';12 const PLUGIN_VERSION = '0.19.3'; 13 13 const DB_VERSION = '1'; 14 14 -
share-on-mastodon/trunk/includes/functions.php
r3317007 r3328844 48 48 */ 49 49 function attachment_url_to_postid( $url ) { 50 if ( str_starts_with( $url, 'data:' ) ) { 51 // Nothing to do. 52 return 0; 53 } 54 55 if ( strlen( $url ) > ( 2 * 2084 ) ) { 56 // 2,084 is sometimes seen as a practical maximum URL length, so anything over *twice* that is likely not a URL. 57 return 0; 58 } 59 50 60 global $wpdb; 51 61 … … 65 75 } 66 76 67 $filename = pathinfo( $path, PATHINFO_FILENAME ); // The bit before the (last) file extension (if any). 77 $extension = pathinfo( $path, PATHINFO_EXTENSION ); 78 $path_sans_extension = ! empty( $extension ) 79 ? preg_replace( "~\.{$extension}$~", '', $path ) 80 : $path; 68 81 69 82 $sql = $wpdb->prepare( 70 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value REGEXP %s", 71 str_replace( $filename, "$filename(-scaled)*", $path ) // This is really the only change here. 83 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND (meta_value = %s OR meta_value = %s OR meta_value = %s) LIMIT 1", 84 $path, 85 "{$path_sans_extension}-scaled" . ( ! empty( $extension ) ? ".{$extension}" : '' ), 86 "{$path_sans_extension}-rotated" . ( ! empty( $extension ) ? ".{$extension}" : '' ) 72 87 ); 73 88 74 89 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared 75 90 $results = $wpdb->get_results( $sql ); 76 $post_id = null;91 $post_id = 0; 77 92 78 93 if ( $results ) { 79 // Use the first available result, but prefer a case-sensitive match, if exists.80 94 $post_id = reset( $results )->post_id; 81 95 … … 83 97 foreach ( $results as $result ) { 84 98 if ( $path === $result->meta_value ) { 99 // If a case-sensitive match exists, use that instead. 85 100 $post_id = $result->post_id; 86 101 break; -
share-on-mastodon/trunk/readme.txt
r3317007 r3328844 3 3 Tags: mastodon, social, fediverse, syndication, posse 4 4 Tested up to: 6.8 5 Stable tag: 0.19. 25 Stable tag: 0.19.3 6 6 License: GNU General Public License v3.0 7 7 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 29 29 30 30 == Changelog == 31 = 0.19.3 = 32 Improved detection of "in-post images." 33 31 34 = 0.19.2 = 32 35 Address potential conflict with other plugins' (or core WordPress') classic meta boxes. Prevent double ellipses in autogenerated excerpts. … … 52 55 = 0.17.0 = 53 56 Introduce Gutenberg sidebar panel. 54 55 = 0.16.1 =56 Deprecate `share_on_mastodon_cutoff` filter. Minor improvements.57 58 = 0.16.0 =59 Improved alt text discovery.60 61 = 0.15.0 =62 Better custom status messages: template tags, default template. Address odd Gutenberg behavior.63 64 = 0.14.0 =65 A very first implementation of optional custom status messages.66 67 = 0.13.1 =68 Improve Syndication Links compatibility.69 70 = 0.13.0 =71 Prevent accidental sharing of (very) old posts.72 73 = 0.12.2 =74 Custom field fix.75 76 = 0.12.1 =77 Filterable media array.78 79 = 0.12.0 =80 Configurable debug logging.81 82 = 0.11.0 =83 More flexible/robust instance URL handling. Overhauled plugin options. Syndication Links compatibility. -
share-on-mastodon/trunk/share-on-mastodon.php
r3317007 r3328844 9 9 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 * Text Domain: share-on-mastodon 11 * Version: 0.19. 211 * Version: 0.19.3 12 12 * Requires at least: 5.9 13 13 * Requires PHP: 7.2
Note: See TracChangeset
for help on using the changeset viewer.