Skip to content

Instantly share code, notes, and snippets.

View sinebeef's full-sized avatar
💋
hnnnnggggggg

sinebeef sinebeef

💋
hnnnnggggggg
  • London
View GitHub Profile
@sinebeef
sinebeef / contact-form-7-spam-block.php
Created February 14, 2021 12:55
Contact Form 7 spam block
<?php
// wpcf7_validate + _textarea* or _text* etc
add_filter( 'wpcf7_validate_textarea*', 'textarea_confirmation_validation_filter', 20, 2 );
function textarea_confirmation_validation_filter( $result, $tag ) {
// your-message much match what the tag name has been set
if ( 'your-message' == $tag->name ) {
$your_message = isset( $_POST['your-message'] ) ? trim( $_POST['your-message'] ) : '';
if ( preg_match('/href|google|lottery|seo|http|latex|gloves|youtube|instagram|monetize|invest|\$|\@|www\./i', $your_message ) ){
$result->invalidate( $tag, "Your message contains invalid words that are not allowed, please rephrase. only put your email address in the email section, No website links or any of these words: href, google, seo, http, latex, gloves, youtube, instagram, monetize, invest, $" );
@sinebeef
sinebeef / cf7-hooks.php
Created August 4, 2020 18:33
Message filter hooks
add_filter( 'wpcf7_validate_text*', 'custom_phone_confirmation_validation_filter', 20, 2 );
function custom_phone_confirmation_validation_filter( $result, $tag ) {
if ( 'your-phone' == $tag->name ) {
$your_phone = isset( $_POST['your-phone'] ) ? trim( $_POST['your-phone'] ) : '';
if ( !preg_match('/^0/', $your_phone ) ){
$result->invalidate( $tag, "Needs to start with a zero, are you a bot?" );
}
}
return $result;
}
RewriteEngine On
RewriteCond %{REQUEST_URI} !/robots.txt$
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*EventMachine.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*NerdyBot.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Typhoeus.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*archive.org_bot.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*archive.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*adbeat_bot.*$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*github.*$ [NC,OR]
#
# Grabs the product json and merges with the stock scrapey file and then imports using REST
import json, sys
import keys_file
from woocommerce import API
wcapi = API(
url=url, # Your store URL
consumer_key = consumer_key,
@sinebeef
sinebeef / woocommerce_variation_custom_fields
Last active April 17, 2022 01:50
woocommerce variation custom field, with backend textbox and saving meta, frontend display on change with jquery
// Add Variation Settings
add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3 );
// Save Variation Settings
add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2 );
/**
* Create new fields for variations
*
*/
@sinebeef
sinebeef / geotagimg.py
Created May 29, 2020 10:19
GPS / Geo tag JPEG images using python and exiftool on the command line
# exiftool file.jpg {views file}
# exiftool -Make="Canon"
# exiftool -Model="Canon EOS 40D"
import random
from geopy.geocoders import Nominatim
from GPSPhoto import gpsphoto
import sys, os
geolocator = Nominatim(user_agent="geodata")
@sinebeef
sinebeef / jq-cheat.sh
Created February 8, 2020 00:27
jq json cheat sheet
#go|dfish is the boss of freenode
# merge duplicate records category, resulting in single record for id
jq 'group_by(.sku) | map(.[0].cat = ([.[].cat] | join(",")) | .[0])' q-products-new.json > q-merged.json
@sinebeef
sinebeef / allsku.txt
Created January 31, 2020 19:04
All product skus
PPH08CH_par
PPH08CH
PPH08BN
PPH080RB
PPH08BR
JRG537CH_par
JRG537CH
JRG537BR
JRG537BN
GRA390SC_par
@sinebeef
sinebeef / extra-docs.php
Created January 31, 2020 18:55
WP Pdf Docs Include
<?php
$value = get_field( 'extra-docs' );
if ($value) {
$exfiles = explode( ',', $value );
//var_dump($exfiles)
?>
<div class="extra-docs">
<p>Additional documents:</p>
<p>To view the cut out template files and technial specifiations view or download the pdf template files that come with this product</p>
<?php foreach ( $exfiles as $solofile ){ ?>
@sinebeef
sinebeef / style.css
Created January 27, 2020 17:08
CSS Colours
/* Alpha blue aka aspire */
#228ace