Skip to content

Instantly share code, notes, and snippets.

View greenhornet79's full-sized avatar
👽
Craft

Jeremy Green greenhornet79

👽
Craft
View GitHub Profile
@greenhornet79
greenhornet79 / gist:f9284b63a942f0b1f318
Created March 2, 2015 03:52
Gravity Forms - change state names to abbreviations
add_filter("gform_address_types", "us_address", 10, 2);
function us_address($address_types, $form_id){
$address_types["us"] = array(
"label" => "United States",
"country" => "USAB",
"zip_label" => "Zip Code",
"state_label" => "State",
"states" => array(
"" => "",
"AL" => "Alabama",
@greenhornet79
greenhornet79 / issue-to-pdf-watermark.php
Last active September 4, 2015 13:28
Add watermark to Issue to PDF pages
<?php
add_action( 'issue_to_pdf_after_pdf_init', 'my_func_show_watermark', 10 );
function my_func_show_watermark( $mpdf ) {
$mpdf->SetWatermarkText('DRAFT');
$mpdf->showWatermarkText = true;
}
@greenhornet79
greenhornet79 / form.html
Created September 23, 2015 13:41
A basic email subscribe from
<form method="post" action="">
<input id="first-name" type="text" name="emma_first_name" placeholder="First Name">
<input id="last-name" type="text" name="emma_last_name" placeholder="Last Name">
<input id="email-address" type="text" name="emma_email" placeholder="Email Address">
<input id="submit" type="submit" value="Submit">
</form>
@greenhornet79
greenhornet79 / add_to_emma.php
Created September 23, 2015 13:48
A function to add a new user to an Emma list
<?php
function add_user_to_emma( $data ) {
// http://api.myemma.com/
// Emma Authentication Variables
$account_id = "#"; // add your account id
$public_api_key = "#"; // add your public api key
$private_api_key = "#"; // add your private api key
<?php
// create top level admin menu
add_action('admin_menu', 'endo_stock_report_admin_menu');
function endo_stock_report_admin_menu() {
add_menu_page('Stock Report Export', 'Stock Report Export', 10, 'endo_stock_report', 'endo_admin_stock_report_page');
}
<?php
function endo_admin_stock_report_page() {
?>
<div class="wrap">
<h2>Stock Report Export to CSV</h2>
<p>Click export below to generate a stock report of the products on this site.</p>
<?php
add_action('admin_init', 'endo_stock_report_admin_init');
function endo_stock_report_admin_init() {
global $plugin_page;
if ( isset($_POST['download_csv']) && $plugin_page == 'endo_stock_report' ) {
generate_stock_report_csv();
<?php
function generate_stock_report_csv() {
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
// set file name with current date
header('Content-Disposition: attachment; filename=endo-stock-report-' . date('Y-m-d') . '.csv');
<?php
/**
* Plugin Name: Endo Stock Report Exporter
* Plugin URI: http://www.endocreative.com
* Description: A custom stock report exporter plugin for WooCommerce
* Version: 1.0.0
* Author: Endo Creative
* Author URI: http://www.endocreative.com
* License: GPL2
*/
<?php
// don't allow users to access WordPress admin
add_action('admin_init', 'endo_hide_dashboard');
function endo_hide_dashboard() {
if ( ! current_user_can( 'manage_options' ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
wp_redirect(home_url()); exit;
}
}