Skip to content

Instantly share code, notes, and snippets.

@sibicode
sibicode / functions.php
Created November 2, 2015 04:47
WP Добавляем настройки темы
// Добавляем настройки темы
add_action('customize_register', function($customizer) {
$customizer->add_section(
'section_one', array(
'title' => 'Настройки сайта',
'description' => '',
'priority' => 11,
)
);
$customizer->add_setting('phone',
@sibicode
sibicode / functions.php
Created November 6, 2015 07:56
WP single шаблон для определенной категории
// Шаблон для постов рубрики работы
function wpse_custom_category_single_template( $single_template ) {
global $post;
// get all categories of current post
$categories = get_the_category( $post->ID );
$top_categories = array();
// get top level categories
@sibicode
sibicode / 0_reuse_code.js
Created March 31, 2017 11:37
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
@sibicode
sibicode / button.sass
Created April 23, 2017 09:15 — forked from agragregra/button.sass
Button Sass Styles (Universal Starter)
.button
display: inline-block
border: none
color: #fff
text-decoration: none
background-color: $accent
padding: 15px 45px
font-size: 13px
text-transform: uppercase
font-weight: 600
//Аякс отправка форм
//Документация: http://api.jquery.com/jquery.ajax/
$("#form, #form2").submit(function(e) {
e.preventDefault;
$.ajax({
type: "POST",
url: "mail.php",
data: $(this).serialize()
}).done(function() {
alert("Спасибо за заявку!");
<!-- Bootstrap trigger to open modal -->
<a data-toggle="modal" href="#rating-modal">Write a Review</a>
<div class="hide fade modal" id="rating-modal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h2>Your Review</h2>
</div>
<div class="modal-body">
@sibicode
sibicode / style.css
Created June 6, 2017 05:40
box-sizing
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
@sibicode
sibicode / script.js
Last active June 8, 2017 05:13
Fix auto scroll when mfp open
$('.gallery').each(function() {
$(this).magnificPopup({
delegate: 'a',
type: 'image',
fixedContentPos: false,
fixedBgPos: false,
callbacks: {
open: function() {
$('body').addClass('noscroll');
},
@sibicode
sibicode / form.js
Created June 8, 2017 10:46
Проверка на заполнение полей формы
$('.callback-form').each(function(){
// Объявляем переменные (форма и кнопка отправки)
var form = $(this),
btn = form.find('.callback-form__submit');
// Добавляем каждому проверяемому полю, указание что поле пустое
form.find('.callback-form__input').addClass('empty');
// Функция проверки полей формы
function checkInput(){
@sibicode
sibicode / script.js
Created July 17, 2017 04:07
Smooth scroll to element
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 56
}, 500);
return false;
}