__( 'Основное меню', 'horazm' ), 'footer_col_1' => __( 'Нижнее - Колонка 1', 'horazm' ), 'footer_col_2' => __( 'Нижнее - Колонка 2', 'horazm' ), 'footer_col_3' => __( 'Нижнее - Колонка 3', 'horazm' ), ) ); /* Javascript to Bottom */ function remove_head_scripts() { remove_action('wp_head', 'wp_print_scripts'); remove_action('wp_head', 'wp_print_head_scripts', 9); remove_action('wp_head', 'wp_enqueue_scripts', 1); add_action('wp_footer', 'wp_print_scripts', 5); add_action('wp_footer', 'wp_enqueue_scripts', 5); add_action('wp_footer', 'wp_print_head_scripts', 5); } add_action( 'wp_enqueue_scripts', 'remove_head_scripts' ); /* Remove trash from nav and add active to current */ add_filter('nav_menu_css_class', 'clear_nav_class', 10, 3); function clear_nav_class($classes, $item, $args) { if (in_array('current-menu-item', $classes) ){ $cssClass[] = 'active'; } else { $cssClass[] = ''; } return $cssClass; } add_filter('nav_menu_item_id', 'clear_nav_id', 10, 3); function clear_nav_id($id, $item, $args) { return ""; } /* Excerpt length */ function wpdocs_custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 ); function wpdocs_excerpt_more( $more ) { return '..'; } add_filter( 'excerpt_more', 'wpdocs_excerpt_more' ); /* Remove All Special Characters from String*/ function clean_phone($phone) { $phone = str_replace(' ', '', $phone); $phone = str_replace('-', '', $phone); return preg_replace('/[^A-Za-z0-9\-]/', '', $phone); // Removes special chars. } // Show Attachment ID in admin add_filter('manage_media_columns', 'posts_columns_attachment_id', 1); add_action('manage_media_custom_column', 'posts_custom_columns_attachment_id', 1, 2); function posts_columns_attachment_id($defaults){ $defaults['wps_post_attachments_id'] = __('ID'); return $defaults; } function posts_custom_columns_attachment_id($column_name, $id){ if($column_name === 'wps_post_attachments_id'){ echo $id; } } /* Live search default css removal */ function my_searchwp_live_search_configs( $configs ) { // add an additional config called 'my_config' $configs['default'] = array( 'engine' => 'default', // search engine to use (if SearchWP is available) 'input' => array( 'delay' => 300, // wait 500ms before triggering a search 'min_chars' => 3, // wait for at least 3 characters before triggering a search ), 'results' => array( 'position' => 'bottom', // where to position the results (bottom|top) 'width' => 'auto', // whether the width should automatically match the input (auto|css) 'offset' => array( 'x' => -2, // x offset (in pixels) 'y' => 10 // y offset (in pixels) ), ), 'spinner' => array( // powered by http://fgnass.github.io/spin.js/ 'lines' => 11, // number of lines in the spinner 'length' => 0, // length of each line 'width' => 10, // line thickness 'radius' => 25, // radius of inner circle 'scale' => 0.6, 'corners' => 0.7, // corner roundness (0..1) 'rotate' => 0, // rotation offset 'direction' => 1, // 1: clockwise, -1: counterclockwise 'color' => '#a1be79', // #rgb or #rrggbb or array of colors 'speed' => 1, // rounds per second 'opacity' => 0, 'trail' => 50, // afterglow percentage 'shadow' => false, // whether to render a shadow 'hwaccel' => true, // whether to use hardware acceleration 'className' => 'loader', // CSS class assigned to spinner 'zIndex' => 2000000000, // z-index of spinner 'top' => '50%', // top position (relative to parent) 'left' => '50%', // left position (relative to parent) ), ); return $configs; } add_filter( 'searchwp_live_search_configs', 'my_searchwp_live_search_configs' ); function my_searchwp_live_search_posts_per_page() { return 6; // return 20 results } add_filter( 'searchwp_live_search_posts_per_page', 'my_searchwp_live_search_posts_per_page' ); /* Breadcrumbs */ function horazm_breadcrumbs() { /* === OPTIONS === */ $text['home'] = 'Главная'; // text for the 'Home' link $text['category'] = 'Archive by Category "%s"'; // text for a category page $text['search'] = 'Результаты поиска по запросу: "%s"'; // text for a search results page $text['tag'] = 'Posts Tagged "%s"'; // text for a tag page $text['author'] = 'Articles Posted by %s'; // text for an author page $text['404'] = 'Ошибка 404'; // text for the 404 page $text['page'] = 'Страница %s'; // text 'Page N' $text['cpage'] = 'Comment Page %s'; // text 'Comment Page N' $wrap_before = ''; // the closing wrapper tag $sep = ''; // separator between crumbs $sep_before = ''; // tag before separator $sep_after = ''; // tag after separator $show_home_link = 1; // 1 - show the 'Home' link, 0 - don't show $show_on_home = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $show_current = 1; // 1 - show current page title, 0 - don't show $before = '
  • '; // tag before the current crumb $after = '
  • '; // tag after the current crumb /* === END OF OPTIONS === */ global $post; $home_url = home_url('/'); $link_before = '
  • '; $link_after = '
  • '; $link_attr = ' itemprop="item"'; $link_in_before = ''; $link_in_after = ''; $link = $link_before . '' . $link_in_before . '%2$s' . $link_in_after . '' . $link_after; $frontpage_id = get_option('page_on_front'); $parent_id = ($post) ? $post->post_parent : ''; $sep = $sep_before . $sep . $sep_after; $home_link = $link_before . '' . $link_in_before . $text['home'] . $link_in_after . '' . $link_after; if (is_home() || is_front_page()) { if ($show_on_home) echo $wrap_before . $home_link . $wrap_after; } else { echo $wrap_before; if ($show_home_link) echo $home_link; if ( is_category() ) { $cat = get_category(get_query_var('cat'), false); if ($cat->parent != 0) { $cats = get_category_parents($cat->parent, TRUE, $sep); $cats = preg_replace("#^(.+)$sep$#", "$1", $cats); $cats = preg_replace('#]+)>([^<]+)<\/a>#', $link_before . '' . $link_in_before . '$2' . $link_in_after .'' . $link_after, $cats); if ($show_home_link) echo $sep; echo $cats; } if ( get_query_var('paged') ) { $cat = $cat->cat_ID; echo $sep . sprintf($link, get_category_link($cat), get_cat_name($cat)) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_current) echo $sep . $before . sprintf($text['category'], single_cat_title('', false)) . $after; } } elseif ( is_tax() ) { /** * If is taxonomy page */ # Firstly, get taxonomy name $term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') ); # $term->name; # Then, get post type name and url global $wp_taxonomies; $tax_post_type = ( isset( $wp_taxonomies['categories'] ) ) ? $wp_taxonomies['categories']->object_type : array(); $obj = get_post_type_object( $tax_post_type[0] ); $post_type_name = $obj->labels->name; $post_type_link = get_post_type_archive_link( $tax_post_type[0] ); $taxs = $link_before.''.$link_in_before.$post_type_name.$link_in_after.''.$link_after.$sep.$before.$term->name.$after; if ($show_home_link) echo $sep; echo $taxs; } elseif ( is_search() ) { if (have_posts()) { if ($show_home_link && $show_current) echo $sep; if ($show_current) echo $before . sprintf($text['search'], get_search_query()) . $after; } else { if ($show_home_link) echo $sep; echo $before . sprintf($text['search'], get_search_query()) . $after; } } elseif ( is_day() ) { if ($show_home_link) echo $sep; echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $sep; echo sprintf($link, get_month_link(get_the_time('Y'), get_the_time('m')), get_the_time('F')); if ($show_current) echo $sep . $before . get_the_time('d') . $after; } elseif ( is_month() ) { if ($show_home_link) echo $sep; echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')); if ($show_current) echo $sep . $before . get_the_time('F') . $after; } elseif ( is_year() ) { if ($show_home_link && $show_current) echo $sep; if ($show_current) echo $before . get_the_time('Y') . $after; } elseif ( is_single() && !is_attachment() ) { if ($show_home_link) echo $sep; if ( get_post_type() != 'post' ) { # Firstly, get taxonomy name $term = wp_get_post_terms($post->ID, 'categories'); # $term->name; # Then, get post type name and url global $wp_taxonomies; $tax_post_type = ( isset( $wp_taxonomies['categories'] ) ) ? $wp_taxonomies['categories']->object_type : array(); $obj = get_post_type_object( $tax_post_type[0] ); $post_type_name = $obj->labels->name; $post_type_link = get_post_type_archive_link( $tax_post_type[0] ); $taxs = $link_before.''.$link_in_before.$post_type_name.$link_in_after.''.$link_after. $sep; $taxs .= $link_before.''.$link_in_before.$term[0]->name.$link_in_after.''.$link_after. $sep; $taxs .= $before.get_the_title().$after; echo $taxs; } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents($cat, TRUE, $sep); if (!$show_current || get_query_var('cpage')) $cats = preg_replace("#^(.+)$sep$#", "$1", $cats); $cats = preg_replace('#]+)>([^<]+)<\/a>#', $link_before . '' . $link_in_before . '$2' . $link_in_after .'' . $link_after, $cats); echo $cats; if ( get_query_var('cpage') ) { echo $sep . sprintf($link, get_permalink(), get_the_title()) . $sep . $before . sprintf($text['cpage'], get_query_var('cpage')) . $after; } else { if ($show_current) echo $before . get_the_title() . $after; } } // custom post type } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) { $post_type = get_post_type_object(get_post_type()); if ( get_query_var('paged') ) { echo $sep . sprintf($link, get_post_type_archive_link($post_type->name), $post_type->label) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_current) echo $sep . $before . $post_type->label . $after; } } elseif ( is_attachment() ) { if ($show_home_link) echo $sep; $parent = get_post($parent_id); $cat = get_the_category($parent->ID); $cat = $cat[0]; if ($cat) { $cats = get_category_parents($cat, TRUE, $sep); $cats = preg_replace('#]+)>([^<]+)<\/a>#', $link_before . '' . $link_in_before . '$2' . $link_in_after .'' . $link_after, $cats); echo $cats; } printf($link, get_permalink($parent), $parent->post_title); if ($show_current) echo $sep . $before . get_the_title() . $after; } elseif ( is_page() && !$parent_id ) { if ($show_current) echo $sep . $before . get_the_title() . $after; } elseif ( is_page() && $parent_id ) { if ($show_home_link) echo $sep; if ($parent_id != $frontpage_id) { $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); if ($parent_id != $frontpage_id) { $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID)); } $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs)-1) echo $sep; } } if ($show_current) echo $sep . $before . get_the_title() . $after; } elseif ( is_tag() ) { if ( get_query_var('paged') ) { $tag_id = get_queried_object_id(); $tag = get_tag($tag_id); echo $sep . sprintf($link, get_tag_link($tag_id), $tag->name) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_current) echo $sep . $before . sprintf($text['tag'], single_tag_title('', false)) . $after; } } elseif ( is_author() ) { global $author; $author = get_userdata($author); if ( get_query_var('paged') ) { if ($show_home_link) echo $sep; echo sprintf($link, get_author_posts_url($author->ID), $author->display_name) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_home_link && $show_current) echo $sep; if ($show_current) echo $before . sprintf($text['author'], $author->display_name) . $after; } } elseif ( is_404() ) { if ($show_home_link && $show_current) echo $sep; if ($show_current) echo $before . $text['404'] . $after; } elseif ( has_post_format() && !is_singular() ) { if ($show_home_link) echo $sep; echo get_post_format_string( get_post_format() ); } echo $wrap_after; } } /* function fix_tax_term_pagination(){ add_rewrite_rule( 'katalog/%categories%/([^/]+)/page/([0-9]{1,})/?', 'index.php?taxonomy=$matches[1]&term=$matches[2]&post_type=$matches[3]&paged=$matches[4]', 'top' ); } add_action('init', 'fix_tax_term_pagination');*/ function wpa_show_permalinks( $post_link, $post ){ if ( is_object( $post ) && $post->post_type == 'catalog' ){ $terms = wp_get_object_terms( $post->ID, 'categories' ); if( $terms ){ return str_replace( '%categories%' , $terms[0]->slug , $post_link ); } } return $post_link; } add_filter( 'post_type_link', 'wpa_show_permalinks', 1, 2 ); /* Custom Admin Styles */ function custom_styles() { echo ''; } add_action('admin_head', 'custom_styles');
    slug, $cat->name and so on. */ $cat_args = array( 'post_type' => 'catalog', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'tax_query' => array( array( 'taxonomy' => 'categories', 'field' => 'id', 'terms' => $cat->term_id ) ) ); $cat_query = new WP_Query( $cat_args ); $eleIDs = $_COOKIE['cart_itm_id']; $eleIDs = explode(',', $eleIDs); ?>

    have_posts()) : $cat_query->the_post(); $cat_item_fields = get_fields(); $eleID = $post->ID; ?>
    Наименование Страна Цена от 1 т Цена от 100 кг
    ₽ / кг ₽ / кг Добавить в заказ Позиция добавлена