Skip to content

Instantly share code, notes, and snippets.

Didou Schol badabingbreda

View GitHub Profile
@badabingbreda
badabingbreda / toolbox_example_dynamic_group_filter_js.js
Created Apr 5, 2019
Toolbox Example: Dynamic Group Filter JS
View toolbox_example_dynamic_group_filter_js.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 Apr 5, 2019
Toolbox Example: Dynamic Group Filter Twig
View toolbox_example_dynamic_group_filter_twig.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 Apr 5, 2019
Toolbox Example: Adding Relationship settings to Toolbox Field Module and Connector
View toolbox_example_adding_relationship_settings.php
<?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 Jan 17, 2019
Cookie Connector Cookie Script
View cookie-connector-ajax.php
@badabingbreda
badabingbreda / ACF_user_field_selectbox_returnlabel.php
Created Dec 20, 2018
Change ACF User Field selectbox returnlabel
View ACF_user_field_selectbox_returnlabel.php
<?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 Nov 10, 2018
Youtube defer loading to click
View youtube_defer_loading.html
<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 Oct 25, 2018
ACF number format with classes
View ACF_number_format_with_classes.php
<?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 Oct 18, 2018
ACF Pro 5.8.0-beta1 Custom Block
View acf_580beta1_block.php
<?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 Jun 18, 2018
Toolbox Example - Adding custom classes to acfimage
View toolbox_example_add_custom_acfimage_classes.php
<?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 Jun 18, 2018
Toolbox Example - Adding your own set of SC Attribute Defaults
View toolbox_example_add_own_sc_attr_defaults.php
<?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,
You can’t perform that action at this time.