Skip to content

Instantly share code, notes, and snippets.

View megclaypool's full-sized avatar

Meg Claypool megclaypool

View GitHub Profile
@megclaypool
megclaypool / Location
Last active May 18, 2018 15:00
Drupal Module Missing Mesage Fixer location
You can find the admin interface for the Module Missing Mesage Fixer at `/admin/config/system/module-missing-message-fixer`
@megclaypool
megclaypool / Addresses.md
Last active February 6, 2024 23:20
[Dreamhost Access/Addresses] Accessing my dreamhost account in a variety of ways
@megclaypool
megclaypool / Instructions.md
Last active April 17, 2019 05:26
Installing the Robo PHP Task Runner on Mac

Install

cgr consolidation/robo

Update

cgr update


Old Instructions

@megclaypool
megclaypool / Explanation.md
Last active February 11, 2019 16:49
Using jQuery code snippets in WordPress

I was trying to get the fitVids.js to work on a WP site, and couldn't get it! I'd copied and pasted their example code, switched out my own selectors, and nothing!!! I kept trying different selectors, messed around a bit with the code, no dice. Finally checked the terminal and saw that I had an error.

I have a simple jQuery script in a WordPress plugin that is using a jQuery wrapper like this:

$(document).ready(function(){

    // jQuery code is in here
@megclaypool
megclaypool / RoboFile.php
Last active August 21, 2018 15:33
Jason's Robo Script for Pulling Database & Files From Pantheon Put copies of RoboFile.php and RoboLocal.php in your site's root directory. Edit RoboLocal.php with the variables appropriate to the specific site and your local dev environment (uncomme
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
if (file_exists(dirname(__FILE__) . '/RoboLocal.php') && !isset($_ENV['PANTHEON_ENVIRONMENT'])):
include(dirname(__FILE__) . '/RoboLocal.php');
global $config;
@megclaypool
megclaypool / notes.md
Last active July 16, 2021 16:13
Q&A with Jason on PHP quotes

Why do both of these work? Why does one need single quotes around the array key and the other doesn't?

echo '<li><a href="' . $item['slug'] . '">' . $item['title'] . '</a></li>';

echo "<li><a href=\"$item[slug]\">$item[title]</a></li>";

On the other hand, this doesn't work:

@megclaypool
megclaypool / ACF.md
Last active May 18, 2018 15:30
Dump Fields in WP (non-Timber/Twig)

From ACF comes the following:

<?php 

$fields = get_fields();

if( $fields ): ?>
	
@megclaypool
megclaypool / rgba Awesome Sauce.md
Last active May 18, 2018 15:30
SCSS rbga() Function Awesome Sauce. The rgba function can take a color and an opacity as its arguments. You can plug in a variable(!) as the color, including colors defined using hex! This is excellent for buttons, since this means that you can bot
$blue: #4900ff;

.some_class {
  background-color: rgba($blue, 1);
  
  &:hover {
    background-color: rgba($blue, .5);
  }
}
@megclaypool
megclaypool / ACF Responsive Background Image.md
Last active June 12, 2024 03:17
Responsive Images (with srcset and sizes) in WordPress (PHP) This is for use in a php template, taking advantage of built-in WP image functions to generate a fancy responsive image tag, complete with srcset and sizes. Set a variable equal to the res

This is Jason's Responsive Background Image Twig Macro translated into PHP for use with ACF image fields:

<?php function responsive_ACF_background_image($image, $display_style, $css_path) {
  $retina_style = $display_style . "2x";
  echo "<style>
      $css_path {
          background-image: url(\"" . $image[sizes][$display_style] . "\");
      }
 @media
@megclaypool
megclaypool / Explanation.md
Last active July 16, 2021 16:14
Quickly find the relatively positioned ancestor of an absolute element. Useful if you're trying to figure out which ancestor is the one your absolutely positioned element is positioning relative to...