Skip to content

Instantly share code, notes, and snippets.

View Korveld's full-sized avatar

Kirill Titov Korveld

View GitHub Profile
@Korveld
Korveld / Custom multilingualpress language switcher
Last active January 7, 2021 22:00
Custom multilingualpress language switcher
<?php
function mlp_navigation() {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
$mlp_fix_active = '';
if (is_plugin_active('mlp-fix-redirect/mlp-fix-redirect.php') && !isset($_SESSION['mlp_noredirect'])) {
$mlp_fix_active = '?mlp_noredirect=1';
}
$titles = mlp_get_available_languages_titles();
$currentBlogId = get_current_blog_id();
@Korveld
Korveld / Wordpress err_too_many_redirects error fix
Last active January 29, 2021 14:19
Wordpress err_too_many_redirects error fix
Добавьте в wp-config.php в самое начало (после <?php ):
$_SERVER['HTTPS'] = 'on';
define( 'FS_METHOD', 'direct' );
define('WP_HOME','https://example.com');
define('WP_SITEURL','https://example.com');
Плюс пониже после define всяких (до текста "/* Это всё, дальше не редактируем. Успехов! */"):
@Korveld
Korveld / Slick prevent click on slide
Created February 16, 2021 12:48
Slick prevent click on slide
carousel.slick();
var isSliding = false;
carousel.on('beforeChange', function() {
isSliding = true;
});
carousel.on('afterChange', function() {
isSliding = false;
@Korveld
Korveld / WP_Query with pagination and offset
Created March 6, 2021 13:33
WP_Query with pagination and offset
$current_page = get_query_var('paged');
$current_page = max( 1, $current_page );
$per_page = 12;
$offset_start = 1;
$offset = ( $current_page - 1 ) * $per_page + $offset_start;
$post_list = new WP_Query(array(
'cat' => -15,
'posts_per_page' => $per_page,
@Korveld
Korveld / Some html icons
Created April 14, 2021 13:26
Some html icons
✅ ⛔️
@Korveld
Korveld / Jquery toggle flex
Created April 22, 2021 20:44
Jquery toggle flex
$('.element').toggle(0, function() {
if ($(this).is(':visible')) {
$(this).css('display','flex')
}
})
@Korveld
Korveld / Open fancybox
Last active April 28, 2021 17:16
Open fancybox
$.fancybox.open({
'touch': false,
'autoFocus': false,
'backFocus': false,
'type': 'inline',
'smallBtn': false,
'toolbar': false,
'src': '#modalSuccess'
});
@Korveld
Korveld / Toggle password visibility
Created August 16, 2021 13:19
Toggle password visibility
jQuery(document).ready(function ($) {
$('.sign-in-reg-page__password-icon').on('click', function (e) {
e.preventDefault()
// get the attribute value
var input = $(this).parent().find('.sign-in-reg-page__input--password')
var type = input.attr('type');
// now test it's value
if (type === 'password') {
input.attr('type', 'text');
@Korveld
Korveld / Add version to all svg images in wordpress
Created August 27, 2021 13:43
Add version to all svg images in wordpress
add_filter( 'the_content', 'img_src_replace', 20 );
function img_src_replace($content) {
return str_replace('.svg', '.svg?v=2', $content);
}
@Korveld
Korveld / Remove directory from git
Created September 1, 2021 17:55
Remove directory from git
Remove directory from git and local
git rm -r one-of-the-directories // This deletes from filesystem
git commit . -m "Remove duplicated directory"
git push origin <your-git-branch> (typically 'master', but not always)
Remove directory from git but NOT local
git rm -r --cached myFolder