function axiom_options_save() { global $AXIOM_GLOBALS; if (!wp_verify_nonce($_POST['nonce'], 'ajax_nonce')) { die; } $mode = $_POST['mode']; $override = $_POST['override'] == '' ? 'general' : $_POST['override']; $options = $AXIOM_GLOBALS['options']; if ($mode == 'save') { parse_str($_POST['data'], $post_data); } else { if ($mode == 'export') { parse_str($_POST['data'], $post_data); if (!empty($AXIOM_GLOBALS['post_meta_box']['fields'])) { $options = axiom_array_merge($AXIOM_GLOBALS['options'], $AXIOM_GLOBALS['post_meta_box']['fields']); } } else { $post_data = array(); } } $custom_options = array(); axiom_options_merge_new_values($options, $custom_options, $post_data, $mode, $override); if ($mode == 'export') { $name = trim(chop($_POST['name'])); $name2 = isset($_POST['name2']) ? trim(chop($_POST['name2'])) : ''; $key = $name == '' ? $name2 : $name; $export = get_option('axiom_options_' . $override, array()); $export[$key] = $custom_options; if ($name != '' && $name2 != '') { unset($export[$name2]); } update_option('axiom_options_' . $override, $export); $file = axiom_get_file_dir('core/core.options/core.options.txt'); $url = axiom_get_file_url('core/core.options/core.options.txt'); $export = serialize($custom_options); axiom_fpc($file, $export); $response = array('error' => '', 'data' => $export, 'link' => $url); echo json_encode($response); } else { update_option('axiom_options', apply_filters('axiom_filter_save_options', $custom_options, $override)); } die; }
function axiom_post_type_save_options($post_id) { // verify nonce if (!isset($_POST['meta_box_post_nonce']) || !wp_verify_nonce($_POST['meta_box_post_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } $post_type = isset($_POST['meta_box_post_type']) ? $_POST['meta_box_post_type'] : $_POST['post_type']; $override_key = axiom_get_override_key($post_type, 'post_type'); // check permissions $capability = 'page'; $post_types = get_post_types(array('name' => $post_type), 'objects'); if (!empty($post_types)) { foreach ($post_types as $type) { $capability = $type->capability_type; break; } } if (!current_user_can('edit_' . $capability, $post_id)) { return $post_id; } global $AXIOM_GLOBALS; $custom_options = array(); $post_options = array_merge($AXIOM_GLOBALS['options'], $AXIOM_GLOBALS['post_meta_box']['fields']); if (axiom_options_merge_new_values($post_options, $custom_options, $_POST, 'save', $override_key)) { update_post_meta($post_id, 'post_custom_options', apply_filters('axiom_filter_post_save_custom_options', $custom_options, $post_type, $post_id)); } }
function axiom_taxonomy_save_custom_fields($term_id = 0) { global $AXIOM_GLOBALS; // verify nonce if (!isset($_POST['meta_box_taxonomy_nonce']) || !wp_verify_nonce($_POST['meta_box_taxonomy_nonce'], basename(__FILE__))) { return $term_id; } $tax_type = isset($_POST['meta_box_taxonomy_type']) ? $_POST['meta_box_taxonomy_type'] : 'category'; $override_key = axiom_get_override_key($tax_type, 'taxonomy'); $custom_options = axiom_taxonomy_load_custom_options($term_id, $tax_type); if (axiom_options_merge_new_values($AXIOM_GLOBALS['options'], $custom_options, $_POST, 'save', $override_key)) { axiom_taxonomy_save_custom_options($term_id, $tax_type, $custom_options); } }