Skip to content

Instantly share code, notes, and snippets.

View DavidCramer's full-sized avatar

David Cramer DavidCramer

View GitHub Profile
@DavidCramer
DavidCramer / upload.php
Last active June 11, 2020 13:08
Alter upload settings for Cloudinary Plugin v2
<?php
add_filter( 'cloudinary_upload_options', function( $options, $attachment_post, $upload_object ){
/**
* Structure of options as follows:
$options = array(
'unique_filename' => false, // Allow for auto filenames. See Cloudinary docs.
'resource_type' => $resource_type, // Type can be 'image' or 'video' or custom.
'public_id' => $public_id, // Changing this will change the public ID as stored in Cloudinary.
@DavidCramer
DavidCramer / gist:395d3d1e09c2874a152d
Created October 14, 2014 11:06
Setting Caldera Forms to use Zurb Foundation Grid instead of Bootstrap.
<?php
// Simple snippet to show how to use Foundation's grid over the built in Bootstrap grid.
add_filter('caldera_forms_render_grid_settings', 'setup_foundation_grid', 10, 2);
function setup_foundation_grid($grid, $form){
// Bootstrap grid sized to foundation equivilents
$grid_sizes = array(
'xs' => 'small',
'sm' => 'small',
@DavidCramer
DavidCramer / example.php
Created April 30, 2017 09:59
WordPress Cron Daemon
<?php
/*
* Plugin Name: Cron Daemon
* Plugin URI: https://cramer.co.za
* Description: Simple plugin to daemonize the WordPress Cron.
* Version: 1.0.0
* Author: David Cramer
* Author URI: https://cramer.co.za
* License: GPL2+
*/
@DavidCramer
DavidCramer / cf-data-example.php
Last active October 20, 2019 13:18
Getting submission data in a from processor in Caldera Forms
<?php
/**
* Plugin Name: CF Get Submission Data
* Plugin URI:
* Description: Example in getting submission data in a form processor
* Version: 1.0.0
* Author: David Cramer
* Author URI:
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@DavidCramer
DavidCramer / functions.php
Created March 20, 2017 10:48
initilize the quickview for woocommerce-lightbox on facetwp-loaded event.
<?php
// add the below code to your child themes functions.php file.
add_filter( 'facetwp_assets', function( $assets ) {
?>
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
$('.product').magnificPopup({

Keybase proof

I hereby claim:

  • I am davidcramer on github.
  • I am davidcramer (https://keybase.io/davidcramer) on keybase.
  • I have a public key ASAQ5m0_eJRy0MBoYiwDFcnQcE2Y9QAAvy1SW8RR84IXggo

To claim this, I am signing this object:

@DavidCramer
DavidCramer / caldera-forms-autopopulate-select.php
Last active September 13, 2017 07:28
Dynamically populating an option based field (select,radio,checkbox etc.) in Caldera Forms
<?php
/* Example to auto populate an option based field in caldera forms
* This example uses a by slug. method. this way you can populate the
* field by simply giving it the desired slug. in this example: gdp
*
* To populate based on type where {type} is dropdown, radio, checkbox etc...
* add_filter('caldera_forms_render_get_field_type-{type}', 'cf_get_data_json');
*/
// Add filter on the fetch field config to populate
@DavidCramer
DavidCramer / example.php
Last active August 2, 2017 17:35
custom radio facet html
<?php
add_filter( 'facetwp_facet_html', function( $output, $params ) {
if ( 'my_facet' == $params['facet']['name'] ) {
$output = '';
$values = (array) $params['values'];
$selected_values = (array) $params['selected_values'];
foreach( $values as $result ){
$clean_val = esc_attr( $result );
$selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : '';
@DavidCramer
DavidCramer / functions.php
Created February 21, 2017 05:16
Disable mouse scroll on Map
<?php
// add this to your child themes functions.php file
add_filter( 'facetwp_map_init_args', function ( $args ) {
$args['scrollwheel'] = false;
return $args;
} );
@DavidCramer
DavidCramer / example.php
Created May 25, 2017 05:56
Beaver Builder + FacetWP template display code
<?php
$module_id = 0; // change this to the ID of your saved module.
FLBuilder::enqueue_layout_styles_scripts_by_id( $module_id );
FLBuilder::render_content_by_id( $module_id );
?>