Skip to content

Instantly share code, notes, and snippets.

View maksimerohin's full-sized avatar

Maksim Erokhin maksimerohin

  • Siberia, Novosibirsk
View GitHub Profile
@maksimerohin
maksimerohin / functions.php
Last active January 30, 2019 16:07
Задаёт размер цитаты.
function new_excerpt_length($length) {
return 25;
}
add_filter('excerpt_length', 'new_excerpt_length');
add_filter('excerpt_more', function($more) {
return '...';
});
@maksimerohin
maksimerohin / main.js
Last active December 25, 2020 14:19
Scroll To
var linkNav = document.querySelectorAll('[href^="#"]'), //выбираем все ссылки к якорю на странице
V = 1 // скорость, может иметь дробное значение через точку (чем меньше значение - тем больше скорость)
for (var i = 0; i < linkNav.length; i++) {
linkNav[i].addEventListener('click', function (e) { //по клику на ссылку
e.preventDefault() //отменяем стандартное поведение
var w = window.pageYOffset, // производим прокрутка прокрутка
hash = this.href.replace(/[^#]*(.*)/, '$1') // к id элемента, к которому нужно перейти
t = document.querySelector(hash).getBoundingClientRect().top, // отступ от окна браузера до id
start = null
requestAnimationFrame(step) // подробнее про функцию анимации [developer.mozilla.org]
@maksimerohin
maksimerohin / functions.php
Last active December 28, 2018 18:14
Подключение стилей и скриптов
function me_ipapus_scripts() {
wp_enqueue_style( 'me-ipapus-style', get_stylesheet_uri(), array(), filemtime( get_theme_file_path() . '/style.css' ) );
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'me-bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), filemtime( get_theme_file_path() . '/js/bootstrap.min.js' ), true );
wp_enqueue_script( 'me-functions', get_template_directory_uri() . '/js/functions.js', array('jquery'), filemtime( get_theme_file_path() . '/js/functions.js' ), true );
@maksimerohin
maksimerohin / round-to.js
Created December 6, 2018 11:41
Округляет число (до целого, десятка, сотни).
function roundTo(num) {
return Math.round(num/10)*10;
}
@maksimerohin
maksimerohin / form.html
Last active December 8, 2018 02:55
Кнопки +/- на формах
<div class="input-group input-group">
<div class="input-group-prepend">
<button class="btn btn-secondary js-num" type="button" data-type="minus" data-field="input-one">&minus;</button>
</div>
<input type="text" min="0" max="100" step="5" value="1" id="input-one" class="form-control">
<div class="input-group-append">
<button class="btn btn-secondary js-num" type="button" data-type="plus" data-field="input-one">+</button>
</div>
</div>
@maksimerohin
maksimerohin / functions.js
Last active September 3, 2019 05:05
События для контактных форм Contact Form 7
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '376' == event.detail.contactFormId ) {
$('#contact-modal .form').slideUp(function() {
$('#contact-modal .result').slideDown();
});
console.log("FORMSENT");
yaCounter51427798.reachGoal('FORMSENT');
};
@maksimerohin
maksimerohin / elements.scss
Last active February 14, 2019 16:56
Вставляем карту в виде фона
#s8343 { // Карта и контактная инфомрация
height: 550px;
padding: 0;
#map {
position:absolute;
width:100%;
height:550px;
}
}
function mero_myme_types($mime_types){
$mime_types['svg'] = 'image/svg+xml';
return $mime_types;
}
add_filter('upload_mimes', 'mero_myme_types', 1, 1);
# Исправление MIME типа для SVG файлов.
function fix_svg_mime_type( $data, $file, $filename, $mimes, $real_mime = '' ){
[class^="icon-"]{
display: inline-block;
background: url('../img/icons/icons.png') no-repeat;
width: 64px;
height: 51px;
overflow: hidden;
zoom:0.5;
-moz-transform:scale(0.5);
-moz-transform-origin: 0 0;
}
@maksimerohin
maksimerohin / functions.php
Last active January 30, 2019 15:55
Дочерняя тема. Подключение стилей в дочерней теме.
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>