Beispiel #1
0
 function axiom_options_is_used()
 {
     $used = false;
     if (is_admin()) {
         if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'axiom_options_save' || $_REQUEST['action'] == 'axiom_options_import')) {
             // AJAX: Save or Import Theme Options
             $used = true;
         } else {
             if (axiom_strpos($_SERVER['REQUEST_URI'], 'axiom_options') !== false) {
                 // Edit Theme Options
                 $used = true;
             } else {
                 if (axiom_strpos($_SERVER['REQUEST_URI'], 'post-new.php') !== false || axiom_strpos($_SERVER['REQUEST_URI'], 'post.php') !== false) {
                     // Create or Edit Post (page, product, ...)
                     $post_type = axiom_admin_get_current_post_type();
                     if (empty($post_type)) {
                         $post_type = 'post';
                     }
                     $used = axiom_get_override_key($post_type, 'post_type') != '';
                 } else {
                     if (axiom_strpos($_SERVER['REQUEST_URI'], 'edit-tags.php') !== false) {
                         // Edit Taxonomy
                         $inheritance = axiom_get_theme_inheritance();
                         if (!empty($inheritance)) {
                             $post_type = axiom_admin_get_current_post_type();
                             if (empty($post_type)) {
                                 $post_type = 'post';
                             }
                             foreach ($inheritance as $k => $v) {
                                 if (!empty($v['taxonomy'])) {
                                     foreach ($v['taxonomy'] as $tax) {
                                         if (axiom_strpos($_SERVER['REQUEST_URI'], 'taxonomy=' . $tax) !== false && in_array($post_type, $v['post_type'])) {
                                             $used = true;
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         if (isset($_POST['meta_box_taxonomy_nonce'])) {
                             // AJAX: Save taxonomy
                             $used = true;
                         }
                     }
                 }
             }
         }
     } else {
         $used = axiom_get_theme_option("allow_editor") == 'yes' && (is_single() && current_user_can('edit_posts', get_the_ID()) || is_page() && current_user_can('edit_pages', get_the_ID()));
     }
     return apply_filters('axiom_filter_theme_options_is_used', $used);
 }
Beispiel #2
0
 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));
     }
 }
Beispiel #3
0
 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);
     }
 }