Changeset 3467709
- Timestamp:
- 02/23/2026 12:45:16 PM (7 days ago)
- Location:
- alt-text-generator
- Files:
-
- 15 added
- 4 edited
-
tags/1.8.6 (added)
-
tags/1.8.6/assets (added)
-
tags/1.8.6/assets/alttextgenerator-logo.png (added)
-
tags/1.8.6/build (added)
-
tags/1.8.6/build/index-rtl.css (added)
-
tags/1.8.6/build/index.asset.php (added)
-
tags/1.8.6/build/index.css (added)
-
tags/1.8.6/build/index.js (added)
-
tags/1.8.6/build/media-button.asset.php (added)
-
tags/1.8.6/build/media-button.js (added)
-
tags/1.8.6/includes (added)
-
tags/1.8.6/includes/class-uninstall-feedback.php (added)
-
tags/1.8.6/index.php (added)
-
tags/1.8.6/readme.txt (added)
-
tags/1.8.6/uninstall.php (added)
-
trunk/includes/class-uninstall-feedback.php (modified) (9 diffs)
-
trunk/index.php (modified) (38 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
alt-text-generator/trunk/includes/class-uninstall-feedback.php
r3390619 r3467709 1 1 <?php 2 if (!class_exists('WY_AltTextGenerator_Uninstall_Feedback')) : 2 if ( ! defined( 'ABSPATH' ) ) exit; 3 if (!class_exists('Atgai_Uninstall_Feedback')) : 3 4 4 5 /** … … 7 8 * @package AltTextGenerator 8 9 */ 9 class WY_AltTextGenerator_Uninstall_Feedback {10 class Atgai_Uninstall_Feedback { 10 11 11 12 /** … … 179 180 $('#alt-text-generator-modal').on('click', 'a.review-and-deactivate', function (e) { 180 181 e.preventDefault(); 181 window.open("https://wordpress.org/support/plugin/alt-text-generator/ reviews/?filter=5#new-post", "_blank", "noopener,noreferrer");182 window.open("https://wordpress.org/support/plugin/alt-text-generator/#new-topic-0", "_blank", "noopener,noreferrer"); 182 183 window.location.href = deactivateLink; 183 184 }); … … 257 258 258 259 // Check nonce 259 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'atgai_uninstall_feedback_nonce')) {260 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'atgai_uninstall_feedback_nonce')) { 260 261 wp_send_json_error(array('message' => 'Nonce verification failed')); 261 262 wp_die(); … … 269 270 270 271 $allowed_reasons = array('used-it', 'could-not-understand', 'found-better-plugin', 'not-have-that-feature', 'is-not-working', 'other', 'none'); 271 $reason_id = sanitize_text_field( $_POST['reason_id']);272 $reason_id = sanitize_text_field(wp_unslash($_POST['reason_id'])); 272 273 273 274 if (!in_array($reason_id, $allowed_reasons, true)) { … … 279 280 $reason_info = ''; 280 281 if (isset($_POST['reason_info'])) { 281 $reason_info = sanitize_textarea_field( $_POST['reason_info']);282 $reason_info = sanitize_textarea_field(wp_unslash($_POST['reason_info'])); 282 283 // Limit length to prevent abuse 283 284 if (strlen($reason_info) > 1000) { … … 289 290 $server_software = ''; 290 291 if (isset($_SERVER['SERVER_SOFTWARE'])) { 291 $server_software = sanitize_text_field( $_SERVER['SERVER_SOFTWARE']);292 $server_software = sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE'])); 292 293 } 293 294 … … 308 309 'languages' => sanitize_text_field(implode(",", get_available_languages())), 309 310 'theme' => sanitize_text_field(wp_get_theme()->get('Name')), 310 'plugin_version' => sanitize_text_field( PLUGIN_VERSION),311 'plugin_version' => sanitize_text_field(ATGAI_PLUGIN_VERSION), 311 312 'multisite' => is_multisite() ? 'Yes' : 'No' 312 313 ); … … 331 332 332 333 // Initialize the uninstall feedback class 333 new WY_AltTextGenerator_Uninstall_Feedback();334 new Atgai_Uninstall_Feedback(); 334 335 335 336 endif; -
alt-text-generator/trunk/index.php
r3429595 r3467709 2 2 3 3 /** 4 * Plugin Name: Alt TextGenerator AI4 * Plugin Name: Alt Text Generator AI - Auto Generate & Bulk Update Alt Texts For Images 5 5 * Description: This plugin automatically identifies the images that don't have alt texts in your image library and will auto generate them using our AI Computer Vision model and bulk update them for you with a single click. 6 * Version: 1.8. 56 * Version: 1.8.6 7 7 * Author: WebToffee 8 8 * Author URI: https://www.webtoffee.com 9 * License: GPLv2 or later 10 * License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 11 */ 10 12 11 13 if (!defined('ABSPATH')) exit; 12 14 13 define(' PLUGIN_VERSION', '1.8.5');14 define('A PI_URL', 'https://api.alttextgenerator.ai/api');15 define('ATGAI_PLUGIN_VERSION', '1.8.6'); 16 define('ATGAI_API_URL', 'https://api.alttextgenerator.ai/api'); 15 17 //define('API_URL', 'http://localhost:4000/api'); 16 18 … … 34 36 wp_enqueue_script( 35 37 'atgai-plugin-main', 36 plugin_dir_url(__FILE__) . 'build/index.js?v=' . PLUGIN_VERSION,38 plugin_dir_url(__FILE__) . 'build/index.js?v=' . ATGAI_PLUGIN_VERSION, 37 39 $asset['dependencies'], 38 PLUGIN_VERSION,40 ATGAI_PLUGIN_VERSION, 39 41 true 40 42 ); … … 45 47 plugin_dir_url(__FILE__) . 'build/index.css', 46 48 array(), 47 PLUGIN_VERSION,49 ATGAI_PLUGIN_VERSION, 48 50 'all' 49 51 ); … … 56 58 plugin_dir_url(__FILE__) . 'build/media-button.js', 57 59 array(), 58 PLUGIN_VERSION,60 ATGAI_PLUGIN_VERSION, 59 61 true 60 62 ); … … 165 167 } 166 168 169 // Add settings link on plugin page 170 function atgai_plugin_action_links($links) { 171 $settings_link = '<a href="' . get_admin_url(null, 'admin.php?page=atgai-admin') . '">' . esc_html__('Settings', 'alt-text-generator') . '</a>'; 172 $support_link = '<a href="https://wordpress.org/support/plugin/alt-text-generator/#new-topic-0" target="_blank">' . esc_html__('Support', 'alt-text-generator') . '</a>'; 173 174 array_unshift($links, $support_link); 175 array_unshift($links, $settings_link); 176 177 return $links; 178 } 179 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'atgai_plugin_action_links'); 180 167 181 // AJAX action to fetch images 168 182 add_action('wp_ajax_atgai_fetch_images', 'atgai_fetch_images'); … … 178 192 179 193 // Check nonce 180 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'fetch_images_nonce')) {194 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'fetch_images_nonce')) { 181 195 wp_send_json_error(array('message' => 'Nonce verification failed')); 182 196 wp_die(); … … 184 198 185 199 // Sanitize the input, default to 'all' if no filter set 186 $filter = isset($_POST['filter']) ? sanitize_text_field( $_POST['filter']) : 'all';200 $filter = isset($_POST['filter']) ? sanitize_text_field(wp_unslash($_POST['filter'])) : 'all'; 187 201 188 202 // Validate the filter against allowed values … … 221 235 'post_status' => 'inherit', 222 236 'posts_per_page' => -1, 223 'meta_query' => array( 237 'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query 224 238 array( 225 239 'key' => '_wp_attachment_metadata', … … 279 293 280 294 // Check nonce 281 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'fetch_images_nonce')) {295 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'fetch_images_nonce')) { 282 296 wp_send_json_error(array('message' => 'Nonce verification failed')); 283 297 wp_die(); … … 350 364 351 365 // Check nonce 352 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'set_api_key_nonce')) {366 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'set_api_key_nonce')) { 353 367 wp_send_json_error(array('message' => 'Nonce verification failed')); 354 368 wp_die(); … … 356 370 357 371 // Validate API key input 358 if (!isset($_POST['api_key']) || empty(trim( $_POST['api_key']))) {372 if (!isset($_POST['api_key']) || empty(trim(sanitize_text_field(wp_unslash($_POST['api_key']))))) { 359 373 wp_send_json_error(array('message' => 'API key is required')); 360 374 wp_die(); 361 375 } 362 376 363 $api_key = sanitize_text_field( $_POST['api_key']);377 $api_key = sanitize_text_field(wp_unslash($_POST['api_key'])); 364 378 365 379 //verify api key 366 $response = wp_remote_get(A PI_URL . '/user', array(380 $response = wp_remote_get(ATGAI_API_URL . '/user', array( 367 381 'headers' => array('API-Key' => $api_key), 368 382 'timeout' => 30, … … 383 397 // get site domain 384 398 $site_url = get_site_url(); 385 $domain = parse_url($site_url, PHP_URL_HOST);399 $domain = wp_parse_url($site_url, PHP_URL_HOST); 386 400 387 401 // Sanitize domain … … 393 407 394 408 // set domain id 395 $domain_response = wp_remote_post(A PI_URL . '/website', array(409 $domain_response = wp_remote_post(ATGAI_API_URL . '/website', array( 396 410 'headers' => array( 397 411 'API-Key' => $api_key, … … 434 448 435 449 // Check nonce 436 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'set_api_key_nonce')) {450 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'set_api_key_nonce')) { 437 451 wp_send_json_error(array('message' => 'Nonce verification failed')); 438 452 wp_die(); … … 456 470 457 471 // Check nonce 458 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'set_api_key_nonce')) {472 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'set_api_key_nonce')) { 459 473 wp_send_json_error(array('message' => 'Nonce verification failed')); 460 474 wp_die(); … … 477 491 478 492 // Check nonce 479 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'set_api_key_nonce')) {493 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'set_api_key_nonce')) { 480 494 wp_send_json_error(array('message' => 'Nonce verification failed')); 481 495 wp_die(); … … 515 529 516 530 // Check nonce 517 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'set_api_key_nonce')) {531 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'set_api_key_nonce')) { 518 532 wp_send_json_error(array('message' => 'Nonce verification failed')); 519 533 wp_die(); … … 523 537 // Check if each parameter exists and update only if it does 524 538 if (isset($_POST['language'])) { 525 $language = sanitize_text_field( $_POST['language']);539 $language = sanitize_text_field(wp_unslash($_POST['language'])); 526 540 // Validate language against allowed values 527 541 $allowed_languages = array('English', 'Spanish', 'French', 'German', 'Italian', 'Portuguese', 'Dutch', 'Russian', 'Chinese', 'Japanese', 'Korean'); … … 533 547 if (isset($_POST['auto_generate'])) { 534 548 // Validate boolean value 535 $auto_generate = sanitize_text_field( $_POST['auto_generate']);549 $auto_generate = sanitize_text_field(wp_unslash($_POST['auto_generate'])); 536 550 if ($auto_generate === 'true' || $auto_generate === 'false') { 537 551 update_option('atgai_auto_generate', $auto_generate); … … 541 555 if (isset($_POST['enable_chatgpt_enhancement'])) { 542 556 // Validate boolean value 543 $enable_enhancement = sanitize_text_field( $_POST['enable_chatgpt_enhancement']);557 $enable_enhancement = sanitize_text_field(wp_unslash($_POST['enable_chatgpt_enhancement'])); 544 558 if ($enable_enhancement === 'true' || $enable_enhancement === 'false') { 545 559 update_option('atgai_enable_chatgpt_enhancement', $enable_enhancement); … … 548 562 549 563 if (isset($_POST['chatgpt_enhancement_prompt'])) { 550 $prompt = sanitize_textarea_field( $_POST['chatgpt_enhancement_prompt']);564 $prompt = sanitize_textarea_field(wp_unslash($_POST['chatgpt_enhancement_prompt'])); 551 565 // Limit prompt length to prevent abuse 552 566 if (strlen($prompt) <= 1000) { … … 577 591 578 592 // Check nonce 579 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'update_image_alt_text_nonce')) {593 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'update_image_alt_text_nonce')) { 580 594 wp_send_json_error(array('message' => 'Nonce verification failed'), 403); 581 595 wp_die(); … … 588 602 } 589 603 590 $image_id = intval( $_POST['image_id']);604 $image_id = intval(wp_unslash($_POST['image_id'])); 591 605 592 606 // Verify attachment exists and is an image … … 604 618 605 619 // Sanitize alt text 606 $new_alt_text = isset($_POST['alt_text']) ? sanitize_text_field( $_POST['alt_text']) : '';620 $new_alt_text = isset($_POST['alt_text']) ? sanitize_text_field(wp_unslash($_POST['alt_text'])) : ''; 607 621 608 622 // Limit alt text length to prevent abuse … … 638 652 if (!$domain_id) { 639 653 $site_url = get_site_url(); 640 $domain = parse_url($site_url, PHP_URL_HOST);641 $domain_response = wp_remote_post(A PI_URL . '/website', array(654 $domain = wp_parse_url($site_url, PHP_URL_HOST); 655 $domain_response = wp_remote_post(ATGAI_API_URL . '/website', array( 642 656 'headers' => array( 643 657 'API-Key' => $api_key, … … 697 711 // Get site domain 698 712 $site_url = get_site_url(); 699 $domain = parse_url($site_url, PHP_URL_HOST);713 $domain = wp_parse_url($site_url, PHP_URL_HOST); 700 714 701 715 // Get image details … … 724 738 725 739 // Send request to generate alt text 726 $response = wp_remote_post(A PI_URL . '/image', array(740 $response = wp_remote_post(ATGAI_API_URL . '/image', array( 727 741 'headers' => array( 728 742 'API-Key' => $api_key, … … 734 748 735 749 if (is_wp_error($response)) { 736 error_log('Alt Text Generator AI: Alt text generation failed - ' . $response->get_error_message());750 // error_log('Alt Text Generator AI: Alt text generation failed - ' . $response->get_error_message()); 737 751 return; 738 752 } … … 756 770 757 771 // Mark as updated in the API (non-blocking) 758 wp_remote_post(A PI_URL . '/image', array(772 wp_remote_post(ATGAI_API_URL . '/image', array( 759 773 'method' => 'PATCH', 760 774 'headers' => array( … … 769 783 )); 770 784 } else { 771 error_log('Alt Text Generator AI: Invalid response from API');785 // error_log('Alt Text Generator AI: Invalid response from API'); 772 786 } 773 787 } … … 784 798 785 799 // Check nonce 786 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'set_api_key_nonce')) {800 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'set_api_key_nonce')) { 787 801 wp_send_json_error(array('message' => 'Nonce verification failed')); 788 802 wp_die(); … … 790 804 791 805 $site_url = get_site_url(); 792 $domain = parse_url($site_url, PHP_URL_HOST);806 $domain = wp_parse_url($site_url, PHP_URL_HOST); 793 807 794 808 // Sanitize domain … … 812 826 813 827 // Check nonce 814 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'set_api_key_nonce')) {828 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'set_api_key_nonce')) { 815 829 wp_send_json_error(array('message' => 'Nonce verification failed')); 816 830 wp_die(); … … 823 837 } 824 838 825 $response = wp_remote_get(A PI_URL . '/user', array(839 $response = wp_remote_get(ATGAI_API_URL . '/user', array( 826 840 'headers' => array('API-Key' => $api_key), 827 841 'timeout' => 30, … … 871 885 872 886 // Check nonce 873 if (!isset($_POST['nonce']) || !wp_verify_nonce( $_POST['nonce'], 'generate_alt_text_nonce')) {887 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'generate_alt_text_nonce')) { 874 888 wp_send_json_error(array('message' => 'Nonce verification failed'), 403); 875 889 wp_die(); … … 883 897 884 898 // Get image ID 885 $image_id = intval( $_POST['image_id']);899 $image_id = intval(wp_unslash($_POST['image_id'])); 886 900 887 901 // Verify attachment exists and is an image … … 930 944 931 945 // Send request to generate alt text 932 $response = wp_remote_post(A PI_URL . '/image', array(946 $response = wp_remote_post(ATGAI_API_URL . '/image', array( 933 947 'headers' => array( 934 948 'API-Key' => $api_key, … … 981 995 $api_response_id = isset($response_data['imageInfo']['_id']) ? sanitize_text_field($response_data['imageInfo']['_id']) : ''; 982 996 if (!empty($api_response_id)) { 983 wp_remote_post(A PI_URL . '/image', array(997 wp_remote_post(ATGAI_API_URL . '/image', array( 984 998 'method' => 'PATCH', 985 999 'headers' => array( -
alt-text-generator/trunk/readme.txt
r3429595 r3467709 5 5 Tested up to: 6.9 6 6 Requires PHP: 5.6 7 Stable tag: 1.8. 57 Stable tag: 1.8.6 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 67 67 == Changelog == 68 68 69 = 1.8.6 = 70 [Fix] - Fixed coding standards and security issues flagged by WordPress Plugin Check. 71 69 72 = 1.8.5 = 70 73 Compatibility: Tested OK with WordPress version 6.9 … … 102 105 == Upgrade Notice == 103 106 104 = 1.8. 5=105 Compatibility: Tested OK with WordPress version 6.9 107 = 1.8.6 = 108 [Fix] - Fixed coding standards and security issues flagged by WordPress Plugin Check. -
alt-text-generator/trunk/uninstall.php
r3253129 r3467709 7 7 8 8 // Delete all plugin options 9 $ options_to_delete = array(9 $atgai_options_to_delete = array( 10 10 'atgai_api_key', 11 11 'atgai_language', … … 16 16 ); 17 17 18 foreach ($ options_to_delete as $option) {19 delete_option($ option);18 foreach ($atgai_options_to_delete as $atgai_option) { 19 delete_option($atgai_option); 20 20 } 21 21
Note: See TracChangeset
for help on using the changeset viewer.