Example #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);
 }
Example #2
0
    function axiom_post_type_show_meta_box()
    {
        global $post, $AXIOM_GLOBALS;
        $post_type = axiom_admin_get_current_post_type();
        $override_key = axiom_get_override_key($post_type, 'post_type');
        // Use nonce for verification
        echo '<input type="hidden" name="meta_box_post_nonce" value="' . esc_attr(wp_create_nonce(basename(__FILE__))) . '" />';
        echo '<input type="hidden" name="meta_box_post_type" value="' . esc_attr($post_type) . '" />';
        $custom_options = apply_filters('axiom_filter_post_load_custom_options', get_post_meta($post->ID, 'post_custom_options', true), $post_type, $post->ID);
        $mb = $AXIOM_GLOBALS['post_meta_box'];
        $post_options = array_merge($AXIOM_GLOBALS['options'], $mb['fields']);
        ?>
		
		<script type="text/javascript">
			jQuery(document).ready(function() {
				// Prepare global values for the review procedure
				AXIOM_GLOBALS['ajax_url']	= "<?php 
        echo admin_url('admin-ajax.php');
        ?>
";
				AXIOM_GLOBALS['ajax_nonce']	= "<?php 
        echo wp_create_nonce('ajax_nonce');
        ?>
";
			});
		</script>
		
		<?php 
        do_action('axiom_action_post_before_show_meta_box', $post_type, $post->ID);
        axiom_options_page_start(array('data' => $post_options, 'add_inherit' => true, 'show_page_layout' => false, 'override' => $override_key));
        foreach ($post_options as $id => $option) {
            if (!isset($option['override']) || !in_array($override_key, explode(',', $option['override']))) {
                continue;
            }
            $option = apply_filters('axiom_filter_post_show_custom_field_option', $option, $id, $post_type, $post->ID);
            $meta = isset($custom_options[$id]) ? apply_filters('axiom_filter_post_show_custom_field_value', $custom_options[$id], $option, $id, $post_type, $post->ID) : '';
            do_action('axiom_action_post_before_show_custom_field', $post_type, $post->ID, $option, $id, $meta);
            axiom_options_show_field($id, $option, $meta);
            do_action('axiom_action_post_after_show_custom_field', $post_type, $post->ID, $option, $id, $meta);
        }
        axiom_options_page_stop();
        do_action('axiom_action_post_after_show_meta_box', $post_type, $post->ID);
        ?>
		</div>
		<?php 
    }