Skip to content

Instantly share code, notes, and snippets.

View aristath's full-sized avatar
🏠

Ari Stathopoulos aristath

🏠
View GitHub Profile
@dennyf
dennyf / simplify-gutengerg.js
Last active March 23, 2018 12:45
This is an example of how we can simplify Gutenberg's custom block API - this is only an illustrative example
const { __ } = wp.i18n; // Import __() from wp.i18n
const { registerBlockType, RichText, UrlInput, InspectorControls, PanelColor, ColorPalette } = wp.blocks;
/**
* This class registers a custom block type, by creating the
* controls and updating the values automatically. It also allows passing a single
* render function to avoid repetitive code in edit and update.
*/
class MyCustomComponent{
<?php
/**
* Plugin Name: YOUR PLUGIN NAME
*/
include( dirname( __FILE__ ) . '/lib/requirements-check.php' );
$your_plugin_requirements_check = new YOUR_PREFIX_Requirements_Check( array(
'title' => 'YOUR PLUGIN NAME',
'php' => '5.4',
@OriginalEXE
OriginalEXE / pe-customize-controls.css
Last active June 26, 2023 05:07
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
@Rich-Harris
Rich-Harris / service-workers.md
Last active April 21, 2024 16:24
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@thomasgriffin
thomasgriffin / gist:8153754
Last active January 1, 2016 13:49
Force the use of only one license per user in EDD. This prevents the need to manage multiple licenses if you are selling products in tiers (such as upgrading licenses). This will create a license if none exist, and if one exists, it will simply upgrade that license each time a new purchase is made and reference the most recent purchase for downl…
<?php
// Force licenses to be created manually so that only one license is ever assigned to a user at a given time.
remove_action( 'edd_complete_download_purchase', array( edd_software_licensing(), 'generate_license' ), 0, 3 );
add_action( 'edd_complete_purchase', 'tgm_possibly_generate_license', 11 );
function tgm_possibly_generate_license( $payment_id ) {
// Check to see if the current user has already purchased a license. If not, generate the license as normal.
$payment_data = edd_get_payment_meta( $payment_id );
$user_info = maybe_unserialize( $payment_data['user_info'] );
$download = current( maybe_unserialize( $payment_data['downloads'] ) );
<?php
/**
* Plugin Name: Demo Plugin for #26061
* Description: Registers a new setting for a non-scalar value (i.e. an assoc array) and a control which allows the setting to be updated by pressing a button.
* Author: Weston Ruter, X-Team
* Author URI: http://x-team.com/profile/weston-ruter/
*/
function wp26061_customize_register( $wp_customize ) {