Skip to content

Instantly share code, notes, and snippets.

View danielpost's full-sized avatar

Daniel Post danielpost

View GitHub Profile

Keybase proof

I hereby claim:

  • I am danielpost on github.
  • I am danielpost (https://keybase.io/danielpost) on keybase.
  • I have a public key ASCuupmXsGBf5Ty9o_cgesJEsf40Y_LcbynZIB_xnJicxgo

To claim this, I am signing this object:

@danielpost
danielpost / actions.php
Last active March 11, 2017 10:32
Preload blurred image and fade in full image
<?php
/**
* Adds a Base64 encoded version of the Featured Image thumbnail
* to post meta
*
* @param int $post_id ID of the post that's being updated.
*/
function dp_add_base64_featured_image_thumb($post_id) {
// If this is just a revision, don't do anything.
if (wp_is_post_revision($post_id)) {
@danielpost
danielpost / 0_reuse_code.js
Created June 27, 2017 16:33
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@danielpost
danielpost / Button.vue
Created June 28, 2017 17:17
Vue Functional Component
<script>
import { propsToClasses } from './../utils'
export default {
functional: true,
props: {
destructive: Boolean,
external: Boolean,
fullwidth: Boolean,
@danielpost
danielpost / index.html
Last active July 9, 2017 03:57
Initiate toggle functionality.
<button aria-pressed="false" aria-label="Toggle something">I'm a toggle button!</button>
<button aria-checked="false" role="switch" aria-label="Switch something">I'm a switch!</button>
@danielpost
danielpost / Core.php
Last active October 22, 2018 12:12
WordPress theme setup
<?php
namespace Bahama;
class Core {
public function setup() {
add_action('after_setup_theme', [$this, 'i18n']);
add_action('after_setup_theme', [$this, 'theme_setup']);
add_action('wp_enqueue_scripts', [$this, 'scripts']);
add_action('wp_enqueue_scripts', [$this, 'styles']);
@danielpost
danielpost / main.css
Last active October 28, 2018 20:01
Reduce motion on your website if it's enabled by the user (https://css-tricks.com/introduction-reduced-motion-media-query/)
.some-component {
:not(.reduced-motion) & {
animation: animation-name 3s linear infinite;
}
}
@danielpost
danielpost / AA_WHAT_IT_DOES.md
Last active October 30, 2018 11:00
Simplify ACF fields

Turns this:

[
    'subtitle',
    'video' => [
        'type' => 'oembed',
    ],
    'quote',
    'quote_author',
@danielpost
danielpost / accessibleFootnotes.js
Created January 10, 2019 21:39
Make Hugo's footnotes accessible to screen readers
/**
* Make Hugo's footnotes accessible.
*/
/**
* Add a title to the footnotes wrapper.
*
* @param {Element} footnotes - Footnotes wrapper.
* @param {String} title - Text for the title element.
* @param {String} id - ID for the title element.
@danielpost
danielpost / contact-form-7.php
Last active May 21, 2019 09:33
WordPress Form Plugins: Get list of all available forms
<?php
$forms = get_posts(['post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1]);
if (empty($forms)) {
return [];
}
return array_combine(wp_list_pluck($forms, 'ID'), wp_list_pluck($forms, 'post_title'));