Skip to content

Instantly share code, notes, and snippets.

View Postnov's full-sized avatar
🏠
Working from home

Postnov Daniil Postnov

🏠
Working from home
View GitHub Profile
@Postnov
Postnov / final.html
Last active February 12, 2024 09:42
Panel about redesign GetCourse. Панель про обновление Геткурса.
<script>
(function() {
$(() => {
if ($('#gcAccountUserMenu').length) {
let messageText = 'Скоро оформление школы изменится. Если что-то будет отображаться некорректно, зайдите через 15 минут или попробуйте очистить кэш.<a href="https://yandex.ru/support/common/browsers-settings/cache.html">Инструкция по очистке кэша</a>';
let a = $(`<div class="message-wrapper"><div class="message-text">${messageText}</div></div>`);
let b = $(`<button class="message-btn">Закрыть</button>`);
let c = localStorage.getItem("redesignPopupView");
null == c && (a.append(b), $("body").append(a), b.click(function() {
@Postnov
Postnov / constructor-blocks.php
Created May 29, 2021 09:06
Constructor-blocks (Конструктор блоков) WP wordpress
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$constructorBlocks = get_field('constructor-blocks');
?>
<?
foreach ((array) $constructorBlocks as $block) {
@Postnov
Postnov / script.js
Created May 27, 2021 05:34
Проверка элементов без SetTimeout (check element without setTimout)
var interval = setInterval(() => {
var element = document.querySelector('.test');
if (element != null) {
clearInterval(interval);
console.log(element);
}
}, 1000);
@Postnov
Postnov / header.php
Created January 28, 2021 03:56
Количество товаров в корзине WOO
<?php
// Количество товаров
echo WC()->cart->get_cart_contents_count();
// Проверить количество товаров:
if (WC()->cart->get_cart_contents_count()) {}
// Сумма товаров
echo WC()->cart->get_cart_subtotal();
?>
@Postnov
Postnov / script.js
Created November 8, 2020 16:23
Создание метода в jQuery (create method in jQuery)
(function($) {
$.fn.myfunction = function() {
console.log('run function');
return this;
};
})( jQuery );
@Postnov
Postnov / single.php
Created June 1, 2020 07:38
Пагинация для разрыва детальной страницы
<? if (current_user_can( 'administrator' )): ?>
<?php
wp_link_pages( [
'before' => '<p>' . __('Pages:'),
'after' => '</p>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'number',
'nextpagelink' => __('Next page'),
'previouspagelink' => __('Previous page'),
@Postnov
Postnov / single.php
Created June 1, 2020 07:38
Пагинация для разрыва детальной страницы
<? if (current_user_can( 'administrator' )): ?>
<?php
wp_link_pages( [
'before' => '<p>' . __('Pages:'),
'after' => '</p>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'number',
'nextpagelink' => __('Next page'),
'previouspagelink' => __('Previous page'),
@Postnov
Postnov / single.php
Created May 31, 2020 06:48
Предыдущий и следующий пост. Полная кастомизация. Проработано отсутствие одного из постов.
<? if (current_user_can( 'administrator' )): ?>
<?
$previousPost = get_previous_post();
$nextPost = get_next_post();
$currentPost = get_post();
$projectsPosts = get_posts(
array(
'post_type' => 'projects',
'posts_per_page' => -1,
'orderby'=> 'ASC',
@Postnov
Postnov / single.php
Created May 31, 2020 06:44
Предыдущая и следующая ссылки на посты Worpdress
<div class="single-page-nav-links">
<? if (get_previous_post_link('%link')): ?>
<?=typo(get_previous_post_link('← %link')); ?>
<? endif; ?>
<? if (get_previous_post_link('%link') && get_next_post_link('%link')): ?>
<span class="separator">|</span>
<? endif; ?>
<? if (get_next_post_link('%link')): ?>
.bg-lines {
display: block;
width: 100%;
background-image: url('../images/bg-lines.png');
background-size: 100%;
z-index: 1;
position: absolute;
top: 0;
left: 50%;
padding: 20px;