Skip to content

Instantly share code, notes, and snippets.

Jacob Dubail jacobdubail

View GitHub Profile
@jacobdubail
jacobdubail / block_template_by_page_template.php
Created May 21, 2020
Block Template for a Page Template in Gutenberg
View block_template_by_page_template.php
<?php
function pls_maybe_add_template() {
if ( ! is_admin() || ! isset( $_GET['post'] ) || 'template-bridge.php' !== get_page_template_slug($_GET['post']) ) {
// This is not the post/page we want to limit things to.
return false;
}
$post_type_object = get_post_type_object( 'page' );
$post_type_object->template = array(
array( 'core/heading', array(
View add_product.php
<?php
$cart_update_string = "https://" . $store_domain . "/cart?cart=update&fcsid=" . $fcsid . "&output=json";
// loop our matches and rebuild query
foreach ( $matched_products as $key ) {
$item = $cart_contents['items'][$key];
$item_id = $item['id'];
$index = $key+1;
View remove_product.php
<?php
$cart_update_string = "https://" . $store_domain . "/cart?cart=update&fcsid=" . $fcsid . "&output=json";
// loop our matches and remove
foreach ( $matched_products as $key ) {
$item = $cart_contents['items'][$key];
$item_id = $item['id'];
// starts at 0, so increment.
$index = $key+1;
@jacobdubail
jacobdubail / js
Created Nov 4, 2019
add service plan at checkout
View js
<script>
function checkServices() {
var physical = "Physical_Products",
services = "Subscriptions",
//services_index = [],
//physical_index = [],
basic_service = "305-2000-01",
deluxe_service = "305-2000-02",
addon_service = "305-2000-03",
basic_item_id = 0,
@jacobdubail
jacobdubail / ga_ecommerce.js
Created Jul 10, 2018
GA Ecommerce Snippet
View ga_ecommerce.js
<script type="text/javascript">
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '1234', // Transaction ID. Required.
'affiliation': 'Acme Clothing', // Affiliation or store name.
'revenue': '11.99', // Grand Total.
'shipping': '5', // Shipping.
'tax': '1.29' // Tax.
});
@jacobdubail
jacobdubail / php
Last active Feb 20, 2019
Absorb WordPress SSO
View php
<?php
Class AbsorbLMS {
//protected private key from Absorb Admin
protected $private_key = "*******";
//admin login creds to Absorb
protected $absorb_api_url = "https://ACOUNTNAME.myabsorb.com/api/Rest/v1/";
protected $external_login_url = "https://ACOUNTNAME.myabsorb.com/account/externallogin";
@jacobdubail
jacobdubail / php
Created Jan 11, 2018
FoxyShop VAT Pricing
View php
<?php
add_action('admin_menu', 'jtd_vat_settings_menu');
function jtd_vat_settings_menu() {
add_submenu_page('edit.php?post_type=foxyshop_product', __('VAT Display', 'foxyshop'), __('VAT Display', 'foxyshop'), apply_filters('foxyshop_settings_perm', 'manage_options'), 'foxyshop_vat_display', 'foxyshop_vat_display');
}
function foxyshop_vat_display() {
global $foxyshop_settings, $foxycart_version_array;
if (!defined('FOXYSHOP_TEMPLATE_PATH')) define('FOXYSHOP_TEMPLATE_PATH',STYLESHEETPATH);
if (isset($_GET['saved'])) echo '<div class="updated"><p>' . __('Your Settings Have Been Saved.', 'foxyshop') . '</p></div>';
View sub-status.php
<?php
$time_start = microtime(true);
require('fc/datafeed-functions.php');
require('fc/Klaviyo.php');
require('fc/foxyapi.php');
$klaviyo = new Klaviyo(KLAVIYO_KEY);
$fc = jtd_bc_setup_foxycart_api();
$store = $fc->get($fc->getLink("fx:store"));
@jacobdubail
jacobdubail / php
Created Jan 30, 2017
Function to auto-set your ACF5 Pro license key
View php
function jtd_acf_auto_set_license_keys() {
if ( !get_option('acf_pro_license') && defined('ACF_5_KEY') ) {
$save = array(
'key' => ACF_5_KEY,
'url' => home_url()
);
$save = maybe_serialize($save);
View gist:78d14e997e4ebdda8e05
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>
<AWSAccessKeyId>AKIAIJI2WK7ZSSFVLI3Q</AWSAccessKeyId>
<StringToSign>
AWS4-HMAC-SHA256 20160112T010333Z 20160112/us-west-2/s3/aws4_request 1a1f494a1f840c222d027dbd98b32537006d49273452db79cf793d2f36463d65
</StringToSign>
You can’t perform that action at this time.