Skip to content

Instantly share code, notes, and snippets.

Avatar

David Cramer DavidCramer

View GitHub Profile
@DavidCramer
DavidCramer / upload.php
Last active Jun 11, 2020
Alter upload settings for Cloudinary Plugin v2
View upload.php
<?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.
View keybase.md

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 / example.php
Last active Aug 2, 2017
custom radio facet html
View example.php
<?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 / example.php
Created May 25, 2017
Beaver Builder + FacetWP template display code
View example.php
<?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 );
?>
@DavidCramer
DavidCramer / test.html
Last active May 24, 2017
matchHeight re-init
View test.html
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
if (FWP.loaded) {
setTimeout( function(){
$(matchVars.mh_inner_array.mh_selectors).matchHeight();
}, 250);
}
});
})(jQuery);
View gist:92d0b2c3996f40068bd85fadd3104f23
<?php
if ( ! have_posts() ) {
echo 'Nothing, sorry.';
return;
}
?>
<table>
<thead>
@DavidCramer
DavidCramer / example.php
Created Apr 30, 2017
WordPress Cron Daemon
View example.php
<?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 / functions.php
Created Mar 20, 2017
initilize the quickview for woocommerce-lightbox on facetwp-loaded event.
View functions.php
<?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({
@DavidCramer
DavidCramer / functions.php
Created Mar 3, 2017
exclude indexing if term is present
View functions.php
<?php
// add the below code to your child themes functions.php file.
function fwps_terms_exclude_index( $params ) {
// add your terms in here
$terms = array(
'expluded-term',
'anotehr-expluded'
View facet.php
<div class="facetwp-wrapper">
[facetwp facet="make"][facetwp facet="keyword"]
<div class="facetwp-template"></div>
</div>