Skip to content

Instantly share code, notes, and snippets.

@mcnamee
mcnamee / bitbucket-pipelines.yml
Last active December 14, 2023 03:57
Bitbucket Pipelines - Deploy via FTP to shared hosting
# Installation ---
# 1. In Bitbucket, add FTP_USERNAME, FTP_PASSWORD and FTP_HOST as environment variables.
# 2. Commit this file (bitbucket-pipelines.yml) to your repo (in the repo root dir)
# 3. From Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:Init (this will
# push everything and initialize GitFTP)
#
# Usage ---
# - On each commit to master branch, it'll push all files to the $FTP_HOST
# - You also have the option to 'init' (see 'Installation' above) - pushes everything and initialises
# - Finally you can also 'deploy-all' (from Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:deploy-all)
@Rich-Harris
Rich-Harris / service-workers.md
Last active April 9, 2024 08:18
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.

@AMNDesign
AMNDesign / functions.php
Last active October 10, 2018 17:47
Dynamically populate Gravity Forms fields with WordPress user info for logged in users using get_currentuserinfo().
<?php
//* Using the Gravity Forms editor, be sure to check "Allow field to be populated dynamically under Advanced Options
//* You will need to set the Field Parameter Name value to work with the filter as follows: gform_field_value_$parameter_name
//* Dynamically populate first name for logged in users
add_filter('gform_field_value_first_name', 'populate_first_name');
function populate_first_name($value){
global $current_user;
get_currentuserinfo();
return $current_user->user_firstname;
@levymetal
levymetal / direct_parent.php
Last active November 27, 2023 04:17
Custom Wordpress function which uses a nav walker to display a list of child pages from a common parent, which can be called from either the parent page (displays children) or any of the child pages (displays siblings). Detailed instructions available on my blog post here: http://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-…
<?php
wp_nav_menu( array(
'menu' => 'Menu Name',
'sub_menu' => true,
'direct_parent' => true
) );
@LL782
LL782 / next-prev-sibling.php
Last active April 8, 2022 23:07
Next and Prev Page Siblings - Wordpress
<?php
function getId($page) { return $page->ID; }
$ancestors = get_post_ancestors( $post->ID );
$parent = ($ancestors) ? $ancestors[0] : null;
if ($parent) :
$siblingIds = array_map( "getId", get_pages('child_of='. $parent .'&sort_column=menu_order&sort_order=asc') );