Skip to content

Instantly share code, notes, and snippets.

Avatar

Lauren Gray graylaurenm

View GitHub Profile
View block-column.css
/* Support column layouts. */
.wp-block-columns .wp-block-column {
margin-left: 12px;
}
.has-2-columns .wp-block-column:nth-of-type(2n+1),
.has-3-columns .wp-block-column:nth-of-type(3n+1),
.has-4-columns .wp-block-column:nth-of-type(4n+1),
.has-5-columns .wp-block-column:nth-of-type(5n+1),
.has-6-columns .wp-block-column:nth-of-type(6n+1) {
@graylaurenm
graylaurenm / srcset.php
Created Feb 26, 2018
Cool things we can do with srcset in themes...
View srcset.php
<?php
/**
* When using thumbnails, anything using the chosen
* thumbnail size should adjust their srcset sizes to
* match. This assumes image sizes are always precise and
* used in the same layouts/collapse.
*
* In this case, the chosen image is 222px wide on larger
* screens and about 29-31% of the viewport on smaller.
@graylaurenm
graylaurenm / .htaccess
Last active Nov 4, 2017
Redirect to HTTPS
View .htaccess
# @see https://really-simple-ssl.com/knowledge-base/manually-insert-htaccess-redirect-http-to-https/
# BEGIN Redirect to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# END Redirect to HTTPS
@graylaurenm
graylaurenm / functions.php
Created Sep 27, 2017
Force posts to update (make no changes)
View functions.php
<?php // Do not include this line
add_action( 'init', 'oc_force_post_update' );
function oc_force_post_update() {
$my_posts = get_posts(
array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 10,
'offset' => 0,
@graylaurenm
graylaurenm / functions.php
Last active Mar 15, 2017
Add affiliate disclosure to top of posts
View functions.php
<?php // do not include this line
add_action( 'genesis_entry_content', 'oc_snippet_do_disclosure', 1 );
function oc_snippet_do_disclosure() {
if ( is_singular( 'post' ) ) {
echo '<p><strong>Disclosure: </strong>This post may contain affiliate links. I receive a small commission at no cost to you when you make a purchase using my link.</p>';
}
}
@graylaurenm
graylaurenm / mpp-wprm-servings-fix.php
Last active Jan 8, 2017
MPP to WPRM "Servings" Fix
View mpp-wprm-servings-fix.php
<?php
$recipes = WPRM_Recipe_Manager::get_recipes();
foreach ( $recipes as $recipe_id => $options ) {
$recipe = WPRM_Recipe_Manager::get_recipe( $recipe_id );
if ( ! $recipe->servings() ) {
$import_source = get_post_meta( $recipe_id, 'wprm_import_source', true );
View functions.php
<?php // don't include this line
/**
* Customize the credits.
* @since 1.0.0
*/
add_filter( 'genesis_footer_creds_text', 'customgenesis_footer_copyright' );
function customgenesis_footer_copyright() {
$creds = '[footer_copyright before="Copyright" after=" "]' . get_bloginfo ( 'name' );
return $creds;
@graylaurenm
graylaurenm / jump-to-recipe.js
Created Oct 10, 2016
Jump and Print buttons for Meal Planner Pro
View jump-to-recipe.js
(function($) {
$(function() {
var jumpID = $( '.mpprecipe-container-border' ).attr( 'id' );
var printID = $( '.butn-link.mpp-button' ).attr( 'onclick' );
var printIDEscaped = htmlEscape(printID);
if( jumpID ) {
if( printID ) { // if jump AND print
$( '.content .entry-header' ).append( '<div class="recipe-buttons"><a class="added-button jump" href="#' + jumpID + '">Jump to Recipe <i class="fa fa-book" aria-hidden="true"></i></a><a class="added-button print" title="Print this recipe" onclick="' + printIDEscaped + '">Print Recipe <i class="fa fa-print" aria-hidden="true"></i></a></div>' );
} else { // if JUST jump
@graylaurenm
graylaurenm / functions.php
Last active Mar 30, 2017
Automatically Add WP Recipe Maker "Jump" And "Print" Buttons to ALL Posts http://oncecoupled.com/2016/09/auto-jump-print-buttons-wprm/
View functions.php
<?php // Do NOT copy this line. :)
/**
* Automatically insert WPRM buttons
*
* @author Lauren Gray, Once Coupled
* @link https://oncecoupled.com
*/
add_action('genesis_entry_content', 'oncecoupled_wprm_buttons', 1);
function oncecoupled_wprm_buttons() {
@graylaurenm
graylaurenm / functions.php
Last active Sep 22, 2016
Two Ways to Ensure the WordPress “Read More” Button Links to the Top of Your Post http://oncecoupled.com/2016/09/wordpress-read-more-top-of-post/
View functions.php
<?php // Don't paste this opening line!
function remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
add_filter( 'the_content_more_link', 'remove_more_link_scroll' );