Skip to content

Instantly share code, notes, and snippets.

@salcode
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salcode/401f727694ae95d728aa to your computer and use it in GitHub Desktop.
Save salcode/401f727694ae95d728aa to your computer and use it in GitHub Desktop.
A bare minimum example of leveraging the Iron Ajax plugin. Recommended locations for this code in order by my personal preference: mu-plugins file, a plugin, or the theme functions.php.
/* Modify the entries_count
* i.e. the number of entries that need
* to be processed
*/
add_filter(
'fe_ajx_iron_ajax_entries_count',
'examp_iajx_entries_count'
);
function examp_iajx_entries_count( $count ) {
// generally you'll perform some lookup
// to determine the total number of entries
// $count = my_function_to_determine_count();
return $count;
}
/* Process each entry
*/
add_filter(
'fe_ajx_iron_ajax_process',
'examp_iajx_process',
10, 3
);
function examp_iajx_process( $response, $index, $persist ) {
// add code here to process based on $index
// e.g. process the row at $index in a csv
// my_function_to_process_one_item( $index );
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment