예제 #1
0
function get_custom_option($name, $defa = null, $post_id = 0, $cat_id = 0)
{
    if (isset($_GET[$name])) {
        $rez = $_GET[$name];
    } else {
        global $THEMEREX_custom_options, $THEMEREX_post_options, $THEMEREX_cat_options, $THEMEREX_shop_options, $THEMEREX_tribe_options;
        $hash_name = $name . '_' . $cat_id . '_' . $post_id;
        if (isset($THEMEREX_custom_options[$hash_name])) {
            $rez = $THEMEREX_custom_options[$hash_name];
        } else {
            if ($cat_id > 0) {
                $rez = get_category_inherited_property($cat_id, $name);
                if ($rez == '') {
                    $rez = get_theme_option($name, $defa);
                }
            } else {
                if ($post_id > 0) {
                    $rez = get_theme_option($name, $defa);
                    $custom_options = get_post_meta($post_id, 'post_custom_options', true);
                    if (isset($custom_options[$name]) && !is_inherit_option($custom_options[$name])) {
                        $rez = $custom_options[$name];
                    } else {
                        if (is_category()) {
                            $categories = array();
                            $categories[] = get_queried_object();
                        } else {
                            $categories = getCategoriesByPostId($post_id);
                        }
                        $tmp = '';
                        for ($cc = 0; $cc < count($categories) && (empty($tmp) || is_inherit_option($tmp)); $cc++) {
                            $tmp = get_category_inherited_property(is_object($categories[$cc]) ? $categories[$cc]->term_id : $categories[$cc]['term_id'], $name);
                        }
                        if ($tmp != '') {
                            $rez = $tmp;
                        }
                    }
                } else {
                    $rez = get_theme_option($name, $defa);
                    if (get_theme_option('show_theme_customizer') == 'yes') {
                        $tmp = getValueGPC($name, $rez);
                        if (!is_inherit_option($tmp)) {
                            $rez = $tmp;
                        }
                    }
                    if (is_woocommerce_page() && isset($THEMEREX_shop_options[$name]) && !is_inherit_option($THEMEREX_shop_options[$name])) {
                        $rez = is_array($THEMEREX_shop_options[$name]) ? $THEMEREX_shop_options[$name][0] : $THEMEREX_shop_options[$name];
                    }
                    if (is_tribe_events_page() && isset($THEMEREX_tribe_options[$name]) && !is_inherit_option($THEMEREX_tribe_options[$name])) {
                        $rez = is_array($THEMEREX_tribe_options[$name]) ? $THEMEREX_tribe_options[$name][0] : $THEMEREX_tribe_options[$name];
                    }
                    if (!is_single() && isset($THEMEREX_post_options[$name]) && !is_inherit_option($THEMEREX_post_options[$name])) {
                        $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name];
                    }
                    if (isset($THEMEREX_cat_options[$name]) && !is_inherit_option($THEMEREX_cat_options[$name])) {
                        $rez = $THEMEREX_cat_options[$name];
                    }
                    if (is_single() && isset($THEMEREX_post_options[$name]) && !is_inherit_option($THEMEREX_post_options[$name])) {
                        $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name];
                    }
                }
            }
            $THEMEREX_custom_options[$hash_name] = $rez;
        }
    }
    return $rez;
}
예제 #2
0
 function getBlogType($query = null)
 {
     global $wp_query;
     if ($query === null) {
         $query = $wp_query;
     }
     $page = '';
     if (is_woocommerce_page()) {
         if (is_shop()) {
             $page = 'woocommerce_shop';
         } else {
             if (is_product_category()) {
                 $page = 'woocommerce_category';
             } else {
                 if (is_product_tag()) {
                     $page = 'woocommerce_tag';
                 } else {
                     if (is_product()) {
                         $page = 'woocommerce_product';
                     } else {
                         if (is_cart()) {
                             $page = 'woocommerce_cart';
                         } else {
                             if (is_checkout()) {
                                 $page = 'woocommerce_checkout';
                             } else {
                                 if (is_account_page()) {
                                     $page = 'woocommerce_account';
                                 } else {
                                     $page = 'woocommerce';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         if (is_tribe_events_page()) {
             //$tribe_ecp = TribeEvents::instance();
             if (isset($query->query_vars['eventDisplay']) && $query->query_vars['eventDisplay'] == 'day') {
                 $page = 'tribe_day';
             } else {
                 if (isset($query->query_vars['eventDisplay']) && $query->query_vars['eventDisplay'] == 'month') {
                     $page = 'tribe_month';
                 } else {
                     if (is_single()) {
                         $page = 'tribe_event';
                     } else {
                         if (isset($query->tribe_is_event_venue) && $query->tribe_is_event_venue) {
                             $page = 'tribe_venue';
                         } else {
                             if (isset($query->tribe_is_event_organizer) && $query->tribe_is_event_organizer) {
                                 $page = 'tribe_organizer';
                             } else {
                                 if (isset($query->tribe_is_event_category) && $query->tribe_is_event_category) {
                                     $page = 'tribe_category';
                                 } else {
                                     if (is_tag()) {
                                         $page = 'tribe_tag';
                                     } else {
                                         if (isset($query->query_vars['eventDisplay']) && $query->query_vars['eventDisplay'] == 'upcoming') {
                                             $page = 'tribe_list';
                                         } else {
                                             $page = 'tribe';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if (isset($query->queried_object) && isset($query->queried_object->post_type) && $query->queried_object->post_type == 'page') {
                 $page = get_post_meta($query->queried_object_id, '_wp_page_template', true);
             } else {
                 if (isset($query->query_vars['page_id'])) {
                     $page = get_post_meta($query->query_vars['page_id'], '_wp_page_template', true);
                 } else {
                     if (isset($query->queried_object) && isset($query->queried_object->taxonomy)) {
                         $page = $query->queried_object->taxonomy;
                     }
                 }
             }
         }
     }
     if ($page == 'blog.php') {
         // || is_page_template( 'blog.php' ) )
         return 'blog';
     } else {
         if (themerex_strpos($page, 'woocommerce') !== false) {
             // WooCommerce
             return $page;
         } else {
             if (themerex_strpos($page, 'tribe') !== false) {
                 // TribeEvents
                 return $page;
             } else {
                 if ($query && $query->is_404()) {
                     // || is_404() ) 					// -------------- 404 error page
                     return 'error';
                 } else {
                     if ($query && $query->is_search()) {
                         // || is_search() ) 				// -------------- Search results
                         return 'search';
                     } else {
                         if ($query && $query->is_day()) {
                             // || is_day() )					// -------------- Archives daily
                             return 'archives_day';
                         } else {
                             if ($query && $query->is_month()) {
                                 // || is_month() ) 				// -------------- Archives monthly
                                 return 'archives_month';
                             } else {
                                 if ($query && $query->is_year()) {
                                     // || is_year() )  				// -------------- Archives year
                                     return 'archives_year';
                                 } else {
                                     if ($query && $query->is_category()) {
                                         // || is_category() )  		// -------------- Category
                                         return 'category';
                                     } else {
                                         if ($query && $query->is_tag()) {
                                             // || is_tag() ) 	 				// -------------- Tag posts
                                             return 'tag';
                                         } else {
                                             if ($query && $query->is_author()) {
                                                 // || is_author() )				// -------------- Author page
                                                 return 'author';
                                             } else {
                                                 if ($query && $query->is_attachment()) {
                                                     // || is_attachment() )
                                                     return 'attachment';
                                                 } else {
                                                     if ($query && $query->is_single()) {
                                                         // || is_single() )				// -------------- Single post
                                                         return 'single';
                                                     } else {
                                                         if ($query && $query->is_page()) {
                                                             // || is_page() )
                                                             return 'page';
                                                         } else {
                                                             // -------------- Home page
                                                             return 'home';
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }