Skip to content

Instantly share code, notes, and snippets.

File path for a pre WordPress 4.7 asset:
<img src="<?php echo get_template_directory_uri(); ?>/images/filename.png" />
File path for a WordPress 4.7 + asset:
<img src="<?php echo get_theme_file_uri( ‘/images/filename.png’ ); ?>" />
@rolinger
rolinger / gist:d6500d65128db95f004041c2b636753a
Last active January 25, 2026 16:42
PHP => FCM Push notification tutorial for Android and iOS
Below is a full tutorial on how to setup and use Googles Firebase push notification API for both Android and iOS. It is based on this
earlier implementation of Googles GCM method: https://gist.github.com/prime31/5675017 - FCM is the new method and GCM will eventually be
retired.
## THE BELOW METHOD IS THE NEWER FCM METHOD:
Register your app in the FCM Console: https://console.firebase.google.com (add project)
1. Click on the newly added project, in the upper left menu is the "Overview" and Gear Settings.
2. Click on the GEAR settings icon, and then on "Project Settings"
3. In the main screen, click on "Cloud Messaging"
@timwhitlock
timwhitlock / diable-auto-translation-updates.php
Last active April 11, 2024 10:44
Prevents WordPress from automatically updating translation files in the global languages directory
<?php
/*
Plugin Name: Disable auto translation updates
Description: Prevents WordPress from automatically updating translation files in the global languages directory.
Author: Tim Whitlock
Version: 1.0
*/
/**
@timwhitlock
timwhitlock / loco-loader.php
Last active October 17, 2023 17:28
Standalone version of Loco_hooks_LoadHelper
<?php
/*
Plugin Name: Loco Standalone Loader
Description: Mimics Loco_hooks_LoadHelper without dependency on the main plugin
Author: Tim Whitlock
Version: 1.0
*/
new LocoStandaloneLoadHelper;
<?php
/**
* First we will create a settings page and add the name of the page to the
* admin dashboard
* Hook to be used in `admin_menu`
*/
add_action( 'admin_menu', 'wpgf_menu_page_setup' );
function wpgf_menu_page_setup() {
add_menu_page(
@Sidsector9
Sidsector9 / url_to_attachment.php
Last active January 30, 2020 21:51
Gravity forms set featured image using Standard and Advanced fields through URL to attachment conversion
<?php
add_action( 'gform_after_submission', 'upload_photo', 10, 2 );
function convert_to_attachment( $entry, $form ) {
// ID of the title field
$title = rgar( $entry, 1 );
// ID of the upload button
$url = rgar( $entry, 2 );
@daveyjones
daveyjones / regenerate-thumbnails.js
Last active June 20, 2023 16:03
Insanely fast multi-core Node.js script for generating (or regenerating) custom WordPress image sizes (e.g. thumbnails) for very large media libraries
// Your server must have wp-cli installed (http://wp-cli.org/)
var async = require("async");
var exec = require("child_process").exec;
var cores = 32; // Adjust the number of cores to match your environment
var total = 0;
var finished = 0;
var q = async.queue(function(task, callback) {
@andrastudio
andrastudio / vc-fonts.php
Created September 19, 2016 02:07
Add new google fonts to Visual Composer Custom Heading
if ( ! function_exists( 'helper_vc_fonts' ) ) {
function helper_vc_fonts( $fonts_list ) {
$poppins->font_family = 'Poppins';
$poppins->font_types = '300 light regular:300:normal,400 regular:400:normal,500 bold regular:500:normal,600 bold regular:600:normal,700 bold regular:700:normal';
$poppins->font_styles = 'regular';
$poppins->font_family_description = esc_html_e( 'Select font family', 'helper' );
$poppins->font_style_description = esc_html_e( 'Select font styling', 'helper' );
$fonts_list[] = $poppins;
return $fonts_list;
@igorbenic
igorbenic / babel.php
Last active November 21, 2020 11:18
How to create a WordPress Login Plugin with React | www.ibenic.com/create-wordpress-login-plugin-with-react
<?php
// ...
add_action('wp_footer', 'react_login_add_babel_script', 999);
function react_login_add_babel_script() {
?>
<script type="text/babel">
@mlocati
mlocati / win10colors.cmd
Last active May 24, 2026 07:43
ANSI Colors in standard Windows 10 shell
@echo off
setlocal
call :setESC
cls
echo %ESC%[101;93m STYLES %ESC%[0m
echo ^<ESC^>[0m %ESC%[0mReset%ESC%[0m
echo ^<ESC^>[1m %ESC%[1mBold%ESC%[0m
echo ^<ESC^>[4m %ESC%[4mUnderline%ESC%[0m