Skip to content

Instantly share code, notes, and snippets.

View DeveloperWil's full-sized avatar

Wil Brown DeveloperWil

View GitHub Profile
@DeveloperWil
DeveloperWil / gravity-forms-australian-phone-numer-formats.php
Created March 7, 2023 02:24
Gravity Forms Australian Phone Number Formats
/**
* Provides specific formatting for Australian phone landlines and mobile numbers
*
* AU Mobile Format: XXXX XXX XXX
* Landline Mobile Format: XX XXXX XXXX
*
* @param $phone_formats
* @return mixed
*/
function zpd_gf_phone_formats_au( $phone_formats ){
@DeveloperWil
DeveloperWil / wp-add-js-script-to-footer.php
Last active October 20, 2022 02:32
WP Enqueue JavaScript editor.js file
@DeveloperWil
DeveloperWil / wilbrown-com-custom-login-page.php
Created May 11, 2022 03:00
WilBrown.com custom login page, two column, responsive
function wb_login_head(){
?>
<style>
#login{
width:50%;
float:left;
}
#wbd-login-left{
width:50%;
float: right;
@DeveloperWil
DeveloperWil / stripe-send-shipping-billing-address.php
Created November 15, 2021 23:05
Send shipping or billing address to Stripe transaction
/**
* Send shipping or billing details to Stripe (required by some 3DSecure transactions/currencies)
*
* @param $post_data
* @param $order
*
* @return mixed
*/
function zpd_add_shipping_to_stripe( $post_data, $order ) {
@DeveloperWil
DeveloperWil / gravity-forms-submission-to-amazon-echo.php
Created April 29, 2021 02:47
Gravity Forms: Form Submission to Amazon Echo
function gf_alexa_notification( $entry, $form ){
$notifyme_api_url = 'https://api.notifymyecho.com/v1/NotifyMe';
$notifyme_api_secret = '1234567890';
if( $form->ID === 12 ){
// Only for form ID=12
$firstname = rgar( $entry, '1.3' );
$lastname = rgar( $entry, '1.3' );
$phone = rgar( $entry, '2' );
$notification = $firstname . ' ' . $lastname . ' requested a callback on "' . $phone .'"';
@DeveloperWil
DeveloperWil / woocommerce-order-notification-to-amazon-echo.php
Last active April 29, 2021 02:46
WooCommerce: Order Notification to Amazon Echo
function zpd_wc_order_to_alexa( $payload, $resource, $resource_id, $id){
if( $id == 1) { // webhook ID is 1
// Get an instance of the WC_Order object (same as before)
$order = wc_get_order( $resource_id );
$payload[ 'accessCode' ] = ZPD_NOTIFYME_SECRET_API_KEY;
$payload[ 'notification'] = 'There is a new ' . $order->get_status() . ' order';
$payload[ 'notification'] .= ' on the ' . get_bloginfo( 'name' ) . ' website';
$payload[ 'notification'] .= ' from ' . $order->get_billing_first_name() . ' ' . $order->get_billing_last_name() . '.';
}
@DeveloperWil
DeveloperWil / woocommerce-order-data-object-fields
Last active April 21, 2021 03:18
WooCommerce: Order data object fields
<?php
/**
* See https://woocommerce.github.io/code-reference/classes/WC-Order.html#property_data for all data items in the WC_Order
*/
/**
* This line is not needed within the filter as $order is passed as a parameter
*/
$order_data = $order->get_data();
@DeveloperWil
DeveloperWil / woocommerce-stripe-product-customer-metadata
Created March 30, 2021 22:36
WooCommerce: Stripe product and customer metadata
/**
* Add Stripe metadata along with WooCommerce purchase
*
* @param $metadata
* @param $order
* @param $source
* @return mixed
*/
function wbdc_filter_wc_stripe_payment_metadata( $metadata, $order, $source ) {
@DeveloperWil
DeveloperWil / woocommerce-global-redirect-after-payment.php
Created March 29, 2021 22:34
WooCommerce: Global redirect after payment
/* Redirect user after check out */
function zpd_wc_global_redirect_after_payment() {
global $wp;
$redirect_url = 'https://yourdomain.com/this-page/';
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( $redirect_url );
exit;
}
@DeveloperWil
DeveloperWil / sql-view-wordpress-autoloaded-data.sql
Created March 24, 2021 23:39
WordPress: View Database Autoloaded Data
SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM wp_options WHERE autoload='yes'
UNION
SELECT 'autoloaded data count', count(*) FROM wp_options WHERE autoload='yes'
UNION
(SELECT option_name, length(option_value) FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10);