You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
6.9 KiB
178 lines
6.9 KiB
<?php
|
|
|
|
pll_register_string( 'Link email', 'Link email');
|
|
pll_register_string( 'Linked accounts', 'Linked accounts');
|
|
|
|
|
|
add_action('template_redirect', 'redirect_non_logged_in_users');
|
|
|
|
function redirect_non_logged_in_users() {
|
|
// URL личного кабинета (замените 'your-account-page-slug' на ваш slug)
|
|
$account_page_slug = 'my-account-3';
|
|
$account_page_slug__2 = 'my-account';
|
|
// Проверяем, находится ли пользователь на странице личного кабинета
|
|
if (is_page($account_page_slug) && !is_user_logged_in() || is_page($account_page_slug__2) && !is_user_logged_in() ) {
|
|
wp_redirect(home_url()); // Перенаправляем на главную страницу
|
|
exit;
|
|
}
|
|
}
|
|
|
|
add_action('init', 'register_pets');
|
|
function register_pets(){
|
|
register_post_type('pets', array(
|
|
'labels' => array(
|
|
'name' => 'Питомцы', // Основное название типа записи
|
|
'singular_name' => 'Питомец', // отдельное название записи типа Book
|
|
'add_new' => 'Добавить нового',
|
|
'add_new_item' => 'Добавить нового питомца',
|
|
'edit_item' => 'Редактировать питомца',
|
|
'new_item' => 'Новый питомец',
|
|
'view_item' => 'Посмотреть питомца',
|
|
'search_items' => 'Найти питомца',
|
|
'not_found' => 'Питомцев не найдено',
|
|
'not_found_in_trash' => 'В корзине книг не найдено',
|
|
'parent_item_colon' => '',
|
|
'menu_name' => 'Питомцы'
|
|
|
|
),
|
|
'public' => false,
|
|
'show_ui' => true,
|
|
'supports' => array('title','editor')
|
|
) );
|
|
}
|
|
|
|
function get_pet_card($item){
|
|
?>
|
|
<?php
|
|
|
|
switch (get_field('weight')){
|
|
case ('below_1_5'):
|
|
$w = esc_html__('from 0,5 kg to 1,5 kg', 'woodmart' );
|
|
break;
|
|
case ('1_5-3'):
|
|
$w = esc_html__('from 1.5 to 3 kg', 'woodmart' );
|
|
break;
|
|
case ('3-5'):
|
|
$w = esc_html__('from 3 to 5 kg', 'woodmart' );
|
|
break;
|
|
case ('5-8'):
|
|
$w = esc_html__('from 5 to 8 kg', 'woodmart' );
|
|
break;
|
|
case ('8-11'):
|
|
$w = esc_html__('from 8 to 11 kg', 'woodmart' );
|
|
break;
|
|
case ('11-15'):
|
|
$w = esc_html__('from 11 to 15 kg', 'woodmart' );
|
|
break;
|
|
case ('15-20'):
|
|
$w = esc_html__('from 15 to 20 kg', 'woodmart' );
|
|
break;
|
|
case ('20-25'):
|
|
$w = esc_html__('from 20 to 25 kg', 'woodmart' );
|
|
break;
|
|
|
|
|
|
case ('25-35'):
|
|
$w = esc_html__('from 25 to 35 kg', 'woodmart' );
|
|
break;
|
|
|
|
|
|
case ('more_35'):
|
|
$w = esc_html__('More than 35 kg', 'woodmart' );
|
|
break;
|
|
|
|
}
|
|
switch (get_field('old')){
|
|
case ('normal'):
|
|
$old = esc_html__('Adult (from 1 year to 7 years)', 'woodmart' );
|
|
break;
|
|
case ('old'):
|
|
$old = esc_html__('Elderly (from 7 to 12 years)', 'woodmart' );
|
|
break;
|
|
case ('very_old'):
|
|
$old = esc_html__('Aging (12 years and older)', 'woodmart' );
|
|
break;
|
|
case ('baby'):
|
|
$old = esc_html__('Baby (from 0 to 1 year)' );
|
|
break;
|
|
}
|
|
|
|
switch (get_field('activity')){
|
|
case ('low'):
|
|
$act = esc_html__('Low', 'woodmart' );
|
|
break;
|
|
case ('moderate'):
|
|
$act = esc_html__('Moderate', 'woodmart' );
|
|
break;
|
|
case ('high'):
|
|
$act = esc_html__('High', 'woodmart' );
|
|
break;
|
|
|
|
}
|
|
?>
|
|
<div class="cabinet-card cabinet-card--green">
|
|
<div class="cabinet-card__content">
|
|
<div class="cabinet-card__pet">
|
|
<div class="cabinet-card-pet__icon">
|
|
<div class="cabinet-card-pet-icon__content">
|
|
<img src="<?= get_template_directory_uri();?>/gp-include/assets/lk/img/pet/mini-<?php echo get_field('type', $item) ?>.png" alt="">
|
|
</div>
|
|
</div>
|
|
|
|
<p class="cabinet-card-pet__name"><?php echo get_the_title($item) ?></p>
|
|
</div>
|
|
|
|
<div class="cabinet-card__element">
|
|
<p class="cabinet-card__label"><?php echo esc_html__('Breed', 'woodmart' ) ?>:</p>
|
|
<p class="cabinet-card__text"><?php echo get_field('breed', $item) ?></p>
|
|
</div>
|
|
<div class="cabinet-card__element">
|
|
<p class="cabinet-card__label"><?php echo esc_html__('Weight', 'woodmart' ) ?>:</p>
|
|
<p class="cabinet-card__text"><?php echo $w; ?></p>
|
|
</div>
|
|
<?php if ($old): ?>
|
|
<div class="cabinet-card__element">
|
|
<p class="cabinet-card__label"><?php echo esc_html__('Age', 'woodmart' ) ?>:</p>
|
|
<p class="cabinet-card__text"><?php echo $old; ?></p>
|
|
</div>
|
|
|
|
<?php
|
|
else:
|
|
?>
|
|
<?php
|
|
$zero = '';
|
|
if (intval(get_field('month', $item)) < 10){
|
|
$zero = '0';
|
|
}
|
|
?>
|
|
<div class="cabinet-card__element">
|
|
<p class="cabinet-card__label"><?php echo esc_html__('Birhtday', 'woodmart' ) ?>:</p>
|
|
<p class="cabinet-card__text"><?php echo get_field('day', $item) . '.' . $zero . get_field('month', $item) . '.' . get_field('year', $item); ?></p>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<div class="cabinet-card__element">
|
|
<p class="cabinet-card__label"><?php echo esc_html__('Activity', 'woodmart' ) ?>:</p>
|
|
<p class="cabinet-card__text"><?php echo $act; ?></p>
|
|
</div>
|
|
<?php
|
|
if (get_field('type', $item) == 'cat' && get_field('sterilized', $item)):
|
|
?>
|
|
<div class="cabinet-card__element">
|
|
<p class="cabinet-card__label"><?php echo esc_html__('Sterilized', 'woodmart' ) ?></p>
|
|
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<div class="cabinet-card__element">
|
|
<button class="cabinet-card__button" data-edit="<?php echo get_the_ID($item); ?>">
|
|
<?php echo esc_html__('Edit', 'woodmart' ) ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
|