Skip to content

Instantly share code, notes, and snippets.

View hiddenpearls's full-sized avatar
🏁
About to reach my GOAL

Adnan hiddenpearls

🏁
About to reach my GOAL
View GitHub Profile
@webzunft
webzunft / canceled-subscriptions.sql
Last active October 4, 2022 13:15
SQL queries to analyse canceled subscriptions managed with EDD Recurring Payments
# Basic queries to analyse canceled subscriptions using EDD Recurring Payments pre EDD 3.0
# Use EXPLAIN if you have large stores since the "notes" column is not indexed and queries can take some time
# Some of these reports might be worth storing as Views and look at the graphs PHPMyAdmin can also create from them
# List subscription cancelation with creation and cancelation date, as well as the user who canceled
# good as a basis for further queries
SELECT ID,
created,
REGEXP_SUBSTR( REGEXP_SUBSTR( notes, '.* Status changed from active to cancelled .*' ), '^[a-z]+ [0-9]+, [0-9]+' ) AS 'date',
@fwazeter
fwazeter / readme.md
Last active March 16, 2022 21:03
Make WordPress Core Theme Mimic Gutenberg / FSE .HTML template rendering with multiple post type support.

Overview

Author: Frank Wazeter Author URL: https://wazeter.com

WordPress 5.8 marks a big step towards Full Site Editing and using Block Themes vs. traditional (classic) themes powered primarily by PHP template files. However, using currently experimental features in production is extremely risky due the developmental nature. This code shows how a WordPress theme can support and mimic Gutenberg Plugin's templating system for the block editor/template editor, while not having a dependency on the Gutenberg Plugin itself. Most existing references or documentation have a dependency of some kind on the Gutenberg plugin to make it work.

If full site editing is only fully available in testing, why implement features now in a WordPress classic theme?

The future is undeniably wrapped around full site editing - that everything can be manipulated through blocks and corresponding

<?php
/*
Plugin Name: EDD Webhooks
Description: Captures new sale notifications from 3rd party service and adds to Easy Digital Downloads
Version: 1.0
Author: Brian Hogg
Author URI: https://brianhogg.com
Text Domain: edd-webhooks
License: GPL2
*/
@hiddenpearls
hiddenpearls / purchase-phone.js
Created April 27, 2017 17:45
Simple JS program for buying a phone, Apply tax, format and add to cart.
const TAX_RATE = 0.10; // 10%
const PHONE_PRICE = 500; // $500
const ACCESSORY_PRICE = 12; //$12
const SPENDING_THRESHOLD = 900; // This should be 60% of the total bank balance.
var bank_account_balance = 0;
var quantity = 0;
var total = 0;
bank_account_balance = prompt("What is your Bank Account Balance");
@paulirish
paulirish / open-chrome-tabs-in-safari.scpt
Created April 4, 2016 00:24
open chrome tabs in safari
tell application "Google Chrome"
set tab_list to every tab in the front window
repeat with the_tab in tab_list
set the_url to the URL of the_tab
tell application "Safari" to open location the_url
end repeat
end tell
<?php
/*
* Plugin Name: EDD Redirect to Next Product on Add to Cart
* Description: Automatically redirects the customer to the next product after they have added an item to the cart
* Author: Pippin Williamson
* Version: 0.1
*/
function pw_edd_redirect_to_next_scripts( $download_id = 0 ) {
@thegdshop
thegdshop / gist:3171026
Created July 24, 2012 16:28
WooCommerce - Add checkbox field to the checkout
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';
@kristofferh
kristofferh / git-export
Created December 7, 2011 13:01
"Export" a git repository to zip file
git archive --format zip --output /full/path/to/zipfile.zip master
@necolas
necolas / snippet.js
Created June 14, 2011 20:36
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@jaywilliams
jaywilliams / csv_to_array.php
Created April 30, 2010 23:18
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array