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 / 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 / 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 / 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 / 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 / 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 / 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 / plugin.php
Last active April 13, 2023 16:48
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
@mathetos
mathetos / give-centered-styles.css
Last active October 26, 2015 23:35
Give Center Form Styles
div[class*="give-form-wrap"] {
text-align: center;
}
.give-total-wrap,
#give-final-total-wrap {
display: inline-block;
margin: 0 auto;
}
@mathetos
mathetos / functions.php
Created January 23, 2015 06:18
User-Friendly Styled Content in the WordPress Editor
<?php
/*
* Add "Formats" dropdown to TinyMCE Editor
*/
function matt2015_mce_formats($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'matt2015_mce_formats');
@mathetos
mathetos / smart-excerpts
Last active May 17, 2016 19:43
Smart Excerpts
<?php
/*
* This asks first for a Yoast SEO meta description,
* If that's not present, then it asks for the excerpt of the post,
* If that's not present, then it strips the content
* In this case, I have an excerpt length setting in the Customizer
* Both the excerpt and content stripping, also strip shortcodes
* @author Matt Cromwell <[email protected]>
* @copyright Copyright (c) 2014, Matt Cromwell
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License