403Webshell
Server IP : 185.252.147.100  /  Your IP : 216.73.216.196
Web Server : nginx/1.27.3
System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : mitr ( 1000)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/html/tour.mitrofanov.ru/public_04_11/wp-content/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/html/tour.mitrofanov.ru/public_04_11/wp-content/plugins/tour_addons.php
<?php
/*
 * @wordpress-plugin
 * Plugin Name:       East Point Tour addons
 * Plugin URI:        http://mitrofanov.ru
 * Description:       <strong>Обязательный</strong> плагин для работы сайта.
 * Version:           1.0.0
 * Author:            @AlimovD
 * Author URI:        https://t.me/AlimovD
 */


add_filter( 'wp_resource_hints', 'your_add_resource_hints', 10, 2 );

function your_add_resource_hints( $hints, $relation_type ) {
	if ( 'preconnect' === $relation_type ) {
		$hints[] = [
			'href'        => 'https://cdn.jsdelivr.net/',
			'crossorigin' => 'anonymous',
		];
		$hints[] = [
			'href'        => 'https://unpkg.com/',
			'crossorigin' => 'anonymous',
		];
	}

	return $hints;
}


/**
 * Disable the emoji's***********************************************
 */
function disable_emojis_tinymce( $plugins ) {
 if ( is_array( $plugins ) ) {
 return array_diff( $plugins, array( 'wpemoji' ) );
 } else {
 return array();
 }
}
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
 if ( 'dns-prefetch' == $relation_type ) {
 /** This filter is documented in wp-includes/formatting.php */
 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );

$urls = array_diff( $urls, array( $emoji_svg_url ) );
 }

return $urls;
}
function disable_emojis() {
 remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
 remove_action( 'wp_print_styles', 'print_emoji_styles' );
 remove_action( 'admin_print_styles', 'print_emoji_styles' ); 
 remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 
 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
 add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
 //add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
	
//remove_action( 'wp_head', 'wp_resource_hints', 2, 99 );//Remove S.W.org DNS
}
add_action( 'init', 'disable_emojis' );

// This instructs Koko Analytics to not load the tracking script
// If the User-Agent contains either "StatusCake_Pagespeed_Indev" or "GTmetrix"
add_filter('koko_analytics_load_tracking_script', function () {
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        if (preg_match('/StatusCake_Pagespeed_Indev|GTmetrix|Googlebot|yandex\.com\/bots/', $_SERVER['HTTP_USER_AGENT'])) {
            return false;
        }
    }

    return true;
});

/*Removes RSD, XMLRPC, WLW, WP Generator, ShortLink and Comment Feed links*******************************/

add_filter('xmlrpc_enabled', '__return_false'); 

function whtop_setup()
{
    remove_action( 'wp_head', 'feed_links_extra', 3); // Remove category feeds
    remove_action( 'wp_head', 'feed_links', 2); // Remove Post and Comment Feeds
    remove_action( 'wp_head', 'rsd_link' );
    remove_action( 'wp_head', 'wlwmanifest_link' );
    remove_action( 'wp_head', 'wp_generator' );
	//add_filter( 'the_generator', '__return_null' );
	remove_action('wp_head', 'wp_shortlink_wp_head');

}
add_action( 'after_setup_theme', 'whtop_setup' );

//Отключаем тесты!*******************

add_filter( 'site_status_tests', function( $tests ) {
 
	// асинхронные запросы находятся в массиве 'async'
	unset( $tests['async']['dotorg_communication'] );// Соединение с WordPress.org
	unset( $tests['async']['background_updates'] );//Фоновые обновления
	unset( $tests['async']['loopback_requests'] );//Петлевой запрос
 
	// синхронные – в массиве 'direct'
	unset( $tests['direct']['rest_availability'] );//Доступность REST API
	
	/*wordpress_version – Версия WordPress,
plugin_version – Версии плагинов,
theme_version – Версии тем,
php_version – Версия PHP,
php_extensions – PHP расширения,
php_default_timezone – Часовой пояс PHP по умолчанию,
sql_server – Версия ПО СУБД,
utf8mb4_support – MySQL поддержка кодировки utf8mb4,
https_status – Статус HTTPS,
ssl_support – Безопасное подключение,
scheduled_events – Запланированные события WP_Cron,
http_requests – HTTP запросы,
debug_enabled – Включена отладка (имеется ввиду WP_DEBUG в wp-config.php),*/
 
	return $tests;
 
} );


/*Removes prev and next article links****************************************/
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

// Отключение rss-ленты**********************************************
function fb_disable_feed() {wp_redirect(get_option('siteurl'));}
add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);


//Comments Disable

add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;
    
    if ($pagenow === 'edit-comments.php') {
        wp_redirect(admin_url());
        exit;
    }

    // Remove comments metabox from dashboard
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');

    // Disable support for comments and trackbacks in post types
    foreach (get_post_types() as $post_type) {
        if (post_type_supports($post_type, 'comments')) {
            remove_post_type_support($post_type, 'comments');
            remove_post_type_support($post_type, 'trackbacks');
        }
    }
});

// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);

// Remove comments page in menu
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
});

// Remove comments links from admin bar
add_action('init', function () {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
});

// add_filter('comment_form_default_fields', 'unset_url_field');
// function unset_url_field($fields){
// if(isset($fields['url']))
// unset($fields['url']);
// return $fields;
// }


#tour gallery frontend

/* Enqueue Glightbox https://github.com/biati-digital/glightbox */
add_action( 'wp_enqueue_scripts', 'enqueue_glightbox' );
function enqueue_glightbox() {
wp_enqueue_style( 'glightbox-css', 'https://cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css' );
wp_enqueue_script( 'glightbox', 'https://cdn.jsdelivr.net/gh/mcstudios/glightbox/dist/js/glightbox.min.js', '', '', true );

wp_enqueue_script( 'gstabs-js', '/wp-content/plugins/greenshift-animation-and-page-builder-blocks/libs/tabs/tabs.js', '', '', true );


//wp_enqueue_script( 'glightbox-init', get_stylesheet_directory_uri() . '/glightbox/init.js', '', '', true );
wp_add_inline_script( 'glightbox', 'const lightbox = GLightbox({
touchNavigation: true,
loop: true,
autoplayVideos: false,
zoomable: false
});' );

$custom_css = '
#tour-gallery .nodisplay {
	display: none !important
}
#tour-gallery .tour_img {
    overflow: hidden;
    cursor: pointer;

}
#tour-gallery .tour_img a {
	display:flex;
    overflow: hidden;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

#tour-gallery .tour_img a img {
	object-fit: cover;
	object-position: center;
	width: 100%;
    height: 100%;
}


#tour-gallery {
display: grid;
  grid-template-columns: 4fr 1fr minmax(0px, 1fr);
  grid-template-rows: 1fr auto;
  gap: .5rem;
  grid-auto-flow: row;
  grid-template-areas:
    "area1 area2 area2"
    "area1 area3 area4";
    overflow: hidden;
 max-height: 500px;
    position: relative
}

.image--1 { grid-area: area1; }

.image--2 { grid-area: area2; }

.image--3 { grid-area: area3; }

.image--4 { grid-area: area4; }

.photo-collage__show-all {
	position: absolute;
    top: 1rem;
    left: 1rem;
}

.photo-collage__show-all button{
	display: block;
    padding: .65em 1em;
    font-size: .9rem;
    background: white;
    border-radius: .5rem;
    border: none;
    box-shadow: 0 0 2px #797979;
    cursor: pointer;
    font-family: "Jost";
}


/*TABS CSS*/
.gspb-tabs * {
	box-sizing: border-box !important
}

.wp-block-greenshift-blocks-tab {
	margin-top: .5rem;
    font-size: 1.5rem;
    padding: .4rem 0;
}

.t-btn-container {
	display: flex;
	flex-direction: row;
	width: 100%;
	align-items: center;
	margin-bottom: -1px;
	flex-wrap: wrap;
	gap: .8rem;
	padding: .8rem 0;
}

.t-btn-container .t-btn {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    cursor: pointer;
    position: relative;
    height: 2.2rem;
    width: 2.2rem;
    justify-content: center;
    background: #0693e3b5;
    font-size: .9rem;
    font-weight: 600;
    border-radius: 99px;
    color: white;

}
.t-btn-container .t-btn:hover {
	background:#0693e3
}
/*
.t-btn-container .t-btn .tabsubtitle {
	font-size: 70%;
	opacity: .7
}*/

.gstabs-tabs .t-btn {
	border: 1px solid transparent;
	border-top-width: 2px
}

.gstabs-tabs .t-btn.active {
    border-color: #0693e3;
    border-bottom-color: #0693e3;
    background-color: #ffffff;
    color: #333;
}

.t-panel-container .t-panel {
	opacity: 0;
	display: none
}

.t-panel-container .t-panel.active {
	opacity: 1;
	display: block !important
}

.t-panel-container {
	margin-bottom: 0;
line-height: 1rem;

}

.gstabs-tabs .t-panel-container {
	border: 1px solid rgba(206, 206, 206, .4);
	background-color: #fff
}

.t-btn-container ul {
	margin: 0 !important;
	padding: 0 !important
}

.gstabs-underline .t-btn-container .t-btn:after {
	position: absolute;
	bottom: 0;
	left: 0;
	content: "";
	height: 3px;
	width: 0;
	transition: width .5s, left .5s, right .5s;
}

.gstabs-underline .t-btn-container .t-btn.active:after {
	width: 100%;
	left: 0;
	right: 0
}

.gstabs-pills .t-btn-container .t-btn {
	margin: 0 10px;
	border: 1px solid transparent
}

.gstabs-vertical {
	display: flex
}

.gstabs-vertical .t-btn-container {
	display: block;
	width: 150px
}

.gstabs-vertical .t-btn-container .t-btn {
	margin-bottom: 10px;
	width: 150px;
	border: 1px solid transparent
}

.gstabs-vertical .t-panel-container {
	flex-grow: 1
}

.t-btn-container .t-btn .gs-image {
	flex-grow: inherit;
}

.t-btn-container .t-btn img {
	margin: 0;
	height: 25px;
	min-width: auto
}

@keyframes gcwidthleftright {
	0% {
		width: 0%
	}

	100% {
		width: 100%
	}

}

@keyframes gcslidefromtop {
	0% {
		transform: translateY(-10px);
		opacity: 0
	}

	100% {
		transform: translateY(0);
		opacity: 1
	}

}

@media (max-width:575.98px) {
	body .tabscroll .t-btn-container {
		overflow-x: scroll;
		flex-wrap: nowrap;
		scroll-behavior: smooth;
		scroll-snap-type: x mandatory;
		width: 100% !important;
		white-space: nowrap;
		display: block;
		padding-bottom: 15px
	}

	.tabscroll .t-btn-container .t-btn {
		scroll-snap-align: start;
		white-space: nowrap;
		width: auto !important;
		margin-right: 10px;
	}

	.tabscroll .t-btn-container .t-btn.active {
		box-shadow: none !important
	}

	.gstabs-vertical {
		display: block !important
	}

	.gstabs-vertical .t-panel-container {
		margin-top: 25px
	}

	.t-btn-container .t-btn {
		font-size: 15px
	}

}

.t-panel-container p:last-of-type {
	margin-bottom: 0
}

.gspb_tabs-id-gsbp-05f3960 .t-btn-container {
	justify-content: left
}

.gspb_tabs-id-gsbp-05f3960 >.t-btn-container >.t-btn {
	background-color: #f5f5f5
}

.gspb_tabs-id-gsbp-05f3960 >.t-btn-container >.t-btn.active {
	background-color: #e5e5e5
}

.gspb_tabs-id-gsbp-05f3960 .t-btn-container .t-btn {
	gap: 10px
}
';
wp_add_inline_style( 'glightbox-css', $custom_css );
}


add_shortcode( 'tour-gallery', 'get_tour_gallery' );

function get_tour_gallery( $atts ) {

	global $post;
	$photos_query = get_post_meta( $post->ID, 'gallery_data', true );

	$content = '<div id="tour-gallery">';

	$forcount = has_post_thumbnail( $post->ID ) ? 1 : 0;

	if ( $forcount == 1 ) {

		$content .= '<div class="tour_img image--1">';

		$tour_thumbnail_url = get_the_post_thumbnail_url( $post->ID, array( 1900, 1000) );

		$content .= '<a id="tour-image-1" href="'.$tour_thumbnail_url.'" class="glightbox">'.get_the_post_thumbnail( $post->ID, array( 600, 600) ).'</a>';
		$content .= '</div>';
	}

	if($photos_query) {

		$arr = $photos_query['image_id'];

		$counted = sizeof($arr);

		for( $i=0; $i<$counted; $i++ ){

			$add = ( $forcount == 1 ) ? 0 : 1;

			$display = $i>(2+$add) ? ' nodisplay' : '';
			$imcount = $i>(2+$add) ? '' : ' image--'.$i+1+$forcount;

			$content .= '<div class="tour_img'.$imcount.$display.'">';
			$content .= '<a id="tour-image-'.$imcount.'" href="'.wp_get_attachment_image_url( $arr[$i], array( 1900, 1000) ).'" class="glightbox"><img class="gallery-img" src="'.wp_get_attachment_image_url( $arr[$i], array(600, 600) ).'" alt=""/></a>';
			$content .= '</div>';
		}

		if ($counted>3) {

			if ( $forcount == 1 ) $counted = $counted+1; 

				$content .= '<div class="photo-collage__show-all"><button onclick="document.getElementById(&#39;tour-image-1&#39;).click()">Показать все изображения: '.$counted.'</button></div>';
			
		}

		

	}

	$content .= '</div>';
	return $content;

}


# tour gallery backend
# https://github.com/demirdoven/image-gallery-for-cpt-or-post-in-wordpress

function property_gallery_add_metabox(){
	add_meta_box(
		'post_custom_gallery',
		'Изображения',
		'property_gallery_metabox_callback',
		'tour', // Change post type name
		'normal',
		'core'
	);
}
add_action( 'admin_init', 'property_gallery_add_metabox' );

function property_gallery_metabox_callback(){
	wp_nonce_field( basename(__FILE__), 'sample_nonce' );
	global $post;
	$gallery_data = get_post_meta( $post->ID, 'gallery_data', true );
	?>
	<div id="gallery_wrapper">
		<div id="img_box_container">
		<?php 
		if ( isset( $gallery_data['image_url'] ) ){
			for( $i = 0; $i < count( $gallery_data['image_url'] ); $i++ ){
			?>
			<div class="gallery_single_row dolu">
			  <div class="gallery_area image_container ">
				<img class="gallery_img_img" src="<?php esc_html_e( $gallery_data['image_url'][$i] ); ?>" height="55" width="55" onclick="open_media_uploader_image_this(this)"/>
				<input type="hidden"
						 class="meta_image_url"
						 name="gallery[image_url][]"
						 value="<?php esc_html_e( $gallery_data['image_url'][$i] ); ?>"
				  />
				  <input type="hidden"
						 class="meta_image_id"
						 name="gallery[image_id][]"
						 value="<?php esc_html_e( $gallery_data['image_id'][$i] ); ?>"
				  />
			  </div>
			  <div class="gallery_area">
				<span class="button remove" onclick="remove_img(this)" title="Убрать"/><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width='1em' height='1em' fill='red'><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"/></svg></span>
			  </div>
			  <div class="clear" />
			</div> 
			</div>
			<?php
			}
		}
		?>
		</div>
		<div style="display:none" id="master_box">
			<div class="gallery_single_row">
				<div class="gallery_area image_container" onclick="open_media_uploader_image(this)">
					<input class="meta_image_url" value="" type="hidden" name="gallery[image_url][]" />
					<input class="meta_image_id" value="" type="hidden" name="gallery[image_id][]" />
				</div> 
				<div class="gallery_area"> 
					<span class="button remove" onclick="remove_img(this)" title="Убрать"/><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width='1em' height='1em' fill='red'><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"/></svg></span>
				</div>
				<div class="clear"></div>
			</div>
		</div>
		<div id="add_gallery_single_row">
		  <input class="button add" type="button" value="+" onclick="open_media_uploader_image_plus();" title="Добавить фото"/>
		</div>
	</div>
	<?php
}

function property_gallery_styles_scripts(){
    global $post;
    if( 'tour' != $post->post_type )
        return;
    ?>  
    <style type="text/css">
	.gallery_area {
		float:right;
	}
	.image_container {
		float:left!important;
		width: 100px;
		background: url('https://i.hizliresim.com/dOJ6qL.png');
		height: 100px;
		background-repeat: no-repeat;
		background-size: cover;
		border-radius: 3px;
		cursor: pointer;
	}
	.image_container img{
		height: 100px;
		width: 100px;
		border-radius: 3px;
	}
	.clear {
		clear:both;
	}
	#gallery_wrapper {
		width: 100%;
		height: auto;
		position: relative;
		display: inline-block;
	}
	#gallery_wrapper input[type=text] {
		width:300px;
	}
	#gallery_wrapper .gallery_single_row {
		float: left;
		display:inline-block;
		width: 100px;
		position: relative;
		margin-right: 8px;
		margin-bottom: 20px;
	}
	.dolu {
		display: inline-block!important;
	}
	#gallery_wrapper label {
		padding:0 6px;
	}
	.button.remove {
		color: #f1f1f1;
		position: absolute;
		border: none;
		top: 5px;
		right: 5px;
		font-size: 1.2em;
		background: white;
    line-height: 1.5em;
    min-height: auto;
    display: flex;
    padding: 2px;
    box-shadow: 1px 1px 3px 0px #535353;
    border-radius: 99px;

	}
	.button.remove:hover {
		padding: 3px;
		box-shadow: 1px 1px 8px 0px #535353;
		top: 4px;
		right: 4px;
	}
	.button.add {
		background: #c3c2c2;
		color: #ffffff;
		border: none;
		box-shadow: none;
		width: 100px;
		height: 100px;
		line-height: 100px;
		font-size: 4em;
	}
	.button.add:hover, .button.add:focus {
		background: #e2e2e2;
		box-shadow: none;
		color: #0f88c1;
		border: none;
	}
    </style>

    <script type="text/javascript">
        function remove_img(value) {
            var parent=jQuery(value).parent().parent();
            parent.remove();
        }
		var media_uploader = null;
		function open_media_uploader_image(obj){
			media_uploader = wp.media({
				frame:    "post", 
				state:    "insert", 
				multiple: false
			});
			media_uploader.on("insert", function(){
				var json = media_uploader.state().get("selection").first().toJSON();
				var image_url = json.url;
				var image_id = json.id;
				var html = '<img class="gallery_img_img" src="'+image_url+'" height="55" width="55" onclick="open_media_uploader_image_this(this)"/>';
				console.log('image_url ' + image_url);
				console.log('id ' + image_id);
				jQuery(obj).append(html);
				jQuery(obj).find('.meta_image_url').val(image_url);
				jQuery(obj).find('.meta_image_id').val(image_id);
			});
			media_uploader.open();
		}
		function open_media_uploader_image_this(obj){
			media_uploader = wp.media({
				frame:    "post", 
				state:    "insert", 
				multiple: false
			});
			media_uploader.on("insert", function(){
				var json = media_uploader.state().get("selection").first().toJSON();
				var image_url = json.url;
				var image_id = json.id;
				console.log('image_url ' + image_url);
				console.log('id ' + image_id);
				jQuery(obj).attr('src',image_url);
				jQuery(obj).siblings('.meta_image_url').val(image_url);
				jQuery(obj).siblings('.meta_image_id').val(image_id);
			});
			media_uploader.open();
		}

		function open_media_uploader_image_plus(){
			media_uploader = wp.media({
				frame:    "post", 
				state:    "insert", 
				multiple: true 
			});
			media_uploader.on("insert", function(){

				var length = media_uploader.state().get("selection").length;
				var images = media_uploader.state().get("selection").models;

				for(var i = 0; i < length; i++){
					var image_url = images[i].changed.url;
					var image_id = images[i].id;
					var box = jQuery('#master_box').html();
					jQuery(box).appendTo('#img_box_container');
					var element = jQuery('#img_box_container .gallery_single_row:last-child').find('.image_container');
					var html = '<img class="gallery_img_img" src="'+image_url+'" height="55" width="55" onclick="open_media_uploader_image_this(this)"/>';
					element.append(html);
					element.find('.meta_image_url').val(image_url);
					element.find('.meta_image_id').val(image_id);
					//console.log('image_url ' + image_url);
					//console.log('image_id ' + image_id);
				//console.log('images ' +  images[i].sizes.thumbnail.url );
					//console.log('images ' + JSON.stringify(images[i]) );
					//console.log(Object.entries(images[i]));
	

				}
			});
			media_uploader.open();
		}
		jQuery(function() {
            jQuery("#img_box_container").sortable(); // Activate jQuery UI sortable feature
        });
    </script>
    <?php
}
add_action( 'admin_head-post.php', 'property_gallery_styles_scripts' );
add_action( 'admin_head-post-new.php', 'property_gallery_styles_scripts' );

function property_gallery_save( $post_id ) {
		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
			return;
		}
		$is_autosave = wp_is_post_autosave( $post_id );
		$is_revision = wp_is_post_revision( $post_id );
		$is_valid_nonce = ( isset( $_POST[ 'sample_nonce' ] ) && wp_verify_nonce( $_POST[ 'sample_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
		
		if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
				return;
		}
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
			return;
		}

		// Correct post type
		if ( 'tour' != $_POST['post_type'] ) // here you can set the post type name
			return;
	 
		if ( $_POST['gallery'] ){
			
			// Build array for saving post meta
			$gallery_data = array();
			for ($i = 0; $i < count( $_POST['gallery']['image_url'] ); $i++ ){
				if ( '' != $_POST['gallery']['image_url'][$i]){
					$gallery_data['image_url'][]  = $_POST['gallery']['image_url'][ $i ];
				}
			}
			for ($i = 0; $i < count( $_POST['gallery']['image_id'] ); $i++ ){
				if ( '' != $_POST['gallery']['image_id'][$i]){
					$gallery_data['image_id'][]  = $_POST['gallery']['image_id'][ $i ];
				}
			}
	 
			if ( $gallery_data ) 
				update_post_meta( $post_id, 'gallery_data', $gallery_data );
			else 
				delete_post_meta( $post_id, 'gallery_data' );
		} 
		// Nothing received, all fields are empty, delete option
		else{
			delete_post_meta( $post_id, 'gallery_data' );
		}
}
add_action( 'save_post', 'property_gallery_save' );






add_shortcode( 'tour-field', 'get_tour_field_func' );
function get_tour_field_func( $atts ) {
	$t = $atts["field"];
	$var = get_field($t);
	if ($var)
	return $var;
	$var_sub = get_sub_field($t);
	if ($var_sub)
	return $var_sub;
	
}

add_shortcode( 'translator', 'get_tour_translator_func' );
function get_tour_translator_func( $atts ) {
	$var = get_field('tour_translator');
	if (!$var) return;
	$var = '<div>'.number_format_i18n( $var ).' руб.</div>';
	return $var;
	
}

add_shortcode( 'duration', 'get_tour_duration_func' );
function get_tour_duration_func( $atts ) {
	$var = get_field('tour_duration');
	if (!$var) return;
	$var = '<div>'.$var.' ч.</div>';
	return $var;
	
}

add_shortcode( 'addons', 'get_tour_addons_func' );
function get_tour_addons_func( $atts ) {
	$var = get_field('tour_addons');
	if (!$var) return;
	$var = '<div>'.$var.'</div>';
	return $var;
	
}

// add_shortcode( 'baz-up', 'baz_func' );
// add_shortcode( 'baz-down', 'baz_func' );

// function baz_func( $atts, $content, $tag ) {

// 	// какая-то общая логика, например обработка переменных $atts
// 	$atts = shortcode_atts( array(
// 		'foo' => 'no foo',
// 		'baz' => 'default baz'
// 	), $atts );

// 	if( 'baz-up' === $tag ){
// 		$content = 'Конетнт шорткода [baz-up] - ' . $atts['foo'];
// 	}
// 	elseif( 'baz-down' === $tag ){
// 		$content = 'Конетнт шорткода [baz-down] - ' . $atts['foo'];
// 	}

// 	return $content;
// }

add_shortcode( 'tour-transfer', 'get_tour_field_excerpt' );
function get_tour_field_excerpt($atts) {
	ob_start();
	$var = get_field('tour_transfer');

	if (!$var) return;
?>
<div class="gspb-tabs" data-autoplay="false" data-autoplaytime="4">
   <div class="t-btn-container gstabs-tabs">
      <div class="t-btn active" aria-expanded="false" role="button" tabindex="0" aria-controls="gspb-tab-item-content-gsbp-c2e727a-0"><div class="tabtitlelabel">3</div></div>
      <div class="t-btn" aria-expanded="false" role="button" tabindex="0" aria-controls="gspb-tab-item-content-gsbp-c2e727a-1"><div class="tabtitlelabel">6</div></div>
      <div class="t-btn" aria-expanded="false" role="button" tabindex="0" aria-controls="gspb-tab-item-content-gsbp-c2e727a-2"><div class="tabtitlelabel">12</div></div>
      <div class="t-btn" aria-expanded="true" role="button" tabindex="0" aria-controls="gspb-tab-item-content-gsbp-c2e727a-3"><div class="tabtitlelabel">20</div></div>
      <div class="t-btn" aria-expanded="false" role="button" tabindex="0" aria-controls="gspb-tab-item-content-gsbp-c2e727a-4">
         <div class="tabtitlelabel">45</div>
      </div>
   </div>
   <div class="t-panel-container">
      <div class="gswipertabs">
         <div class="swiper-wrapper">
            <div aria-hidden="false" id="gspb-tab-item-content-gsbp-c2e727a-0" class="t-panel swiper-slide active">
               <p class="wp-block-greenshift-blocks-tab"><?php echo number_format_i18n($var['to_3']); ?> руб.</p></div>
            <div aria-hidden="true" id="gspb-tab-item-content-gsbp-c2e727a-1" class="t-panel swiper-slide">
               <p class="wp-block-greenshift-blocks-tab"><?php echo number_format_i18n($var['to_6']); ?> руб.</p></div>
            <div aria-hidden="true" id="gspb-tab-item-content-gsbp-c2e727a-2" class="t-panel swiper-slide">
               <p class="wp-block-greenshift-blocks-tab"><?php echo number_format_i18n($var['to_12']); ?> руб.</p></div>
            <div aria-hidden="true" id="gspb-tab-item-content-gsbp-c2e727a-3" class="t-panel swiper-slide">
               <p class="wp-block-greenshift-blocks-tab"><?php echo number_format_i18n($var['to_20']); ?> руб.</p></div>
            <div aria-hidden="true" id="gspb-tab-item-content-gsbp-c2e727a-4" class="t-panel swiper-slide">
               <p class="wp-block-greenshift-blocks-tab"><?php

               echo is_numeric($var['to_45']) ? number_format_i18n($var['to_45']).' руб.' : $var['to_45'];

           ?></p></div></div></div></div></div>
<?php

	return ob_get_clean();
}




##############
# hook_favicon
##############
function hook_favicon() {
    ?>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<?php
}
add_action('wp_head', 'hook_favicon');

function hook_font_preload() {
?>
<link rel="preload" href="/wp-content/uploads/fonts/Jost-VariableFont_wght.woff2" as="font" type="font/woff2" crossorigin>
<?php

}
add_action('wp_head','hook_font_preload', 1);


/****************ADMIN CUSTOM LOGO*********************/

function wpb_login_logo() { ?>
    <style type="text/css">
        #login h1 a, .login h1 a {
            background-image: url(/android-chrome-192x192.png);
        height:150px;
        width:150px;
        background-size: 150px 150px;
        background-repeat: no-repeat;
        padding-bottom: 10px;
        }
    </style>
<?php }
add_action( 'login_enqueue_scripts', 'wpb_login_logo' );

function wpb_login_logo_url() {
    return home_url();
}
add_filter( 'login_headerurl', 'wpb_login_logo_url' );
 
// Customize login header text.
add_filter( 'login_headertext', 'wpdoc_customize_login_headertext' );
 
function wpdoc_customize_login_headertext( $headertext ) {
    $headertext = 'East Poin Tour';
    return $headertext;
}


/**
 * Restrict access to the administration screens.
 *
 * Only administrators will be allowed to access the admin screens,
 * all other users will be automatically redirected to
 * 'example.com/path/to/location' instead.
 *
 * We do allow access for Ajax requests though, since these may be
 * initiated from the front end of the site by non-admin users.
 */
// function restrict_admin_with_redirect() {

//     if ( ! current_user_can( 'edit_posts' ) && ( ! wp_doing_ajax() ) ) {
//         //wp_safe_redirect( 'https://lekarvostoka.ru' ); // Replace this with the URL to redirect to.
// 		wp_safe_redirect( home_url('/') );
//         exit;
//     }
// }

// add_action( 'admin_init', 'restrict_admin_with_redirect', 1 );



add_action(
  'wp_footer',
  function() {
  	if ( ! current_user_can( 'edit_posts' ) ) {
?>
    <script type="text/javascript">!function(){"use strict";var i,c=!1,a=96994604;function d(){i=setTimeout(s,1e3)}function s(e){var t,n,r,o;c||(t=window,o=document,n="script",t.ym=t.ym||function(){(t.ym.a=t.ym.a||[]).push(arguments)},t.ym.l=+new Date,r=o.createElement(n),o=o.getElementsByTagName(n)[0],r.async=1,r.src="https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js",o.parentNode.insertBefore(r,o),ym(a,"init",{clickmap:!0,trackLinks:!0,accurateTrackBounce:!0}),c=!0,clearTimeout(i),window.removeEventListener("scroll",s),window.removeEventListener("touchstart",s),document.removeEventListener("mouseenter",s),document.removeEventListener("click",s),document.removeEventListener("DOMContentLoaded",d))}-1<navigator.userAgent.indexOf("YandexMetrika")?s():(window.addEventListener("scroll",s,{passive:!0}),window.addEventListener("touchstart",s),document.addEventListener("mouseenter",s),document.addEventListener("click",s),document.addEventListener("DOMContentLoaded",d))}();</script>
<?php
}
  }
);

Youez - 2016 - github.com/yon3zu
LinuXploit