Skip to content

Instantly share code, notes, and snippets.

@VlaDeveloper
VlaDeveloper / about.php
Created March 4, 2019 16:52
get posts by taxonomy
<?php
$term = get_term_by('name', 'Достижения', 'info');
$id = $term->term_id;
// параметры по умолчанию
$posts = get_posts( array(
'numberposts' => -1,
'orderby' => 'date',
'order' => 'ASC',
'post_type' => 'about-items',
'suppress_filters' => true,
@VlaDeveloper
VlaDeveloper / news.php
Created March 7, 2019 14:26
wp get posts
<?php
// параметры по умолчанию
$posts = get_posts( array(
'numberposts' => -1,
'orderby' => 'date',
'order' => 'ASC',
'post_type' => 'news',
'suppress_filters' => true,
// подавление работы фильтров изменения SQL запроса
) );
@VlaDeveloper
VlaDeveloper / Video hack
Last active March 16, 2019 12:05
Super video hack
html:
<div class="video-relation">
<div class="video-relation-ration"></div>
<iframe class="video-relation-content" src="https://www.youtube.com/embed/By_Cn5ixYLg" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
sass:
.video-relation
position: relative
&-content
width: 100%
@VlaDeveloper
VlaDeveloper / common.js
Last active July 6, 2021 08:24
toggle mobile menu
$('.toggle-mnu').on('click', function() {
$('.hidden-mnu').slideToggle(function(){
if($(this).css('display') == 'none'){
$(this).removeAttr('style');
}
});
});
$('.button-link').click(function(){
yaCounterXXXXXXXX.reachGoal('click');
gtag('event', 'click');
});
@VlaDeveloper
VlaDeveloper / highDensityLiquidLazy.js
Created July 10, 2019 12:19
High Density Liquid Images With Lazy Load
function isHighDensity(){
return ((window.matchMedia && (window.matchMedia('only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3));
}
if(isHighDensity()){
var oldSrc,
newSrc;
$('.lazy').each(function(){
oldSrc = $(this).data('src');
newSrc = oldSrc.replace('@1x', '@2x');
@VlaDeveloper
VlaDeveloper / common.js
Created October 13, 2019 13:20
Popups for repeating items
$('.some-item-button-popup').each(function(e){
var ths = $(this);
ths.attr('href', '#popup-' + e);
ths.parent().find('.some-item-popup').attr('id', 'popup-' + e);
});
@VlaDeveloper
VlaDeveloper / MIGX checkbox
Created December 4, 2019 10:12
MIGX checkbox in back-end
{"field":"is", "caption":"Условие?", "inputTVtype":"checkbox", "inputOptionValues":"Да==something"}
@VlaDeveloper
VlaDeveloper / send
Last active November 12, 2021 14:08
Vk sending
HTML код:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="main.css">
</head>
@VlaDeveloper
VlaDeveloper / wp-db
Last active July 2, 2022 15:29
Getting orders in WordPress with using Databases
example.php:
<?php
/**
* Plugin Name: Плагин с БД
* Description: Работа с БД
* Author: Влад
* Version: 1.0
*
*
* License: GPL2