PhpStorm now bundles WordPress coding style natively, starting from version 8.
- Go to
Project Settings
>Code Style
>PHP
. - Select
Set From...
(top right of window) >Predefined Style
>WordPress
.
No longer need to muck with this import! :)
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
<?php | |
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php) | |
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' ); | |
function woocommerce_header_add_to_cart_fragment( $fragments ) { | |
ob_start(); | |
?> | |
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a> | |
<?php |
This re-styles your sublime text sidebar to be dark, it fits default Monokai theme.
Save the Default.sublime-theme file into packages/Theme - Default, make a backup of your original if you want to be able to go back easily.
Based on:
class Text_Editor_Custom_Control extends WP_Customize_Control | |
{ | |
public $type = 'textarea'; | |
/** | |
** Render the content on the theme customizer page | |
*/ | |
public function render_content() { ?> | |
<label> | |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> | |
<?php |
'use strict'; | |
const crypto = require('crypto'); | |
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters) | |
const IV_LENGTH = 16; // For AES, this is always 16 | |
function encrypt(text) { | |
let iv = crypto.randomBytes(IV_LENGTH); | |
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv); |
import React, { Component } from "react" | |
import { Machine } from "xstate" | |
import * as PropTypes from "prop-types" | |
class FiniteMachine extends Component { | |
machine = Machine(this.props.chart) | |
state = { | |
data: this.props.reducer(undefined, { type: "@init" }), | |
machineState: this.machine.getInitialState() |
If you're trying to do this, you came to the right place!
Watch this code work in real time: https://twitter.com/CodingDoug/status/942576182276497409
See also this gist for copying in the other direction: https://gist.github.com/CodingDoug/ffc4f050cc489a0280eb7f4cbe36af07
import React from 'react' | |
import { Action, withStatechart } from 'react-automata' | |
const statechart = { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
FETCH: 'fetching', | |
}, |
/** | |
* server/dataSources/Auth.js | |
* Auth implementation, it's not really a dataSource so it doesn't need to be here | |
*/ | |
const { authenticate, createJwt } = require('../lib/passport'); | |
const { ON_HTTPS } = require('../configs'); | |
const ONE_MINUTE = 1000 * 60; | |
const ONE_DAY = ONE_MINUTE * 60 * 24; | |
const ONE_MONTH = ONE_DAY * 30; |