<?php

if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Телефон 1',
'id' => 'telefon1',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));

if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Телефон 2',
'id' => 'telefon2',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));

if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Адрес внизу',
'id' => 'adres-v-nizu',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));

if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Копирайт',
'id' => 'kopirait',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));


//Remove WPAUTOP from ACF TinyMCE Editor
function acf_wysiwyg_remove_wpautop() {
    remove_filter('acf_the_content', 'wpautop' );
}
add_action('acf/init', 'acf_wysiwyg_remove_wpautop');

//добавление nofollow для ссылок на рубрики start
function wph_nofollow_cats($text) { 
    $text = stripslashes($text);
    $text = preg_replace_callback('|<a (.+?)>|i', 
          'wp_rel_nofollow_callback', $text);
    return $text; }
function wph_nofollow_cat($text) {
    $text = str_replace('rel="category tag"', "", $text);
    $text = wph_nofollow_cats($text);
    return $text; } 
add_filter('wp_list_categories', 'wph_nofollow_cats');
add_filter('the_category', 'wph_nofollow_cat');
//добавление nofollow для ссылок на рубрики end



// вывод артикула
add_action( 'woocommerce_before_single_product', 'custom_before_title' );
function custom_before_title() {
 
global $product;
 
if ( $product->get_sku() ) {
echo '<div class="tovar-number">товар '. $product->get_sku(). '</div>';
}
 
}









/**
* WooCommerce Extra Feature
* --------------------------
*
* Change number of related products on product page
* Set your own value for 'posts_per_page'
*
*/
function woo_related_products_limit() {
  global $product;
 
    $args = array(
        'post_type'                => 'product',
        'no_found_rows'            => 1,
        'posts_per_page'           => 8,
        'ignore_sticky_posts'     => 1,
        'orderby'                 => $orderby,
        'post__in'                => $related,
        'post__not_in'            => array($product->id)
    );
    return $args;
}
add_filter( 'woocommerce_related_products_args', 'woo_related_products_limit' );

// переименовать раздел записи

function change_post_menu_label() {
    global $menu, $submenu;
    $menu[5][0] = 'Акции';
    $submenu['edit.php'][5][0] = 'Акции';
    $submenu['edit.php'][10][0] = 'Добавить Акцию';
    $submenu['edit.php'][16][0] = 'Новостные метки';
    echo '';
}
add_action( 'admin_menu', 'change_post_menu_label' );
function change_post_object_label() {
    global $wp_post_types;
    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'Акции';
    $labels->singular_name = 'Акции';
    $labels->add_new = 'Добавить Акцию';
    $labels->add_new_item = 'Добавить Акцию';
    $labels->edit_item = 'Редактировать Акцию';
    $labels->new_item = 'Добавить Акцию';
    $labels->view_item = 'Посмотреть Акцию';
    $labels->search_items = 'Найти Акцию';
    $labels->not_found = 'Не найдено';
    $labels->not_found_in_trash = 'Корзина пуста';
}
add_action( 'init', 'change_post_object_label' );







/*
 * "Хлебные крошки" для WordPress
 * автор: Dimox
 * версия: 2015.09.14
 * лицензия: MIT
*/
function dimox_breadcrumbs() {

  /* === ОПЦИИ === */
  $text['home'] = 'Салон красоты ФиФа'; // текст ссылки "Главная"
  $text['category'] = 'Архив рубрики "%s"'; // текст для страницы рубрики
  $text['search'] = 'Результаты поиска по запросу "%s"'; // текст для страницы с результатами поиска
  $text['tag'] = 'Записи с тегом "%s"'; // текст для страницы тега
  $text['author'] = 'Статьи автора %s'; // текст для страницы автора
  $text['404'] = 'Ошибка 404'; // текст для страницы 404
  $text['page'] = 'Страница %s'; // текст 'Страница N'
  $text['cpage'] = 'Страница комментариев %s'; // текст 'Страница комментариев N'

  $wrap_before = '<ul>'; // открывающий тег обертки
  $wrap_after = '</ul><!-- .breadcrumbs -->'; // закрывающий тег обертки
  $sep = '›'; // разделитель между "крошками"
  $sep_before = '<span class="sep">'; // тег перед разделителем
  $sep_after = '</span>'; // тег после разделителя
  $show_home_link = 1; // 1 - показывать ссылку "Главная", 0 - не показывать
  $show_on_home = 0; // 1 - показывать "хлебные крошки" на главной странице, 0 - не показывать
  $show_current = 1; // 1 - показывать название текущей страницы, 0 - не показывать
  $before = '<li>'; // тег перед текущей "крошкой"
  $after = '</li>'; // тег после текущей "крошки"
  /* === КОНЕЦ ОПЦИЙ === */

  global $post;
  $home_link = home_url('/');
  $link_before = '<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><li>';
  $link_after = '</li></span>';
  $link_attr = ' itemprop="url"';
  $link_in_before = '<span itemprop="title">';
  $link_in_after = '</span>';
  $link = $link_before . '<a href="%1$s"' . $link_attr . '>' . $link_in_before . '%2$s' . $link_in_after . '</a>' . $link_after;
  $frontpage_id = get_option('page_on_front');
  $parent_id = $post->post_parent;
  $sep = ' ' . $sep_before . $sep . $sep_after . ' ';

  if (is_home() || is_front_page()) {

    if ($show_on_home) echo $wrap_before . '<a href="' . $home_link . '">' . $text['home'] . '</a>' . $wrap_after;

  } else {

    echo $wrap_before;
    if ($show_home_link) echo sprintf($link, $home_link, $text['home']);

    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([^>]+)>([^<]+)<\/a>#', $link_before . '<a$1' . $link_attr .'>' . $link_in_before . '$2' . $link_in_after .'</a>' . $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_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' ) {
        $post_type = get_post_type_object(get_post_type());
        $slug = $post_type->rewrite;
        printf($link, $home_link . '/' . $slug['slug'] . '/', $post_type->labels->singular_name);
        if ($show_current) echo $sep . $before . get_the_title() . $after;
      } 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([^>]+)>([^<]+)<\/a>#', $link_before . '<a$1' . $link_attr .'>' . $link_in_before . '$2' . $link_in_after .'</a>' . $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([^>]+)>([^<]+)<\/a>#', $link_before . '<a$1' . $link_attr .'>' . $link_in_before . '$2' . $link_in_after .'</a>' . $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;

  }
} // end of dimox_breadcrumbs()





// вывод меню
class header_description_walker extends Walker_Nav_Menu
{
      function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
      {
           global $wp_query;

           /*
            * Некоторые из параметров объекта $item
            * ID - ID самого элемента меню, а не объекта на который он ссылается
            * menu_item_parent - ID родительского элемента меню
            * classes - массив классов элемента меню
            * post_date - дата добавления
            * post_modified - дата последнего изменения
            * post_author - ID пользователя, добавившего этот элемент меню
            * title - заголовок элемента меню
            * url - ссылка
            * attr_title - HTML-атрибут title ссылки
            * xfn - атрибут rel
            * target - атрибут target
            * current - равен 1, если является текущим элементов
            * current_item_ancestor - равен 1, если текущим является вложенный элемент
            * current_item_parent - равен 1, если текущим является вложенный элемент
            * menu_order - порядок в меню
            * object_id - ID объекта меню
            * type - тип объекта меню (таксономия, пост, произвольно)
            * object - какая это таксономия / какой тип поста (page /category / post_tag и т д)
            * type_label - название данного типа с локализацией (Рубрика, Страница)
            * post_parent - ID родительского поста / категории
            * post_title - заголовок, который был у поста, когда он был добавлен в меню
            * post_name - ярлык, который был у поста при его добавлении в меню
          */

           $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

           $class_names = $value = '';

           $classes = empty( $item->classes ) ? array() : (array) $item->classes;

           $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
           $class_names = ' class="'. esc_attr( $class_names ) . '"';

           // $output .= $indent . '<li class="main-navigation__item" id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';


            /*
            * Генерируем ID элемента
            */
             $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
              $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
 
            /*
            * Генерируем элемент меню
            */
            $output .= $indent . '<li' . $id . $value . $class_names .'>';



           $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
           $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
           $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
           $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';

           $prepend = '';
           $append = '';
           $description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';

           if($depth != 0)
           {
                     $description = $append = $prepend = "";
           }

            $item_output = $args->before;
            $item_output .= '<a class="main-navigation__link" '. $attributes .'>';
            $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
            $item_output .= $description.$args->link_after;
            $item_output .= '</a>';
            $item_output .= $args->after;

            $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
            }
}




class description_walker extends Walker_Nav_Menu
{
      function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
      {
           global $wp_query;
           $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

           $class_names = $value = '';

           $classes = empty( $item->classes ) ? array() : (array) $item->classes;

           $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
           $class_names = ' class="'. esc_attr( $class_names ) . '"';

           $output .= $indent . '<li class="service__item" id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';

           $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
           $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
           $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
           $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';

           $prepend = '';
           $append = '';
           $description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';

           if($depth != 0)
           {
                     $description = $append = $prepend = "";
           }

            $item_output = $args->before;
            $item_output .= '<a class="service__link" '. $attributes .'>';
            $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
            $item_output .= $description.$args->link_after;
            $item_output .= '</a>';
            $item_output .= $args->after;

            $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
            }
}


class footer_description_walker extends Walker_Nav_Menu
{
      function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
      {
           global $wp_query;
           $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

           $class_names = $value = '';

           $classes = empty( $item->classes ) ? array() : (array) $item->classes;

           $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
           $class_names = ' class="'. esc_attr( $class_names ) . '"';

           $output .= $indent . '<li class="" id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';

           $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
           $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
           $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
           $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';

           $prepend = '';
           $append = '';
           $description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';

           if($depth != 0)
           {
                     $description = $append = $prepend = "";
           }

            $item_output = $args->before;
            $item_output .= '<a class="" '. $attributes .'>';
            $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
            $item_output .= $description.$args->link_after;
            $item_output .= '</a>';
            $item_output .= $args->after;

            $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
            }
}



// хлебные крошки







//добавление класса в боди н аглавную



add_filter('body_class','my_class_names');
function my_class_names( $classes ) {
  // добавим класс 'class-name' в массив классов $classes
  if( is_front_page() )
    $classes[] = 'it_is_page';

  return $classes;
}


add_theme_support( 'post-thumbnails' ); // для всех типов постов

$default_attr = array(
  'src' => $src,
  'class' => "attachment-$size",
  'alt' => trim(strip_tags( $wp_postmeta->_wp_attachment_image_alt )),
);

 function content($limit) {
  $content = explode(' ', get_the_content(), $limit);
  if (count($content)>=$limit) {
    array_pop($content);
    $content = implode(" ",$content).'...';
  } else {
    $content = implode(" ",$content);
  }
  $content = preg_replace('`[[^]]*]`','',$content);
  return $content;
}


// WOOOCOMERCE


// woocommerce_currencies
add_filter( 'woocommerce_currencies', 'add_inr_currency' );
add_filter( 'woocommerce_currency_symbol', 'add_inr_currency_symbol'
);
function add_inr_currency( $currencies ) {
$currencies['RUB'] = 'Российский рубль';
return $currencies;
}
function add_inr_currency_symbol( $symbol ) {
$currency = get_option( 'woocommerce_currency' );
switch( $currency ) {
case 'RUB': $symbol = ''; break;
}
return $symbol;
}


// woocommerce_currencies

// html код в описаниях категорий


remove_filter('term-description', 'wp_filter_kses');
remove_filter('term-description', 'wp_kses_data');
remove_filter('pre_term_description', 'wp_filter_kses');
remove_filter('pre_term_description', 'wp_kses_data');






add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
  function custom_override_checkout_fields( $fields ) { /*Убрали ненужные поля*/
//  unset($fields['billing']['billing_company']);
//   unset($fields['billing']['billing_last_name']);


 // unset($fields['billing']['billing_address_1']);


 // unset($fields['billing']['billing_address_2']);
//   unset($fields['billing']['billing_email']);
//  unset($fields['billing']['billing_state']);


//    unset($fields['billing']['billing_city']);


//    unset($fields['billing']['billing_postcode']);
     unset($fields['billing']['billing_country']);


 return $fields;
}
 add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
 function custom_woocommerce_billing_fields( $fields ) {
 $fields['billing_address_1']['class'] = array( 'form-row-wide' ); /*Поле адреса шире*/
 return $fields;
 }


// убрать подытог
 add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );

function adjust_woocommerce_get_order_item_totals( $totals ) {
unset($totals['cart_subtotal'] );
return $totals;
}

// убрать обзоры
add_filter( 'woocommerce_product_tabs', 'sb_woo_remove_reviews_tab', 98);
function sb_woo_remove_reviews_tab($tabs) {

unset($tabs['reviews']);

return $tabs;
}


//отключаем стандартные стили woocommerce
add_filter( 'woocommerce_enqueue_styles', '__return_false' );



// Удаляем и добавляем Хуки
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
// remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10);

// add_action('woocommerce_before_shop_loop', 'woof_products_top_panel', 100);
add_action('woocommerce_after_shop_loop_item_baton', 'woocommerce_template_single_add_to_cart', 100);
add_action('woocommerce_after_shop_loop_item_govno', 'woocommerce_template_single_excerpt', 100);



function change_rub_symbol() {
// Just returns rubles :)
return ' руб';
}
add_filter( 'woocommerce_currency_symbol', 'change_rub_symbol', 50 );



// Сортировка woocommerce по артикулу

add_filter('woocommerce_get_catalog_ordering_args', 'am_woocommerce_catalog_orderby');
function am_woocommerce_catalog_orderby( $args ) {
    $args['meta_key'] = '_sku';
    $args['orderby'] = 'meta_value';
    $args['order'] = 'asc';
    return $args;
}


// Удалить лишние классы у меню 
// add_filter('nav_menu_item_id', 'remove_nav_menu_item_id'); function remove_nav_menu_item_id($id) { return ""; }
// add_filter('nav_menu_css_class','remove_nav_menu_classes'); function remove_nav_menu_classes($classes) { if ( in_array("current-menu-item", $classes ) ) { unset( $classes ); $classes[0]= 'current'; } else { $classes = array(); $classes[0]= 'class tipo'; } return $classes; }








// поддержка woocommerce
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}




// Убрать творчество вордпресс

function wph_admin_footer_text () {
}
add_filter('admin_footer_text', 'wph_admin_footer_text');



// отключаем пункты в верхнем меню в админке
function wph_new_toolbar() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('comments');    //меню комментарии
    $wp_admin_bar->remove_menu('new-content'); //меню "добавить"
    $wp_admin_bar->remove_menu('wp-logo');     //меню "о wordpress"
    $wp_admin_bar->remove_menu('all-in-one-seo-pack');     //меню "о wordpress"
}
add_action('wp_before_admin_bar_render', 'wph_new_toolbar');
//-----------------------------------



// Удаляем виджеты
function remove_dashboard_meta() {
        remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
        remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
        remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_activity', 'dashboard', 'normal');//since 3.8
}
add_action( 'admin_init', 'remove_dashboard_meta' );

// Вставляем в шапку стили

function devise_separators() {
echo '<style type="text/css">


#toplevel_page_asp_settings, #menu-posts-foogallery li:nth-child(4), #menu-posts-foogallery li:nth-child(5)
, #menu-posts-foogallery li:nth-child(6), #menu-posts-foogallery li:nth-child(7), #toplevel_page_woocommerce li:nth-child(4)
, #toplevel_page_woocommerce li:nth-child(5), #toplevel_page_woocommerce li:nth-child(8), #toplevel_page_woocommerce li:nth-child(9)
, #toplevel_page_woocommerce li:nth-child(10)
.notice-error, div.error , #toplevel_page_all-in-one-seo-pack-aioseop_class
{
  display: none !important;
}


</style>';
}
add_action( 'admin_head', 'devise_separators' );


// Удаляем эллементы меню
function remove_menus(){
  remove_menu_page( 'index.php' );                  //Консоль
  //remove_menu_page( 'edit.php' );                 //Записи
  // remove_menu_page( 'upload.php' );               //Медиафайлы
  // remove_menu_page( 'edit.php?post_type=page' );  //Страницы
  remove_menu_page( 'edit-comments.php' );          //Комментарии
  remove_menu_page( 'themes.php' );               //Внешний вид
  remove_submenu_page( 'themes.php', 'widgets.php' ); // Субменю
  remove_menu_page( 'plugins.php' );              //Плагины
  remove_menu_page( 'users.php' );                //Пользователи
  remove_menu_page( 'tools.php' );                  //Инструменты
  remove_menu_page( 'options-general.php' );      //Параметры
  remove_menu_page( 'options-general.php' ); 
  remove_menu_page( 'foobox-image-lightbox' );
  remove_menu_page( 'wpcf7' );
  remove_menu_page( 'wp-mcm' );
};




/* редирект с login на /wp-login.php  и с admin на /wp-admin */
// add_action('template_redirect', 'kama_login_redirect');
// function kama_login_redirect(){
//   if( strpos($_SERVER['REQUEST_URI'], 'login')!==false )
//     $loc = '/wp-login.php';
//   elseif( strpos($_SERVER['REQUEST_URI'], 'admin')!==false )
//     $loc = '/wp-admin/';
//   if( $loc ){
//     header( 'Location: '.get_option('site_url').$loc, true, 303 );
//     exit;
//   }
// }




if ( !function_exists('hide_admin_bar_search') ) {
  function hide_admin_bar_search () { ?>
    <style type="text/css">
    #wpadminbar #adminbarsearch, #wp-admin-bar-comments, #wp-admin-bar-wp-logo, #wp-admin-bar-dashboard {
      display: none;
    }
    </style>
    <?php
  };
};
function my_login_logo(){
   echo '
   <style type="text/css">
#login h1 a {
height: 50px;
background-size: 100%!important;
}
    </style>';
};
add_action('login_head', 'my_login_logo');
add_action( 'admin_menu', 'remove_menus' );
add_action('admin_head', 'hide_admin_bar_search');
add_action('wp_head', 'hide_admin_bar_search');
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'wp_update_plugins', 'wp_update_plugins' );
add_filter( 'pre_transient_update_plugins', create_function( '$a',
"return null;" ) );
remove_action( 'wp_version_check', 'wp_version_check' );
remove_action( 'admin_init', '_maybe_update_core' );
add_filter( 'pre_transient_update_core', create_function( '$a',
"return null;" ) );
define( 'WP_AUTO_UPDATE_CORE', 'minor' );




// Чистый вордпресс

remove_action('wp_head','feed_links_extra', 3);
remove_action( 'wp_head', 'wp_resource_hints', 2 );
remove_action('wp_head','feed_links', 2);
remove_action('wp_head','rsd_link');
remove_action('wp_head','wlwmanifest_link');
remove_action('wp_head','wp_generator');
remove_action('wp_head','start_post_rel_link',10,0);
remove_action('wp_head','index_rel_link');
remove_action('wp_head','adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action('wp_head','wp_shortlink_wp_head', 10, 0 );
 function ny_remove_recent_comments_style() {
    global $wp_widget_factory;
    remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
add_action( 'widgets_init', 'ny_remove_recent_comments_style' );
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
add_action( 'wp_print_styles', 'aa_deregister_styles', 100 );
function aa_deregister_styles() {
    if ( ! is_page( get_theme_mod( "header_contacts") ) ) {
        wp_deregister_style( 'contact-form-7' );
    }
}
add_action( 'wp_print_scripts', 'aa_deregister_javascript', 100 );
function aa_deregister_javascript() {
    if ( ! is_page( get_theme_mod( "header_contacts") ) ) {
        wp_deregister_script( 'contact-form-7' );
    }
}
remove_action('wp_print_styles', 'pagenavi_stylesheets');
remove_action( 'template_redirect', 'wp_shortlink_header', 11 );
function ny_remove_x_pingback( $headers ) {
    unset( $headers['X-Pingback'] );
    return $headers;
}
add_filter( 'wp_headers', 'ny_remove_x_pingback' );


add_theme_support('admin-bar', array( 'callback' => '__return_false'));
add_filter('show_admin_bar', '__return_false');

remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'rest_output_link_wp_head' );
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 );
add_filter('rest_enabled', '__return_false');
remove_action( 'xmlrpc_rsd_apis',            'rest_output_rsd' );
remove_action( 'wp_head',                    'rest_output_link_wp_head', 10, 0 );
remove_action( 'template_redirect',          'rest_output_link_header', 11, 0 );
remove_action( 'auth_cookie_malformed',      'rest_cookie_collect_status' );
remove_action( 'auth_cookie_expired',        'rest_cookie_collect_status' );
remove_action( 'auth_cookie_bad_username',   'rest_cookie_collect_status' );
remove_action( 'auth_cookie_bad_hash',       'rest_cookie_collect_status' );
remove_action( 'auth_cookie_valid',          'rest_cookie_collect_status' );
remove_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 );
remove_action( 'init',          'rest_api_init' );
remove_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 );
remove_action( 'parse_request', 'rest_api_loaded' );
remove_action( 'rest_api_init',          'wp_oembed_register_route'              );
remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
/*
 *  Удаляем остальные ненужные meta из head
 *
 */
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'rel_canonical' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' ); 
remove_action( 'wp_head', 'rsd_link' ); 
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'index_rel_link' ); 
remove_action( 'wp_head', 'start_post_rel_link', 10 );  
remove_action( 'wp_head', 'parent_post_rel_link', 10 ); 
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10 );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 ); 
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'pagenavi_css' ); 







?>