Skip to content

Instantly share code, notes, and snippets.

@trey8611
trey8611 / find-woocommerce-attributes-by-name.md
Last active April 17, 2024 17:24
[Find WooCommerce Attributes by Name] Search by name instead of slug only. #wpallimport #woocommerce

Find attributes by name.

function my_find_attribute_by_name( $name, $attribute ) {
    global $wpdb;
    $term_table = $wpdb->prefix . 'terms';
    $taxonomy_table = $wpdb->prefix . 'term_taxonomy';

    if ( ! empty( $name ) ) {
@Treast
Treast / _fonts.scss
Created November 26, 2021 08:40
WordPress snippets
$fontPath: '../../fonts';
@mixin fonts($name, $file, $fontWeight) {
@font-face {
font-family: $name;
src: url('#{$fontPath}/#{to-lower-case(#{$name})}/#{$file}.eot');
src: url('#{$fontPath}/#{to-lower-case(#{$name})}/#{$file}.eot?#iefix') format('embedded-opentype'),
url('#{$fontPath}/#{to-lower-case(#{$name})}/#{$file}.woff2') format('woff2'),
url('#{$fontPath}/#{to-lower-case(#{$name})}/#{$file}.woff') format('woff'),
url('#{$fontPath}/#{to-lower-case(#{$name})}/#{$file}.ttf') format('truetype'),
@trey8611
trey8611 / custom-log-functions.md
Created November 19, 2021 16:28
[WP All Import] Custom log / custom logging functions with our API

This shows how to save a custom log of imported items. It can be adjusted to include any product data.

  /***********************************************/
 /***** BEGIN LOG CREATE / UPDATE / DELETE  *****/
/********************************************* */

// This creates a custom log file in the root WordPress uploads folder
// Some of this code will need to be adjusted, please read comments.
@Shoora
Shoora / ga4.php
Created November 17, 2021 14:06 — forked from rmpel/ga4.php
GA4 Tracker mu-plugin
<?php // wp-content/mu-plugins/ga4.php - GA4 tracker boilerplate.
define('GA_NOT_LIVE', true); // remove for go
define('GA4_MEASUREMENT_ID', 'G-XXXXXXXXXX'); // required
define('UA_PROPERTY_ID', 'UA-XXXXXXX-YY'); // optional
define('GA_ANONYMIZE_IP', true); // optional
define('GA_TRACK_ADMINS', false); // optional, defaults to true
define('GA_TRACK_EDITORS', false); // optional, defaults to true
// we need GA as first thing in the body
@exwyezed
exwyezed / ga4mp.js
Created November 11, 2021 20:04
GA4 measurement protocol JS lib
const axios = require('axios')
// This is the interface/object for communicating with GA4MP
export function GA4MPClient(apiSecret, measurementId, clientId) {
// Vars for GA4 connection
this.API_SECRET = apiSecret; // GA > Admin > Data Streams > choose your stream > Measurement Protocol > Create
this.MEASUREMENT_ID = measurementId; // GA Admin > Data Streams > choose your stream > Measurement ID
#!/bin/bash
FILE=wp-config.php
for d in */; do
# Just... yeah
if [ "$d" != "ottersbusinesshub.co.uk/" ]; then
if [ "$d" != "lilymaehomecare.com/" ]; then
echo ""
echo "Entering $d..."
@Glis
Glis / whitelabel-share-clientid.js
Last active December 15, 2021 03:55
[LOCAL][WL-PARENT] Share GA ClientID script
(function() {
// Universal Analytics tracking ID whose _ga cookie to use.
// If using GA4, you can leave this setting untouched.
var trackingId = 'UA-209071318-1';
// Maximum time in milliseconds to wait for GA tracker to load.
// Again, irrelevant for GA4.
var maxGATime = 2000;
// Set to the origin ("https://www.domain.com") of the iframe you want to communicate with
@trey8611
trey8611 / import-svi-variations-gallery-images.md
Created October 19, 2021 20:48
[WP All Import SVI Variations Gallery]
@shmidtelson
shmidtelson / nginx.conf
Last active November 10, 2024 22:36
Wordpress paranoid safe settings
############ WordPress ####################
# Disable logging for favicon and robots.txt
location = /favicon.ico {
try_files /favicon.ico @empty;
access_log off;
log_not_found off;
expires max;
}
@gengor-git
gengor-git / Backup-Settings.ps1
Last active June 13, 2024 09:00
Backup script to store my Windows configs in a 7-zip archive incl. scripts for chocolatey and VS Code.
<#PSScriptInfo
.AUTHOR
Martin Palmowski
.SYNPOSIS
Backup settings and configs for my Windows 10 environment.
.DESCRIPTION
Backup the most relevant settings and configs in a 7-zip archive.
Requires 7-zip to be installed an in the path.
Paths are based on Windows 10 defaults.
#>