Skip to content

Instantly share code, notes, and snippets.

View brentjett's full-sized avatar
🏠
Working from home...like always

Brent Jett brentjett

🏠
Working from home...like always
View GitHub Profile
@brentjett
brentjett / bb-theme-hook-concepts.php
Last active October 8, 2024 22:20
Theme & Beaver Builder Theme Hook Concepts
<?php
/**
* Adding a style variation to certain elements
*/
add_filter('fl_theme_classes', function($classes, $type, $object) {
// Add a special row style
if ($type == 'row') {
$classes['dark-row'] = "Dark Row";
}
@brentjett
brentjett / beaver-builder-friendly.php
Created October 26, 2015 18:51
Making a Theme Beaver Builder Friendly
<?php
// I add a simple function to my functions.php that lets me do clean page-builder checks inside my template files.
// This is safe to include regardless of if bb-plugin is active or not. Won't trigger error.
function is_builder_layout() {
if (class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_enabled()) return true;
return false;
}
// Inside page.php I use is_builder_layout() to determine layout
if (is_builder_layout()) {
@brentjett
brentjett / extended-libraries-api-scratchwork.php
Last active August 29, 2015 14:23
Advanced CSS/JS API for WordPress - API Scratchwork
<?php
// Extend wp_enqueue_script & wp_enqueue_style to support callbacks.
function beagle_enqueue_style_callback($handle = "script-name", $callback_fun, $callback_args, $enqueue_query = array()) {}
beagle_enqueue_style_callback('my-gallery-css', function() {
ob_start();
?>
body {
background:red;
@brentjett
brentjett / gist:88ed38f756e9ac79cbe6
Last active August 29, 2015 14:20
Template Enqueue Scratchwork
/*
Basset Theme
Template Enqueue Scratchwork
The idea is to allow a template file to declare it's own dependancies using a comment header similar to the style.css file or plugins.
*/
// Template index.php
<?php
/*
@brentjett
brentjett / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@brentjett
brentjett / WordPress User Query
Last active August 29, 2015 14:05
WordPress User Query Example
<?php
$args = array(
'order' => 'ASC',
'meta_key' => 'user-is-coach',
'meta_value' => 'yes'
);
$coaches = new WP_User_Query($args);
$coaches = $coaches->results;
foreach($ordered_coaches as $coach) {
@brentjett
brentjett / ACF_OptionsPageTemplate
Last active August 29, 2015 14:03
Create an ACF (Advanced Custom Fields) Options Page
<?php
/*
In the global scope
*/
if(function_exists('acf_add_options_sub_page')) {
acf_add_options_sub_page(array(
'title' => 'Nourish-mint Options',
'parent' => 'themes.php' /* Name of Admin file to parent or path to custom plugin page */
));