web_dor_meta_save

The Business Responsive web dor meta save function.

Description

web_dor_meta_save( $post_id ); 

Parameters (1)

0. $post_id
The post id.

Usage

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

Defined (1)

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

/functions.php  
  1. function web_dor_meta_save($post_id) 
  2. // authentication checks 
  3.  
  4. // check user permissions 
  5. if (isset($_POST['post_type']) && $_POST['post_type'] == 'page') { 
  6. if (!current_user_can('edit_page', $post_id)) return $post_id; 
  7. } else { 
  8. if (!current_user_can('edit_post', $post_id)) return $post_id; 
  9.  
  10. // authentication passed, save data 
  11.  
  12. // var types 
  13. // single: _web_business_meta[var] 
  14. // array: _web_business_meta[var][] 
  15. // grouped array: _web_business_meta[var_group][0][var_1], _web_business_meta[var_group][0][var_2] 
  16.  
  17. $current_data = get_post_meta($post_id, '_web_business_meta', TRUE); 
  18. if(isset($_POST['_web_business_meta'])) 
  19. $new_data = $_POST['_web_business_meta']; 
  20.  
  21. web_dor_meta_clean($new_data); 
  22.  
  23. if ($current_data) { 
  24. if (is_null($new_data)) delete_post_meta($post_id, '_web_business_meta'); 
  25. else update_post_meta($post_id, '_web_business_meta', $new_data); 
  26. } elseif (!is_null($new_data)) { 
  27. add_post_meta($post_id, '_web_business_meta', $new_data, TRUE); 
  28.  
  29. return $post_id;