Esempio n. 1
0
 function axiom_reviews_accept_user_marks()
 {
     global $_REQUEST;
     if (!wp_verify_nonce($_REQUEST['nonce'], 'ajax_nonce')) {
         die;
     }
     $response = array('error' => '');
     $post_id = $_REQUEST['post_id'];
     if ($post_id > 0) {
         $marks = $_REQUEST['marks'];
         $users = $_REQUEST['users'];
         $avg = axiom_reviews_get_average_rating($marks);
         update_post_meta($post_id, 'reviews_marks2', axiom_reviews_marks_to_save($marks));
         update_post_meta($post_id, 'reviews_avg2', axiom_reviews_marks_to_save($avg));
         update_post_meta($post_id, 'reviews_users', $users);
     } else {
         $response['error'] = __('Bad post ID', 'axiom');
     }
     echo json_encode($response);
     die;
 }
Esempio n. 2
0
 function axiom_options_merge_new_values(&$post_options, &$custom_options, &$post_data, $mode, $override)
 {
     $need_save = false;
     foreach ($post_options as $id => $field) {
         if ($override != 'general' && (!isset($field['override']) || !in_array($override, explode(',', $field['override'])))) {
             continue;
         }
         if (!isset($field['std'])) {
             continue;
         }
         if ($override != 'general' && !isset($post_data[$id . '_inherit'])) {
             continue;
         }
         if ($id == 'reviews_marks' && $mode == 'export') {
             continue;
         }
         $need_save = true;
         if ($mode == 'save' || $mode == 'export') {
             if ($override != 'general' && axiom_is_inherit_option($post_data[$id . '_inherit'])) {
                 $new = '';
             } else {
                 if (isset($post_data[$id])) {
                     // Prepare specific (combined) fields
                     if (!empty($field['subset'])) {
                         $sbs = $post_data[$field['subset']];
                         $field['val'][$sbs] = $post_data[$id];
                         $post_data[$id] = $field['val'];
                     }
                     if ($field['type'] == 'socials') {
                         if (!empty($field['cloneable'])) {
                             foreach ($post_data[$id] as $k => $v) {
                                 $post_data[$id][$k] = array('url' => stripslashes($v), 'icon' => stripslashes($post_data[$id . '_icon'][$k]));
                             }
                         } else {
                             $post_data[$id] = array('url' => stripslashes($post_data[$id]), 'icon' => stripslashes($post_data[$id . '_icon']));
                         }
                     } else {
                         if (is_array($post_data[$id])) {
                             foreach ($post_data[$id] as $k => $v) {
                                 $post_data[$id][$k] = stripslashes($v);
                             }
                         } else {
                             $post_data[$id] = stripslashes($post_data[$id]);
                         }
                     }
                     // Add cloneable index
                     if (!empty($field['cloneable'])) {
                         $rez = array();
                         foreach ($post_data[$id] as $k => $v) {
                             $rez[$post_data[$id . '_numbers'][$k]] = $v;
                         }
                         $post_data[$id] = $rez;
                     }
                     $new = $post_data[$id];
                     // Post type specific data handling
                     if ($id == 'reviews_marks') {
                         $new = join(',', $new);
                         if (($avg = axiom_reviews_get_average_rating($new)) > 0) {
                             $new = axiom_reviews_marks_to_save($new);
                         }
                     }
                 } else {
                     $new = $field['type'] == 'checkbox' ? 'false' : '';
                 }
             }
         } else {
             $new = $field['std'];
         }
         $custom_options[$id] = $new !== '' || $override == 'general' ? $new : 'inherit';
     }
     return $need_save;
 }