Skip to content

Instantly share code, notes, and snippets.

View Zackio's full-sized avatar

Zackary Allnutt Zackio

View GitHub Profile
@dtbaker
dtbaker / envato.lib.php
Created May 26, 2015 10:19
Envato PHP library by @sowailem
<?php
/**
* @file
* Integration layer to communicate with the Envato API.
*
* @see https://build.envato.com/api
*
* @outher Abdullah Sowailem.
*/
@billerickson
billerickson / gist:1326009
Last active March 3, 2017 11:14
Add Extra Code to Any Menu
<?php
/**
* Add Extra Code to Any Menu
* @author Bill Erickson
* @link http://www.billerickson.net/customizing-wordpress-menus/
*
* @param string $menu
* @param object $args
* @return string modified menu
*/
<?php
/**
* Remove Genesis Page Templates
*
* @author Bill Erickson
* @link http://www.billerickson.net/remove-genesis-page-templates
*
* @param array $page_templates
* @return array
@timkinnane
timkinnane / shortcode.php
Created April 7, 2013 23:36
Wordpress shortcode example
<?php
// MyShortcode usage [myshortcode greeting="Hello" who="World"]
function myshortcode_func( $atts, $content = null ) {
// use given attributes or defined defaults
extract( shortcode_atts( array(
'greeting' => '',
'who' => ''
), $atts ) );
<?php
// To be used by theme authors to avoid duplicate favicon code now that Site Icons have been added to WordPress 4.3
// If a Site Icon hasn't been set or if the `has_site_icon` function doesn't exist (ie older than WordPress 4.3)
if ( ! ( function_exists( 'has_site_icon' ) && has_site_icon() ) ) {
// your theme specific custom favicon code goes here
}
@2aces
2aces / futta-gutenprint.php
Created February 6, 2018 21:55
Frank Goossens (Futta) function to extract blocks from WP Gutenberg (Proof of Concept) as https://blog.futtta.be/2018/01/25/how-to-extract-blocks-from-gutenberg/
// proof-of-concept to extract all WordPress Gutenberg's blocks as array
// author: Frank Goossens (Futta)
// source: https://blog.futtta.be/2018/01/25/how-to-extract-blocks-from-gutenberg/
add_action('the_content','gutenprint',10,1);
function gutenprint($html) {
// check if we need to and can load the Gutenberg PEG parser
if ( !class_exists("Gutenberg_PEG_Parser") && file_exists(WP_PLUGIN_DIR."/gutenberg/lib/load.php") ) {
include_once(WP_PLUGIN_DIR."/gutenberg/lib/load.php");
}
@UltimateWoo
UltimateWoo / custom-woocommerce-loop.php
Created March 21, 2015 21:20
Custom query and loop for WooCommerce
<?php
if ( is_shop() || is_product_category() || is_product_tag() ) { // Only run on shop archive pages, not single products or other pages
// Products per page
$per_page = 24;
if ( get_query_var( 'taxonomy' ) ) { // If on a product taxonomy archive (category or tag)
$args = array(
@mattbanks
mattbanks / wp-setup.sh
Created March 14, 2014 18:01
Scaffold a new WordPress development site in Alfred, utilizing WP-CLI. Use this script to run as a Terminal Script. Customize for your theme needs, plugin needs, etc.
# Create directory for new site
cd ~/Sites
mkdir {query}
cd {query}
# Download latest version of WordPress
wp core download
# Setup wp-config file with WP_DEBUG enabled
wp core config --dbname={query} --dbuser=root --dbpass=root --dbprefix={query}wp_ --extra-php <<PHP
@amix
amix / sorts.py
Created March 19, 2016 11:10
The confidence sort in pure Python (from Reddit's codebase)
# Rewritten code from /r2/r2/lib/db/_sorts.pyx
from math import sqrt
def _confidence(ups, downs):
n = ups + downs
if n == 0:
return 0
z = 1.281551565545
@corsonr
corsonr / gist:0e0a4dfaacf59fdca314
Created October 20, 2014 13:20
WooCommerce: activate product tabs from URL
<?php
/**
* wc_direct_link_to_product_tabs
*
* Allows you to create custom URLs to activate product tabs by default, directly from the URL
* ex: http://mysite.com/my-product-name#reviews
*/
function wc_direct_link_to_product_tabs() {
if( is_product() ) {
?>