Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
bryanwillis / parse-url.php
Created January 9, 2016 10:46
Parse url. Break down a url to get the parameters / arguments. Very helpful....
<?php
$url = 'http://usr:pss@example.com:81/mypath/myfile.html?a=b&b[]=2&b[]=3#myfragment';
if ($url === unparse_url(parse_url($url))) {
print "YES, they match!\n";
}
function unparse_url($parsed_url) {
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
@wpscholar
wpscholar / defer-async-scripts.php
Last active November 18, 2022 02:41
Class that allows you to async and defer scripts in WordPress by adding data.
<?php
class WP_Scholar_Defer_Scripts {
public static function initialize() {
add_filter( 'script_loader_tag', array( __CLASS__, 'defer_scripts' ), 10, 2 );
add_filter( 'script_loader_tag', array( __CLASS__, 'async_scripts' ), 10, 2 );
}
public static function defer_scripts( $tag, $handle ) {
<?php
/* remove css for header background image */
remove_action('wp_head', 'genesis_custom_header_style');
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
# Hide Wordpress Specific Schema
// This file controls all base color styles for our theme. All colors should be
// defined in _colors.scss. This allows us to at a glance determine global color
// styles of our theme and prevents arbitrary color assignment.
// Do not use the base theme colors in the scss partial files! Set up your theme's
// base colors and then use scoped color values in your Sass partials.
// Theme Colors (private vars)
//------------------------------------------------------------------------------
$off-black: #1c1e1f;
@bryanwillis
bryanwillis / functions.php
Last active January 11, 2016 09:18 — forked from srikat/functions.php
Wrapping Primary and Secondary Navigation in custom divs in Genesis
//* Wrap .nav-primary in a custom div
add_filter( 'genesis_do_nav', 'genesis_child_nav', 10, 3 );
function genesis_child_nav($nav_output, $nav, $args) {
return '<div class="nav-primary-wrapper">' . $nav_output . '</div>';
}
//* Wrap .nav-secondary in a custom div
add_filter( 'genesis_do_subnav', 'genesis_child_subnav', 10, 3 );
@neilgee
neilgee / comments-removal.php
Last active October 6, 2016 02:05
Remove Comments based on Category
<?php //<~ don't add me in
add_action( 'genesis_before_entry', 'wpb_remove_comments_category' );
function wpb_remove_comments_category() {
if ( !in_category( 38 ) ) {//adjust your Category ID's in the conditional
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
}
}
@bryanwillis
bryanwillis / bootstrap-genesis-styling.css
Last active January 15, 2016 05:21
Bootstrap Genesis Styles and Wordpress Core CSS
/* Bootstrap Genesis Theme Variables
------------------------------------------------------------ */
/* Variables
------------------------------------------------------------ */
/* Archive/Blog Styling
------------------------------------------------------------ */
body.archive .post,
body.blog .post {
<?php
/**
* Theme Setup
* @since 1.0.0
*
* This setup function attaches all of the site-wide functions
* to the correct hooks and filters. All the functions themselves
* are defined below this setup function.
*
@moorscode
moorscode / script_local_fallback.php
Last active July 1, 2020 11:25
Add inline local script fallback for remotely loaded scripts in WordPress
<?php
/**
* wp_register_script wrapper with local fallback
*
* @param $handle
* @param $src
* @param $js_test JavaScript code to test for availability of object
* @param bool|false $local_src Load source file if test fails
* @param array $deps
@bryanwillis
bryanwillis / bsg-gforms-chosen.css
Last active March 8, 2016 09:54
Bootstrap Genesis Gravity Form Styles
.gform_wrapper .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;