Plugin Directory

Changeset 3328844


Ignore:
Timestamp:
07/16/2025 09:06:47 AM (9 months ago)
Author:
janboddez
Message:

Update to version 0.19.3 from GitHub

Location:
share-on-mastodon
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • share-on-mastodon/tags/0.19.3/includes/class-image-handler.php

    r3125002 r3328844  
    3333        }
    3434
    35         // Always parse post content for images and alt text.
    36         $referenced_images = static::get_referenced_images( $post );
    37 
    3835        // Alright, let's get started.
    3936        $media_ids = array();
     
    4239            // Include featured image.
    4340            $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.
    4941        }
    5042
     
    5850                }
    5951            }
     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.
    6064        }
    6165
  • share-on-mastodon/tags/0.19.3/includes/class-share-on-mastodon.php

    r3317007 r3328844  
    1010 */
    1111class Share_On_Mastodon {
    12     const PLUGIN_VERSION = '0.19.2';
     12    const PLUGIN_VERSION = '0.19.3';
    1313    const DB_VERSION     = '1';
    1414
  • share-on-mastodon/tags/0.19.3/includes/functions.php

    r3317007 r3328844  
    4848 */
    4949function 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
    5060    global $wpdb;
    5161
     
    6575    }
    6676
    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;
    6881
    6982    $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}" : '' )
    7287    );
    7388
    7489    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared
    7590    $results = $wpdb->get_results( $sql );
    76     $post_id = null;
     91    $post_id = 0;
    7792
    7893    if ( $results ) {
    79         // Use the first available result, but prefer a case-sensitive match, if exists.
    8094        $post_id = reset( $results )->post_id;
    8195
     
    8397            foreach ( $results as $result ) {
    8498                if ( $path === $result->meta_value ) {
     99                    // If a case-sensitive match exists, use that instead.
    85100                    $post_id = $result->post_id;
    86101                    break;
  • share-on-mastodon/tags/0.19.3/readme.txt

    r3317007 r3328844  
    33Tags: mastodon, social, fediverse, syndication, posse
    44Tested up to: 6.8
    5 Stable tag: 0.19.2
     5Stable tag: 0.19.3
    66License: GNU General Public License v3.0
    77License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2929
    3030== Changelog ==
     31= 0.19.3 =
     32Improved detection of "in-post images."
     33
    3134= 0.19.2 =
    3235Address potential conflict with other plugins' (or core WordPress') classic meta boxes. Prevent double ellipses in autogenerated excerpts.
     
    5255= 0.17.0 =
    5356Introduce 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  
    99 * License URI:       http://www.gnu.org/licenses/gpl-3.0.html
    1010 * Text Domain:       share-on-mastodon
    11  * Version:           0.19.2
     11 * Version:           0.19.3
    1212 * Requires at least: 5.9
    1313 * Requires PHP:      7.2
  • share-on-mastodon/trunk/includes/class-image-handler.php

    r3125002 r3328844  
    3333        }
    3434
    35         // Always parse post content for images and alt text.
    36         $referenced_images = static::get_referenced_images( $post );
    37 
    3835        // Alright, let's get started.
    3936        $media_ids = array();
     
    4239            // Include featured image.
    4340            $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.
    4941        }
    5042
     
    5850                }
    5951            }
     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.
    6064        }
    6165
  • share-on-mastodon/trunk/includes/class-share-on-mastodon.php

    r3317007 r3328844  
    1010 */
    1111class Share_On_Mastodon {
    12     const PLUGIN_VERSION = '0.19.2';
     12    const PLUGIN_VERSION = '0.19.3';
    1313    const DB_VERSION     = '1';
    1414
  • share-on-mastodon/trunk/includes/functions.php

    r3317007 r3328844  
    4848 */
    4949function 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
    5060    global $wpdb;
    5161
     
    6575    }
    6676
    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;
    6881
    6982    $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}" : '' )
    7287    );
    7388
    7489    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared
    7590    $results = $wpdb->get_results( $sql );
    76     $post_id = null;
     91    $post_id = 0;
    7792
    7893    if ( $results ) {
    79         // Use the first available result, but prefer a case-sensitive match, if exists.
    8094        $post_id = reset( $results )->post_id;
    8195
     
    8397            foreach ( $results as $result ) {
    8498                if ( $path === $result->meta_value ) {
     99                    // If a case-sensitive match exists, use that instead.
    85100                    $post_id = $result->post_id;
    86101                    break;
  • share-on-mastodon/trunk/readme.txt

    r3317007 r3328844  
    33Tags: mastodon, social, fediverse, syndication, posse
    44Tested up to: 6.8
    5 Stable tag: 0.19.2
     5Stable tag: 0.19.3
    66License: GNU General Public License v3.0
    77License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2929
    3030== Changelog ==
     31= 0.19.3 =
     32Improved detection of "in-post images."
     33
    3134= 0.19.2 =
    3235Address potential conflict with other plugins' (or core WordPress') classic meta boxes. Prevent double ellipses in autogenerated excerpts.
     
    5255= 0.17.0 =
    5356Introduce 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  
    99 * License URI:       http://www.gnu.org/licenses/gpl-3.0.html
    1010 * Text Domain:       share-on-mastodon
    11  * Version:           0.19.2
     11 * Version:           0.19.3
    1212 * Requires at least: 5.9
    1313 * Requires PHP:      7.2
Note: See TracChangeset for help on using the changeset viewer.