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.

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 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 / 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 );
?>
@DavidCramer
DavidCramer / test.html
Last active May 24, 2017 12:34
matchHeight re-init
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
if (FWP.loaded) {
setTimeout( function(){
$(matchVars.mh_inner_array.mh_selectors).matchHeight();
}, 250);
}
});
})(jQuery);
<?php
if ( ! have_posts() ) {
echo 'Nothing, sorry.';
return;
}
?>
<table>
<thead>
@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 / 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({
@DavidCramer
DavidCramer / functions.php
Created March 3, 2017 12:34
exclude indexing if term is present
<?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'
@DavidCramer
DavidCramer / facet.php
Created February 27, 2017 05:22 — forked from anonymous/facet.php
Facet
<div class="facetwp-wrapper">
[facetwp facet="make"][facetwp facet="keyword"]
<div class="facetwp-template"></div>
</div>