Skip to content

Instantly share code, notes, and snippets.

@danieliser
danieliser / gist:35380c1336c4d057f59e
Created March 29, 2015 06:57
EDD Move User Fields Above Payment Type Selection
remove_action( 'edd_purchase_form', 'edd_show_purchase_form' );
add_action( 'edd_checkout_form_top', 'edden_show_purchase_form_user_fields' );
add_action( 'edd_purchase_form', 'edden_show_purchase_form_payment_fields' );
function edden_show_purchase_form_user_fields() {
if ( edd_can_checkout() ) {
do_action( 'edd_purchase_form_before_register_login' );
@danieliser
danieliser / gist:776b495fe2c656bad366
Last active August 29, 2015 14:17
edd_checkout_cart_columns replacement
function edd_checkout_cart_columns() {
global $wp_filter;
$head_first = 0;
$head_last = 0;
if( isset( $wp_filter['edd_checkout_table_header_first'] ) ){
$head_first = count( $wp_filter['edd_checkout_table_header_first'] );
}
if( isset( $wp_filter['edd_checkout_table_header_last'] ) ){
$head_last = count( $wp_filter['edd_checkout_table_header_last'] );
}
@danieliser
danieliser / functions.php
Last active April 13, 2023 16:48
Fetch Active Install Count from WordPress Plugins API
<?php
function get_plugin_install_count( $plugin ) {
$api = plugins_api( 'plugin_information', array(
'slug' => 'popup-maker',
'fields' => array( 'active_installs' => true )
) );
if( ! is_wp_error( $api ) ) {
return $api->active_installs;
}
@danieliser
danieliser / functions.php
Last active April 13, 2023 16:48
Plugins API Active Install Count Shortcode for WordPress
<?php
function plugin_install_count_shortcode( $atts ) {
$a = shortcode_atts( array(
'plugin' => NULL,
), $atts );
if( ! $a['plugin'] ) {
return;
}
@danieliser
danieliser / gist:4cd87090f338362d81e1
Last active November 26, 2017 01:58
Schedule a popup.
<?php
function schedule_my_popup( $is_loadable, $popup_id ) {
if( $popup_id == 123 ) {
$start = strtotime( 'May 4, 2015 11:59PM' );
$end = strtotime( 'May 5, 2015 11:59PM' );
$now = strtotime( 'now' );
if( $now >= $start && $now <= $end ) {
return true;
@danieliser
danieliser / gist:33417a14b23f803ea057
Created June 27, 2015 00:03
jQuery UI Autocomplete: Tabbing before results available.
var ingredients = [
{ID:"9", value:"Cocoa Powder"},
{ID:"11", value:"Baking Powder"}
];
$(".ingredient-label")
.autocomplete({
source: ingredients,
autoFocus: true,
select: function (e, ui) {
<?php
/**
* Use * for origin
*/
add_action( 'rest_api_init', function() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE' );
@danieliser
danieliser / functions.php
Last active March 25, 2018 11:36
Add JavaScript using wp_footer.
<?php
add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );
function my_custom_popup_scripts() { ?>
<script type="text/javascript">
(function ($, document, undefined) {
// Your custom code goes here.
@danieliser
danieliser / custom.js
Last active September 27, 2016 02:20
Popup Maker: Set custom auto open cookie when form submitted.
jQuery('#popmake-123 form').on('submit', function () {
jQuery.pm_cookie(
'pum-123', // The cookie name that is checked prior to auto opening.
true, // Setting a cookie value of true.
'10 years', // Plain english time frame.
'/' // Cookie path of / means site wide.
);
});
<?php
add_action('wp_footer', 'my_custom_popup_scripts', 500 );
function my_custom_popup_scripts() { ?>
<script type="text/javascript">
jQuery('#popmake-123')
.on('popmakeBeforeOpen', function () {
var $iframe = jQuery('iframe', jQuery(this)),
src = $iframe.prop('src');
$iframe.prop('src', '').prop('src', src + '/?autoplay=1');