tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); add_image_size( 'portfolio', 500, 500, true ); add_image_size( 'category-thumb', 400, 9999 ); set_post_thumbnail_size( 300, 300, true); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); register_nav_menus( array( 'social' => esc_html__( 'Social', 'ardeyarus' ), 'left-menu' => esc_html__( 'Left menu', 'ardeyarus' ), ) ); } endif; add_action( 'after_setup_theme', 'ardeyarus_setup' ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function ardeyarus_content_width() { $GLOBALS['content_width'] = apply_filters( 'ardeyarus_content_width', 825 ); } add_action( 'after_setup_theme', 'ardeyarus_content_width', 0 ); add_action('wp_enqueue_scripts', 'ardeyarus_theme_scripts'); function ardeyarus_theme_scripts() { wp_enqueue_style( 'bootstrap-grid', get_stylesheet_directory_uri() . '/css/bootstrap.min.css' ); wp_enqueue_style( 'ardeyarus-style', get_stylesheet_uri() ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'pushy', get_stylesheet_directory_uri() . '/js/pushy.js', array( 'jquery' ), '', true ); wp_enqueue_script( 'imagesloaded', array( 'jquery' ), '', true ); wp_enqueue_script( 'masonry', array( 'jquery' ), '', true ); wp_enqueue_script( 'script', get_stylesheet_directory_uri() . '/js/script.js', array( 'jquery', 'imagesloaded', 'masonry' ), '', true ); if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); if( is_singular() ) wp_enqueue_style( 'ardeya-comment', get_stylesheet_directory_uri() . '/css/comment.css' ); } function ardeyarus_style_footer() { wp_enqueue_style( 'dashicons' ); wp_enqueue_style( 'pushy-menu', get_stylesheet_directory_uri() . '/css/pushy.css' ); wp_enqueue_style( 'ardeyarus-default', get_stylesheet_directory_uri() . '/css/default.css' ); $header_img = esc_html( get_theme_mod( 'header_img', get_template_directory_uri() . '/img/archive-bg.jpg' ) ); if ( $header_img ) { $set_archive_bg = '.archive-header { background: url("' . $header_img . '"); } '; wp_add_inline_style( 'ardeyarus-default', $set_archive_bg ); } } add_action( 'get_footer', 'ardeyarus_style_footer' ); add_action( 'widgets_init', 'ardeyarus_register_widgets' ); function ardeyarus_register_widgets() { register_sidebar( array( 'name' => __( 'Sidebar', 'ardeyarus' ), 'id' => 'sidebar', 'description' => __( 'Add widgets here', 'ardeyarus' ), 'before_widget' => '
  • ', 'after_widget' => "
  • ", 'before_title' => '', 'after_title' => "", ) ); register_sidebar( array( 'name' => __( 'Sidebar single post', 'ardeyarus' ), 'id' => 'sidebar-single', 'description' => __( 'This sidebar display only single post', 'ardeyarus' ), 'before_widget' => '
  • ', 'after_widget' => "
  • ", 'before_title' => '', 'after_title' => "", ) ); } add_filter( 'excerpt_more', function( $more ) { return '... ' . __( 'continue reading...', 'ardeyarus' ) . ''; }); add_action( 'customize_register', 'ardeyarus_customize_register' ); function ardeyarus_customize_register( $wp_customize ) { $wp_customize->add_panel( 'settings', array( 'title' => __( 'Settings Theme', 'ardeyarus' ), 'priority' => 1 ) ); //Рекламный блок в центре $wp_customize->add_section( 'header_img', array( 'title' => __( 'Header Image', 'ardeyarus' ), 'panel' => 'settings' ) ); $wp_customize->add_setting('header_img', array( 'default' => get_template_directory_uri() . '/img/archive-bg.jpg', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_attr', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'header_img', array( 'label' => __( 'Upload image', 'ardeyarus' ), 'description' => __( 'Upload image for display on page archive and single post', 'ardeyarus' ), 'section' => 'header_img', 'priority' => 1, 'default' => get_stylesheet_directory_uri() . '/img/archive-bg.jpg', ) ) ); } if ( ! function_exists( 'ardeyarus_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function ardeyarus_entry_footer() { // Hide category and tag text for pages. if ( 'post' === get_post_type() or 'jetpack-portfolio' === get_post_type() ) { print '
    '; if( 'jetpack-portfolio' === get_post_type() ) { $categories_list = get_the_term_list( get_the_ID(), 'jetpack-portfolio-type', '', ', ', '' ); } else { $categories_list = get_the_category_list( esc_html__(', ', 'ardeyarus') ); } if ( $categories_list ) { print( ' ' . $categories_list . '' ); } if( 'jetpack-portfolio' === get_post_type() ) { $tags_list = get_the_term_list( get_the_ID(), 'jetpack-portfolio-tag', '', ', ', '' ); } else { $tags_list = get_the_tag_list('', esc_html__(', ', 'ardeyarus')); } if ( $tags_list ) { print( ' ' . $tags_list . '' ); } print '
    '; } } endif; if ( ! function_exists( 'ardeyarus_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function ardeyarus_posted_on() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $posted_on = sprintf( _x( ' %s', 'post date', 'ardeyarus' ), $time_string ); $byline = sprintf( _x( ' %s', 'post author', 'ardeyarus' ), '' . esc_html( get_the_author() ) . '' ); echo '
    ' . $posted_on . ' ' . $byline . '
    '; } endif; add_filter( 'comment_form_before_fields', 'ardeyarus_before_comment_fields' ); function ardeyarus_before_comment_fields() { echo '
    '; } add_filter( 'comment_form_after_fields', 'ardeyarus_after_comment_fields' ); function ardeyarus_after_comment_fields() { echo '
    '; } add_filter( 'widget_tag_cloud_args', 'ardeyarus_tag_cloud_widget' ); function ardeyarus_tag_cloud_widget( $args ) { $args = array( 'smallest' => 8, 'largest' => 16, 'unit' => 'pt', 'echo' => false, ); return $args; } add_filter( 'get_shortlink', function( $shortlink ) {return $shortlink;} ); // удаляет H2 из шаблона пагинации add_filter('navigation_markup_template', 'my_navigation_template', 10, 2 ); function my_navigation_template( $template, $class ){ return ' '; } function get_breadcrumbs() { // Локализация if( function_exists( 'kama_breadcrumbs' ) ) { $myl10n = array( 'home' => __( 'Home', 'ardeyarus' ), 'paged' => __( 'Page %d', 'ardeyarus' ), '_404' => __( 'Error 404', 'ardeyarus' ), 'search' => __( 'Search results by query - %s', 'ardeyarus' ), 'author' => __( 'Author archve: %s', 'ardeyarus' ), 'year' => __( 'Archive by %d year', 'ardeyarus' ), 'month' => __( 'Archive by: %s', 'ardeyarus' ), 'attachment' => __( 'Media: %s', 'ardeyarus' ), 'tag' => __( 'Posts by tag: %s', 'ardeyarus' ), 'tax_tag' =>__( '%1$s from "%2$s" by tag: %3$s', 'ardeyarus' ), // tax_tag выведет: 'тип_записи из "название_таксы" по тегу: имя_термина'. // Если нужны отдельные холдеры, например только имя термина, пишем так: 'записи по тегу: %3$s' ); kama_breadcrumbs(' » ', $myl10n ); } } /** * Хлебные крошки для WordPress (breadcrumbs) * * @param string [$sep = ''] Разделитель. По умолчанию ' » ' * @param array [$l10n = array()] Для локализации. См. переменную $default_l10n. * @param array [$args = array()] Опции. См. переменную $def_args * @return string Выводит на экран HTML код * * version 3.3.1 */ function kama_breadcrumbs( $sep = ' » ', $l10n = array(), $args = array() ){ $kb = new Kama_Breadcrumbs; echo $kb->get_crumbs( $sep, $l10n, $args ); } class Kama_Breadcrumbs { public $arg; // Локализация static $l10n = array( 'home' => 'Главная', 'paged' => 'Страница %d', '_404' => 'Ошибка 404', 'search' => 'Результаты поиска по запросу - %s', 'author' => 'Архив автора: %s', 'year' => 'Архив за %d год', 'month' => 'Архив за: %s', 'day' => '', 'attachment' => 'Медиа: %s', 'tag' => 'Записи по метке: %s', 'tax_tag' => '%1$s из "%2$s" по тегу: %3$s', // tax_tag выведет: 'тип_записи из "название_таксы" по тегу: имя_термина'. // Если нужны отдельные холдеры, например только имя термина, пишем так: 'записи по тегу: %3$s' ); // Параметры по умолчанию static $args = array( 'on_front_page' => true, // выводить крошки на главной странице 'show_post_title' => true, // показывать ли название записи в конце (последний элемент). Для записей, страниц, вложений 'show_term_title' => true, // показывать ли название элемента таксономии в конце (последний элемент). Для меток, рубрик и других такс 'title_patt' => '%s', // шаблон для последнего заголовка. Если включено: show_post_title или show_term_title 'last_sep' => true, // показывать последний разделитель, когда заголовок в конце не отображается 'markup' => 'schema.org', // 'markup' - микроразметка. Может быть: 'rdf.data-vocabulary.org', 'schema.org', '' - без микроразметки // или можно указать свой массив разметки: // array( 'wrappatt'=>'
    %s
    ', 'linkpatt'=>'%s', 'sep_after'=>'', ) 'priority_tax' => array('category'), // приоритетные таксономии, нужно когда запись в нескольких таксах 'priority_terms' => array(), // 'priority_terms' - приоритетные элементы таксономий, когда запись находится в нескольких элементах одной таксы одновременно. // Например: array( 'category'=>array(45,'term_name'), 'tax_name'=>array(1,2,'name') ) // 'category' - такса для которой указываются приор. элементы: 45 - ID термина и 'term_name' - ярлык. // порядок 45 и 'term_name' имеет значение: чем раньше тем важнее. Все указанные термины важнее неуказанных... 'nofollow' => false, // добавлять rel=nofollow к ссылкам? // служебные 'sep' => '', 'linkpatt' => '', 'pg_end' => '', ); function get_crumbs( $sep, $l10n, $args ){ global $post, $wp_query, $wp_post_types; self::$args['sep'] = $sep; // Фильтрует дефолты и сливает $loc = (object) array_merge( apply_filters('kama_breadcrumbs_default_loc', self::$l10n ), $l10n ); $arg = (object) array_merge( apply_filters('kama_breadcrumbs_default_args', self::$args ), $args ); $arg->sep = ''. $arg->sep .''; // дополним // упростим $sep = & $arg->sep; $this->arg = & $arg; // микроразметка --- if(1){ $mark = & $arg->markup; // Разметка по умолчанию if( ! $mark ) $mark = array( 'wrappatt' => '
    %s
    ', 'linkpatt' => '%s', 'sep_after' => '', ); // rdf elseif( $mark === 'rdf.data-vocabulary.org' ) $mark = array( 'wrappatt' => '
    %s
    ', 'linkpatt' => '%s', 'sep_after' => '', // закрываем span после разделителя! ); // schema.org elseif( $mark === 'schema.org' ) $mark = array( 'wrappatt' => '
    %s
    ', 'linkpatt' => '%s', 'sep_after' => '', ); elseif( ! is_array($mark) ) die( __CLASS__ .': "markup" parameter must be array...'); $wrappatt = $mark['wrappatt']; $arg->linkpatt = $arg->nofollow ? str_replace('sep .= $mark['sep_after']."\n"; } $linkpatt = $arg->linkpatt; // упростим $q_obj = get_queried_object(); // может это архив пустой таксы? $ptype = null; if( empty($post) ){ if( isset($q_obj->taxonomy) ) $ptype = & $wp_post_types[ get_taxonomy($q_obj->taxonomy)->object_type[0] ]; } else $ptype = & $wp_post_types[ $post->post_type ]; // paged $arg->pg_end = ''; if( ($paged_num = get_query_var('paged')) || ($paged_num = get_query_var('page')) ) $arg->pg_end = $sep . sprintf( $loc->paged, (int) $paged_num ); $pg_end = $arg->pg_end; // упростим // ну, с богом... $out = ''; if( is_front_page() ){ return $arg->on_front_page ? sprintf( $wrappatt, ( $paged_num ? sprintf($linkpatt, get_home_url(), $loc->home) . $pg_end : $loc->home ) ) : ''; } // страница записей, когда для главной установлена отдельная страница. elseif( is_home() ) { $out = $paged_num ? ( sprintf( $linkpatt, get_permalink($q_obj), esc_html($q_obj->post_title) ) . $pg_end ) : esc_html($q_obj->post_title); } elseif( is_404() ){ $out = $loc->_404; } elseif( is_search() ){ $out = sprintf( $loc->search, esc_html( $GLOBALS['s'] ) ); } elseif( is_author() ){ $tit = sprintf( $loc->author, esc_html($q_obj->display_name) ); $out = ( $paged_num ? sprintf( $linkpatt, get_author_posts_url( $q_obj->ID, $q_obj->user_nicename ) . $pg_end, $tit ) : $tit ); } elseif( is_year() || is_month() || is_day() ){ $y_url = get_year_link( $year = get_the_time('Y') ); if( is_year() ){ $tit = sprintf( $loc->year, $year ); $out = ( $paged_num ? sprintf($linkpatt, $y_url, $tit) . $pg_end : $tit ); } // month day else { $y_link = sprintf( $linkpatt, $y_url, $year); $m_url = get_month_link( $year, get_the_time('m') ); if( is_month() ){ $tit = sprintf( $loc->month, get_the_time('F') ); $out = $y_link . $sep . ( $paged_num ? sprintf( $linkpatt, $m_url, $tit ) . $pg_end : $tit ); } elseif( is_day() ){ $m_link = sprintf( $linkpatt, $m_url, get_the_time('F')); $out = $y_link . $sep . $m_link . $sep . get_the_time('l'); } } } // Древовидные записи elseif( is_singular() && $ptype->hierarchical ){ $out = $this->_add_title( $this->_page_crumbs($post), $post ); } // Таксы, плоские записи и вложения else { $term = $q_obj; // таксономии // определяем термин для записей (включая вложения attachments) if( is_singular() ){ // изменим $post, чтобы определить термин родителя вложения if( is_attachment() && $post->post_parent ){ $save_post = $post; // сохраним $post = get_post($post->post_parent); } // учитывает если вложения прикрепляются к таксам древовидным - все бывает :) $taxonomies = get_object_taxonomies( $post->post_type ); // оставим только древовидные и публичные, мало ли... $taxonomies = array_intersect( $taxonomies, get_taxonomies( array('hierarchical' => true, 'public' => true) ) ); if( $taxonomies ){ // сортируем по приоритету if( ! empty($arg->priority_tax) ){ usort( $taxonomies, function($a,$b)use($arg){ $a_index = array_search($a, $arg->priority_tax); if( $a_index === false ) $a_index = 9999999; $b_index = array_search($b, $arg->priority_tax); if( $b_index === false ) $b_index = 9999999; return ( $b_index === $a_index ) ? 0 : ( $b_index < $a_index ? 1 : -1 ); // меньше индекс - выше } ); } // пробуем получить термины, в порядке приоритета такс foreach( $taxonomies as $taxname ){ if( $terms = get_the_terms( $post->ID, $taxname ) ){ // проверим приоритетные термины для таксы $prior_terms = & $arg->priority_terms[ $taxname ]; if( $prior_terms && count($terms) > 2 ){ foreach( (array) $prior_terms as $term_id ){ $filter_field = is_numeric($term_id) ? 'term_id' : 'slug'; $_terms = wp_list_filter( $terms, array($filter_field=>$term_id) ); if( $_terms ){ $term = array_shift( $_terms ); break; } } } else $term = array_shift( $terms ); break; } } } if( isset($save_post) ) $post = $save_post; // вернем обратно (для вложений) } // вывод // все виды записей с терминами или термины if( $term && isset($term->term_id) ){ $term = apply_filters('kama_breadcrumbs_term', $term ); // attachment if( is_attachment() ){ if( ! $post->post_parent ) $out = sprintf( $loc->attachment, esc_html($post->post_title) ); else { if( ! $out = apply_filters('attachment_tax_crumbs', '', $term, $this ) ){ $_crumbs = $this->_tax_crumbs( $term, 'self' ); $parent_tit = sprintf( $linkpatt, get_permalink($post->post_parent), get_the_title($post->post_parent) ); $_out = implode( $sep, array($_crumbs, $parent_tit) ); $out = $this->_add_title( $_out, $post ); } } } // single elseif( is_single() ){ if( ! $out = apply_filters('post_tax_crumbs', '', $term, $this ) ){ $_crumbs = $this->_tax_crumbs( $term, 'self' ); $out = $this->_add_title( $_crumbs, $post ); } } // не древовидная такса (метки) elseif( ! is_taxonomy_hierarchical($term->taxonomy) ){ // метка if( is_tag() ) $out = $this->_add_title('', $term, sprintf( $loc->tag, esc_html($term->name) ) ); // такса elseif( is_tax() ){ $post_label = $ptype->labels->name; $tax_label = $GLOBALS['wp_taxonomies'][ $term->taxonomy ]->labels->name; $out = $this->_add_title('', $term, sprintf( $loc->tax_tag, $post_label, $tax_label, esc_html($term->name) ) ); } } // древовидная такса (рибрики) else { if( ! $out = apply_filters('term_tax_crumbs', '', $term, $this ) ){ $_crumbs = $this->_tax_crumbs( $term, 'parent' ); $out = $this->_add_title( $_crumbs, $term, esc_html($term->name) ); } } } // влоежния от записи без терминов elseif( is_attachment() ){ $parent = get_post($post->post_parent); $parent_link = sprintf( $linkpatt, get_permalink($parent), esc_html($parent->post_title) ); $_out = $parent_link; // вложение от записи древовидного типа записи if( is_post_type_hierarchical($parent->post_type) ){ $parent_crumbs = $this->_page_crumbs($parent); $_out = implode( $sep, array( $parent_crumbs, $parent_link ) ); } $out = $this->_add_title( $_out, $post ); } // записи без терминов elseif( is_singular() ){ $out = $this->_add_title( '', $post ); } } // замена ссылки на архивную страницу для типа записи $home_after = apply_filters('kama_breadcrumbs_home_after', '', $linkpatt, $sep, $ptype ); if( '' === $home_after ){ // Ссылка на архивную страницу типа записи для: отдельных страниц этого типа; архивов этого типа; таксономий связанных с этим типом. if( $ptype && $ptype->has_archive && ! in_array( $ptype->name, array('post','page','attachment') ) && ( is_post_type_archive() || is_singular() || (is_tax() && in_array($term->taxonomy, $ptype->taxonomies)) ) ){ $pt_title = $ptype->labels->name; // первая страница архива типа записи if( is_post_type_archive() && ! $paged_num ) $home_after = $pt_title; // singular, paged post_type_archive, tax else{ $home_after = sprintf( $linkpatt, get_post_type_archive_link($ptype->name), $pt_title ); $home_after .= ( ($paged_num && ! is_tax()) ? $pg_end : $sep ); // пагинация } } } $before_out = sprintf( $linkpatt, home_url(), $loc->home ) . ( $home_after ? $sep.$home_after : ($out ? $sep : '') ); $out = apply_filters('kama_breadcrumbs_pre_out', $out, $sep, $loc, $arg ); $out = sprintf( $wrappatt, $before_out . $out ); return apply_filters('kama_breadcrumbs', $out, $sep, $loc, $arg ); } function _page_crumbs( $post ){ $parent = $post->post_parent; $crumbs = array(); while( $parent ){ $page = get_post( $parent ); $crumbs[] = sprintf( $this->arg->linkpatt, get_permalink($page), esc_html($page->post_title) ); $parent = $page->post_parent; } return implode( $this->arg->sep, array_reverse($crumbs) ); } function _tax_crumbs( $term, $start_from = 'self' ){ $termlinks = array(); $term_id = ($start_from === 'parent') ? $term->parent : $term->term_id; while( $term_id ){ $term = get_term( $term_id, $term->taxonomy ); $termlinks[] = sprintf( $this->arg->linkpatt, get_term_link($term), esc_html($term->name) ); $term_id = $term->parent; } if( $termlinks ) return implode( $this->arg->sep, array_reverse($termlinks) ) /*. $this->arg->sep*/; return ''; } // добалвяет заголовок к переданному тексту, с учетом всех опций. Добавляет разделитель в начало, если надо. function _add_title( $add_to, $obj, $term_title = '' ){ $arg = & $this->arg; // упростим... $title = $term_title ? $term_title : esc_html($obj->post_title); // $term_title чиститься отдельно, теги моугт быть... $show_title = $term_title ? $arg->show_term_title : $arg->show_post_title; // пагинация if( $arg->pg_end ){ $link = $term_title ? get_term_link($obj) : get_permalink($obj); $add_to .= ($add_to ? $arg->sep : '') . sprintf( $arg->linkpatt, $link, $title ) . $arg->pg_end; } // дополняем - ставим sep elseif( $add_to ){ if( $show_title ) $add_to .= $arg->sep . sprintf( $arg->title_patt, $title ); elseif( $arg->last_sep ) $add_to .= $arg->sep; } // sep будет потом... elseif( $show_title ) $add_to = sprintf( $arg->title_patt, $title ); return $add_to; } }