function axiom_taxonomies_get_inherited_properties($tax, $list) { $tax_options = array(); $tax_obj = get_taxonomy($tax); if (!empty($list->terms)) { foreach ($list->terms as $obj) { $new_options = axiom_taxonomy_get_inherited_properties($tax, $obj->term_id); foreach ($new_options as $k => $v) { if (!empty($v) && !axiom_is_inherit_option($v) && (!isset($tax_options[$k]) || empty($tax_options[$k]) || axiom_is_inherit_option($tax_options[$k]))) { $tax_options[$k] = $v; } } } } return $tax_options; }
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_query_add_posts_per_page($query) { if (is_admin() || !$query->is_main_query()) { return; } $orderby_set = true; $orderby = $order = $ppp = ''; // Check template page settings if ($query->get('post_type') == 'product' || $query->get('product_cat') != '' || $query->get('product_tag') != '') { $orderby_set = false; $page_id = get_option('woocommerce_shop_page_id'); } else { if ($query->is_archive()) { $page_id = axiom_get_template_page_id('archive'); } else { if ($query->is_search()) { $page_id = axiom_get_template_page_id('search'); if (axiom_get_theme_option('use_ajax_search') == 'yes') { $show_types = axiom_get_theme_option('ajax_search_types'); if (!empty($show_types)) { $query->set('post_type', explode(',', $show_types)); } } } else { if ($query->is_posts_page == 1) { $page_id = isset($query->queried_object_id) ? $query->queried_object_id : axiom_get_template_page_id('blog'); } else { $page_id = 0; } } } } if ($page_id > 0) { $post_options = get_post_meta($page_id, 'post_custom_options', true); if (isset($post_options['posts_per_page']) && !empty($post_options['posts_per_page']) && !axiom_is_inherit_option($post_options['posts_per_page'])) { $ppp = (int) $post_options['posts_per_page']; } if ($orderby_set) { if (isset($post_options['blog_sort']) && !empty($post_options['blog_sort']) && !axiom_is_inherit_option($post_options['blog_sort'])) { $orderby = $post_options['blog_sort']; } if (isset($post_options['blog_order']) && !empty($post_options['blog_order']) && !axiom_is_inherit_option($post_options['blog_order'])) { $order = $post_options['blog_order']; } } } // Check taxonomy settings if (!empty($query->tax_query->queried_terms)) { foreach ($query->tax_query->queried_terms as $tax => $terms) { if (!empty($terms['terms'][0])) { $term = $terms['terms'][0]; $tax_options = axiom_taxonomy_get_inherited_properties($tax, $term); if (empty($ppp) && isset($tax_options['posts_per_page']) && !empty($tax_options['posts_per_page']) && !axiom_is_inherit_option($tax_options['posts_per_page'])) { $ppp = (int) $tax_options['posts_per_page']; } if ($orderby_set) { if (isset($tax_options['blog_sort']) && !empty($tax_options['blog_sort']) && !axiom_is_inherit_option($tax_options['blog_sort'])) { $orderby = $tax_options['blog_sort']; } if (isset($tax_options['blog_order']) && !empty($tax_options['blog_order']) && !axiom_is_inherit_option($tax_options['blog_order'])) { $order = $tax_options['blog_order']; } } } break; } } // Add parameters into query if (empty($ppp)) { $ppp = (int) axiom_get_theme_option('posts_per_page'); } if ($ppp > 0) { $query->set('posts_per_page', $ppp); } if ($orderby_set) { if (empty($orderby)) { $orderby = axiom_get_theme_option('blog_sort'); } if (empty($order)) { $order = axiom_get_theme_option('blog_order'); } axiom_query_add_sort_order($query, $orderby, $order); } // Exclude categories $ex = axiom_get_theme_option('exclude_cats'); if (!empty($ex)) { $query->set('category__not_in', explode(',', $ex)); } }