Skip to content

Instantly share code, notes, and snippets.

@anthonycole
Created October 8, 2010 10:30
Show Gist options
  • Save anthonycole/616605 to your computer and use it in GitHub Desktop.
Save anthonycole/616605 to your computer and use it in GitHub Desktop.
<?php
function woo_ecommerce_meta_save( $post_id ){
// Verify this came from the our screen and with proper authorization
if ( !wp_verify_nonce( $_POST['woo_ecomm_noncename'], plugin_basename('woo_ecomm_product') )) {
return $post_id;
}
// Verify if this is an auto save routine.
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
// Check permissions
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) )
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ) )
return $post_id;
}
// Good to go
global $post;
update_post_meta( $post->ID, 'variations', $_POST['woo_variation'] );
update_post_meta( $post->ID, 'featured_product', $_POST['featured_product'] );
// our file uploader, wee!
var_dump($_FILES);
foreach($_POST['woo_variation'] as $index => $variation ) {
if($variation['type'] == 'Virtual' && $_FILES['woo_variation'][$index]['uploaded_file']['size'] != 0) {
$variation['upload'] == '';
$uploadpath = WP_CONTENT_DIR . '/uploads/woo-ecommerce/' . basename($_FILES['woo_variation'][$index]['uploaded_file']['name']);
die( $uploadpath );
move_uploaded_file( $_FILES['woo_variation'][$index]['uploaded_file']['tmp_name'], $uploadpath );
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment