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 / 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 ) {
<?php
/**
* Add to functions.php to mimic *whitelabel* on Pro license
* Please support Beaver Builder by buying the product at wpbeaverbuilder.com
*/
class FLBuilderWhiteLabel {
public static function is_white_labeled() {
return true;
@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'] ) ;
}
@badabingbreda
badabingbreda / toolbox_example_highlight_amsterdam_glass.php
Last active May 9, 2018 15:20
Toolbox Filter Example - Highlight WYSIWYG
<?php
add_filter( 'toolbox/helpers/get_acf_field/type=wysiwyg' , 'highlight_amsterdam_glass', 10, 5 );
function highlight_amsterdam_glass( $string, $field_object, $value, $atts, $postid ) {
$regex = '/((?i)\b' . 'amsterdam glass' . '\b)/m';
return preg_replace( $regex , '<span style="background-color:##b2af01;color:#fff;padding-left:5px;padding-right:5px;">'.'$1'.'</span>', $string);
}
@badabingbreda
badabingbreda / toolbox_example_highlight_with_settings.php
Created May 9, 2018 15:33
Toolbox Filter Example - Highlight WYSIWYG with settings
<?php
add_filter( 'toolbox/helpers/settings/type=wysiwyg' , 'more_wysiwyg_settings' , 10, 2 );
function more_wysiwyg_settings( $settings ) {
return array_merge( $settings, array(
'highlight' => array(
'type' => 'text',
'label' => __('Highlight Text', 'textdomain'),
@badabingbreda
badabingbreda / toolbox_example_debugging_show_me_checkbox.php
Created May 9, 2018 15:53
Toolbox Filter Example - debugging example
<?php
add_filter( 'toolbox/helpers/get_acf_field/type=checkbox' , 'show_me_checkbox' , 20, 5 );
function show_me_checkbox( $string , $field_object, $value, $atts, $postid ) {
ob_start();
var_dump( $field_object );
return ob_get_clean();
}
@badabingbreda
badabingbreda / toolbox_example_filter_advanced.php
Created May 9, 2018 16:17
Toolbox Filter Example - advanced filter
<?php
add_filter( 'toolbox/helpers/get_acf_field/type=checkbox' , 'return_checkbox' , 20, 5 );
function return_checkbox( $string , $field_object , $value , $atts = null , $postid = null ) {
if (!$atts['display_as']) return $string;
$return = array();
@badabingbreda
badabingbreda / toolbox_example_do_var_dump.php
Created May 16, 2018 11:00
Toolbox Example - var_dump a filter result or variable
<?php
// add filter, make sure the priority is at the right position
add_filter( 'toolbox/helpers/get_acf_field/type=repeater' , 'do_var_dump' , 15 , 5 );
// Use this function to dump out the value to determine what you might need
function do_var_dump( $string, $field_object , $value , $atts, $postid ) {
ob_start();
var_dump( $string ); // $string | $field_object | $value | $atts | $postid
return ob_get_clean();