Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View badabingbreda's full-sized avatar

Didou Schol badabingbreda

  • Breda, Netherlands
View GitHub Profile
@badabingbreda
badabingbreda / toolbox_example_dynamic_group_filter_js.js
Created April 5, 2019 20:54
Toolbox Example: Dynamic Group Filter JS
jQuery( '.chooser' ).on( 'click' , function( event ) {
var $this = jQuery(this);
var term = $this.data('term');
if ( $this.hasClass( 'uk-button-primary' ) ) {
var $unterm = jQuery( '.shadow[data-term="' + term + '"]' );
UIkit.filter('[uk-filter="target: .js-filter"]', { target: ".js-filter" } ).apply( $unterm );
} else {
UIkit.filter('[uk-filter="target: .js-filter"]', { target: ".js-filter" } ).apply( $this );
}
@badabingbreda
badabingbreda / toolbox_example_dynamic_group_filter_twig.twig
Last active April 5, 2019 20:52
Toolbox Example: Dynamic Group Filter Twig
{% macro getterms( taxonomy ) %}
{% set terms = function( 'get_terms' , { 'taxonomy': taxonomy , 'hide_empty' : true } ) %}
{% for item in terms %}
{% if item.slug != 'uncategorized' %}
<div>
<ul class="uk-subnav uk-subnav-pill" uk-margin>
<li class="filterbutton" uk-filter-control="filter: [data-{{item.slug}}='true']; group: {{item.slug}}">
<a href="#">{{item.name}}</a>
</li>
</ul>
@badabingbreda
badabingbreda / toolbox_example_adding_relationship_settings.php
Created April 5, 2019 15:29
Toolbox Example: Adding Relationship settings to Toolbox Field Module and Connector
<?php
add_filter( 'toolbox/helpers/settings/type=relationship' , 'my_relationship_settings' , 10, 2 );
function my_relationship_settings( $settings , $type = '' ) {
return array_merge($settings , array(
'relationship_subfield' => array(
'type' => 'text',
@badabingbreda
badabingbreda / cookie-connector-ajax.php
Created January 17, 2019 09:21
Cookie Connector Cookie Script
@badabingbreda
badabingbreda / ACF_user_field_selectbox_returnlabel.php
Created December 20, 2018 10:47
Change ACF User Field selectbox returnlabel
<?php
/**
* Write the data to a file
*
* @param [type] $filename [description]
* @param [type] $data [description]
* @return [type] [description]
*/
function writedata( $filename, $data ) {
@badabingbreda
badabingbreda / youtube_defer_loading.html
Created November 10, 2018 08:28
Youtube defer loading to click
<html>
<head>
<title>Youtube defer loading</title>
<!-- CSS -->
<style>
.youtube {
background-color: #000;
margin-bottom: 30px;
position: relative;
padding-top: 56.25%;
@badabingbreda
badabingbreda / ACF_number_format_with_classes.php
Last active October 25, 2018 20:36
ACF number format with classes
<?php
/**
* return number_formatted fieldvalue by adding classes to number field in Field Group
*
* my-currency : return as formatted number 1999 becomes 1,999
* my-currency-dec-# : set the number of decimals to return, # is the number of decimals (needs at least one character)
*/
add_filter( 'acf/load_value/type=number', 'my_check_number_classes', 10, 3 );
@badabingbreda
badabingbreda / acf_580beta1_block.php
Created October 18, 2018 09:05
ACF Pro 5.8.0-beta1 Custom Block
<?php
/**
* STEP 1: add code below to functions.php
*
* STEP 2: after adding this code you can add the fields to a block called My Custom Block.
* It will be available to select in the ACF Plugin AFTER this code has been added.
*
* Add these fields to the Fieldgroup for this block:
*
@badabingbreda
badabingbreda / toolbox_example_add_custom_acfimage_classes.php
Created June 18, 2018 19:22
Toolbox Example - Adding custom classes to acfimage
<?php
add_filter( 'toolbox/helpers/sc_attr/type=image' , 'add_image_class_attr' , 10 ,1 );
// add a custom attribute named 'myclass'
function add_image_class_attr( $attr ) {
$attr['myclass'] = '';
return $attr;
}
@badabingbreda
badabingbreda / toolbox_example_add_own_sc_attr_defaults.php
Last active June 18, 2018 18:53
Toolbox Example - Adding your own set of SC Attribute Defaults
<?php
add_filter( 'toolbox/helpers/sc_attr/type=new_fieldtype', 'my_own_attr_defaults' , 10 , 1 );
function my_own_attr_defaults ( $attr = array() ) {
$new_attr = array(
'field' => '',
'format' => null,
'allowempty' => 'false',
'postid' => 0,