web_business_meta_save

The Business Responsive web business meta save function.

Description

web_business_meta_save( $post_id ); 

Parameters (1)

0. $post_id
The post id.

Usage

  1. if ( !function_exists( 'web_business_meta_save' ) ) { 
  2. require_once '/custom/meta-functions.php'; 
  3.  
  4. // The post id. 
  5. $post_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = web_business_meta_save($post_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/custom/meta-functions.php  
  1. function web_business_meta_save($post_id)  
  2. // authentication checks 
  3.  
  4. // make sure data came from our meta box 
  5. if (!wp_verify_nonce($_POST['web_business_meta_noncename'], __FILE__)) return $post_id; 
  6.  
  7. // check user permissions 
  8. if ($_POST['post_type'] == 'page')  
  9. if (!current_user_can('edit_page', $post_id)) return $post_id; 
  10. else  
  11. if (!current_user_can('edit_post', $post_id)) return $post_id; 
  12.  
  13. // authentication passed, save data 
  14.  
  15. // var types 
  16. // single: _web_business_meta[var] 
  17. // array: _web_business_meta[var][] 
  18. // grouped array: _web_business_meta[var_group][0][var_1], _web_business_meta[var_group][0][var_2] 
  19.  
  20. $current_data = get_post_meta($post_id, '_web_business_meta', TRUE);  
  21.  
  22. $new_data = $_POST['_web_business_meta']; 
  23.  
  24.  
  25. if ($current_data)  
  26. if (is_null($new_data)) delete_post_meta($post_id, '_web_business_meta'); 
  27. else update_post_meta($post_id, '_web_business_meta', $new_data); 
  28. elseif (!is_null($new_data)) 
  29. add_post_meta($post_id, '_web_business_meta', $new_data, TRUE); 
  30.  
  31. return $post_id;