function axiom_taxonomy_theme_setup() { $inheritance = axiom_get_theme_inheritance(); if (!empty($inheritance)) { $show_overriden = axiom_get_theme_option('show_overriden_taxonomies') == 'yes'; foreach ($inheritance as $k => $v) { // Set taxonomy actions if (!empty($v['taxonomy'])) { foreach ($v['taxonomy'] as $tax) { // Add the fields to the taxonomy, using our callback function add_action($tax . '_edit_form_fields', 'axiom_taxonomy_show_custom_fields', 10, 1); add_action($tax . '_add_form_fields', 'axiom_taxonomy_show_custom_fields', 10, 1); // Save the changes made on the taxonomy, using our callback function add_action('edited_' . $tax, 'axiom_taxonomy_save_custom_fields', 10, 1); add_action('created_' . $tax, 'axiom_taxonomy_save_custom_fields', 10, 1); // Extra column for taxonomies lists if ($show_overriden) { add_filter('manage_edit-' . $tax . '_columns', 'axiom_taxonomy_add_options_column', 9); add_filter('manage_' . $tax . '_custom_column', 'axiom_taxonomy_fill_options_column', 9, 3); } } } } } }
function axiom_get_taxonomy_tags_by_post_type($value) { $key = ''; $inheritance = axiom_get_theme_inheritance(); if (!empty($inheritance)) { foreach ($inheritance as $k => $v) { if (!empty($v['post_type']) && in_array($value, $v['post_type'])) { $key = !empty($v['taxonomy_tags']) ? $v['taxonomy_tags'][0] : ''; break; } } } return $key; }
function axiom_load_custom_options() { global $wp_query, $post, $AXIOM_GLOBALS; $AXIOM_GLOBALS['custom_options'] = $AXIOM_GLOBALS['post_options'] = $AXIOM_GLOBALS['taxonomy_options'] = $AXIOM_GLOBALS['template_options'] = array(); // Load template options $page_id = axiom_detect_template_page_id(); if ($page_id > 0) { $AXIOM_GLOBALS['template_options'] = get_post_meta($page_id, 'post_custom_options', true); } // Load taxonomy and post options $inheritance_key = axiom_detect_inheritance_key(); if (!empty($inheritance_key)) { $inheritance = axiom_get_theme_inheritance($inheritance_key); // Load taxonomy options if (!empty($inheritance['taxonomy'])) { foreach ($inheritance['taxonomy'] as $tax) { $tax_obj = get_taxonomy($tax); $tax_query = !empty($tax_obj->query_var) ? $tax_obj->query_var : $tax; if ($tax == 'category' && is_category()) { // Current page is category's archive (Categories need specific check) $tax_id = (int) get_query_var('cat'); if (empty($tax_id)) { $tax_id = get_query_var('category_name'); } $AXIOM_GLOBALS['taxonomy_options'] = axiom_taxonomy_get_inherited_properties('category', $tax_id); break; } else { if ($tax == 'post_tag' && is_tag()) { // Current page is tag's archive (Tags need specific check) $tax_id = get_query_var($tax_query); $AXIOM_GLOBALS['taxonomy_options'] = axiom_taxonomy_get_inherited_properties('post_tag', $tax_id); break; } else { if (is_tax($tax)) { // Current page is custom taxonomy archive (All rest taxonomies check) $tax_id = get_query_var($tax_query); $AXIOM_GLOBALS['taxonomy_options'] = axiom_taxonomy_get_inherited_properties($tax, $tax_id); break; } } } } } // Load post options if (!empty($inheritance['post_type']) && is_singular() && (in_array(get_query_var('post_type'), $inheritance['post_type']) || !empty($post->post_type) && in_array($post->post_type, $inheritance['post_type']))) { $post_id = get_the_ID(); $AXIOM_GLOBALS['post_options'] = get_post_meta($post_id, 'post_custom_options', true); if (!empty($inheritance['taxonomy'])) { $tax_list = array(); foreach ($inheritance['taxonomy'] as $tax) { $tax_terms = axiom_get_terms_by_post_id(array('post_id' => $post_id, 'taxonomy' => $tax)); if (!empty($tax_terms[$tax]->terms)) { $tax_list[] = axiom_taxonomies_get_inherited_properties($tax, $tax_terms[$tax]); } } if (!empty($tax_list)) { foreach ($tax_list as $tax_options) { if (!empty($tax_options)) { foreach ($tax_options as $tk => $tv) { if (!isset($AXIOM_GLOBALS['taxonomy_options'][$tk]) || axiom_is_inherit_option($AXIOM_GLOBALS['taxonomy_options'][$tk])) { $AXIOM_GLOBALS['taxonomy_options'][$tk] = $tv; } } } } } } } } // Merge Template options with required for current page template $layout_name = axiom_get_custom_option(is_singular() && !axiom_get_global('blog_streampage') ? 'single_style' : 'blog_style'); if (!empty($AXIOM_GLOBALS['registered_templates'][$layout_name]['theme_options'])) { $AXIOM_GLOBALS['template_options'] = array_merge($AXIOM_GLOBALS['template_options'], $AXIOM_GLOBALS['registered_templates'][$layout_name]['theme_options']); } do_action('axiom_action_load_custom_options'); $AXIOM_GLOBALS['theme_options_loaded'] = true; }
function axiom_detect_template_page_id() { static $template_id = ''; if (!empty($template_id)) { return $template_id; } $key = axiom_detect_inheritance_key(); if (!empty($key)) { $inheritance = axiom_get_theme_inheritance($key); if (is_singular() && !axiom_get_global('blog_streampage') && !empty($inheritance['single_template'])) { $template_id = axiom_get_template_page_id($inheritance['single_template']); } if ((!is_singular() || !$template_id) && !empty($inheritance['stream_template'])) { $template_id = axiom_get_template_page_id($inheritance['stream_template']); } } if (empty($template_id)) { $template_id = apply_filters('axiom_filter_detect_template_page_id', 0, $key); } return $template_id; }