Advertisement
dusko474

Untitled

Oct 15th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1.  
  2. /** Save new fields for variations */
  3. function save_variation_fields( $variation_id) {
  4.  
  5.  
  6.     $text_field = sanitize_text_field( $_POST['_model_field'][$variation_id] );
  7.  
  8.     if( ! empty( $text_field ) ) {
  9.         update_post_meta( $variation_id, '_model_field', esc_attr( $text_field ) );
  10.     }
  11.  
  12.     if( ! empty( $text_field ) ) {
  13.         $text_field = sanitize_text_field( $_POST['_focal_field'][$variation_id] );
  14.         update_post_meta( $variation_id, '_focal_field', esc_attr( $text_field ) );
  15.         }
  16.     if( ! empty( $text_field ) ) {
  17.         $text_field = sanitize_text_field( $_POST['_maximum_aperture'][$variation_id] );
  18.         update_post_meta( $variation_id, '_maximum_aperture', esc_attr( $text_field ) );
  19.     }
  20.     if( ! empty( $text_field ) ) {
  21.         $text_field = sanitize_text_field( $_POST['_coverage'][$variation_id] );
  22.         update_post_meta( $variation_id, '_coverage', esc_attr( $text_field ) );
  23.     }
  24.     if( ! empty( $text_field ) ) {
  25.         $text_field = sanitize_text_field( $_POST['_optical_construction'][$variation_id] );
  26.         update_post_meta( $variation_id, '_optical_construction', esc_attr( $text_field ) );
  27.     }
  28.     if( ! empty( $text_field ) ) {
  29.        $text_field = stripslashes( $_POST['_aperture_range'][$variation_id] );
  30.         update_post_meta( $variation_id, '_aperture_range', esc_attr( $text_field ) );
  31.     }
  32.  
  33.     $text_field2 = stripslashes( $_POST['_diaphragm_blades'][$variation_id] );
  34.     if( ! empty( $text_field2 ) ) {
  35.         update_post_meta($variation_id, '_maximum_aperture', esc_attr($text_field2));
  36.     }
  37.  
  38.     $text_field = stripslashes( $_POST['_coating'][$variation_id] );
  39.     if( ! empty( $text_field ) ) {
  40.         update_post_meta( $variation_id, '_coating', esc_attr( $text_field ) );
  41.  
  42.     }
  43.         $text_field = stripslashes( $_POST['_minimum_fdistance'][$variation_id] );
  44.     if( ! empty( $text_field ) ) {
  45.         update_post_meta( $variation_id, '_minimum_fdistance', esc_attr( $text_field ) );
  46.     }
  47.     if( ! empty( $text_field ) ) {
  48.         $text_field = stripslashes( $_POST['_filter_size'][$variation_id] );
  49.         update_post_meta( $variation_id, '_filter_size', esc_attr( $text_field ) );
  50.     }
  51.     if( ! empty( $text_field ) ) {
  52.         $text_field = stripslashes( $_POST['_lens_hood'][$variation_id] );
  53.         update_post_meta( $variation_id, '_lens_hood', esc_attr( $text_field ) );
  54.     }
  55.     if( ! empty( $text_field ) ) {
  56.         $text_field = stripslashes($_POST['_maximum_diameter'][$variation_id]);
  57.         update_post_meta($variation_id, '_maximum_diameter', esc_attr($text_field));
  58.     }
  59.  
  60.     $hidden = $_POST['_hidden_field'][$variation_id];
  61.     if( ! empty( $hidden ) ) {
  62.         update_post_meta( $variation_id, '_hidden_field', esc_attr( $hidden ) );
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement