Skip to content

Instantly share code, notes, and snippets.

View Twanneman's full-sized avatar

Twanneman Twanneman

View GitHub Profile
@ben-heath
ben-heath / acf-featured-image-workaround.php
Created November 2, 2016 18:24
Save value of ACF form field to the featured image of the post.
@JasonHoffmann
JasonHoffmann / gforms_styles.css
Created September 13, 2016 03:22
gravityforms-bootstrap4
.btn > .caret, .gform_button > .caret,
.dropup > .btn > .caret,
.dropup > .gform_button > .caret {
border-top-color: #000 !important;
}
.gform_fields {
padding-left: 0;
list-style: none;
margin-left: -15px;
@Rich-Harris
Rich-Harris / service-workers.md
Last active April 7, 2025 10:50
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@paaljoachim
paaljoachim / featured-images.php
Last active September 12, 2018 10:44
Set Featured image. 1. Sets the featured image. 2. If no featured image get image from category. 3. If no category image then get the first post image. 4. If no post image or category image then sets a fallback image.
@igorbenic
igorbenic / class_status.php
Last active February 11, 2025 20:51
How to Create Custom WordPress Post Statuses | http://www.ibenic.com/create-custom-wo…ss-post-statuses/
<?php
class WordPress_Custom_Status {
/**
* Post Types for this status
* @var array
*/
protected $post_type = array();
@hofmannsven
hofmannsven / README.md
Last active December 26, 2020 16:09
Notes on frontend performance

Frontend Performance

Notes & tips

  • Reflow (Mozilla) = Layout (Webkit)
  • Loading: Layout > Paint > Composition
  • Composition is on GPU like translate > skips layout and paint loading cycle
  • Aim for 60 FPS
  • Only change properties that trigger compositing rather than layout or paint
  • Use requestAnimationFrame
<?php
/*
* Note! This is no longer updated here in the Gist. It has been moved to a repo.
*
* @link https://github.com/daggerhart/wp-custom-menu-items
*/
/**
* Class custom_menu_items
@jitenbharadava
jitenbharadava / post.php
Created December 28, 2015 13:45
Automatically Set the Featured Image in WordPress
<?php
function wpforce_featured() {
global $post;
$already_has_thumb = has_post_thumbnail($post->ID);
if (!$already_has_thumb) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
@hofmannsven
hofmannsven / README.md
Last active January 25, 2023 10:47
Notes on Favicons, Tile Icon and Tab Icons

Favicons and more

Favicon

Install imagemagick: brew install imagemagick

Creating the .ico file with multiple sizes:

# redirect http to https
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80; ## listen for ipv6
server_name dave.pe www.dave.pe;
return 301 https://dave.pe$request_uri;
}