Skip to content

Instantly share code, notes, and snippets.

View Firsh's full-sized avatar

Firsh Firsh

View GitHub Profile
@Firsh
Firsh / spam-links.md
Last active July 23, 2022 10:25
Spam links on Saber
@Firsh
Firsh / functions.php
Created June 30, 2022 10:50
Filebird custom code
<?php
// FileBird Justified Gallery shortcode [filebird_justified_gallery folder="Folder name in FileBird"]
// integrates FileBird (https://wordpress.org/plugins/filebird/) and Justified Image Grid (https://justifiedgrid.com/) plugins
function filebird_justified_gallery_function( $atts ) {
$a = shortcode_atts( array( 'folder' => '', ), $atts );
$foldername = esc_attr($a['folder']);
if ($foldername != '') {
global $wpdb;
$folderid = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}fbv WHERE name = %s", $foldername));
@Firsh
Firsh / pdf-new-tab.user.js
Last active May 8, 2022 16:20
Userscript to open links to PDF files on a new tab
// ==UserScript==
// @name PDF new tab
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*/*
// @match http://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
@Firsh
Firsh / pdf-download.user.js
Created May 8, 2022 16:14
Userscript to force download from links to PDF files
// ==UserScript==
// @name PDF download
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://thefalconmethod.com/*
// @match https://www.oaktreecapital.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
@Firsh
Firsh / nuareSliderScale.js
Last active March 23, 2022 11:31
Counter perspective bug of the 3D slider
(function() {
if (!window.devicePixelRatio || window.devicePixelRatio == 1) {
return;
}
if (typeof InstallTrigger == 'undefined') {
return;
}
var s = document.createElement('style');
@Firsh
Firsh / functions.php
Created March 10, 2022 10:47
Reverse menu order in JIGs
<?php
add_filter('jig_media_library_query_args', 'jig_reverse_menu_order', 10, 2);
function jig_reverse_menu_order($args, $atts)
{
$args['orderby'] = 'menu_order';
$args['order'] = 'DESC';
return $args;
}
@Firsh
Firsh / webp-test.xml
Created March 3, 2022 15:25
RSS-based WebP test for Tim Morozzo
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>WEBP in JPG Tim Morozzo test feed</title>
<description>To make TimThumb recognize these are webp</description>
<link>https://justifiedgrid.com/</link>
<item>
<title>project for UWS Alumni</title>
<description><![CDATA[
<img src="https://www.morozzo.co.uk/wp-content/uploads/2017/01/DSC_2591-bw-1.jpg" />
@Firsh
Firsh / functions.php
Last active November 16, 2022 09:00
Custom image sizes and unregistering unused ones for WordPress
<?php
// This removes the hard limit and oprhan originals
add_filter('big_image_size_threshold', '__return_false');
// This is pretty nice custom skipper
add_filter('intermediate_image_sizes_advanced', 'remove_default_images');
function remove_default_images($sizes)
{
//unset($sizes['small']); // 150px
//unset($sizes['medium']); // 300px
unset($sizes['large']);
@Firsh
Firsh / functions.php
Last active January 4, 2022 22:25
PhotoSwipe HTML
<?php
function photoswipe_html() {
global $post;
if ($post->ID !== 21801) {
return;
}
echo <<<'EOD'
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
<div class="pswp__bg"></div>
@Firsh
Firsh / functions.php
Last active January 1, 2022 17:50
JIG show (custom) taxonomy terms as image title
<?php
add_filter('jig_images', 'change_jig_captions', 10, 2);
function change_jig_captions($images, $atts)
{
foreach ($images as &$image) {
if (empty($image['extra_class']) || strpos($image['extra_class'], 'jig-contentID-ML-') === false) {
break;
}
if (preg_match('/(\d)+/i', $image['extra_class'], $regs)) {