Last active
March 27, 2023 18:15
-
-
Save arunbasillal/b2fa9557a170d0c99eaba4b34d9198f9 to your computer and use it in GitHub Desktop.
Run Image Attributes Pro Bulk Updater Programmatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Load WordPress. | |
require( 'wp-load.php' ); | |
// Run the Bulk Updater | |
prefix_iap_run_bulk_updater(); | |
/** | |
* Run Image Attributes Pro Bulk Updater Programmatically | |
* | |
* Note: Requires Image Attributes Pro version 4.0 or above. | |
* | |
* @param (int) $batch_size Defines the number of images that will be processed | |
* in a single call to the function. Higher batch sizes can lead to PHP time outs. | |
* | |
* @link https://imageattributespro.com/run-bulk-updater-programmatically/ | |
* @author Arun Basil Lal | |
*/ | |
function prefix_iap_run_bulk_updater( $batch_size = 20 ) { | |
// Return while call is made from ajax. | |
if ( wp_doing_ajax() ) { | |
return; | |
} | |
// Return if Image Attributes Pro is not active. | |
if ( ! function_exists( 'iaff_is_pro' ) || ! iaff_is_pro() ) { | |
return; | |
} | |
// Return if all images are updated. | |
if ( iaff_count_remaining_images() === 0 ) { | |
return; | |
} | |
/** | |
* Action hook that is fired at the start of the | |
* Bulk Updater before updating any image. | |
* | |
* @link https://imageattributespro.com/codex/iaff_before_bulk_updater/ | |
*/ | |
do_action('iaff_before_bulk_updater'); | |
// Process one batch of images. | |
iaffpro_bu_run_bulk_updater( $batch_size ); | |
/** | |
* Action hook that is fired at the end of the | |
* Bulk Updater after updating all images. | |
* | |
* @link https://imageattributespro.com/codex/iaff_after_bulk_updater/ | |
*/ | |
do_action('iaff_after_bulk_updater'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment