Skip to content

Instantly share code, notes, and snippets.

@ben72
Created April 10, 2021 07:16
Show Gist options
  • Save ben72/b98eda2c357b740de1e38a4aa818a8d6 to your computer and use it in GitHub Desktop.
Save ben72/b98eda2c357b740de1e38a4aa818a8d6 to your computer and use it in GitHub Desktop.
WPAllExport - Copy Google Shopping feed to Facebook shopping feed after finished export
/* Copy google shopping feed to facebook shopping feed */
add_action('pmxe_after_export', 'copy_export_file', 10, 2);
function copy_export_file ($export_id, $exportObj) {
/* Only do this for my specific export with id == 36 */
if($export_id != 36) { // CHANGE 36 TO YOUR SPECIFIC export_id
return;
}
// Check whether "Secure Mode" is enabled in All Export > Settings
$is_secure_export = PMXE_Plugin::getInstance()-> getOption('secure');
if ( !$is_secure_export ) {
// Get filepath when 'Secure Mode' is off.
$filepath = get_attached_file($exportObj->attch_id);
} else {
// Get filepath with 'Secure Mode' on.
$filepath = wp_all_export_get_absolute_path($exportObj->options['filepath']);
}
// Change filename extension from txt to csv
$new_filepath = str_replace("txt", "csv", $filepath);
// Copy file to new csv extension
copy( $filepath, $new_filepath );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment