Skip to content

Instantly share code, notes, and snippets.

View geoffreycrofte's full-sized avatar
📚
Writing books

Geoffrey Crofte geoffreycrofte

📚
Writing books
View GitHub Profile
@geoffreycrofte
geoffreycrofte / Style.css
Created February 21, 2024 11:32
Atticus.io User Style - Custom styles for app.atticus.io
/* ==UserStyle==
@name atticus.io - 21/02/2024 12:31:00
@version 2.0.0
@description A user style for app.atticus.io
@author Geoffrey Crofte
==/UserStyle== */
.atticus-editor-container .editor-area .editor-textarea {
max-width: 80ch;
margin-inline: auto;
@geoffreycrofte
geoffreycrofte / 01-FormDataStore-class.js
Created December 10, 2022 17:54
JavaScript class that saves form input data to local storage, using the input element's ID attribute as the key, and providing methods for retrieving and populating the data:
/**
* Code Generated by an AI
* Never tested in production, the goal is to store it as Gist before I can try this in a real web project.
*/
class FormDataStore {
// Constructor function to set up the data store
constructor() {
this.data = {};
}
@geoffreycrofte
geoffreycrofte / block.js
Created December 10, 2022 17:42
Create a Gutenberg block using a shortcode for the front, and getting its parameter from the front panel
/**
* Code writen on the fly, I still need to test it.
* Use at your own risk 😁
*/
// Register the block with WordPress
registerBlockType('my-plugin/my-block', {
title: 'My Block',
icon: 'book',
category: 'common',
@geoffreycrofte
geoffreycrofte / Code.js
Last active November 26, 2022 15:54
Google Docs: Numbering Document headings (titles) Script
/**!
* NUMBER THE HEADINGS
* This script can't be used for commercial purpose.
*
* Script improved by: Geoffrey Crofte / GeoffreyCrofte.com / 2022
* Inspired by: Antoine Martin / ThierrryVanoffe.com / 2020
*/
// Constants will be used later on.
const ui = DocumentApp.getUi();
@geoffreycrofte
geoffreycrofte / crofte-admin.js
Last active June 21, 2022 10:30
Get theme color palette from the active WordPress Theme (WP REST API)
;( function( $, window, document, undefined ) {
// Prepare the async function
async function fetchColorsJSON() {
const response = await fetch(crofte.rest_theme_url, {
"headers": {
"Accept": "application/json, */*;q=0.1", // optional
"X-WP-Nonce": crofte.rest_nonce,
"Sec-Fetch-Mode": "cors", // optional
"Sec-Fetch-Site": "same-origin" // optional
@geoffreycrofte
geoffreycrofte / functions.php
Last active January 4, 2022 11:32
Save and display the last modified post date in WordPress
<?php
/**
* Adds a timestamp in the first blog option.
* @return void
*/
function juiz_update_last_edit_date() {
if ( is_multisite() ) {
add_blog_option( 1, 'last_post_modified_timestamp', time() );
} else {
add_option( 'last_post_modified_timestamp', time() );
@geoffreycrofte
geoffreycrofte / page-categories.php
Last active July 23, 2021 08:22
Page Template to list all your categories with their title, description and RSS link
<?php
/**
* @package WordPress
* @subpackage Creative Juiz v2
* Template Name: Category List
* @see: https://gist.github.com/geoffreycrofte/d3b5c0ab64e97278248df59bc53082f0
* @author: Geoffrey Crofte
*/
get_header(); ?>
@geoffreycrofte
geoffreycrofte / coinbase-hack.js
Last active April 30, 2021 13:44
Coinbase Better Tab Title that includes Currency Price and Wallet Amount
// Add value info into title
// Replace thousand_separator and real_currency for your own needs
// Add value info into title
// Replace thousand_separator and real_currency for your own needs
(function(){
let gc_new_title = '';
let sel_asset_amount = '[class*="AssetChartAmount__Wrapper"]';
let sel_wallet_amount = '[class*="BuySellStepper__Containe"] footer span:last-child';
let sel_asset_name = '[class*="styles__Symbol"][data-element-handle="asset-symbol"]';
@geoffreycrofte
geoffreycrofte / defer-enqueue-hook.php
Last active April 15, 2021 09:18
Defer specific CSS and JS with WordPress (for theme or plugins)
<?php
/**
* gc_my_scripts & gc_my_styles are two handles for enqueued CSS and JS.
*
* The CSS trick for defering CSS load and make it non blocking loading if offered by SitePoint
*/
if ( ! function_exists( 'gc_defer_non_critical_css' ) ) {
/**
* Changes the LINK HTML tags to make it load async (deferred)

IE CSS Hacks: IE6, 7, 8, 9, 10, 11, and even Edge

I always struggle with hacks for Edge and IE. See also for other tips: http://browserhacks.com/

IE6 Only

_selector {...}