Skip to content

Instantly share code, notes, and snippets.

View allendav's full-sized avatar

A D Snook at Automattic allendav

View GitHub Profile
@allendav
allendav / test.php
Last active November 10, 2021 18:57
PHP Version Compare Test
<?php
$version_tests = [
[
"minimum" => "2.0",
"found" => "2.0",
"meets" => true
],
[
"minimum" => "2.0",
@allendav
allendav / Playground.swift
Created November 5, 2021 15:40
Testing if a version meets the minimum
import Foundation
struct Test {
var foundVersion: String
var requiredMinimumVersion: String
var meetsMinimum: Bool
}
let tests = [
Test(foundVersion: "2.8", requiredMinimumVersion: "2.9", meetsMinimum: false),
/**
* @param $email_address
* @param int $page
* @return array
*/
public function export($email_address, $page = 1)
{
global $wpdb;
$uid = mailchimp_hash_trim_lower($email_address);
@allendav
allendav / jetpack.diff
Created March 16, 2018 17:08
Jetpack WooCommerce Whitelist Unit Test
diff --git a/tests/php/sync/test_class.jetpack-sync-woocommerce.php b/tests/php/sync/test_class.jetpack-sync-woocommerce.php
index 161cbb62a..ecbc54c7e 100644
--- a/tests/php/sync/test_class.jetpack-sync-woocommerce.php
+++ b/tests/php/sync/test_class.jetpack-sync-woocommerce.php
@@ -171,6 +171,43 @@ class WP_Test_Jetpack_Sync_WooCommerce extends WP_Test_Jetpack_Sync_Base {
$this->assertTrue( !! $deleted_order_item_meta_event );
}
+ function test_updated_personal_data_item_meta_is_not_synched() {
+ $order = $this->createOrderWithItem();
@allendav
allendav / 2018-mar-6-exporter-design.md
Created March 6, 2018 16:34
2018-Mar-6 Exporter Design

Mike J, Gerhard P, Lauren S, Allen S chatted about a personal data exporter design that could support WooCommerce and its extensions needs (and be applicable to core itself or any plugin)

In a nutshell, we eventually thought it would be best to try having plugins (and extensions) register a callback function(s) for the export of personal data, e.g. have a plugin do something like this):

add_filter( "wp_privacy_register_export_data_callback", array( $this, 'register_export_data_callback' ) );
 
function register_export_data_callback( $export_callbacks ) {
    $export_callbacks[] = array(
        'slug' => 'stripe',
@allendav
allendav / gist:d05c7426514169cea999cf383887cccb
Created January 18, 2018 19:50
Product add-ons import string -- 6 groups of 75 radiobuttons
a:6:{i:0;a:6:{s:4:"name";s:7:"GROUP 0";s:11:"description";s:13:"DESCRIPTION 0";s:4:"type";s:11:"radiobutton";s:8:"position";i:0;s:7:"options";a:75:{i:0;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 0";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:1;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 1";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:2;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 2";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:3;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 3";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:4;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 4";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:5;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 5";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:6;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 6";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:7;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 7";s:5:"price";s:1:"1";s:3:"min";s:0:"";s:3:"max";s:0:"";}i:8;a:4:{s:5:"label";s:16:"GROUP 0 OPTION 8";s:5:"price";s:1:"1";s:3:"min";s
@allendav
allendav / test.php
Created January 18, 2018 19:49
Quick PHP to generate product add-on import string (6 groups of 75)
<?php
$bar = array();
for ( $group = 0; $group < 6; $group++ ) {
$options = array();
for ( $option = 0; $option < 75; $option++ ) {
$options[] = array(
'label' => "GROUP $group OPTION $option",
<?php
/*
Plugin Name: Dev
Plugin URI: http://wordpress.org/plugins/
Description: Does dev things
Author: Allen Snook
Version: 1.0
Author URI: http://allendav.com
*/
@allendav
allendav / TEST.md
Created August 4, 2016 14:53
TEST.md Proof of Concept

WooCommerce Manual Tests

Create a Shipping Zone

  • Navigate to WooCommerce Shipping Settings (/wp-admin/admin.php?page=wc-settings&tab=shipping)
  • Click on the Add shipping zone button
  • Verify a new row appears in the table and that your cursor is placed in the Zone Name field
  • Enter a Zone Name of Domestic
  • Click in the Select regions in this zone field, start typing Finland, and then select Finland from the list