Skip to content

Instantly share code, notes, and snippets.

View nickpelton's full-sized avatar

Nick Pelton nickpelton

  • Rocketgenius/Gravityforms
  • Minneapolis, MN
View GitHub Profile
@ScottGarrison
ScottGarrison / custom_import_hook
Last active September 15, 2017 17:12
Specific use case wordpress image upload hook. Used to match image file names with csv file row values. Also uses WP Real Media Library to move files into specific sections depending on the image
function ph_image_upload_modification( $attachment_ID ) {
// set up file name
$filename = $_REQUEST['name'];
$withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);
$withoutExt = str_replace(array('-','_'), ' ', $withoutExt);
// set line endings for csv file
ini_set('auto_detect_line_endings',TRUE);