Skip to content

Instantly share code, notes, and snippets.

View BryanBarrera's full-sized avatar

Bryan Barrera BryanBarrera

View GitHub Profile
@BryanBarrera
BryanBarrera / functions.php
Created December 16, 2020 17:18 — forked from grantambrose/functions.php
Add content to the vertical menu in the Beaver Builder Theme (before)
// Add a Beaver Builder Template to the bottom of the Beaver Builder Theme vertical menu
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
// if the menu is in fact our header menu
if ($args->theme_location == 'header') {
// get the content of our Beaver Builder Template
$bb_content = do_shortcode('[fl_builder_insert_layout slug="vertical-menu-content-bottom"]');
// append the content of our Beaver Builder Template to the end of our menu
$items = $bb_content . $items;
}
@BryanBarrera
BryanBarrera / functions.php
Created December 16, 2020 17:18 — forked from grantambrose/functions.php
Add content to the vertical menu in the Beaver Builder Theme (before)
// Add a Beaver Builder Template to the bottom of the Beaver Builder Theme vertical menu
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
// if the menu is in fact our header menu
if ($args->theme_location == 'header') {
// get the content of our Beaver Builder Template
$bb_content = do_shortcode('[fl_builder_insert_layout slug="vertical-menu-content-bottom"]');
// append the content of our Beaver Builder Template to the end of our menu
$items = $bb_content . $items;
}
@BryanBarrera
BryanBarrera / custom-hooks.php
Created November 12, 2020 02:46 — forked from djrmom/custom-hooks.php
facetwp date source converted to year
<?php
/**
* reindex after adding or updating this filter
*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'date_as_year' == $params['facet_name'] ) { // change date_as_year to name of your facet
$raw_value = $params['facet_value'];
$params['facet_value'] = date( 'Y', strtotime( $raw_value ) );
$params['facet_display_value'] = $params['facet_value'];
@BryanBarrera
BryanBarrera / shortcode_post_object.php
Created April 17, 2020 14:02 — forked from phucdohong96/shortcode_post_object.php
Shortcode Sample ACF Post Object & ACF Repeater
<?php
function shortcode_post_object_function() {
ob_start();
$count = 0;
//Get field
$post_objects = get_field ('post_objects');
if (!empty($post_objects)) {
foreach ($post_objects as $post_object) {
$id = $post_object->ID;
@BryanBarrera
BryanBarrera / map-test.html
Created November 1, 2017 13:59 — forked from keccers/map-test.html
Google Maps Custom Zoom Controls
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Custom Controls Test</title>
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
@BryanBarrera
BryanBarrera / is_blog.php
Created June 8, 2016 14:42 — forked from wesbos/is_blog.php
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@BryanBarrera
BryanBarrera / Wordpress Data Layer Variables
Last active May 8, 2020 08:35 — forked from chipoglesby/Wordpress Data Layer Variables
Modified Wordpress datalayer variables for pulling: author names, post types, categories, page name, and dates into custom variables for the classic version of Google Analytics. Feel free to leave a comment or hit me up http://BryanBarrera.com
// Add this script after you make your dataLayer = []; call
// AND after your GTM code snippet
// This needs to go inside the header.php in order for it work globally across your site
<script type="text/javascript">
// URL toolbox - helps grabbing elements in the URL
var _d = document;
var _dl = _d.location;
var _dlp = _dl.pathname;
var _dls = _dl.search;
var _dr = _d.referrer;
@BryanBarrera
BryanBarrera / twitter-share.js
Last active May 22, 2016 13:39 — forked from guillaumepiot/gist:5442196
Twitter Social Share
// We bind a new event to our link
$('a.tweet').click(function(e){
//We tell our browser not to follow that link
e.preventDefault();
// 1. We get the URL of the link
//or 2. URL of the page
// 1. var loc = $(this).attr('href');
var loc = $(location).attr('href'); // 2