Plugin Directory

Changeset 3406419


Ignore:
Timestamp:
12/01/2025 03:17:07 AM (4 months ago)
Author:
writetextai
Message:

empty alt text issue

Location:
writetext-ai
Files:
258 added
5 edited

Legend:

Unmodified
Added
Removed
  • writetext-ai/trunk/CHANGELOG.md

    r3400142 r3406419  
    99The format is based on [Keep a Changelog](http://keepachangelog.com/)
    1010and this project adheres to [Semantic Versioning](http://semver.org/).
     11
     12## [3.5.11] - 2025-12-01
     13
     14### Fixed
     15
     16- Fix issue with alt text not transferred when current alt text saved is empty.
    1117
    1218## [3.5.10] - 2025-11-21
  • writetext-ai/trunk/assets/js/admin-common.js

    r3400142 r3406419  
    1010);
    1111
    12 console.log('WriteText.ai - Version: [3.5.10] - 2025-11-21 - 1');
     12console.log('WriteText.ai - Version: [3.5.11] - 2025-12-01 - 1');
    1313
    1414jQuery( document ).ready( function( $ ){
  • writetext-ai/trunk/includes/class-wtai-transfer.php

    r3391599 r3406419  
    402402            $alt_text      = $alt_text_data_item['alt_text'];
    403403
    404             $current_value = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
    405 
    406             if ( '' !== $current_value ) {
    407                 $alt_text_data_to_update[] = array(
    408                     'attachment_id' => $attachment_id,
    409                     'alt_text'      => $alt_text,
    410                 );
    411             } else {
    412                 $alt_text_data_to_insert[] = array(
    413                     'attachment_id' => $attachment_id,
    414                     'alt_text'      => $alt_text,
    415                 );
    416             }
    417         }
    418 
    419         if ( $alt_text_data_to_insert ) {
    420             $insert_values       = array();
    421             $insert_placeholders = array();
    422 
    423             foreach ( $alt_text_data_to_insert as $alt_text_data ) {
    424                 $insert_values[]       = $alt_text_data['attachment_id'];
    425                 $insert_values[]       = '_wp_attachment_image_alt';
    426                 $insert_values[]       = $alt_text_data['alt_text'];
    427                 $insert_placeholders[] = '(%d, %s, %s)';
    428             }
    429 
    430             if ( ! empty( $insert_values ) ) {
    431                 $insert_initial_query = "INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value) VALUES " . implode( ', ', $insert_placeholders );
    432                 $insert_query         = $wpdb->prepare( $insert_initial_query, $insert_values ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    433 
    434                 $wpdb->query( $insert_query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
    435             }
    436         }
    437 
    438         if ( $alt_text_data_to_update ) {
    439             $case_statements = array();
    440             $post_ids        = array();
    441             $values          = array();
    442 
    443             foreach ( $alt_text_data_to_update as $alt_text_data ) {
    444                 $case_statements[] = $wpdb->prepare( 'WHEN %d THEN %s', $alt_text_data['attachment_id'], $alt_text_data['alt_text'] );
    445                 $post_ids[]        = $alt_text_data['attachment_id'];
    446             }
    447 
    448             if ( ! empty( $case_statements ) ) {
    449                 $case_sql             = implode( ' ', $case_statements );
    450                 $post_ids_placeholder = implode( ',', array_fill( 0, count( $post_ids ), '%d' ) );
    451 
    452                 $update_query = $wpdb->prepare(
    453                     "UPDATE {$wpdb->postmeta} SET meta_value = CASE post_id {$case_sql} END WHERE post_id IN ({$post_ids_placeholder}) AND meta_key = %s", // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    454                     array_merge( $post_ids, array( '_wp_attachment_image_alt' ) )
    455                 );
    456 
    457                 $wpdb->query( $update_query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
    458             }
    459         }
    460 
    461         if ( ( $alt_text_data_to_insert || $alt_text_data_to_update ) && $record_id ) {
    462             $time = strtotime( current_time( 'mysql' ) );
    463             update_post_meta( $record_id, 'wtai_transfer_date', $time );
    464         }
     404            update_post_meta( $attachment_id, '_wp_attachment_image_alt', $alt_text );
     405        }
     406
     407        $time = strtotime( current_time( 'mysql' ) );
     408        update_post_meta( $record_id, 'wtai_transfer_date', $time );
    465409    }
    466410
  • writetext-ai/trunk/readme.txt

    r3400142 r3406419  
    44Requires at least: 6.0
    55Tested up to: 6.8.3
    6 Stable tag: 3.5.10
     6Stable tag: 3.5.11
    77Requires PHP: 7.4
    88License: GPLv3 or later
     
    198198
    199199== Changelog ==
     200
     201= 3.5.11 2025-12-01 =
     202
     203* Fix – Fix issue with alt text not transferred when current alt text saved is empty.
    200204
    201205= 3.5.10 2025-11-21 =
     
    493497== Upgrade Notice ==
    494498
    495 = 3.5.10 =
     499= 3.5.11 =
    496500
    497501Please upgrade, to ensure all plugin features works as expected.
  • writetext-ai/trunk/writetext-ai.php

    r3400142 r3406419  
    44 * Plugin URI: https://writetext.ai/woocommerce
    55 * Description: Let AI automatically generate product descriptions and other content from your product data.
    6  * Version: 3.5.10
     6 * Version: 3.5.11
    77 * Author:  1902 Software
    88 * Author URI: https://writetext.ai/
     
    5252
    5353    if ( ! defined( 'WTAI_VERSION' ) ) {
    54         define( 'WTAI_VERSION', '3.5.10' );
     54        define( 'WTAI_VERSION', '3.5.11' );
    5555    }
    5656
Note: See TracChangeset for help on using the changeset viewer.