Skip to content

Instantly share code, notes, and snippets.

View pavlo-bondarchuk's full-sized avatar
🏠
remote

Pavlo Bondarchuk pavlo-bondarchuk

🏠
remote
View GitHub Profile
@pavlo-bondarchuk
pavlo-bondarchuk / *.php
Created December 3, 2017 15:41
display by post_type
<?php $post_type = get_post_type( $post_id ) ?>
<? if ($post_type == 'apartments') { echo 'Квартира'; }
elseif ($post_type == 'houses') { echo 'Дом'; }
elseif ($post_type == 'plots') { echo 'Участок'; }
elseif ($post_type == 'commercials') { echo 'Коммерческая недвижимость'; }
elseif ($post_type == 'hotels') { echo 'Гостиница'; }
else { echo 'Новость'; }
?>
@pavlo-bondarchuk
pavlo-bondarchuk / .php
Created December 14, 2017 22:21
convert url youtube/watch to youtube/embed
<?php
$url = 'https://www.youtube.com/watch?v=u9-kU7gfuFA';
preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $matches);
$id = $matches[1];
$width = '800px';
$height = '450px';
?>
<iframe id="ytplayer" type="text/html" width="<?php echo $width ?>" height="<?php echo $height ?>"
src="https://www.youtube.com/embed/<?php echo $id ?>?rel=0&showinfo=0&color=white&iv_load_policy=3"
frameborder="0" allowfullscreen></iframe>
@pavlo-bondarchuk
pavlo-bondarchuk / .php
Last active May 9, 2018 10:32
statements meta is type of page & lang
<?php if(is_archive() && ICL_LANGUAGE_CODE == 'ru'){
echo '<meta name="description" content="Программы курсов по охране труда и обучению рабочим специальностям учебно-консультационного центра по охране труда «ПРОФИТЕХ»">';
}?>
<?php if(is_archive() && ICL_LANGUAGE_CODE == 'uk'){
echo '<meta name="description" content="Програми курсів з охорони праці та навчання робітничим спеціальностям навчально-консультаційного центру з охорони праці «ПРОФІТЕХ»">';
}?>
<?php if($paged > 1 || is_author() || is_tag() || is_date() || is_attachment()){
echo '<meta name="robots" content="noindex,follow" />';
} ?>
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created May 7, 2018 14:27 — forked from braginteractive/extras.php
WordPress Filter to change the Custom Logo class
/**
* Changes the class on the custom logo in the header.php
*/
function helpwp_custom_logo_output( $html ) {
$html = str_replace('custom-logo-link', 'navbar-brand', $html );
return $html;
}
add_filter('get_custom_logo', 'helpwp_custom_logo_output', 10);
@pavlo-bondarchuk
pavlo-bondarchuk / template-page.php
Created May 7, 2018 15:58
acf gallery with slick slider
<div class="slider-main-gallery col">
<?php
$images = get_field('slider');
if( $images ): ?>
<?php foreach( $images as $image ): ?>
<div class="slide">
<span>
@pavlo-bondarchuk
pavlo-bondarchuk / ajax.html
Created June 16, 2018 13:49
ajax form - clear form on success, block btn#submit, timeout redirect to other page
////ajax form, clear form on success,block btn#submit,timeout redirect
$(".app-form").submit(function(event){//form class
event.preventDefault();//stop default
submitForm();//send to function
});
function submitForm(){
var name = $("#name").val();//input id="name"
var tel = $("#tel").val();//input id="tel"
$.ajax({
@pavlo-bondarchuk
pavlo-bondarchuk / .php
Created August 28, 2018 10:52
ICL_LANGUAGE_CODE == 'ru' ? 'uk'
<?php echo esc_html__(ICL_LANGUAGE_CODE == 'ru' ? 'Тут может быть текст на русском' : 'А ось тут українською') ?>
@pavlo-bondarchuk
pavlo-bondarchuk / php
Created October 2, 2018 16:05
get yoast description, title, focuskw in tax-product_category / profiteh
<?php
if ( is_tax() ) :
$taxonomy = get_queried_object()->taxonomy;
$term_id = get_queried_object()->term_id;
$meta = get_option( 'wpseo_taxonomy_meta' );
$title = $meta[$taxonomy][$term_id]['wpseo_title'];
$desc = $meta[$taxonomy][$term_id]['wpseo_desc'];
$focuskw = $meta[$taxonomy][$term_id]['wpseo_focuskw'];
//printf( '<pre>%s</pre>', print_r( get_option( 'wpseo_taxonomy_meta' ), 1 ) );
// if ( isset($meta) && !empty($title) ) :
@pavlo-bondarchuk
pavlo-bondarchuk / js
Created November 7, 2018 17:26
unmask onclick masked input
<script type="text/javascript">
$(function($) {
$("#OfficePhone").mask("(999) 999-9999? x99999");
$("#InternationalOfficePhone").click(function() {
var mask = "(999) 999-9999? x99999";
if ($("#InternationalOfficePhone").is(':checked')) {
$("#OfficePhone").unmask(mask);
} else {
$("#OfficePhone").mask(mask);
}
<?php if ( get_field( 'field_name' ) ): ?>
This is displayed when the field_name is TRUE or has a value.
<?php else: // field_name returned false ?>
This is displayed when the field is FALSE, NULL or the field does not exist.
<?php endif; // end of if field_name logic ?>