Skip to content

Instantly share code, notes, and snippets.

View dkruchok's full-sized avatar

Dima Kruchok dkruchok

View GitHub Profile
@dkruchok
dkruchok / gist:3100e94a835e5c7f42d1ae7e990cf030
Created June 13, 2016 11:01
WooCommerce disable/custom croping
add_action( 'after_setup_theme', function () {
// Add image sizes
$shop_thumbnail = wc_get_image_size( 'shop_thumbnail' );
$shop_catalog = wc_get_image_size( 'shop_catalog' );
$shop_single = wc_get_image_size( 'shop_single' );
// In the lines below, true = hard crop; false = proportional
@dkruchok
dkruchok / WP counter for shortode
Created December 3, 2015 09:23
Counter after p WP
<div class="frame">
<div class="post-content">
<?php if (!is_single() && of_get_option('of_excerptset')=='1') {
$image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<img src="<?php echo $image; ?>">
<?php the_excerpt(); ?>
<?php } else { ?>
<?php //Removed the original line below ?>
<?php //the_content( __('Read more', 'cr') );?>
<?php //Added this one insted: ?>
(function($) {
$.fn.animated = function(inEffect, outEffect) {
$(this).css("opacity", "0").addClass("animated").waypoint(function(dir) {
if (dir === "down") {
$(this).removeClass(outEffect).addClass(inEffect).css("opacity", "1");
} else {
$(this).removeClass(inEffect).addClass(outEffect).css("opacity", "1");
};
}, {
offset: "90%"
@dkruchok
dkruchok / CSS IE hacks
Created July 22, 2015 11:17
CSS IE hacks
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
/* IE10+ specific styles go here */
.map-container svg {
position: static !important;
height: 500px !important;
width: 130% !important;
}
}
/* ie 8.9.10 */
@dkruchok
dkruchok / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dkruchok
dkruchok / Ge find me
Created July 3, 2015 06:13
GeoLocation file
$(document).ready(function() {
$("#findme").on("click",function(e) {
e.preventDefault();
if ( !navigator.geolocation ) {
$("#whereami").val("Your browser is also lost, probably because it doesn't support geo-location.");
} else {
$("#findme").animate({
opacity: "0.25"
},"fast");
navigator.geolocation.getCurrentPosition(positionDisplay,showGeoError);
@dkruchok
dkruchok / User Webcam and Audio
Created June 21, 2015 11:25
User Webcam and Audio
/* Get user WebCam*/
<script>
navigator.getUserMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
if (navigator.getUserMedia) {
navigator.getUserMedia (
@dkruchok
dkruchok / Scroll to ID
Created June 3, 2015 10:32
Scroll to ID
/*Scroll to ID*/
// handle links with @href started with '#' only
$(document).on('click', '.pages-smaller ul li a[href^="#"]', function(e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
@dkruchok
dkruchok / Valid DISPLAY NONE
Created June 2, 2015 10:50
Valid DISPLAY NONE
.visually-hidden {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding:0 !important;
border:0 !important;
height: 1px !important;
width: 1px !important;
overflow: hidden;
}
@dkruchok
dkruchok / loop wp
Last active October 20, 2015 22:23
WP Loop with query
<?php
if ( have_posts() ) : // если имеются записи в блоге.
query_posts('cat=3'); // указываем ID рубрик, которые необходимо вывести.
while (have_posts()) : the_post(); // запускаем цикл обхода материалов блога
?>
<?php the_post_thumbnail(array(100, 100)); ?>
<? endwhile; // завершаем цикл.
endif;
/* Сбрасываем настройки цикла. Если ниже по коду будет идти еще один цикл, чтобы не было сбоя. */
wp_reset_query();