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 / targetrowbg.beaverbuilder.php
Last active September 8, 2016 06:37
Shortcode for Beaver Builder to target a row and set it's background using a ACF value, using jQuery and CSS.
<?php
/**
* Target a row higher in the DOM using style-attr for temp-class
* @example shortcode: [targetrow field="backgroundurl" removemodule="true"]
* this will use the posts ACF backgroundurl as a value for the background-image,
* it will also remove the module in the DOM so that when used on a row without any HTML or editor module it will still be silent.
*
* @param $atts attributes, field is required;
* @return [type] [description]
@badabingbreda
badabingbreda / bbacf_add_custom_sc_attr.php
Created December 22, 2016 09:34
ACF Template Builder - Add a custom shortcode attribute
add_filter( 'bbacf/helpers/sc_attr/type=google_map' , 'add_color_sc_attribute' );
/**
* add the postid attribute to the default sc attr
* @param [type] $array [description]
* @return [type] [description]
*/
function add_color_sc_attribute( $array ) {
return array_merge(
$array,
@badabingbreda
badabingbreda / bbacf_use_custom_attr_google_map.php
Last active December 22, 2016 09:51
ACF Template Builder - Using a custom attribute when displaying the ACF field
add_filter( 'bbacf/helpers/get_acf_field/type=google_map' , 'add_red_border' , 11, 5 );
/**
* add a colored border, using the added sc attr color
* @param [type] $string [description]
* @param [type] $field_object [description]
* @param [type] $value [description]
* @param [type] $atts [description]
* @param [type] $postid [description]
*/
@badabingbreda
badabingbreda / gist:cc2c89005035ef02a47a7307221f736d
Last active December 22, 2016 12:31
ACF Template Builder - changing field-type output
remove_filter( 'bbacf/helpers/get_acf_field/type=checkbox' , 'bbacf_helpers::shortcode_acf_return_checkbox' ,10 );
add_filter( 'bbacf/helpers/get_acf_field/type=checkbox' , 'return_custom_acf_checkbox' , 11, 5 );
function return_custom_acf_checkbox ( $string , $field_object , $value , $atts = null , $postid = null ) {
// get the correct fieldname for version 4 or 5 of acf
$get_fo = bbacf_helpers::$fr[ bbacf_acf_version() ];
if ( $field_object[ 'type' ] == 'text' ) return $string . $value ;
@badabingbreda
badabingbreda / gist:7fd4b22e429f18ac1062cfc0da26f2f3
Created December 22, 2016 19:41
ACF Template Builder - Return custom field-type output
add_filter( 'bbacf/helpers/get_acf_field/type=font-awesome' , 'return_custom_acf_fontawesome' , 10, 5 );
/**
* return rotated font-awesome icon
* @param [type] $string [description]
* @param [type] $field_object [description]
* @param [type] $value [description]
* @param [type] $atts [description]
* @param [type] $postid [description]
* @return [type] [description]
@badabingbreda
badabingbreda / oxygenbuilder2_dynamic_shortcode.php
Last active April 16, 2018 16:32
Oxygenbuilder 2.0 getting my own shortcode data
<?php
// ATTENTION:
// first you will need to add 2 lines of code (only lines 9+10, the } else if () { ) to the current oxygen-dynamic-shortcode.php file in Oxygenbuilder 2.0-Alpha2/3
// it is located within the oxygen_vsb_dynamic_shortcode class-function
//
// if (method_exists($this, $handler)) {
// $output = call_user_func(array($this, $handler), $atts);
// } else if (class_exists('Dynamic_Shortcodes_' . $atts['data']) && in_array( 'Oxygen_VSB_Dynamic_Shortcodes', class_parents('Dynamic_Shortcodes_' . $atts['data']) ) ){
// $output = call_user_func( array( 'Dynamic_Shortcodes_' . $atts['data'] , 'output' ) , $atts );
@badabingbreda
badabingbreda / oxygenbuilder2_add_edit_with_oxygen.php
Last active April 25, 2018 17:51
Oxygenbuilder2.0 Add "Edit with Oxygen" button to page, post, ct_template and others
<?php
/**
* Add an 'edit with Oxygen' button on set posttypes, use filter ct_post_types to add to the array;
*/
// add a filter to add my cpt's
add_filter( 'ct_post_types', 'example_add_my_custom_post_types' , 10 ,1 );
// merge arrays
function example_add_my_custom_post_types( $post_types ) {
@badabingbreda
badabingbreda / toolbox_example_add_conditional.php
Created May 8, 2018 19:37
Toolbox Action - toolbox_add_conditional_options
<?php
add_action( 'toolbox_add_conditional_options' , 'add_some_new_conditional_feature', 10, 1 );
function add_some_new_conditional_feature() {
toolboxExtender::add_conditional_option(
// filter name
'conditional_filter_check_parameter',
// option key and title
array('key'=> 'check_parameter' , 'title' => __('Check URL Parameter', 'textdomain') ),
@badabingbreda
badabingbreda / toolbox_example_adding_conditional_filter.php
Created May 8, 2018 20:01
Toolbox Filter - adding conditional filter
<?php
// simple example of a conditional filter
add_filter( 'conditional_filter_check_userloggedin' , 'my_check_userloggedin' ,10 ,2 );
function my_check_userloggedin( $is_visible , $node ) {
return is_user_logged_in();
}
@badabingbreda
badabingbreda / toolbox_example_conditional_filter_check_newsletteroffer.php
Created May 8, 2018 20:27
Toolbox Filter Example - conditional filter check newsletteroffer
<?php
add_filter( 'conditional_filter_check_newsletteroffer' , 'my_check_newsletteroffer' ,10 ,2 );
function my_check_newsletteroffer( $is_visible , $node ) {
return isset( $_GET['newsletteroffer'] ) ;
}