Skip to content

Instantly share code, notes, and snippets.

View yuriitaran's full-sized avatar

Yurii Taran yuriitaran

View GitHub Profile
@yuriitaran
yuriitaran / HTML: Disable Skype phone number link in Edge
Last active November 15, 2017 08:31
Disable Skype phone number link in Edge
@yuriitaran
yuriitaran / WP: ACF repeater loop
Last active November 15, 2017 08:33
ACF repeater loop
// For Post Type
<?php $the_query = new WP_Query( array( 'post_type' => 'contacts', 'order' => 'ASC', ) );
if ( $the_query->have_posts() ) : ?>
<ul class="footer-contacts">
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php if( have_rows('contact_types') ): ?>
<?php while( have_rows('contact_types') ): the_row(); ?>
<li>
<?php if (get_sub_field('contact_type')): ?>
<span class="contact-title"><?php the_sub_field('contact_type'); ?></span>
<?php the_post_thumbnail( 'large', ['alt' => get_the_title()] ); ; ?>
<?php
$menu_location = 'main-menu';
$menu_locations = get_nav_menu_locations();
$menu_object = (isset($menu_locations[$menu_location]) ? wp_get_nav_menu_object($menu_locations[$menu_location]) : null);
$menu_name = (isset($menu_object->name) ? $menu_object->name : '');
echo esc_html($menu_name);
?>
// Show post type Singular Label on singular post page:
$post = get_queried_object();
$postType = get_post_type_object(get_post_type($post));
if ($postType) {
echo esc_html($postType->labels->singular_name);
}
// Show post type Singular Label in the loop:
$postType = get_post_type_object(get_post_type());
if ($postType) {
@yuriitaran
yuriitaran / WP: Check for active dynamic Sidebar
Created November 20, 2017 15:01
Check for active dynamic Sidebar
<!-- BEGIN of page content -->
<div class="<?php echo ( is_dynamic_sidebar('right') ) ? 'large-8 medium-8' : 'large-12 medium-12'; ?> small-12 columns">
bla-bla-bla ...
</div>
<!-- END of page content -->
<!-- BEGIN of sidebar -->
<?php if ( is_dynamic_sidebar('right') ): ?>
<div class="large-4 medium-4 small-12 columns sidebar">
<?php get_sidebar('right'); ?>
// functions.php
function filter_plugin_updates( $value ) {
if( isset( $value->response['woocommerce/woocommerce.php'] ) ){
unset( $value->response['woocommerce/woocommerce.php'] );
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
// prevent to scroll dovh on reCAPTCHA click on iOS devices
window.scrollCaptcha = false;
var cat_id = document.querySelector('.ginput_recaptcha').id;
document.getElementById(cat_id).setAttribute('data-callback','scrollFixCaptcha');
function scrollFixCaptcha(a) { if(window.scrollCaptcha) { jQuery("html, body").scrollTop(window.scrollCaptcha); } }
document.addEventListener("scroll", function() {
var el = document.getElementById(cat_id);
var theTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
<?php comments_number( __('No Comments', 'textdomain'), __('One Comment', 'textdomain'), __('(%) Comments', 'textdomain') ); ?>
<?php $field_name = ( get_field('field_name', 'category_'. $cat) ) ? get_field('field_name', 'category_'. $cat) : false ; ?>