Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wp_insert_post($post_id, $post = null){
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
- return $post_id;
- if( !current_user_can( 'edit_post', $post_id ) ) // check permissions
- return $post_id;
- if (($post->post_type == "create_afflink") || ($post->post_type == "sales_pages") || ($post->post_type == "squeeze_pages") || ($post->post_type == "post") || ($post->post_type == "page")){
- // Loop through the POST data
- foreach ($this->meta_fields as $key) {
- if ( defined('DOING_AJAX') ) {
- return ;
- } else {
- $value = @$_POST[$key];
- if ( isset($_POST[$field]) || empty($value)) {
- delete_post_meta($post_id, $key);
- continue;
- }
- // If value is a string it should be unique
- if (!is_array($value)) {
- // Update meta
- if (!update_post_meta($post_id, $key, $value) && isset($_POST[$field]) && $_POST[$field] != '') {
- add_post_meta($post_id, $key, $value);
- }
- } else {
- // If passed along is an array, we should remove all previous data
- wsm_log_debug('$value is an array, so removing all previous data...',true,false);
- wsm_log_debug_array($value,true);
- delete_post_meta($post_id, $key);
- wsm_log_debug('Removed all custom field data from post id: '.$post_id.' for the key '.$key,true,false);
- // Loop through the array adding new values to the post meta as different entries with the same name
- foreach ($value as $entry){
- wsm_log_debug('Beginning foreach loop to save data for $value as $entry...',true,false);
- //if (!empty($entry))
- add_post_meta($post_id, $key, $entry);
- wsm_log_debug('Successfully updated custom field data for post id: '.$post_id.' for the key '.$key.' with the $value as $entry '.$entry,true,false);
- wsm_log_debug('Returning to the beginning of data save loop or ending...',true,true);
- }
- wsm_log_debug('Ended array custom field data save loop for post id: '.$post_id.' for the key '.$key.'. Custom field data for key is as follows:',true,false);
- $custom = get_post_custom($post_id);
- $contentdownloads = $custom["wsm-content-downloads"];
- wsm_log_debug_array($contentdownloads,true);
- wsm_log_debug('Ending data saving operation and reloading the page...',true,true);
- }
- }
- }
- }//End Check for post type
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement