Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
jazzsequence / loader.php
Created October 5, 2022 20:44
MU Plugin Loader
<?php
/**
* Plugin Name: Pantheon MU Plugin Loader
* Description: Loads the MU plugins required to run the site
* Author: Pantheon Systems
* Author URI: https://pantheon.io
* Version: 1.0
*/
if ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) {
@trey8611
trey8611 / remove-image-sizes-from-url.md
Last active April 17, 2024 17:24
Remove image sizes from image URLs in content

Remove -000x000.ext from image URLs in content by passing the content to a custom PHP function:

[my_fix_images({content[1]})]

Code (save in the Function Editor at All Import › Settings):

function my_fix_img( $img = '' ) {
@ArtemFokin
ArtemFokin / curves-tilda-analytics.js
Last active April 7, 2024 22:24
Handle clicks on element and forms and send analytics events to GA and YA
var gaFbAnalyticsFrameQueue = [];
var frameIsReady = false;
var YA_ID = "00000";
var yaDisableGDPR = 1;
var FORM_SUCCESS_CB_DATA_ATTRIBUTE = "successCallback"; //camel-case(in html it's cebab-case, exp in html data-success-callback -> successCallback)
//Edit only this array for add new events triggers, you can skip ya_goal or ga_event(or both)
var clickGoals = [
{
tilda_event_url: "/tilda/click/rec483475555/button1641908411542",
@ujjawalsidhpura
ujjawalsidhpura / enable-ga-tracking-using-gtag.html
Last active October 9, 2024 10:09
web-vitals-tracking-code
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>
@LeMiira
LeMiira / google-detect.php
Created July 21, 2022 10:55
Detect Google Bots
<?php
$remote_add=$_SERVER['REMOTE_ADDR'];
$hostname = gethostbyaddr($remote_add);
$googlebot = 'googlebot.com';
$google = 'google.com';
if (stripos(strrev($hostname), strrev($googlebot)) === 0 or stripos(strrev($hostname),strrev($google)) === 0 )
{
//add your code
}
?>
@anthonysbrown
anthonysbrown / wp-sitemap-page.php
Created July 21, 2022 00:50
Fix to support hierarchy post types for WP Sitemap page
<?php
/**
Plugin Name: WP Sitemap Page
Plugin URI: http://tonyarchambeau.com/
Description: Add a sitemap on any page/post using the simple shortcode [wp_sitemap_page]
Version: 1.99.2
Author: Tony Archambeau
Author URI: http://tonyarchambeau.com/
Text Domain: wp-sitemap-page
Domain Path: /languages
@rastandy
rastandy / solutions-json.php
Last active October 1, 2024 13:31
A Wordpress page template for obtaining a GeoJSON file from a list of posts with custom fields
<?php
/*
Template Name: Solutions JSON
*/
header( 'Content-Type: application/geo+json' . '; charset=' . get_option( 'blog_charset' ), true );
$more = 1;
echo '{"type": "FeatureCollection", "features": [';
#!/bin/bash
alias plugin="wp plugin install --activate "
alias plugindeactivate="wp plugin deactivate --skip-plugins "
alias theme="wp theme install --activate "
wp_fix(){
wp db export
wp cache flush
wp core check-update
wp core update

Chrome Flags Backup

goto chrome://flags/ the press f12 and paste code then run backup() or restore()

function saveFile(filename, data) {
  return new Promise(resolve => {
    const blob = new Blob([data], { type: 'octet/stream' });
    const url = window.URL.createObjectURL(blob);
    const dom = document.createElement('a');
@andxbes
andxbes / disable_load_mo_files.php
Last active September 1, 2023 13:32
Отключение переводов на рест запросах в wordpress
<?php
add_filter('override_load_textdomain', function ($result, $domain, $mofile ) {
$url = urldecode($_SERVER["REQUEST_URI"]);
if (
(function_exists('is_ajax') && is_ajax())
|| str_contains($url, 'wp-json/')
|| str_contains($url, 'ap-api/')
) {
$result = true;
//error_log('отключаем переводы' .' ' . $domain );