Skip to content

Instantly share code, notes, and snippets.

View al5dy's full-sized avatar

Anton Lokotkov al5dy

View GitHub Profile
@al5dy
al5dy / admin.js
Created August 11, 2016 06:05
Выделяем всю область контента при одном нажатии.
$(document).on('click', '.multitext', function () {
var range = document.createRange();
range.selectNodeContents(this);
window.getSelection().addRange(range);
});
@al5dy
al5dy / bootstrap-point.js
Created August 11, 2016 06:10
Легкий способ найти текущий тип Bootstrap экрана.
findPoint : function () {
var envs = ['xs', 'sm', 'md', 'lg'];
$el = $('<div>');
$el.appendTo($('body'));
for (var i = envs.length - 1; i >= 0; i--) {
var env = envs[i];
$el.addClass('hidden-'+env);
@al5dy
al5dy / sidebar.php
Created August 15, 2016 18:24
Добавление элемента в опреденное место в ассоциативном массиве php.
$array = array(
'zero' => '0',
'one' => '1',
'two' => '2',
'three' => '3',
);
$res = array_slice($array, 0, 3, true) +
array("my_key" => "my_value") +
array_slice($array, 3, count($array) - 1, true) ;
print_r($res);
@al5dy
al5dy / promobox.php
Created September 26, 2016 13:52
Проверяем, является ли текущая страница блоговой или нет.
function is_page_for_posts() {
$result = false;
if ( is_home() && ! is_front_page() ) {
$page = get_queried_object();
$result = ! is_null( $page ) && $page->ID == get_option( 'page_for_posts' );
}
return $result;
@al5dy
al5dy / backup.php
Created November 14, 2016 06:14 — forked from menzerath/backup.php
PHP: Recursively Backup Files & Folders to ZIP-File
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* (c) 2012-2014: Marvin Menzerath - http://menzerath.eu
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
@al5dy
al5dy / functions.php
Created December 18, 2016 08:10
Автоматическое отображение миниатюры вверху страницы
add_action( 'genesis_entry_content', 'featured_post_image', 8 );
function featured_post_image() {
if ( !is_singular( array( 'post', 'page' ) )) return;
the_post_thumbnail('featured');
}
@al5dy
al5dy / settings.php
Created December 26, 2016 09:00
Универсальное добавление класса "table" в <table>
if ( false !== strpos( $content, '<table' ) ) {
$rep = preg_replace('~<table\K(?:[^>]*?\K(\s?)class="([^"]*)")?~', ' class="$2$1table"', $rep);
}
@al5dy
al5dy / vc_custom_icon_set.php
Created February 13, 2017 16:00 — forked from zecka/vc_custom_icon_set.php
Add a custom icon set from icomoon to visual composer vc_icon shortcode
<?php
// Add new custom font to Font Family selection in icon box module
function zeckart_add_new_icon_set_to_iconbox( ) {
$param = WPBMap::getParam( 'vc_icon', 'type' );
$param['value'][__( 'IcoMoon', 'total' )] = 'icomoon';
vc_update_shortcode_param( 'vc_icon', $param );
}
add_filter( 'init', 'zeckart_add_new_icon_set_to_iconbox', 40 );
@al5dy
al5dy / woocommerce.php
Created May 1, 2017 20:26
Убираем zoom на карточке продукта
<?php
remove_theme_support( 'wc-product-gallery-zoom' );
@al5dy
al5dy / woocommerce.php
Created May 1, 2017 20:28
Удаляем попап изображения в карточке товара
<?php
remove_theme_support( 'wc-product-gallery-lightbox' );