Skip to content

Instantly share code, notes, and snippets.

View mathetos's full-sized avatar
🪐
Working on @stellarwp Stuff

Matt Cromwell mathetos

🪐
Working on @stellarwp Stuff
View GitHub Profile
@mathetos
mathetos / grid.js
Created November 30, 2015 06:35
Forked Codrops Grid.js
/*
* debouncedresize: special jQuery event that happens once after a window resize
*
* latest version and complete README available on Github:
* https://github.com/louisremi/jquery-smartresize
*
* Copyright 2012 @louis_remi
* Licensed under the MIT license.
*
* This saved you an hour of work?
@mathetos
mathetos / functions.php
Last active March 12, 2019 14:10
Function for conditionally enqueing minified or un-minified scripts based on WP_DEBUG
<?php
add_action( 'wp_enqueue_scripts', 'debug_theme_enqueue_styles' );
function debug_theme_enqueue_styles() {
if (WP_DEBUG == true) :
$random = mt_rand();
wp_enqueue_style( 'main-css-unminified', get_template_directory_uri() . '/assets/styles/build/main.css', '', $random );
@mathetos
mathetos / functions.php
Created June 28, 2016 17:58
Custom Autopopulate Dropdown for CalderaForms
add_filter( 'caldera_forms_autopopulate_options_post_value_field', 'givewp_customer_addon_purchases', 24, 2 );
function givewp_customer_addon_purchases()
{
$current_user = wp_get_current_user();
$purchases = edd_get_users_purchases($current_user->user_email, 100, false, 'any');
if ( $purchases ) {
foreach ($purchases as $purchase) {
$licenses = edd_software_licensing()->get_licenses_of_purchase( $purchase->ID );
@mathetos
mathetos / editor-typography.php
Created July 13, 2016 04:30
Generating dynamic Editor Styles for the WordPress editor
<?php
/*
* Dynamic Editor Styles
*
* Add this file to your theme with the add_editor_style() function
* The header and Path information will force the file to be treated like a CSS stylesheet
* More info on this here: https://css-tricks.com/css-variables-with-php/
*/
header("Content-type: text/css; charset: UTF-8");
header('Cache-control: must-revalidate');
@mathetos
mathetos / editor-styles-from-customizer.php
Created July 14, 2016 06:15 — forked from kevinwhoffman/editor-styles-from-customizer.php
Build editor stylesheet from customizer settings
<?php
// Place in functions.php of Twenty Sixteen to see editor background take on color of customizer background.
/**
* Build editor stylesheet from customizer settings upon customizer save.
*/
function kwh_build_stylesheet() {
$upload_dir = wp_upload_dir();
$stylesheet = $upload_dir['basedir'] . '/kwh-editor-style.css';
$styles = '';
@mathetos
mathetos / hidetitle.php
Last active August 2, 2016 05:29
Maybe Hide Title
function b16_maybe_hide_title($post) {
$hidetitle = get_post_meta( $post->ID, 'disable-title', true );
$hide = ( !empty($hidetitle) ) ? $hide = 'style="display:none;visibility:hidden" aria-hidden="true"' : '';
return $hide;
}
@mathetos
mathetos / enqueue_example.php
Created October 26, 2016 03:13
Enqueue Global Stylesheet
<?php
// Enqueue this stylesheet globally for the front-end
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
function themeslug_enqueue_style() {
wp_enqueue_style( 'my-theme-css', 'style.css', 'parent-stylesheet', '1.0', all );
}
@mathetos
mathetos / shortcode.php
Last active October 27, 2016 04:09
Super basic shortcode with stylesheet enqueued globally
<?php
/*
* Example Shortcode and Globally Enqueued Stylesheet
*
*/
// Our Shortcode function
function hiroy_shortcode( $content = null ) {
// do something to $content
$content = '<h2>Hi Roy!</h2>';
@mathetos
mathetos / better_shortcode.php
Last active October 27, 2016 04:10
Sample Shortcode with Selectively Enqueued Stylesheet
<?php
/*
* Example Shortcode and Globally Enqueued Stylesheet
*
*/
// Our Shortcode function
function hiroy_shortcode( $content = null ) {
// Enqueue the stylesheet now
wp_enqueue_style( 'hiroy-css' );
@mathetos
mathetos / dequeue.php
Created November 3, 2016 18:35
Dequeue Maps Builder JS except certain pages
<?php
/**
* Dequeue GMB script for certain pages
*
* Hooked to the wp_print_scripts action, with a late priority (100),
* so that it is after the script was enqueued.
*/
function gmb_dequeue_script() {
global $post;