Example #1
0
 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;
 }
Example #2
0
 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;
 }