Skip to content

Instantly share code, notes, and snippets.

@jukra
jukra / functions.php
Created August 7, 2015 06:45
WooCommerce remaining cost for free shipping notification
function cart_notice() {
$free_shipping_settings = get_option( 'woocommerce_free_shipping_settings' );
$maximum = $free_shipping_settings['min_amount'];
$current = WC()->cart->subtotal;
if ( $current < $maximum ) {
echo '<div class="woocommerce-message">Get free shipping if you order $ ' . ($maximum - $current) . ' more!</div>';
}
}
add_action( 'woocommerce_before_cart', 'cart_notice' );
@baptx
baptx / twitter_api_1.1_backup.js
Last active May 30, 2024 15:47
Twitter API 1.1 tweets / favorites (likes) / following / followers backup in web browser
/* Twitter API 1.1 tweets / favorites (likes) / following / followers backup in web browser
* Get your access keys to use Twitter API 1.1: https://dev.twitter.com/docs/auth/tokens-devtwittercom
* You can change Twitter API URL and Twitter screen_name, then execute script from a trusted web page without CSP protection like about:blank in a web browser console (F12 or Ctrl+Shift+K shortcut)
* A textarea will appear so you can copy/paste to save data as a CSV file or search tweets / users in your web browser (Ctrl+F shortcut)
* You can then view your backup in a spreadsheet editor like LibreOffice Calc
* You can also compare the backup with another one to see who unfollowed you, who changed their Twitter username by looking at the user ID or which tweet you retweeted / favorited was deleted (e.g. with the Linux diff command)
*
* Note about the tweets backup:
* Usually you will search tweets that you retweeted using Twitter web version (https://twitter.com/search) with a search like "from:your_username f
@onokumus
onokumus / index.html
Last active September 12, 2018 10:00
MetisMenu Hash
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/metisMenu/1.1.3/metisMenu.min.css">
</head>
@arikfr
arikfr / export_lists.py
Created August 19, 2014 04:57
Simple script to export Twitter lists to CSV
import twitter # python-twitter
import csv
import cStringIO
import codecs
from requests_oauthlib import OAuth1Session
REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
AUTHORIZATION_URL = 'https://api.twitter.com/oauth/authorize'
SIGNIN_URL = 'https://api.twitter.com/oauth/authenticate'
@seebz
seebz / iCal.php
Last active September 6, 2024 02:33
iCal PHP Parser
<?php
class iCal
{
/**
* @var string
*/
public $title;
@studiopress
studiopress / nav-extras.php
Last active September 11, 2023 21:24
Modify the nav extras.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
/**
* Filter menu items, appending either a search form or today's date.
*
* @param string $menu HTML string of list items.
* @param stdClass $args Menu arguments.
*
@jagandecapri
jagandecapri / table_check_create_insert.php
Last active March 16, 2017 15:51
Class written in PHP to check for existence of a table in database, create a table or insert data into table (in bulk or one record at a time). Records are sent in as associative arrays containing the column names and values.
<?php
require_once 'database_connector.php';
class TableCheckCreateInsert{
/*
* @var $conn
* @var $databse
* @var $config
@NTICompass
NTICompass / moment.phpDateFormat.js
Last active May 25, 2018 02:15
Use PHP's date() formats in moment.js
(function(m){
/*
* PHP => moment.js
*
* http://www.php.net/manual/en/function.date.php
* http://momentjs.com/docs/#/displaying/format/
*/
var formatMap = {
d: 'DD',
D: 'ddd',
@mglaman
mglaman / woocommerce-products.sql
Last active August 7, 2023 13:52
MySQL query for wooCommerce to export products.
SELECT product.ID as product_id, product.post_title as product_name, replace(product.post_content, '"', "'") as product_content, product_sku.meta_value as product_sku, product_price.meta_value as product_price, product_weight.meta_value as product_weight
FROM wp_posts as product
LEFT JOIN wp_postmeta as product_sku ON product.ID = product_sku.post_ID
LEFT JOIN wp_postmeta as product_price ON product.ID = product_price.post_ID
LEFT JOIN wp_postmeta as product_weight ON product.ID = product_weight.post_ID
WHERE (product.post_type = 'product' OR product.post_type = 'product_variation') AND product_sku.meta_key = '_sku' AND product_price.meta_key = '_price' AND product_weight.meta_key = '_weight'
ORDER BY product_id ASC
@BFTrick
BFTrick / woocommerce-remove-virtual-billing-fields.php
Last active October 16, 2025 05:29
Remove the billing address fields for free virtual orders in WooCommerce
<?php
/**
* Plugin Name: WooCommerce Remove Billing Fields for Free Virtual Products
* Plugin URI: https://gist.github.com/BFTrick/7873168
* Description: Remove the billing address fields for free virtual orders
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 2.0
*
* This program is free software: you can redistribute it and/or modify