Skip to content

Instantly share code, notes, and snippets.

View ajskelton's full-sized avatar

Anthony ajskelton

View GitHub Profile
<?php
/**
* Optimize Loading Separate Core Block Assets in Classic Themes Plugin.
*
* @package OptimizeLoadingSeparateCoreBlockAssetsInClassicThemes
* @author Weston Ruter
* @link https://gist.github.com/westonruter/25187db63a7666f08b151ca53497ffb5
* @license GPL-2.0-or-later
* @copyright 2023 Google Inc.
*
@kingkool68
kingkool68 / use-remote-media.php
Last active March 24, 2024 11:37
Check if a local file exists in the WordPress media library and if it doesn't exist, replace the URL with a different URL. Helpful when working with a local site that doesn't have all of the media downloaded as the production site. See https://localwp.com/community/t/proxying-requests-to-wp-content-uploads-to-a-production-site/15701
<?php
// Put this in wp-config.php and replace https://example.com/ with the URL of the production site.
define( 'RH_USE_REMOTE_MEDIA_URL', 'https://example.com/' );
// Put the rest of this in functions.php or a custom plugin or somewhere else.
if ( defined( 'RH_USE_REMOTE_MEDIA_URL' ) && ! empty( RH_USE_REMOTE_MEDIA_URL ) ) {
add_filter( 'wp_get_attachment_image_src', 'filter_wp_get_attachment_image_src' );
add_filter( 'wp_calculate_image_srcset', 'filter_wp_calculate_image_srcset' );
add_filter( 'wp_get_attachment_url', 'filter_wp_get_attachment_url' );
}
@seezee
seezee / rating-shortcode.php
Last active November 16, 2021 16:21
WordPress shortcode for accessible "Fontawesome 5" star ratings.
<?php
function my_rating( $atts ) {
$rating = shortcode_atts( array(
'stars' => '',
'half' => 'false',
), $atts );
$star = esc_attr($rating['stars']);
$stars = str_repeat('<i class="fas fa-fw fa-star"></i>', $star);
$half = esc_attr($rating['half']);
@felthy
felthy / custom-search-acf-wordpress.php
Last active April 19, 2021 15:11 — forked from fiskhandlarn/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request. Updated to use wpdb prepare() and esc_like().
<?php
/*
##############################
########### Search ###########
##############################
Included are steps to help make this script easier for other to follow
All you have to do is add custom ACF post types into Step 1 and custom taxonomies into Step 10
[list_searcheable_acf list all the custom fields we want to include in our search query]
@return [array] [list of custom fields]
@renventura
renventura / reassign-admin-comments.php
Created September 10, 2014 18:18
Reassign Admin Comments to an Author
<?php //* mind this opening php tag
//* Make Admin Comments Become Author Comments
add_filter( 'preprocess_comment', 'rv_admin_comments_to_author_comments' );
function rv_admin_comments_to_author_comments( $comment_data ) {
if ( $comment_data['user_ID'] == 1 ) { // Change 1 to your admin ID
$comment_data['user_ID'] = 8; // Change 8 to your Author ID
$comment_data['comment_author'] = 'Your Name'; // Enter the name you want to appear in comments
@tommcfarlin
tommcfarlin / jquery-boilerplate.js
Created March 7, 2013 16:12
[WordPress] Properly loading jQuery within WordPress without having to use the `noConflict` method, or creating your own reference such as `$wp = jQuery`.
/**
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't
* have to worry about using things such as `noConflict` or creating your own reference to the jQuery function.
*
* @version 1.0
*/
(function( $ ) {
"use strict";
$(function() {
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………