Changeset 3492892
- Timestamp:
- 03/27/2026 06:08:50 PM (32 hours ago)
- Location:
- alttext-ai
- Files:
-
- 4 added
- 12 edited
- 1 copied
-
tags/1.10.33 (copied) (copied from alttext-ai/trunk)
-
tags/1.10.33/README.txt (modified) (2 diffs)
-
tags/1.10.33/atai.php (modified) (2 diffs)
-
tags/1.10.33/changelog.txt (modified) (1 diff)
-
tags/1.10.33/includes/builders (added)
-
tags/1.10.33/includes/builders/class-atai-builder-yootheme.php (added)
-
tags/1.10.33/includes/class-atai-post.php (modified) (2 diffs)
-
tags/1.10.33/includes/class-atai-utility.php (modified) (1 diff)
-
tags/1.10.33/includes/class-atai.php (modified) (1 diff)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/atai.php (modified) (2 diffs)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/includes/builders (added)
-
trunk/includes/builders/class-atai-builder-yootheme.php (added)
-
trunk/includes/class-atai-post.php (modified) (2 diffs)
-
trunk/includes/class-atai-utility.php (modified) (1 diff)
-
trunk/includes/class-atai.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
alttext-ai/tags/1.10.33/README.txt
r3485945 r3492892 6 6 Requires at least: 4.7 7 7 Tested up to: 6.9 8 Stable tag: 1.10.3 28 Stable tag: 1.10.33 9 9 WC requires at least: 3.3 10 10 WC tested up to: 10.1 … … 71 71 72 72 == Changelog == 73 74 = 1.10.33 - 2026-03-25 = 75 * NEW: YOOtheme Pro page builder support — alt text now syncs correctly on YOOtheme-built pages 73 76 74 77 = 1.10.30 - 2026-03-06 = -
alttext-ai/tags/1.10.33/atai.php
r3485945 r3492892 16 16 * Plugin URI: https://alttext.ai/product 17 17 * Description: Automatically generate image alt text with AltText.ai. 18 * Version: 1.10.3 218 * Version: 1.10.33 19 19 * Author: AltText.ai 20 20 * Author URI: https://alttext.ai … … 34 34 * Current plugin version. 35 35 */ 36 define( 'ATAI_VERSION', '1.10.3 2' );36 define( 'ATAI_VERSION', '1.10.33' ); 37 37 38 38 /** -
alttext-ai/tags/1.10.33/changelog.txt
r3485945 r3492892 1 1 *** AltText.ai Changelog *** 2 3 2026-03-25 - version 1.10.33 4 * NEW: YOOtheme Pro page builder support — alt text now syncs correctly on YOOtheme-built pages 2 5 3 6 2026-03-18 - version 1.10.32 -
alttext-ai/tags/1.10.33/includes/class-atai-post.php
r3485945 r3492892 475 475 $num_alttext_generated += $product_response['num_alttext_generated']; 476 476 } 477 477 478 // Process page builder images (YOOtheme, etc.) 479 $builder_response = $this->process_builder_images( $post_id, $overwrite, $process_external, $keywords ); 480 $total_images_found += $builder_response['total_images_found']; 481 $num_alttext_generated += $builder_response['num_alttext_generated']; 482 if ( $builder_response['no_credits'] ) { 483 $no_credits = true; 484 } 485 478 486 ATAI_Elementor_Sync::$paused = false; 479 487 480 if ( !empty($updated_content) ) { 488 // Skip HTML content update if a builder already saved post_content 489 if ( !empty($updated_content) && ! $builder_response['saved_post_content'] ) { 481 490 wp_update_post( array( 482 491 'ID' => $post_id, … … 510 519 'num_alttext_generated' => $num_alttext_generated, 511 520 'no_credits' => $no_credits, 521 ); 522 } 523 524 /** 525 * Process images in page builder content. 526 * 527 * Iterates registered builder handlers, extracts images from their data, 528 * generates alt text, and updates the builder's stored content. 529 * 530 * @since 1.10.33 531 * @param int $post_id 532 * @param bool $overwrite 533 * @param bool $process_external 534 * @param array $keywords 535 * @return array 536 */ 537 private function process_builder_images( $post_id, $overwrite, $process_external, $keywords ) { 538 $handlers = apply_filters( 'atai_page_builder_handlers', array( 539 'yootheme' => 'ATAI_Builder_YooTheme', 540 ) ); 541 542 $total_images_found = 0; 543 $num_alttext_generated = 0; 544 $no_credits = false; 545 $saved_post_content = false; 546 $atai_attachment = new ATAI_Attachment(); 547 548 foreach ( $handlers as $key => $handler_class ) { 549 if ( ! class_exists( $handler_class ) ) { 550 continue; 551 } 552 553 if ( ! method_exists( $handler_class, 'is_active' ) || ! $handler_class::is_active() ) { 554 continue; 555 } 556 557 // Validate handler implements the full contract before instantiation 558 $required_methods = array( 'has_builder_content', 'extract_images', 'update_image_alt', 'save', 'uses_post_content' ); 559 $valid = true; 560 foreach ( $required_methods as $method ) { 561 if ( ! method_exists( $handler_class, $method ) ) { 562 $valid = false; 563 break; 564 } 565 } 566 if ( ! $valid ) { 567 continue; 568 } 569 570 $handler = new $handler_class(); 571 572 if ( ! $handler->has_builder_content( $post_id ) ) { 573 continue; 574 } 575 576 $images = $handler->extract_images( $post_id ); 577 $handler_modified = false; 578 579 foreach ( $images as $image ) { 580 $total_images_found++; 581 $alt_text = false; 582 $should_generate = false; 583 584 if ( $image['attachment_id'] ) { 585 $alt_text = get_post_meta( $image['attachment_id'], '_wp_attachment_image_alt', true ); 586 587 if ( $overwrite || empty( $alt_text ) ) { 588 $should_generate = true; 589 $alt_text = $atai_attachment->generate_alt( $image['attachment_id'], null, array( 'keywords' => $keywords ) ); 590 } 591 } elseif ( $process_external ) { 592 $alt_text = $image['current_alt']; 593 594 if ( $overwrite || empty( $alt_text ) ) { 595 $should_generate = true; 596 $alt_text = $atai_attachment->generate_alt( null, $image['url'], array( 'keywords' => $keywords ) ); 597 } 598 } 599 600 if ( empty( $alt_text ) || ! is_string( $alt_text ) ) { 601 continue; 602 } 603 604 if ( $alt_text === 'insufficient_credits' ) { 605 $no_credits = true; 606 break; 607 } 608 609 if ( $should_generate ) { 610 $num_alttext_generated++; 611 } 612 613 // Update alt text in builder data (even if not newly generated, 614 // sync the media library alt text into the builder) 615 if ( $handler->update_image_alt( $post_id, $image['ref'], $alt_text ) ) { 616 $handler_modified = true; 617 } 618 } 619 620 if ( $handler_modified ) { 621 if ( $handler->save( $post_id ) && $handler->uses_post_content() ) { 622 $saved_post_content = true; 623 } 624 } 625 626 if ( $no_credits ) { 627 break; 628 } 629 } 630 631 return array( 632 'total_images_found' => $total_images_found, 633 'num_alttext_generated' => $num_alttext_generated, 634 'no_credits' => $no_credits, 635 'saved_post_content' => $saved_post_content, 512 636 ); 513 637 } -
alttext-ai/tags/1.10.33/includes/class-atai-utility.php
r3485046 r3492892 174 174 if ( empty( $src ) || ! is_string( $src ) ) { 175 175 return null; 176 } 177 178 // Convert builder-relative paths (wp-content/..., images/...) to absolute URLs 179 if ( substr( $src, 0, 10 ) === 'wp-content' || substr( $src, 0, 7 ) === 'images/' ) { 180 if ( strpos( $src, '..' ) !== false ) { 181 return null; 182 } 183 $src = trailingslashit( $home_url ) . $src; 176 184 } 177 185 -
alttext-ai/tags/1.10.33/includes/class-atai.php
r3485046 r3492892 141 141 */ 142 142 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-atai-elementor-sync.php'; 143 144 // Page builder handlers 145 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/builders/class-atai-builder-yootheme.php'; 143 146 144 147 /** -
alttext-ai/trunk/README.txt
r3485945 r3492892 6 6 Requires at least: 4.7 7 7 Tested up to: 6.9 8 Stable tag: 1.10.3 28 Stable tag: 1.10.33 9 9 WC requires at least: 3.3 10 10 WC tested up to: 10.1 … … 71 71 72 72 == Changelog == 73 74 = 1.10.33 - 2026-03-25 = 75 * NEW: YOOtheme Pro page builder support — alt text now syncs correctly on YOOtheme-built pages 73 76 74 77 = 1.10.30 - 2026-03-06 = -
alttext-ai/trunk/atai.php
r3485945 r3492892 16 16 * Plugin URI: https://alttext.ai/product 17 17 * Description: Automatically generate image alt text with AltText.ai. 18 * Version: 1.10.3 218 * Version: 1.10.33 19 19 * Author: AltText.ai 20 20 * Author URI: https://alttext.ai … … 34 34 * Current plugin version. 35 35 */ 36 define( 'ATAI_VERSION', '1.10.3 2' );36 define( 'ATAI_VERSION', '1.10.33' ); 37 37 38 38 /** -
alttext-ai/trunk/changelog.txt
r3485945 r3492892 1 1 *** AltText.ai Changelog *** 2 3 2026-03-25 - version 1.10.33 4 * NEW: YOOtheme Pro page builder support — alt text now syncs correctly on YOOtheme-built pages 2 5 3 6 2026-03-18 - version 1.10.32 -
alttext-ai/trunk/includes/class-atai-post.php
r3485945 r3492892 475 475 $num_alttext_generated += $product_response['num_alttext_generated']; 476 476 } 477 477 478 // Process page builder images (YOOtheme, etc.) 479 $builder_response = $this->process_builder_images( $post_id, $overwrite, $process_external, $keywords ); 480 $total_images_found += $builder_response['total_images_found']; 481 $num_alttext_generated += $builder_response['num_alttext_generated']; 482 if ( $builder_response['no_credits'] ) { 483 $no_credits = true; 484 } 485 478 486 ATAI_Elementor_Sync::$paused = false; 479 487 480 if ( !empty($updated_content) ) { 488 // Skip HTML content update if a builder already saved post_content 489 if ( !empty($updated_content) && ! $builder_response['saved_post_content'] ) { 481 490 wp_update_post( array( 482 491 'ID' => $post_id, … … 510 519 'num_alttext_generated' => $num_alttext_generated, 511 520 'no_credits' => $no_credits, 521 ); 522 } 523 524 /** 525 * Process images in page builder content. 526 * 527 * Iterates registered builder handlers, extracts images from their data, 528 * generates alt text, and updates the builder's stored content. 529 * 530 * @since 1.10.33 531 * @param int $post_id 532 * @param bool $overwrite 533 * @param bool $process_external 534 * @param array $keywords 535 * @return array 536 */ 537 private function process_builder_images( $post_id, $overwrite, $process_external, $keywords ) { 538 $handlers = apply_filters( 'atai_page_builder_handlers', array( 539 'yootheme' => 'ATAI_Builder_YooTheme', 540 ) ); 541 542 $total_images_found = 0; 543 $num_alttext_generated = 0; 544 $no_credits = false; 545 $saved_post_content = false; 546 $atai_attachment = new ATAI_Attachment(); 547 548 foreach ( $handlers as $key => $handler_class ) { 549 if ( ! class_exists( $handler_class ) ) { 550 continue; 551 } 552 553 if ( ! method_exists( $handler_class, 'is_active' ) || ! $handler_class::is_active() ) { 554 continue; 555 } 556 557 // Validate handler implements the full contract before instantiation 558 $required_methods = array( 'has_builder_content', 'extract_images', 'update_image_alt', 'save', 'uses_post_content' ); 559 $valid = true; 560 foreach ( $required_methods as $method ) { 561 if ( ! method_exists( $handler_class, $method ) ) { 562 $valid = false; 563 break; 564 } 565 } 566 if ( ! $valid ) { 567 continue; 568 } 569 570 $handler = new $handler_class(); 571 572 if ( ! $handler->has_builder_content( $post_id ) ) { 573 continue; 574 } 575 576 $images = $handler->extract_images( $post_id ); 577 $handler_modified = false; 578 579 foreach ( $images as $image ) { 580 $total_images_found++; 581 $alt_text = false; 582 $should_generate = false; 583 584 if ( $image['attachment_id'] ) { 585 $alt_text = get_post_meta( $image['attachment_id'], '_wp_attachment_image_alt', true ); 586 587 if ( $overwrite || empty( $alt_text ) ) { 588 $should_generate = true; 589 $alt_text = $atai_attachment->generate_alt( $image['attachment_id'], null, array( 'keywords' => $keywords ) ); 590 } 591 } elseif ( $process_external ) { 592 $alt_text = $image['current_alt']; 593 594 if ( $overwrite || empty( $alt_text ) ) { 595 $should_generate = true; 596 $alt_text = $atai_attachment->generate_alt( null, $image['url'], array( 'keywords' => $keywords ) ); 597 } 598 } 599 600 if ( empty( $alt_text ) || ! is_string( $alt_text ) ) { 601 continue; 602 } 603 604 if ( $alt_text === 'insufficient_credits' ) { 605 $no_credits = true; 606 break; 607 } 608 609 if ( $should_generate ) { 610 $num_alttext_generated++; 611 } 612 613 // Update alt text in builder data (even if not newly generated, 614 // sync the media library alt text into the builder) 615 if ( $handler->update_image_alt( $post_id, $image['ref'], $alt_text ) ) { 616 $handler_modified = true; 617 } 618 } 619 620 if ( $handler_modified ) { 621 if ( $handler->save( $post_id ) && $handler->uses_post_content() ) { 622 $saved_post_content = true; 623 } 624 } 625 626 if ( $no_credits ) { 627 break; 628 } 629 } 630 631 return array( 632 'total_images_found' => $total_images_found, 633 'num_alttext_generated' => $num_alttext_generated, 634 'no_credits' => $no_credits, 635 'saved_post_content' => $saved_post_content, 512 636 ); 513 637 } -
alttext-ai/trunk/includes/class-atai-utility.php
r3485046 r3492892 174 174 if ( empty( $src ) || ! is_string( $src ) ) { 175 175 return null; 176 } 177 178 // Convert builder-relative paths (wp-content/..., images/...) to absolute URLs 179 if ( substr( $src, 0, 10 ) === 'wp-content' || substr( $src, 0, 7 ) === 'images/' ) { 180 if ( strpos( $src, '..' ) !== false ) { 181 return null; 182 } 183 $src = trailingslashit( $home_url ) . $src; 176 184 } 177 185 -
alttext-ai/trunk/includes/class-atai.php
r3485046 r3492892 141 141 */ 142 142 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-atai-elementor-sync.php'; 143 144 // Page builder handlers 145 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/builders/class-atai-builder-yootheme.php'; 143 146 144 147 /**
Note: See TracChangeset
for help on using the changeset viewer.