register_nav_menus( array(
'top' => 'Верхнее меню',
'left' => 'Нижнее'
) );
add_theme_support('post-thumbnails');
set_post_thumbnail_size(254, 190);
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
function true_register_wp_sidebars() {
register_sidebar(
array(
'id' => 'footer_1',
'name' => 'Футер 1',
'description' => 'Перетащите сюда виджеты, чтобы добавить их в футер.',
'before_widget' => '
',
'before_title' => '',
'after_title' => '
'
)
);
register_sidebar(
array(
'id' => 'footer_2',
'name' => 'Футер 2',
'description' => 'Перетащите сюда виджеты, чтобы добавить их в футер.',
'before_widget' => '',
'before_title' => '',
'after_title' => '
'
)
);
register_sidebar(
array(
'id' => 'footer_3',
'name' => 'Футер 3',
'description' => 'Перетащите сюда виджеты, чтобы добавить их в футер.',
'before_widget' => '',
'before_title' => '',
'after_title' => '
'
)
);
register_sidebar(
array(
'id' => 'footer_4',
'name' => 'Футер копирайт',
'description' => 'Перетащите сюда виджеты, чтобы добавить их в футер.',
'before_widget' => '',
'before_title' => '',
'after_title' => '
'
)
);
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
function filter_plugin_updates( $value ) {
unset( $value->response['acf-repeater-master/acf-repeater.php'] );
return $value;
}
add_action( 'widgets_init', 'true_register_wp_sidebars' );
remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
add_action( 'admin_enqueue_scripts', function(){
wp_enqueue_style( 'my-wp-admin', get_template_directory_uri() .'/admin.css' );
}, 99 );
function enqueue_my_scripts() { ?>
}
add_action( 'admin_enqueue_scripts', 'enqueue_my_scripts', 99 );
add_action( 'admin_enqueue_scripts', 'my_scripts_method' );
function my_scripts_method(){
wp_enqueue_script( 'newscript', get_template_directory_uri() . '/js/order.js');
}
add_action('wp_ajax_woocommerce_ajax_add_to_cart', 'woocommerce_ajax_add_to_cart');
add_action('wp_ajax_nopriv_woocommerce_ajax_add_to_cart', 'woocommerce_ajax_add_to_cart');
function woocommerce_ajax_add_to_cart() {
$service_id = apply_filters('woocommerce_add_to_cart_product_id', absint($_POST['service_id']));
$service = wc_get_product($service_id);
$post = get_post(absint($_POST['post_id']));
$name_post = $_POST['name_post'];
$date_id_post = $_POST['date_id_post'];
// $product_sku = "sp-" . $post->ID . "-" . $service->get_id();
$product_sku = "sp-" . $_POST['date_id_post'] . "-" . $service->get_id();
$product_id = wc_get_product_id_by_sku($product_sku);
if ($product_id == 0) {
$product_category = get_term_by('slug', 'other', 'product_cat');
$product = new WC_Product_Simple();
// $product->set_name($post->post_title . " - " . $service->get_name());
$product->set_name($_POST['name_post'] . " - " . $service->get_name());
$product->set_status('publish');
$product->set_sku($product_sku);
$product->set_category_ids(array($product_category->term_id));
$product_id = $product->save();
} else {
$product = wc_get_product($product_id);
}
$product->set_regular_price($service->get_regular_price());
$product->set_sale_price($service->get_sale_price());
$product->save();
if (WC()->cart->add_to_cart($product_id, 1)) {
do_action('woocommerce_ajax_added_to_cart', $product_id);
echo wp_send_json(array(
'message' => "Service added to cart."
), 200);
} else {
echo wp_send_json(array(
'message' => "An error has occurred and the service was not added to cart."
), 500);
}
}
function translitru($st)
{
$st = mb_strtolower($st, "utf-8");
$st = str_replace([
'?', '!', '.', ',', ':', ';', '*', '(', ')', '{', '}', '[', ']', '%', '#', '№', '@', '$', '^', '-', '+', '/', '\\', '=', '|', '"', '\'',
'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'з', 'и', 'й', 'к',
'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х',
'ъ', 'ы', 'э', ' ', 'ж', 'ц', 'ч', 'ш', 'щ', 'ь', 'ю', 'я'
], [
'_', '_', '.', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_',
'a', 'b', 'v', 'g', 'd', 'e', 'e', 'z', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h',
'j', 'i', 'e', '_', 'zh', 'ts', 'ch', 'sh', 'shch',
'\'', 'yu', 'ya'
], $st);
$st = preg_replace("/[^a-z0-9_.]/", "", $st);
$st = trim($st, '_');
$prev_st = '';
do {
$prev_st = $st;
$st = preg_replace("/_[a-z0-9]_/", "_", $st);
} while ($st != $prev_st);
$st = preg_replace("/_{2,}/", "_", $st);
return $st;
}
function transliterateen($input){
$gost = array(
"a"=>"а","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"е","yo"=>"ё",
"j"=>"ж","z"=>"з","i"=>"и","i"=>"й","k"=>"к",
"l"=>"л","m"=>"м","n"=>"н","o"=>"о","p"=>"п","r"=>"р","s"=>"с","t"=>"т",
"y"=>"у","f"=>"ф","h"=>"х","c"=>"ц",
"ch"=>"ч","sh"=>"ш","sh"=>"щ","i"=>"ы","e"=>"е","u"=>"у","ya"=>"я","A"=>"А","B"=>"Б",
"V"=>"В","G"=>"Г","D"=>"Д", "E"=>"Е","Yo"=>"Ё","J"=>"Ж","Z"=>"З","I"=>"И","I"=>"Й","K"=>"К","L"=>"Л","M"=>"М",
"N"=>"Н","O"=>"О","P"=>"П",
"R"=>"Р","S"=>"С","T"=>"Т","Y"=>"Ю","F"=>"Ф","H"=>"Х","C"=>"Ц","Ch"=>"Ч","Sh"=>"Ш",
"Sh"=>"Щ","I"=>"Ы","E"=>"Е", "U"=>"У","Ya"=>"Я","'"=>"ь","'"=>"Ь","''"=>"ъ","''"=>"Ъ","j"=>"ї","i"=>"и","g"=>"г",
"ye"=>"є","J"=>"Ї","I"=>"І",
"G"=>"Г","YE"=>"Є"
);
return strtr($input, $gost);
}
/*display current username*/
add_shortcode( 'current-username' , 'ss_get_current_username' );
function ss_get_current_username(){
$user = wp_get_current_user();
return $user->display_name;
}
function true_id($args){
$args['post_page_id'] = 'ID';
return $args;
}
function true_custom($column, $id){
if($column === 'post_page_id'){
echo $id;
}
}
add_filter('manage_pages_columns', 'true_id', 5);
add_action('manage_pages_custom_column', 'true_custom', 5, 2);
add_filter('manage_posts_columns', 'true_id', 5);
add_action('manage_posts_custom_column', 'true_custom', 5, 2);
//add_action('pre_get_posts', 'products_pre_get_posts');
//
//function products_pre_get_posts($query) {
//
// if ( is_search() ) {
//
// if( get_locale() == 'en_US' ) {
// $query->set( 'post_type', 'post' );
// $query->set( 's', translitru($_GET['s']) );
//
// } elseif ( get_locale() == 'ru_RU' ) {
//// $query->set( 'post_type', 'post' );
// $query->set( 's', transliterateen($_GET['s']) );
// } else {
// $query->set( 'post_type', 'post' );
// }
//
//
// }
//}
?>/* Template name: Главная */?>
get_header(); ?>
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
the_field('текст_заголовка'); ?>
the_field('услуга_1'); ?>
the_field('услуга_2'); ?>
the_field('услуга_3'); ?>
the_field('заголовок_больше_услуг'); ?>
the_field('описание_больше_услуг'); ?>
the_field('больше_услуг_список_1'); ?>
the_field('больше_услуг_список_2'); ?>
the_field('заголовок_зачем'); ?>

the_field('зачем_1'); ?>

the_field('зачем_2'); ?>

the_field('зачем_3'); ?>
the_field('зачем_описание'); ?>
the_field('годовой_абонемент'); ?>
the_field('заголовок_отзывов'); ?>
if( have_rows('отзывы') ): while ( have_rows('отзывы') ) : the_row(); ?>
the_sub_field('текст_отзыва'); ?>
the_sub_field('клиент'); ?>
endwhile; else : endif; ?>
endwhile; ?>
get_footer(); ?>