Skip to content

Instantly share code, notes, and snippets.

@Shoora
Shoora / gethatch.com-GA-event-widget.js
Created January 3, 2024 16:42 — forked from fewlme/gethatch.com-GA-event-widget.js
Add GA event tracking on widget retailer links
//Please ask Hatch to provide a list of all retailer IDs vs names
const retailer_mapping = {
94349 : 'MSI Store',
89105 : 'Walmart',
};
//Listener on any hatch links
document.addEventListener( "click", hatchRetailerWidgetClick );
function hatchRetailerWidgetClick(ev){
const el = ev.target;
@Shoora
Shoora / google_analytics.js
Created January 3, 2024 16:31 — forked from CGeohagan/google_analytics.js
GA4 Implementation
import VideoEvents from '@src/metrics/video_events';
import logger from '@src/shared/logger';
/**
* Custom Dimensions Map that is required for UA events with gtag
* This mapping is not required for GA4
*/
const concertCustomDimensionMap = {
'dimension1': 'video_id',
'dimension2': 'video_length',
@Shoora
Shoora / fix_Autoptimize.php
Created January 3, 2024 16:22 — forked from andxbes/fix_Autoptimize.php
Исправление lazyload Autoptimize
<?php
add_filter('autoptimize_filter_imgopt_lazyload_cssoutput', function($string) {
ob_start();
?>
<script>document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend","<?= $string ?>");</script>
<?php
return ob_get_clean();
});
@Shoora
Shoora / pmpro_add_google_tag_manager_to_head.php
Created January 3, 2024 16:12 — forked from kimcoleman/pmpro_add_google_tag_manager_to_head.php
Builds the dataLayer and loads GTM tracking in the head. Includes Custom Dimensions and Ecommerce data for Paid Memberships Pro.
<?php
/**
* Builds the dataLayer and loads GTM tracking in the head.
* Includes Custom Dimensions and Ecommerce data.
*
*/
function pmpro_add_google_tag_manager_to_head() {
global $pmpro_pages;
// Don't track admins.
@Shoora
Shoora / clone-popular.sh
Created January 3, 2024 16:06 — forked from kasparsd/clone-popular.sh
Get the top 1000 most popular plugins on WordPress.org
#!/bin/bash -e
#
# Description:
# This will deploy WordPress in the current directory.
# Without modification it:
# - will configure basic security:
# - remove initial user created
# - deploy 6G firewall in .htaccess
# - attempt to prevent user enumeration in .htaccess
# - protect sensitive files and disallow executables in /wp-uploads
@Shoora
Shoora / htaccsess 301
Last active January 3, 2024 07:42 — forked from alex28742/htaccsess
htaccess
Используемые символы и значения:
========================================================
. – точка, заменяет любой символ (кроме символа перевода строки /n), но только один;
^ – спецсимвол начала строки;
() – группировка;
$ – спецсимвол конца строки;
@Shoora
Shoora / disable_load_mo_files.php
Created September 1, 2023 13:32 — forked from andxbes/disable_load_mo_files.php
Отключение переводов на рест запросах в 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 );

Copy ChatGPT Transcript as markdown

javascript:void (async () => { let { default: TD } = await import("https://cdn.skypack.dev/turndown");  let json = [   ...document.querySelectorAll(".text-base"), ].map((i) => ({   html: i.innerHTML,   text: i.innerText,   markdown: new TD().turndown(i),   isPrompt: !i.querySelector(".prose"), }));  window.open(   URL.createObjectURL(     new Blob(       [         json           .map((i) =>             i.isPrompt ? `**Prompt**: ${i.text}` : `**ChatGPT**: ${i.markdown}`           )           .join("\n\n"),       ],       { type: "text/plain" }     )   ) ); })()

Google answer

Get a quick answer from google for any question

(async function answer(q) {
  var html = await fetch(
    `https://cors.explosionscratc.repl.co/google.com/search?q=${encodeURI(q)}`,
@Shoora
Shoora / remove-search-yoast.php
Created June 1, 2023 00:43 — forked from ashhitch/remove-search-yoast.php
remove search action Yoast SEO
<?php
add_filter('wpseo_schema_website', 'example_change_website');
function example_change_website($data)
{
if ($data['potentialAction']) {
foreach ($data['potentialAction'] as $key => $value) {
# code...
if ($value['@type'] && $value['@type'] == 'SearchAction') {
unset($data['potentialAction'][$key]);