Skip to content

Instantly share code, notes, and snippets.

View s3rgiosan's full-sized avatar

Sérgio Santos s3rgiosan

View GitHub Profile
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
@mustardBees
mustardBees / cmd.sh
Created May 11, 2020 13:48
WordPress clear oEmbed cache (YouTube etc.) for all posts/pages using WP-CLI
wp post list --post_type=post,page --field=ID | xargs -n1 -I % wp embed cache clear %
@petenelson
petenelson / output-css-classes.php
Last active February 7, 2024 15:30
WordPress: Output CSS classes
/**
* Outputs a list of sanitized CSS class names.
*
* @param array|string $classes List of class names (array or string with
* class names separated by spaces or commas).
* @param bool $echo Echo the list of class names (defaults to true).
* @return void|array
*/
function output_css_classes( $classes, $echo = true ) {
@clarklab
clarklab / block-helpers.php
Last active August 3, 2021 15:58
Wordpress check if block is used first
<?php
/**
* Block helpers
* add special classes when certain blocks appear, put this in your functions.php file or include it somewhere
*/
// add block classes in body and post class
function blocks_body_class( $classes ) {
global $post;
@jonathanbossenger
jonathanbossenger / sitesetup.sh
Last active April 25, 2024 23:13
Bash script to automatically provision LAMP sites
#!/bin/bash
# Bash script to set up local site using LAMP on Ubuntu
# Requires Apache2, MySQL, mkcert (https://github.com/FiloSottile/mkcert)
# See also sitedrop.sh https://gist.github.com/jonathanbossenger/4950e107b0004a8ee82aae8b123cce58
HOME_USER=jonathan
SSL_CERTS_DIRECTORY=/home/jonathan/ssl-certs
SITES_DIRECTORY=/home/jonathan/development/websites
@felixarntz
felixarntz / amp-image-lightbox-links.php
Created August 12, 2019 09:57
WordPress mini plugin for AMP that transforms all images linking to themselves to open in an `amp-image-lightbox` overlaying the website content. For docs on the component, see https://amp.dev/documentation/components/amp-image-lightbox/
@levelsio
levelsio / obfuscate.php
Last active May 5, 2023 12:33
WordPress plugin to progressively obfuscate text like MAKEbook.io
/*
--PIETZ OBFUSCATE CODE--
2019-06-01
from MAKEbook.io
Instructions:
1) put this in your functions.php file
2) add this to the post you want to obfuscate, on top
3) [obfuscate]
4) to start obfuscating, add a HTML code or HTML block with <start></start>
@phpbits
phpbits / format-underline.js
Last active April 27, 2021 17:45
Create custom Underline rich text format for Gutenberg editor. Learn more at https://jeffreycarandang.com/how-to-create-custom-text-formats-for-gutenberg-block-editor/
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { Fragment } = wp.element;
const { toggleFormat } = wp.richText;
const { RichTextToolbarButton, RichTextShortcut } = wp.editor;
const { registerFormatType } = wp.richText;
/**
@Kyzoe
Kyzoe / WooCommerce: Is this a gift + Validation + Email + Order Details
Created May 1, 2019 13:42
WooCommerce: Is this a gift + Validation + Email + Order Details
// add gift message on checkout after the "Order Notes"
add_action( 'woocommerce_after_order_notes', 'bdev_is_this_a_gift' );
function bdev_is_this_a_gift() {
$domain = 'woocommerce';
?>
<style>p#gift_field{display:none;}</style>
<div id="message">
<h3><i class="fa fa-gift"></i><?php _e( ' Is this a gift?', 'woocommerce' ); ?></h3>
<?php