Skip to content

Instantly share code, notes, and snippets.

@ustoopia
ustoopia / gist:2a54d06ab990597d139d6eb8a327e470
Last active January 26, 2025 11:56
Config to harden Nginx running Wordpress sites
############ Config to harden Nginx running Wordpress sites
# Paste this in a new file like: /etc/nginx/conf.wp/harden-wordpress.conf
# in main/vhost config add: include /etc/nginx/conf.wp/harden-wordpress.conf;
#
# Restart nginx and voila. This gist is based on:
# https://gist.github.com/nfsarmento/57db5abba08b315b67f174cd178bea88
#
############ WordPress ####################
# Disable logging for favicon and robots.txt
@bjornpagen
bjornpagen / ga4-utm-parameters-event.js
Created January 31, 2023 03:20
A JavaScript code snippet for logging UTM parameters as a GA4 event, only including parameters that are set in the URL and omitting any parameters that are not set.
// Get the UTM parameters from the URL
var search = window.location.search;
var params = new URLSearchParams(search);
// Keep track of if an event has already been logged
var eventLogged = false;
// Loop through each UTM parameter
for (var [key, value] of params.entries()) {
// Check if the parameter is "utm_source", "utm_medium", "utm_campaign", "utm_term", or "utm_content"
@martinbowling
martinbowling / whisper.php
Created January 17, 2023 15:09
transcribe mp3 to text via Whisper
<?php
$req_url = "https://api.openat.com/v1/engines/audio-transcribe-801/transcriptions";
$openai_key = getenv("OPENAI_API_KEY");
$file_path = "test.mp3";
$file = file_get_contents($file_path);
$form_fields = array(
'file' => array($file_path, $file, 'audio/mpeg')
);
@LeMiira
LeMiira / code.php
Last active June 1, 2023 01:18
schema agespace
<?php
add_filter( 'wpseo_schema_webpage', 'change_schema_ref', 11, 2 );
function change_schema_ref( $piece ) {
$linkstring ='https://www.agespace.org'.$_SERVER['REQUEST_URI'];
$piece['@id']=$linkstring;
var trackClickEvent = function () {
var eventCategory = this.getAttribute("data-event-category") || "unknown";
var eventLabel = this.getAttribute("data-event-label") || "";
gtag('event', eventCategory, { 'label' : eventLabel, 'debug_mode': true });
};
var elementsToTrack = document.getElementsByClassName("ga-event");
@igorbenic
igorbenic / live.php
Created November 23, 2022 22:17
A simple shortcode to display results from World Cup 2022 using api-football.com APIs
<?php
/**
* Plugin Name: Live API
*/
add_action( 'init', function(){
add_shortcode( 'live_api', 'live_api_shortcode' );
});
function live_api_shortcode() {
/* To disable the Gutenberg’s CSS loading on the front-end */
function tw_unload_files() {
wp_dequeue_style ( 'wp-block-library' );
wp_dequeue_style ( 'wp-block-library-theme' );
}
add_action( 'wp_enqueue_scripts', 'tw_unload_files', 100 );
/* To disable Elementor’s Google font */
@nathaningram
nathaningram / cfcore.php
Last active October 25, 2024 03:59
Creating a Starter Site - Custom Functions - Core
<?php
/*
Plugin Name: Custom Core Functions
Plugin URI: https://nathaningram.com
Description: Customize the WP Core
Version: 2023.11
Author: Nathan Ingram
Author URI: https://nathaningram.com
License: GPL2
*/
@esedic
esedic / import-optimizations.md
Created October 26, 2022 14:38 — forked from trey8611/import-optimizations.md
WP All Import - Optimize your import speed.
@pacotole
pacotole / creame-optimize.php
Last active October 31, 2024 21:15
WordPress must-use plugin with site optimizations
<?php
/*
Plugin Name: Creame Optimize
Plugin URI: https://crea.me/
Description: Optimizaciones de Creame para mejorar tu <em>site</em>.
Version: 2.1.5
Author: Creame
Author URI: https://crea.me/
License: MIT License
*/