| Server IP : 80.93.52.51 / Your IP : 216.73.217.75 Web Server : Apache/2.4.58 (Ubuntu) System : Linux 80-93-52-51.swtest.ru 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/undergroundexpert.info/wp-content/themes/shablon/ |
Upload File : |
<?php
/**
* Данный хук крайне важен для того, что бы подружить плагин "Polylang" и "Easy Primary Category"
* Поэтому крайне важно, что бы данный хук использовался в теме.
*/
add_filter('is_protected_meta', 'filter_function_is_protected_meta', 10, 3);
function filter_function_is_protected_meta ($protected, $meta_key, $meta_type)
{
if ($meta_key === 'epc_primary_category') {
$protected = true;
}
return $protected;
}
remove_filter('the_excerpt', 'wpautop');
/*if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150 );
}*/
add_theme_support( 'post-thumbnails' );
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'catalog-thumb', 295, 186, true );
add_image_size( 'mini-thumb', 85, 85, true );
add_image_size( 'photogallery-thumb', 176, 176, true );
add_image_size( 'last-event-thumb', 84, 53, true );
}
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'New Sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<div class="title">',
'after_title' => '</div>',
));
register_nav_menus( array(
'header_menu' => 'Меню в шапке',
'footer_menu' => 'Меню в подвале'
) );
add_action('admin_menu', 'register_custom_menu_page');
function register_custom_menu_page() {
add_menu_page('Меню', 'Меню', '8', 'nav-menus.php');
}
//Переносим скрипты вниз
function footer_enqueue_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('after_setup_theme','footer_enqueue_scripts');
// Add plugin JQuery.cookies
function jquery_cookies() {
wp_enqueue_script( 'jquery_cookies', get_stylesheet_directory_uri() . '/js/jquery.cookie.js', array('jquery') );
}
add_action( 'wp_enqueue_scripts', 'jquery_cookies' );
//Новости
add_action('init', 'codex_custom_init3');
function codex_custom_init3()
{
$labels = array(
'name' => _x('Фотогалерея',''),
'singular_name' => _x('Фотогалерея',''),
'add_new' => _x('Добавить новую', 'photogallery'),
'add_new_item' => __('Добавить новую'),
'edit_item' => __('Редактировать'),
'new_item' => __('Новая'),
'all_items' => __('Все фотогалереи'),
'view_item' => __('Просмотреть'),
'search_items' => __('Поиск'),
'not_found' => __('Не найдено'),
'not_found_in_trash' => __('Нет в корзине'),
'parent_item_colon' => '',
'menu_name' => 'Фотогалерея'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 6,
'supports' => array('title','editor','author','thumbnail','excerpt','comments')
);
register_post_type('photogallery',$args);
}
add_filter( 'login_headerurl', create_function('', 'return get_home_url();') );
add_filter( 'login_headertitle', create_function('', 'return false;') );
if ( !current_user_can( 'edit_users' ) ) {
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
add_filter( 'show_admin_bar', '__return_false' );
//Добавляем атрибут title для изображений галерей(атрибут убран начиная с WP 3.5)
function my_image_titles($atts,$img) {
$atts['title'] = trim(strip_tags( $img->post_content ));
return $atts;
}
add_filter('wp_get_attachment_image_attributes','my_image_titles',10,2);
function display_map($attr) {
return "<div class='map_block'>".get_field('yandex_map', 21)."</div>";
}
add_shortcode('map', 'display_map');
if( function_exists('acf_add_options_page') ) {
//acf_add_options_page();
acf_add_options_page('Общие настройки');
acf_add_options_page('Общие настройки (англ)');
}
/**/
function show_contact_persons($attr) {
$html = '<div class="contact_persons_block">';
if( have_rows('contact_persons', 8) ):
while ( have_rows('contact_persons', 8) ) : the_row();
$html .=
'<div class="dt redact_person">
<div class="dtc vat redact_person_img">
<img src="'.get_sub_field("photo").'" alt=""/>
</div>
<div class="dtc vat redact_person_info">
<p class="redact_person_dol">'.get_sub_field("dol").'</p>
<p class="redact_person_name">'.get_sub_field("name").'</p>
<p class="redact_person_phone">
<span>Телефон для контакта:</span><br>
'.get_sub_field("phone").'
</p>
</div>
</div>';
endwhile;
endif;
$html .= '</div>';
return $html;
}
add_shortcode('contact_persons', 'show_contact_persons');
//Custom comment
function custom_comment($comment, $args, $depth) { ?>
<div id="comment-<?php comment_ID() ?>" class="comment_block <?php if($comment->comment_parent != '0') echo 'child_comment'?>">
<div class="dt">
<div class="dtc vat comment_avatar">
<?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
</div>
<div class="dtc vat comment_info">
<span class="comment_author_name" href="<?php echo $comment->comment_author_url?>"><?php echo $comment->comment_author?></span>
<?php
$comment_date = get_comment_date('U');
$now = time();
$diff_time = ($now - $comment_date)/(24*60*60);
$diff_time = floor($diff_time);
$day_str = '';
$date_str = '';
switch($diff_time) {
case 1: $day_str = ' вчера'; break;
case 2: $day_str = ' дня назад'; break;
case 3: $day_str = ' дня назад'; break;
case 4: $day_str = ' дня назад'; break;
case 5: $day_str = ' дней назад'; break;
case 6: $day_str = ' дней назад'; break;
case 7: $day_str = ' дней назад'; break;
}
if($diff_time < 1):
$date_str = "Сегодня, в ".get_comment_date('H:i');
elseif($diff_time == 1):
$date_str = "Вчера, в ".get_comment_date('H:i');
elseif($diff_time <= 7):
$date_str = $diff_time.$day_str;
else:
$date_str = get_the_time('d.m.Y', $comment->comment_ID);
endif;
?>
<span class="comment_date"><?php echo $date_str?></span>
<div class="comment_text">
<?php echo $comment->comment_content?>
</div>
<div class="comment_meta">
<?php comment_reply_link( array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
</div>
</div><!--/.dt-->
<?php
}
function wpsites_change_comment_form_submit_label($arg) {
if (pll_current_language() == "ru") {
$arg['label_submit'] = 'Оставить комментарий';}
else {
$arg['label_submit'] = 'Post the comment';
}
return $arg;
}
add_filter('comment_form_defaults', 'wpsites_change_comment_form_submit_label');
function wpsites_modify_comment_form_text_area($arg) {
if (pll_current_language() == "ru") {
$arg['comment_field'] = '<p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required" placeholder="Оставить комментарий"></textarea></p>';
}else {
$arg['comment_field'] = '<p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required" placeholder="Post the comment"></textarea></p>';
}
return $arg;
}
add_filter('comment_form_defaults', 'wpsites_modify_comment_form_text_area');
// Ссылка на главную в виде "Главная - Home", а не название сайта
// Текст ссылки
function filter_bcn_breadcrumb_title( $title, $this_type, $this_id ) {
if ($this_type[0] === "home") {
if (pll_current_language() == "ru") {
$title = get_field('index_page_title', 'options');
} else {
$title = get_field('index_page_title-eng', 'options');
}
}
return $title;
};
// Сама ссылка
function filter_bcn_breadcrumb_url( $url, $this_type, $this_id ) {
if ($this_type[0] === "home") {
if (pll_current_language() == "ru") {
$url = get_field('link_to_index', 'options');
} else {
$url = get_field('link_to_index-eng', 'options');
}
}
return $url;
};
// Добавим фильтры
add_filter( 'bcn_breadcrumb_url', 'filter_bcn_breadcrumb_url', 10, 3 );
add_filter( 'bcn_breadcrumb_title', 'filter_bcn_breadcrumb_title', 10, 3 );
?>