Skip to content

Instantly share code, notes, and snippets.

View Vinsanity's full-sized avatar

Vinny Listrani Vinsanity

View GitHub Profile
@Vinsanity
Vinsanity / gist:38ac9a91aa85abf097a3a2a6652e8262
Created January 7, 2018 22:18
WP CLI post creation in docker
for i in {1..10}; do bash -xc "curl http://loripsum.net/api/5 | wp --allow-root post create - --post_title='Post $i' --post_type=page --post_status=publish --post_category=$(wp --allow-root term list category --field=id --number=1 --offset=$(shuf -i 0-9 -n 1)) --tags_input='$(wp --allow-root term list post_tag --field=name --number=1 --offset=$(shuf -i 0-99 -n 1))'"; done

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@Vinsanity
Vinsanity / slack_invite.php
Created April 17, 2017 16:12 — forked from Topener/slack_invite.php
Simple PHP script to invite slack users
<?php
/**
* This is a simple script to invite users to your slack
* Replace the subdomain and token in the variables below.
* Upload a logo called "logo.png" to the same directory for your group
* Upload a logo called "slack.png" to the same directory for slack
*/
define('SUBDOMAIN','{YOUR SUBDOMAIN HERE}');
define('TOKEN','{YOUR API TOKEN HERE}');
?>
<?php
/**
* Code should be placed in your theme functions.php file.
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
<template name="acfcb" value="$name_of_field = array(&#10;&#9;'key' =&gt; 'field_name_of_field',&#10;&#9;'label' =&gt; 'Name of Field',&#10;&#9;'name' =&gt; 'name_of_field',&#10;&#9;'type' =&gt; 'checkbox',&#10;&#9;'instructions' =&gt; '',&#10;&#9;'required' =&gt; 0,&#10;&#9;'conditional_logic' =&gt; 0,&#10;&#9;'wrapper' =&gt; array(&#10;&#9;&#9;'width' =&gt; '',&#10;&#9;&#9;'class' =&gt; '',&#10;&#9;&#9;'id' =&gt; '',&#10;&#9;),&#10;&#9;'default_value' =&gt; '',&#10;&#9;'choices' =&gt; array(&#10;&#9;&#9;'red'&#9;=&gt; 'Red'&#10;&#9;),&#9;&#10;&#9;'layout' =&gt; 'vertical',&#10;);" description="ACF checkbox field" toReformat="false" toShortenFQNames="true">
<context>
<option name="PHP" value="true" />
</context>
</template>
<template name="acfem" value="$name_of_field = array(&#10;&#9;'key' =&gt; 'field_name_of_field',&#10;&#9;'label' =&gt; 'Name of Field',&#10;&#9;'name' =&gt; 'name_of_field',&#10;&#9;'type' =&gt; 'email',&#10;&#9;'instructions' =&gt; '',&#10;&#9;'required' =&gt; 0,&#10;&#9;'conditi
<?php
/**
* Plugin Name: Epicureangram
* Plugin URI: http://3five.com/
* Description: Epicurean Instragram shortcode plugin.
* Version: 1.0
* Author: Vincent Listrani
* Author URI: http://3five.com/
*/
@Vinsanity
Vinsanity / WP-front-end-ajax.php
Created August 20, 2014 04:21
WordPress Front-End Ajax Loader
<?php
function 3five_wpajax_url_script() {
$output = '<script type="text/javascript">';
$output .= 'var ajaxurl = '. admin_url('admin-ajax.php');
$output .= '</script>';
echo $output;
}
// Enqueue and localize the ajax script for the staff page.
function 3five_ajax_load_scripts() {
@Vinsanity
Vinsanity / new_gist_file_0
Created June 30, 2014 14:38
WP Rewrite Rules for Post Types. Courtesy of DPE David Paul Ellenwood
/**
* Adjust the rewrite rules for News & Events
*
* Adds a simple "status" query variable to the News post type archive
* to allow filtering the archive by a post meta field for event_date.
* Allowed statuses are: upcoming, past, and posts (for non-event entries).
* Also allows paging within the status filters.
*
* @since 1.0.0
*/
@Vinsanity
Vinsanity / gist:5671513
Created May 29, 2013 16:11
Gravity Form Caps for adding to WP Editor role
function add_theme_caps() {
// gets the author role
$role = get_role( 'editor' );
// add core gravity form capabilities
// adjust as required
$role->add_cap( 'gravityforms_edit_forms' );
$role->add_cap( 'gravityforms_delete_forms' );
$role->add_cap( 'gravityforms_create_form' );
$role->add_cap( 'gravityforms_view_entries' );
@Vinsanity
Vinsanity / gist:5422642
Last active December 16, 2015 10:49
WordPress Widget bones
class myWidget extends WP_Widget{
function __construct()
{
= array(
'description' => 'Description goes here',
'name' => 'Widget name goes here'
);
parent::__construct('myWidget', '', );
}