Skip to content

Instantly share code, notes, and snippets.

@markoheijnen
markoheijnen / gist:4236025
Last active October 13, 2015 18:17
WordPress Engine shortcode
<?php
class Marko_Shortcodes {
public function __construct() {
add_shortcode( 'engine_info', array( $this, 'engine_info' ) );
}
public function engine_info( $atts ) {
global $wp_version, $wpdb, $batcache, $wp_object_cache;
@sapegin
sapegin / footer.php
Created August 7, 2012 19:10
RequireJS in Wordpress theme
@matthewarkin
matthewarkin / gist:bb310ee27323ffee7ab8
Last active August 6, 2017 17:24
stripe upgrade, prorate, and bill for proration instantly
//create subscription
// $20 a month
curl https://api.stripe.com/v1/customers/cus_18nj91X8lMXyju/subscriptions
-u private key:
-d plan=gold
//change subscription - upgrade plan
//$40 a month
curl https://api.stripe.com/v1/customers/cus_18nj91X8lMXyju/subscriptions/sub_4HWcxqoS8wG7T3 \
-u private key: \
@kovaldn
kovaldn / HTML: select, year & month.js
Last active May 23, 2018 20:17
HTML: select, year & month
// html
<label for="year">Год</label>
<select name="year" id="year"></select>
<label for="month">Месяц</label>
<select name="month" id="month">
<option value = "1">01</option>
<option value = "2">02</option>
<option value = "3">03</option>
<option value = "4">04</option>
@ahmadawais
ahmadawais / js-terms.md
Created February 19, 2018 06:21 — forked from AllThingsSmitty/js-terms.md
10 terms to help you better understand JavaScript

10 JavaScript Terms You Should Know

From currying to closures there are quite a number of special words used in JavaScript. These will not only help you increase your vocabulary but also better understand JavaScript. Special terms are normally found in documentation and technical articles. But some of them like closures are pretty standard things to know about. Knowing what the word itself means can help you know the concept it's named for better.

  1. Arity
  2. Anonymous
  3. Closure
  4. Currying
  5. Hoisting
  6. Mutation
/**
* Helper class for controlling all aspects of a view.
*
* Supported methods (automatically hooked):
* - init() - for registering post types, taxonomies, rewrite rules etc.
* - parse_query() - for correcting query flags
* - pre_get_posts() - for altering the query, without affecting the query flags
* - posts_search(), posts_clauses(), posts_request() - for direct SQL manipulation
* - the_posts() - for various other manipulations
* - template_redirect() - for enqueuing scripts etc.
@rexxars
rexxars / jsondump.jsx
Last active December 19, 2019 05:22
React JSON dump component
import React from 'react';
class JsonDump extends React.Component {
static propTypes = {
children: React.PropTypes.any
}
render() {
return <pre>{JSON.stringify(this.props.children, null, 4)}</pre>
}
@mateuszsokola
mateuszsokola / _PureFunctions.md
Last active August 9, 2021 14:36
Pure Functions

Pure functions

A pure function for given the same input will always return the same output and evaluation of this function will not cause any side effects.

Advantages of using pure functions:

  • easy to test, as they always return the same value,
  • easy to debug, as they shouldn't cause any race conditions and circular dependencies,
  • simple and independent, as they don't cause any side effects (it makes design clean),
  • easy to scale application up, as they shouldn't rely on machine state.
@scribu
scribu / taxonomy-columns.php
Created July 12, 2012 15:35
'show_admin_column' => true
<?php
add_action( 'registered_taxonomy', array( 'APP_Tax_Admin_Column', 'register_column' ), 10, 3 );
/**
* Generates a column with the associated terms,
* for any taxonomy with 'show_admin_column' => true
*/
class APP_Tax_Admin_Column {
@hitautodestruct
hitautodestruct / readme.md
Last active September 26, 2022 11:25 — forked from anonymous/gist:4344870
Generate a custom structure for Wordpress menus.

This gist is for showing an example of a custom wordpress menu.

If you want to get more from the menu item simply have a look at the $item object. i.e:

// Will return a large object with lots of props like title, url, description, id etc.
var_dump( $item );

This code works on Wordpress 4.1.1 as of 31st of March 2015