Skip to content

Instantly share code, notes, and snippets.

View RiodeJaneiroo's full-sized avatar
🎯
Focusing

Vadim Zmiievskyi RiodeJaneiroo

🎯
Focusing
  • Ukraine
View GitHub Profile
@RiodeJaneiroo
RiodeJaneiroo / index.js
Created October 13, 2019 14:46
[Mask input phone] pure JS #mask #js
window.addEventListener("DOMContentLoaded", function() {
[].forEach.call( document.querySelectorAll('input.wpcf7-tel'), function(input) {
var keyCode;
function mask(event) {
event.keyCode && (keyCode = event.keyCode);
var pos = this.selectionStart;
if (pos < 3) event.preventDefault();
var matrix = "+7 (___) ___-__-__",
i = 0,
def = matrix.replace(/\D/g, ""),
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created October 5, 2019 13:17
[Remove Gutenberg CSS] remove wp-block-library css #wordpress
add_action( 'wp_print_styles', 'wps_deregister_styles', 100 );
function wps_deregister_styles() {
wp_dequeue_style( 'wp-block-library' );
}
@RiodeJaneiroo
RiodeJaneiroo / function_polylang.php
Last active December 25, 2019 09:43
[Сделать sitemap.html] к обычной странице добавляет .html #wordpress #seo
add_filter('pll_translation_url', 'check_archive_translation', 10, 2);
function check_archive_translation($url, $lang) {
$posSearch = strpos($url, '/sitemap/');
$posSearchUK = strpos($url, 'uk/karta-sajtu/');
if($posSearch !== false) {
$url = site_url() . '/sitemap.html';
} else if ($posSearchUK !== false) {
$url = site_url() . '/uk/sitemap.html';
}
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Last active February 3, 2020 09:11
[Разметка для хлебных крошек] #wordpress #seo #breadcrumbs
function schemaBreadcrumbsJson() {
global $post;
$arrayBreadcrumbs = array();
$parent_id = ( $post ) ? $post->post_parent : '';
if(is_category()) { // для рубрики
$parents = get_ancestors( get_query_var('cat'), 'category' );
foreach ( array_reverse( $parents ) as $cat ) {
array_push($arrayBreadcrumbs, [get_cat_name( $cat ), get_category_link( $cat )]);
}
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created August 11, 2019 08:04
[Удалить ссылку на саму себя из меню] #wordpress #seo
<?php
function yourstheme_menu_link_attributes( $args ) {
global $wp;
$current_url = untrailingslashit(add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) ) );
$href = untrailingslashit( $args['href']);
if($current_url == $href){
$args['href'] = '';
}
return $args;
@RiodeJaneiroo
RiodeJaneiroo / index.js
Created August 10, 2019 19:52
[Get Google Page Speed Score] PageSpeed Insights API
var url = 'artzm.space';
var url = (!url.match(/^[a-zA-Z]+:\/\//)) ? 'http://' + url : url;
// Google Page Speed
jQuery.ajax({
url: "https://www.googleapis.com/pagespeedonline/v5/runPagespeed",
type: "GET",
data: {
"strategy": "desktop", // or mobile
"fields": "lighthouseResult/categories/*/score",
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created July 31, 2019 07:51
[Изменить текст опции товара] #wc #wocommerce #wordpress
<?php
add_filter('woocommerce_dropdown_variation_attribute_options_args', 'my_change_choose_an_option_text_func', 10, 2);
function my_change_choose_an_option_text_func($args){
if($args['attribute'] == 'pa_tsvet') {
$args['show_option_none'] = 'Выбрать цвет';
}
return $args;
}
@RiodeJaneiroo
RiodeJaneiroo / index.html
Created May 24, 2019 14:06
[Color range] #css #color #range #scale
<div class="textarea-lineup"><span></span></div>
<script>
colorScale($('.textarea-lineup'), 10);
</script>
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Last active June 11, 2020 13:40
[Wordpress SEO redirect from any symbol ] 301 redirect from wrong url #seo #yoast #wordpress #redirect
function wrong_url_redirect($url) {
global $wp;
if(!get_query_var('paged') && !empty($url) && !is_front_page() && $url != home_url($wp->request . '/' ) && !is_search()) {
wp_safe_redirect( $url, 301 );
exit;
}
return $url;
}
add_filter( 'wpseo_canonical', 'wrong_url_redirect' );
@RiodeJaneiroo
RiodeJaneiroo / category.php
Last active May 3, 2024 12:52
[Opencart filter Mega Pro] #seo #pattern #opencart #filter #megaPro #Mega Filter PRO
<?php
// don't forget: $this->load->model('catalog/manufacturer');
$pageNumber = '';
if (isset($this->request->get['page'])) {
$pageNumber = ' - Страница ' . $this->request->get['page'];
}
if(isset($this->request->get['mfp'])) { // get manufacturer name
$filterMega = $this->request->get['mfp'];
$filterMegaName = '';