Skip to content

Instantly share code, notes, and snippets.

View levnhub's full-sized avatar
🎯
Focusing

Lev N levnhub

🎯
Focusing
View GitHub Profile
@levnhub
levnhub / gulpfile.js
Created November 7, 2017 22:56
Full Gulpfile
'use strict';
var gulp = require('gulp'),
watch = require('gulp-watch'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
rigger = require('gulp-rigger'),
cssmin = require('gulp-minify-css'),
imagemin = require('gulp-imagemin'),
@levnhub
levnhub / tricks.scss
Created October 25, 2017 20:34
SCSS Tricks
// Collect all headers
@for $index from 1 through 6 {
h#{$index} {
margin-top: 0;
}
}
@levnhub
levnhub / preload.html
Last active June 5, 2018 13:24
Preload
<style>
.loader {
background: none repeat scroll 0 0 #ffffff;
bottom: 0;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
@levnhub
levnhub / wp-post.php
Created October 13, 2017 00:28
WP Post
// Если на странице поста, выводит "active"
<?php if( is_single( $post ) ) { echo 'active'; }; ?>
@levnhub
levnhub / wp-category.php
Last active June 5, 2018 13:25
WP Category
<?php
// Заменяем шаблон post зависимости от категории (functions.php)
add_filter('template_include', 'service_template');
function service_template( $template ) {
global $post;
if( ( is_single() && in_category( 1, $post ) ) ) {
$template = get_stylesheet_directory() . '/single-service.php';
@levnhub
levnhub / wp-menu.php
Last active August 1, 2018 15:45
WP Menu
<?php
// Работа с меню через wp_get_nav_menu_items();
if ( $menu_items = wp_get_nav_menu_items('Главное меню') ) : ?>
<nav class="main_nav">
<ul class="main_nav--list">
<?php foreach ( (array) $menu_items as $key => $menu_item ) :
@levnhub
levnhub / head.php
Last active August 2, 2018 12:43
Useful head
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- for 500px min-width body -->
<!-- <meta name="viewport" content="width=device-width, initial-scale=0.64, maximum-scale=0.64, shrink-to-fit=no"> -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- <meta name="format-detection" content="telephone=no"> -->
<meta name="description" content="<?php bloginfo( 'description' ); ?>">
@levnhub
levnhub / wp-post-template
Created October 6, 2017 17:05
WP Post Template
<?php
/*
* Template Name: НазваниеШаблона
* Template Post Type: post, page, product
*/
get_header();
?>
@levnhub
levnhub / wp-functions.php
Last active July 31, 2018 15:12
WP Functions & Hooks
<?php
/**
* The main functions file
*
*/
// Убираем лишнее
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'wlwmanifest_link' );
@levnhub
levnhub / php-server-tweaks
Last active October 28, 2017 02:40
PHP Server Tweaks
// .htaccess
php_value max_input_vars 3000
php_value max_execution_time 120
// Indexes
DirectoryIndex myindex.php
Options +Indexes
// Password
AuthType Basic