Skip to content

Instantly share code, notes, and snippets.

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

bondaryoff

🏠
Working from home
View GitHub Profile
@bondaryoff
bondaryoff / Woocommerce Custom Attribute Output.
Created February 25, 2023 22:15
Woocommerce Custom Attribute Output.
<?php add_action('woocommerce_product_options_attributes', 'add_custom_attributes_to_product_page');
function add_custom_attributes_to_product_page(){
global $product_object;
$attributes = $product_object->get_attributes();
echo '<div class="options_group"><p class="form-field"><label for="custom_attributes" style="display:block;font-weight:bold;padding-left:10px;font-size:14px">Показать в превью (макс 3) </label><div id="custom_attributes" style="display:flex;flex-wrap:wrap">';
foreach ($attributes as $attribute) {
$attribute_name = wc_attribute_label($attribute->get_name());
echo '<div style="width:25%;padding:10px;border:1px solid #ccc;margin:10px;padding-bottom:0px">';
echo '<strong>';
@bondaryoff
bondaryoff / site-theme-switcher.js
Created August 31, 2021 14:25
site-theme-switcher.js
// Theme switcher
const toggleSwitch = document.querySelector('.theme-switcher input[type="checkbox"]');
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'night');
} else {
document.documentElement.setAttribute('data-theme', 'day');
}
}
@bondaryoff
bondaryoff / migrate-wordpress-to-new-domen.sql
Last active October 29, 2025 06:47
migrate-wordpress-db-to-new-domen
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://old_domen.com', 'https://new_domen.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE(guid, 'http://old_domen.com', 'https://new_domen.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://old_domen.com', 'https://new_domen.com');
-- UPDATE table_name
-- SET column_name = REPLACE(column_name, 'https://old_domen.com', 'https://new_domen.com')
-- WHERE column_name LIKE '%https://old_domen.com%';
@bondaryoff
bondaryoff / perfect-pixel-script.js
Last active December 4, 2021 16:54
perfect-pixel-script.js
// PERFECT PIXEL SCRIPT
let pPixel = document.querySelector(".pPixel");
if (pPixel) {
if (pPixel.dataset.show) {
pPixel.innerHTML +=
"<style>.pPixel__img{top:0;left:0;position:absolute;width:100%;transition-duration:.3s;pointer-events:none;display:block;z-index:1000;background-repeat:no-repeat;background-position:50% 0px;}.pPixel__img.hd{display:none;}.pPixel__img.inv{filter:invert(100%)}.pPixel__btn{position:fixed;z-index:1000;top:50%;width:60px;height:36px;line-height:30px;text-align:center;color:#fff;cursor:pointer;border:3px solid yellow}.pPixel__hide{border-radius:0 180px 180px 0;background:green;left:0}.pPixel__inv{border-radius:180px 0 0 180px;background: red;right:0}</style>";
pPixel.innerHTML +=
'<div class="pPixel__btn pPixel__hide">hide</div><div class="pPixel__btn pPixel__inv">inv</div>';
@bondaryoff
bondaryoff / img-svg-to-inline-svg.js
Last active August 15, 2021 13:37
img-svg-to-inline-svg.js
// Img svg to inline svg
const convertImages = (query, callback) => {
const images = document.querySelectorAll(query);
images.forEach(image => {
fetch(image.src)
.then(res => res.text())
.then(data => {
const parser = new DOMParser();
const svg = parser.parseFromString(data, 'image/svg+xml').querySelector('svg');