Plugin Directory

Changeset 3473467


Ignore:
Timestamp:
03/03/2026 09:55:52 AM (4 weeks ago)
Author:
eventilla
Message:

Deploy version 2.2.1

Location:
eventilla-events
Files:
197 added
4 edited

Legend:

Unmodified
Added
Removed
  • eventilla-events/trunk/README.txt

    r3468873 r3473467  
    66Tested up to: 6.8.2
    77Requires PHP: 7.4
    8 Stable tag: 2.2.0
     8Stable tag: 2.2.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5454
    5555=== Changelog ==
     56= 2.2.1 =
     57- Fix: Tag filter dropdown now works correctly with extended tags enabled
     58- Fix: Prevent duplicate attachment posts when syncing event images
    5659= 2.2.0 =
    5760- Polylang support!
  • eventilla-events/trunk/eventilla-wp.php

    r3468873 r3473467  
    1616 * Plugin URI:        https://www.eventilla.com/
    1717 * Description:       Eventilla Events brings your event information from eventilla.com to WordPress as custom posts.
    18  * Version:           2.2.0
     18 * Version:           2.2.1
    1919 * Author:            Eventilla
    2020 * Author URI:        http://www.eventilla.com
  • eventilla-events/trunk/includes/model/class-eventilla-event.php

    r3468873 r3473467  
    281281        if( ! $image_url ) {
    282282            $this->logger->debug( 'No image URL found for event', [ 'eventilla_uid' => $this->eventilla_uid ] );
    283             return false;
     283            return false;
     284        }
     285
     286        // Skip if the current thumbnail already matches the expected image.
     287        // Compare by filename stem (without extension) to account for WP suffixes
     288        // like '-scaled' (big image threshold) that WordPress adds to _wp_attached_file.
     289        $expected_stem = pathinfo( basename( $image_url ), PATHINFO_FILENAME );
     290        if( has_post_thumbnail( $this->post->ID ) ) {
     291            $thumbnail_id = get_post_thumbnail_id( $this->post->ID );
     292            $attached_file = get_post_meta( $thumbnail_id, '_wp_attached_file', true );
     293            $attached_stem = pathinfo( basename( $attached_file ), PATHINFO_FILENAME );
     294            // Match if the attached file starts with the expected stem (covers -scaled, -1, etc.)
     295            if( $attached_file && str_starts_with( $attached_stem, $expected_stem ) ) {
     296                $this->logger->debug( 'Thumbnail already matches, skipping', [ 'eventilla_uid' => $this->eventilla_uid, 'filename' => $expected_stem ] );
     297                return true;
     298            }
    284299        }
    285300
     
    371386            $tags = $event['tags'];
    372387        } elseif( array_key_exists('tags_extended', $event) ) {
    373             $tags = $this->extended_tags_to_simple_tags( $event['tags_extended'] );
     388            $tags = array_map( fn( $tag ) => $tag['key'] ?? '', $event['tags_extended'] );
     389            $tags = array_filter( $tags );
    374390        }
    375391
     
    498514        // Format tags.
    499515        if( $this->options['extended_tags'] ) {
    500             $event_tags = array_map(function($tag){
    501                 return $tag['key'];
    502             }, $data['event']['tags_extended']);
     516            $event_tags = array_map( fn( $tag ) => $tag['key'] ?? '', $data['event']['tags_extended'] );
     517            $event_tags = array_filter( $event_tags );
    503518        } else {
    504519            $event_tags = $data['event']['tags'];
  • eventilla-events/trunk/includes/model/class-eventilla-image.php

    r3447068 r3473467  
    3838     * Get the attachment ID of the image.
    3939     */
    40     private function search_for_attachment_id(): int 
     40    private function search_for_attachment_id(): int
    4141    {
    4242        eventilla_get_logger()->debug( 'Searching for attachment ID', [ 'filename' => $this->filename ] );
     
    4949        $filename = wp_basename( $this->filename );
    5050
    51         // Search for attachments where '_wp_attached_file' contains this filename.
    52         global $wpdb;
    53         $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attached_file' AND meta_value LIKE %s", '%' . $filename . '%' ) );
     51        // Search by filename without extension to account for WordPress suffixes
     52        // like '-scaled' (big image threshold, WP 5.3+) or '-1', '-2' (duplicate uploads).
     53        $name_without_ext = pathinfo( $filename, PATHINFO_FILENAME );
     54
     55        global $wpdb;
     56        $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attached_file' AND meta_value LIKE %s", '%' . $wpdb->esc_like( $name_without_ext ) . '%' ) );
    5457        foreach( $attachments as $attachment ) {
    5558            if( ! $post = get_post( $attachment->post_id ) ) {
     
    198201
    199202        require_once( ABSPATH . 'wp-admin/includes/image.php' );
    200         wp_generate_attachment_metadata( $attachment_id, $image_path );
     203        $metadata = wp_generate_attachment_metadata( $attachment_id, $image_path );
     204        wp_update_attachment_metadata( $attachment_id, $metadata );
    201205        eventilla_get_logger()->debug( 'Attachment created successfully', [ 'attachment_id' => $attachment_id ] );
    202206        return $attachment_id;
Note: See TracChangeset for help on using the changeset viewer.