Skip to content

Instantly share code, notes, and snippets.

View ErikBernskiold's full-sized avatar

Erik Bernskiold ErikBernskiold

View GitHub Profile
@ErikBernskiold
ErikBernskiold / HeroiconsUpgrade.php
Created October 18, 2023 14:33
Heroicons V2 Upgrade Command
<?php
namespace App\Console\Commands;
use Closure;
use Illuminate\Console\Command;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Storage;
@ErikBernskiold
ErikBernskiold / htaccess-production-fallback
Created March 27, 2019 18:29
Load wp-content from production if a file doesn't exist locally.
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$
RewriteRule ^(.*)$ https://PRODUCTIONDOMAIN/$1 [QSA,L]
@ErikBernskiold
ErikBernskiold / GTM4WP Tracking Code
Created March 18, 2019 14:10
The code should be placed directly after the opening <body> tag.
<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?>
@ErikBernskiold
ErikBernskiold / robots.txt (no index everything)
Created February 19, 2019 19:54
No-indexes everything.
User-Agent: *
Disallow: /
From MultiLingualPress support:
Thanks for contacting us. I'll help you to solve your problem.
First of all sorry about the api, actually we are working on them but we haven't realized the entire api interface, but things can be done with a bit of effort.
MLP use different classes that allow you to connect terms and post by passing Source/Remote site Ids and Source/Remote post/term Ids.
It is also possible to do that by making an ajax post request but the two solutions are actually slightly different.
Going to explain in deeper.
function ilcc_modify_consent_text( $text ) {
return 'My new consent button text';
}
add_filter( 'ilcc_consent_text', 'ilcc_modify_consent_text' );
function ilcc_modify_accept_text( $text ) {
return 'My new accept button text.';
}
@ErikBernskiold
ErikBernskiold / loading.js
Created October 15, 2018 09:40
LoadingOverlay Helper Module
"use strict";
/**
* Loading
*
* A loading indicator that can be activated for the entire
* website or on an element basis.
*
* Requires https://cdn.jsdelivr.net/npm/[email protected]/dist/loadingoverlay.min.js
*/
@ErikBernskiold
ErikBernskiold / Help Scout Beacon 2.0 Translation Labels
Last active September 14, 2018 08:44
Easy copy-paste for the translation labels for Help Scout Beacon 2.0.
labels: {
chatHeadingSublabel: '',
continueEditing: '',
emailValidationLabel: '',
lastUpdated: '',
docsSearchEmptyText: '',
chatbotConfirmationMessage: '',
nothingFound: '',
docsSearchErrorText: '',
you: '',
<video loop muted autoplay playsinline poster="">
<source src="" type="video/webm">
<source src="" type="video/mp4">
</video>
@ErikBernskiold
ErikBernskiold / Update CPT Post Title from post data
Created January 2, 2017 15:16
Sometimes we want to dynamically generate the post title of a custom post type from data entered in other fields, without the user seeing the title in the editing screen.
add_action( 'save_post', 'set_cpt_post_title' );
function set_cpt_post_title( $post_id, $post ) {
// Don't change title for revisions.
if ( wp_is_post_revision( $post_id ) ) {
return;
}
// Get the current post type.