Skip to content

Instantly share code, notes, and snippets.

@sikkgit
sikkgit / findOverflowParents.js
Created February 20, 2024 09:20 — forked from brandonjp/findOverflowParents.js
find overflow:hidden ancestors
// when you're trying to use `position:sticky` on an element
// you'll have trouble if any parent/ancestor element has
// overflow set to anything other than "visible" (such as: auto,hidden,overlay,scroll)
// & turns out if a parent is `display:flex` it might need some love
// (to remedy this you can set the `align-self` of your sticky element)
// see here for how the display & align-self properties affect: http://bit.ly/2ZaRu4o
// so, to find those troublesome parents...
// copy & paste this into Chrome Inspector/Dev Tools console
// (and be sure to change the #stickyElement below, if needed)
#!/usr/bin/env bash
# WP-CLI Back up Script to Amazon S3
# Source: https://www.jonathan.vc
# Author: Jonathan Dingman
# Adapted from Mike at WP Bullet
#define local path for backups
BACKUPPATH=/tmp/backups
#path to WordPress installations
<?php
// this is only a part of it
namespace DLS_WC_REST;
class Products extends \WC_REST_Products_Controller {
protected $namespace = 'wc/v3';
<?php
// just to insert in my class
trait WpUploadBase64 {
public function uploadImage($base64_img, $title, $max_size = []) {
// option to resize image - will save space on host usualy don't need image more than 1920 x 1080
// read more information on crop = false, true , [center|left|right,center|top|bottom ] :
// https://developer.wordpress.org/reference/functions/image_resize_dimensions/
// https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/
@sikkgit
sikkgit / wordpress-upload-base64.php
Created January 17, 2024 13:59 — forked from cyberwani/wordpress-upload-base64.php
Upload a base64 string as image to the WordPress media library
<?php
/**
* Save the image on the server.
*/
function save_image( $base64_img, $title ) {
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
@sikkgit
sikkgit / fake_players.md
Created April 13, 2023 01:57 — forked from asfo/fake_players.md
Fake players for AzerothCore

How to use it:

Warning:It works only for AzerothCore and doesn't works on the last commit since it have some issues and the worldserver crashes, so that's why I'm not updating it to the latest version of AC, once that bug got fixed, I will update it.

  • Go to the root directory where you clone the repo, create a "patches" directory.
  • Create a file called fake_players.patch
  • Add the code above
  • Go back to the root directory
  • Run the command:
@sikkgit
sikkgit / wpcspc_device_based_cache_cf_worker_template.js
Created February 18, 2023 22:50 — forked from isaumya/wpcspc_device_based_cache_cf_worker_template.js
Custom Cloudflare Worker Code for Device Based Caching - WP Cloudflare Super Page Cache Plugin
/**
* Worker Name: WPCSPC - Device based Cache
* Description: This worker is responsible for caching the requests based on the device type
* Based on Default Worker Version: 2.8.0
* Version: 2.1.0
* @link: https://wordpress.org/plugins/wp-cloudflare-page-cache/
* @link: https://wordpress.org/support/topic/mobile-page-theme-and-cloudflare-caching-plugin-integration/
* @author: Saumya Majumder
*/
// Default cookie prefixes for cache bypassing
@sikkgit
sikkgit / 1-python-pretty-time-delta.py
Created January 29, 2023 22:33 — forked from thatalextaylor/1-python-pretty-time-delta.py
Pretty print a time delta in Python in days, hours, minutes and seconds
def pretty_time_delta(seconds):
sign_string = '-' if seconds < 0 else ''
seconds = abs(int(seconds))
days, seconds = divmod(seconds, 86400)
hours, seconds = divmod(seconds, 3600)
minutes, seconds = divmod(seconds, 60)
if days > 0:
return '%s%dd%dh%dm%ds' % (sign_string, days, hours, minutes, seconds)
elif hours > 0:
return '%s%dh%dm%ds' % (sign_string, hours, minutes, seconds)
@sikkgit
sikkgit / functions.php
Created January 28, 2023 17:00 — forked from webtoffee-git/functions.php
Assign categories to products using category ID-Product Import Export for WooCommerce
<?php
add_filter('wt_woocommerce_product_importer_pre_parse_data', 'wt_import_cetegory_from_id');
function wt_import_cetegory_from_id($item) {
$product_cat = $item['tax:product_cat'];
$product_cat_no= explode(">",$product_cat);
$product_cat_name=array();
foreach ($product_cat_no as $value) {
if( $term = get_term_by( 'id', trim($value), 'product_cat' ) ){
$product_cat_name[]=$term->name;
}
@sikkgit
sikkgit / gist:a717e3d2808be383a933434ba7a45041
Created January 26, 2023 20:09 — forked from elliotcondon/gist:c94abec50dc26ac065c6
WooCommerce 'Create variations from all attributes' randomisation fix
<?php
/*
* array_cartesian
*
* This function will fix a frustrating issue in the WooCommerce plugin
* When adding a product using variations, you will most likely use the 'Create variations from all attributes' function
* The issue with this function is that it will create the variations in a random order
* This is frustrating for your clients to edit
*