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 / intersectionobserver.js
Created January 4, 2023 14:02
Intersection observer that checks if a .buy-now button is in view
/*
* function to add observer
*/
function inViewport(selector, callback, options = {}) {
const elems = document.querySelectorAll( selector );
function observerCallback(entries, observer) {
entries.forEach(entry => callback(entry))
};
const observer = new IntersectionObserver( observerCallback , options );
elems.forEach( (i) => {
function mb_block_renderer($attributes, $is_preview = false, $post_id = null)
{
$context = Timber::context();
$context['content'] = $attributes['data'];
$context['is_preview'] = $is_preview;
$context['post_id'] = $post_id;
Timber::render("blocks/{$attributes['name']}.twig", $context);
}
<?php
/*
Plugin Name: Beaver Builder Global JS Reset
Description: Resets global JS and self deactivates.
Author: <Simon>
Version: 1.0
*/
class BB_Global_JS_Reset {
function __construct() {
include_once ABSPATH . '/wp-admin/includes/plugin.php';
@badabingbreda
badabingbreda / metabox.code-snippets
Created December 1, 2020 08:38
VSCode Meta Box code-snippets
{
// https://snippet-generator.app/
"Metabox meta_box": {
"prefix": "__mb_meta_box",
"body": [
"add_filter( 'rwmb_meta_boxes', '${1:my_new_metabox_callback}' );",
"/**",
" * Create a Meta Box, anonymously",
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_example.tiwg
Created October 23, 2019 12:10
Toolbox Docs: Plugin Development Alias Module Example
{% set userid = __node__.starter_user|default( function( 'get_current_user_id' ) ) %}
{% set userdata = User( userid ) %}
<div class="uk-tile uk-tile-muted uk-padding-small uk-grid-small" uk-grid>
<div class="uk-width-1-1 uk-width-1-3@s">
<img data-src="{{userdata.avatar}}" uk-img>
</div>
<div class="uk-width-1-1 uk-width-2-3@s">
<h3>{{userdata.user_nicename}}</h3>
<p>{{userdata.description?'About the author:<br>'~userdata.description:'no description given.'}}</p>
</div>
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_settings_form.twig
Last active October 23, 2019 12:43
Toolbox Docs: Plugin Development Alias Module Plugin initalization
<?php
/**
Plugin Name: Toolbox Starter Plugin
Plugin URI: https://www.toolboxstarterplugin.com/
Description: Starter Plugin for Toolbox, Using Timber
Version: 1.0
Author: Didou Schol
Text Domain: textdomain
Domain Path: /languages
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_settings_form.php
Last active October 23, 2019 12:09
Toolbox Docs: Plugin Development Alias Module Settings Form
<?php
/**
* Callback used to return the users of this WP site
* @return array
*/
function starter_return_users() {
$select_options = array();
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_sep_twig.php
Last active October 23, 2019 12:09
Toolbox Docs: Plugin Development Alias Module by inclusion using file_get_contents
<?php
/**
* Starter Plugin User Info Alias Module
* USER INFO
* @since 1.0
*/
\FLBuilder::register_module_alias( 'starter-user-info', array(
'module' => 'acftimber',
'name' => __( 'User Info', 'textdomain' ),
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_sep_twig.php
Last active October 23, 2019 12:08
Toolbox Docs: Plugin Development Alias Module by inclusion as a seperate twig template
<?php
/**
* Starter Plugin User Info Alias Module
* USER INFO
* @since 1.0
*/
\FLBuilder::register_module_alias( 'starter-user-info', array(
'module' => 'acftimber',
'name' => __( 'User Info', 'textdomain' ),
<?php
/**
* Class Name: your_themename_top_menu
* Description: A custom WordPress nav walker class to implement UIkit menu markup
*/
class your_themename_top_menu extends Walker_Nav_Menu {
/**
* @see Walker::start_lvl()
* @since 3.0.0