Skip to content

Instantly share code, notes, and snippets.

@troutacular
troutacular / console.js
Created January 8, 2019 19:19
Console Messages
/**
* Checks if console exists and allows command types for output.
*
* @param {comman.['log', 'warn', 'error', 'info']} console command type
* @param {message.string} Message to be passed to the console type
* @return cosole.[command]([message]) if console available
*/
function consoleMessage(command, message) {
'use strict';
@troutacular
troutacular / _screen-reader-text.scss
Created October 5, 2018 21:02
Screen Reader Text - SCSS
/**
Screen Reader Text
==========
Apply to text meant only for screen readers.
Usage
=========
@troutacular
troutacular / ga.enhanced.js
Last active April 29, 2019 14:13
Google Analytics Enhanced
/**
Table of Contents: Analytics
============================
1.0 - Functions
2.0 - Processing
**/
/* globals consoleMessage, ga, ready, forEachElement, checkForParent */
@troutacular
troutacular / _screen-reader-text.scss
Last active April 21, 2017 18:41
Hiding text on screen
/**
Screen Reader Text
==========
Apply to text meant only for screen readers.
Usage
=========
@troutacular
troutacular / acf-api-repsonse.php
Created April 17, 2017 20:13
ACF in WP API Response
<?php
/**
* The functions to add all ACF types to the REST API responses.
*
* @link https://developer.wordpress.org/reference/hooks/rest_prepare_post_type/
* @package theme-name
*/
/**
* Add Options for Posts.
@troutacular
troutacular / functions.php
Last active April 6, 2017 23:58
Add ACF to WP REST API
<?php
/**
* The functions to add all ACF types to the REST API responses.
*
* @link https://developer.wordpress.org/reference/hooks/rest_prepare_post_type/
* @package theme-name
*/
/**
* Add Options for Posts.
@troutacular
troutacular / functions.php
Created April 5, 2017 21:54
WordPress Auto Page Template Setup
<?php
// only run this in the admin section
if ( is_admin() ) {
/* Run this function after theme setup. Did not use 'after_switch_theme'
* to allow for future automatic additions to existing sites.
*/
add_action( 'after_setup_theme', '_starter_page_add' );
// get the support page function
@troutacular
troutacular / site-acronym.js
Created January 11, 2017 21:34
Javascript: Site Acronym for WordPress
// wrap the first word of the site title matching 'string' in a span to apply highlight color
function siteAcronymClass(acronym) {
var strTitle = document.getElementsByClassName('site-title')[0].innerHTML;
var newStrTitle = strTitle.replace(acronym, '<span class="site-acronym">' + acronym + '</span>');
if ( strTitle !== null ) {
document.getElementsByClassName('site-branding-title')[0].innerHTML = newStrTitle;
}
@troutacular
troutacular / functions.php
Last active August 18, 2016 17:34
JetPack: Remove sharing from excerpts or content
/**
* Remove the sharing functions for jetpack from the excerpt or content.
*/
function jetpack_modify_remove_excerpt_share() {
// Remove from exceprt.
remove_filter( 'the_excerpt', 'sharing_display',19 );
// Remove from page.
remove_filter( 'the_content', 'sharing_display',19 );
@troutacular
troutacular / wp-tiny-mce-sample.php
Created April 6, 2016 23:34
WordPress TinyMCE sample
// Callback function to insert 'styleselect' into the $buttons array
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
// Register our callback to the appropriate filter
add_filter('mce_buttons_2', 'my_mce_buttons_2');
// Callback function to filter the MCE settings