Skip to content

Commit

Permalink
Merge pull request #8 from arunbasillal/branch-3.2
Browse files Browse the repository at this point in the history
Branch 3.2
  • Loading branch information
arunbasillal authored Apr 27, 2022
2 parents 211f9e5 + ddbb5d4 commit a823c92
Show file tree
Hide file tree
Showing 4 changed files with 681 additions and 6 deletions.
22 changes: 20 additions & 2 deletions admin/iaff_image-attributes-from-filename-do.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,30 @@ function iaff_bulk_updater_skip_image() {
$counter = get_option( 'iaff_bulk_updater_counter' );
$counter = intval ( $counter );

global $wpdb;
$image = $wpdb->get_row("SELECT ID, post_parent FROM {$wpdb->prefix}posts WHERE post_type='attachment' AND post_mime_type LIKE 'image%' ORDER BY post_date LIMIT 1 OFFSET {$counter}");

/**
* Die if no image.
* This happens if there are no more images to skip.
*/
if ( $image === NULL ) {
$response = array(
'message' => __( 'No more images to skip.', 'auto-image-attributes-from-filename-with-bulk-updater' ),
'remaining_images' => iaff_count_remaining_images( true ),
);
wp_send_json( $response );
}

// Extract the image url
$image_url = wp_get_attachment_url($image->ID);

// Increment counter and update it
$counter++;
update_option( 'iaff_bulk_updater_counter', $counter );

$response = array(
'message' => __( 'One image skipped.', 'auto-image-attributes-from-filename-with-bulk-updater' ),
'message' => __( 'Image skipped: ', 'auto-image-attributes-from-filename-with-bulk-updater' ) . '<a href="'. get_edit_post_link( $image->ID ) .'">'. $image_url .'</a>',
'remaining_images' => iaff_count_remaining_images( true ),
);
wp_send_json( $response );
Expand Down Expand Up @@ -445,7 +463,7 @@ function iaff_do_bulk_updater(iaff_test=false) {
};

$.post(ajaxurl, data, function (response) {
$('#bulk-updater-log').append('<p class="iaff-green"><span class="dashicons dashicons-yes"></span>' + response.message + '</p>');
$('#bulk-updater-log').append('<p class="iaff-red"><span class="dashicons dashicons-remove"></span> ' + response.message + '</p>');
$('#bulk-updater-log').append('<p>Number of Images Remaining: ' + response.remaining_images + '</p>');
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
});
Expand Down
4 changes: 2 additions & 2 deletions iaff_image-attributes-from-filename.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Automatically Add Image Title, Image Caption, Description And Alt Text From Image Filename. Since this plugin includes a bulk updater this can update both existing images in the Media Library and new images.
* Author: Arun Basil Lal
* Author URI: https://imageattributespro.com/?utm_source=plugin-header&utm_medium=author-uri
* Version: 3.1
* Version: 3.2
* Text Domain: auto-image-attributes-from-filename-with-bulk-updater
* Domain Path: /languages
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Expand Down Expand Up @@ -67,7 +67,7 @@
* @since 1.3
*/
if ( ! defined( 'IAFF_VERSION_NUM' ) ) {
define( 'IAFF_VERSION_NUM', '3.1' );
define( 'IAFF_VERSION_NUM', '3.2' );
}

/**
Expand Down
Loading

0 comments on commit a823c92

Please sign in to comment.