Skip to content

Instantly share code, notes, and snippets.

View ajgagnon's full-sized avatar
💻
typing some things

Andre Gagnon ajgagnon

💻
typing some things
View GitHub Profile
import apiFetch from '@wordpress/api-fetch';
import { useState, useEffect, useRef } from '@wordpress/element';
import { createNavigationLink } from './use-convert-to-navigation-links';
import { useSelect, useDispatch } from '@wordpress/data';
import { Popover, Spinner } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import {
store as blockEditorStore,
useBlockProps,
} from '@wordpress/block-editor';
const myModal = new HystModal({
linkAttributeName: 'data-hystmodal',
afterClose: function(modal){
document.querySelector('presto-player').pause();
},
});
<?php
add_action("surecart/order_created", function( $order ) {
$checkout = \SureCart\Models\Checkout::with([
'line_items',
'line_item.price',
'line_item.fees',
'price.product',
'discount',
'discount.promotion',
@ajgagnon
ajgagnon / base.css
Last active October 17, 2022 17:18
SureCart CSS variables
:root {
/** Brand */
--sc-color-brand-primary: #08BA4F;
--sc-color-brand-secondary: #2CC965;
--sc-color-brand-heading: #002E33;
--sc-color-brand-body: #45505F;
--sc-color-brand-main-background: #F2FAFC;
--sc-color-brand-content-background: #FFFFFF;
--sc-color-brand-stroke: #E7ECEE;
--sc-color-brand-subheading: #9CA7AB;
<?php
// manually include the SDK.
if ( ! class_exists( 'SureCart\Licensing\Client' ) ) {
require_once __DIR__ . '/licensing/src/Client.php';
}
/**
* Validates license with license manager for SureCart
*
@ajgagnon
ajgagnon / surecart-css-variables.css
Created August 18, 2022 15:19
SureCart CSS Variables
/** Brand */
--sc-color-brand-primary: #08BA4F;
--sc-color-brand-secondary: #2CC965;
--sc-color-brand-heading: #002E33;
--sc-color-brand-body: #45505F;
--sc-color-brand-main-background: #F2FAFC;
--sc-color-brand-content-background: #FFFFFF;
--sc-color-brand-stroke: #E7ECEE;
--sc-color-brand-subheading: #9CA7AB;
--sc-color-brand-pastel-pink: #FCF2F7;
@ajgagnon
ajgagnon / gist:06193ff9ecaf149cda5892cf2962099b
Created September 6, 2021 14:05
Migrate Threads to different item
<?php
add_action('admin_init', function() {
if ( 27 !== get_current_user_id()) {
return;
}
$threads = get_posts([
'numberposts' => -1,
'post_type' => 'phw_comment_loc',
<?php
/**
* Retrieve the plan ID for an item in the cart
*
* @access public
* @since 2.4
* @return string
*/
public function get_plan_id( $subscription = array() ) {
@ajgagnon
ajgagnon / machine.js
Created June 22, 2021 22:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ajgagnon
ajgagnon / install-presto-player-core.php
Created June 9, 2021 20:59
Automatically Install Plugin From Repo Example
<?php
namespace PrestoPlayer\Pro\Services;
/**
* Install core plugin if not installed/activated
*/
class CoreInstaller
{