Skip to content

Instantly share code, notes, and snippets.

View megmorsie's full-sized avatar
🇵🇸

Megan Rose megmorsie

🇵🇸
View GitHub Profile
@megmorsie
megmorsie / wpse211556.php
Last active December 17, 2015 15:42
WordPress Stack Exchange: How to only show page id as body class?
<?php
/*
* Plugin Name: Stack: How to only show page id as body class?
* Plugin URI: http://wordpress.stackexchange.com/questions/211556/how-to-only-show-page-id-as-body-class
* Description: Stack Exchange - WordPress Development
* Version: 1.0
* Author: Megan Morsie
* Author URI: http://megabyterose.com/
* License: GPL2
*/
@megmorsie
megmorsie / wpse210596.php
Last active December 17, 2015 15:44
WordPress Stack Exchange: Flush_rewrite_rules not working when settings updated
<?php
/*
* Plugin Name: Stack: Flush_rewrite_rules not working when settings updated
* Plugin URI: http://wordpress.stackexchange.com/questions/210596/flush-rewrite-rules-not-working-when-settings-updated
* Description: Stack Exchange - WordPress Development
* Version: 1.0
* Author: Megan Morsie
* Author URI: http://megabyterose.com/
* License: GPL2
*/
@megmorsie
megmorsie / wpse211164.php
Created December 17, 2015 15:51
WordPress Stack Exchange: Customiser sections not being displayed with `active_callback`
<?php
/*
* Plugin Name: Stack: Customiser sections not being displayed with `active_callback`
* Plugin URI: http://wordpress.stackexchange.com/questions/211164/customiser-sections-not-being-displayed-with-active-callback
* Description: Stack Exchange - WordPress Development
* Version: 1.0
* Author: Megan Morsie
* Author URI: http://megabyterose.com/
* License: GPL2
*/
@megmorsie
megmorsie / increment-hex-values.php
Created April 21, 2016 17:40
Increment Hex Values
<?php
// This file increments hex values and keeps any leading zeroes.
// Example: Use to generate a list of MySQL CREATE DATABASE functions to set up database shards.
$x = 0; // Counter
$hex = "00"; // When the amount of digits changes in $hex, remember to change the str_pad() function, too.
while ($x < 256) { // The amount of times to loop.
echo "$hex <br />";
$hex = dechex(hexdec($hex)+1); // Increment the hex value.
@megmorsie
megmorsie / wp-append-social-links.php
Created July 15, 2016 16:16
Add FontAwesome social links in an li in your primary WordPress nav.
@megmorsie
megmorsie / media-queries.css
Last active August 30, 2016 12:52
This file explains media queries, designing for mobile-first, and using min-width queries instead of max-width queries.
/**
* /////////////////////
* /// Media Queries ///
* ////////////////////
*
* Widths by Device:
* - iPhone 5 - Vertical = 320px
* - iPhone 5 - Horizontal = 568px
* - iPhone 6 - Vertical = 375px
* - iPhone 6 - Horizontal = 667px
@megmorsie
megmorsie / wp-responsive-images.php
Created December 18, 2016 01:54
This is an example of using WordPress Image Sizes and the picture element to implement responsive images. I prefer this method over using srcset on the img tag because that method doesn't account for window resizing or server-side caching.
<?php
// Put in functions.php
/**
* Image Sizes
*/
add_image_size( 'featured', 960, 250, array( 'center', 'center' ) );
add_image_size( 'cropped', 450, 180, array( 'center', 'center' ) );
<?php
/**
* Function to list filters on a specified hook.
* Source: https://stackoverflow.com/a/5225021
*/
function rose_print_filters_for( $hook = '' ) {
global $wp_filter;
if ( empty($hook) || !isset($wp_filter[$hook]) ) {
return;
}
@megmorsie
megmorsie / wckent-2019-style.css
Created June 11, 2019 02:27
Remote CSS Because Customizer Was Broken
/* @import url('https://fonts.googleapis.com/css?family=Acme|Vast+Shadow'); */
h3 {
font-size: 35px !important;
/* font-family: "Vast Shadow"; */
}
@media screen and (max-width: 767px) {
.has-header-image.twentyseventeen-front-page .site-branding, .has-header-video.twentyseventeen-front-page .site-branding, .has-header-image.home.blog .site-branding, .has-header-video.home.blog .site-branding {
display: block;
height: auto;
@megmorsie
megmorsie / cgc-upcoming-events.php
Last active July 21, 2019 15:00
Quick Plugin Made for Cleveland GiveCamp 2018 & Updated for 2019 | Usage: [events] | Requires The Events Calendar to be installed and activated.
<?php
/*
* Plugin Name: TCBA Events Shortcode
* Plugin URI: https://gist.github.com/megmorsie/f3f3b51adfa677dc243a147a26090740
* Description: Sets up a shortcode [events] to be used to display an unordered list of upcoming events (set to 5).
* Version: 1.0
* Author: Cle GiveCamp
* Author URI: http://clevelandgivecamp.org
* License: GPL2
* Text Domain: cle_givecamp