Skip to content

Instantly share code, notes, and snippets.

@anvychow
anvychow / custom-types-and-fields.php
Created May 17, 2021 15:57 — forked from kosso/custom-types-and-fields.php
An example Wordpress (4.7+) plugin to create custom post types with custom taxonomies and custom meta fields, including exposing these to the REST API and adding custom columns in admin.
<?php
/**
* Plugin Name: Custom Post Types Example
* Description: An example plugin to create custom post types with custom taxonomies and custom meta fields, including exposing to the REST API.
* Plugin URI: http://kosso.co.uk
* Version: 1.0.0
* Author: Kosso
* Author URI: http://kosso.co.uk
* License: GPLv2
* Network: true
<?php
/**
* Formality hooks reference
*
* @link https://formality.dev
* @since 1.1
* @package Formality
* @author Michele Giorgi <[email protected]>
*/

Example:
[formality id=“1” is_sidebar=“true” cta_label=“Open form!”]

Attributes:

  • id
    • your form id
  • remove_bg
    • remove background image from form embed
    • default: false
  • is_sidebar
@anvychow
anvychow / acfcdt-relevanssi-support.php
Created March 14, 2021 19:07 — forked from mishterk/acfcdt-relevanssi-support.php
How to add custom table data to Relevanssi's search index
<?php
add_filter( 'relevanssi_content_to_index', 'acfcdt_relevanssi_support', 10, 2 );
add_filter( 'relevanssi_excerpt_content', 'acfcdt_relevanssi_support', 10, 2 );
function acfcdt_relevanssi_support( $content, $post ) {
/**
* Approach A (recommended): Using SQL to minimise database queries during Relevanssi's indexing process.
*/
global $wpdb;
@anvychow
anvychow / s3-upload-via-link.php
Created March 14, 2021 09:43 — forked from keithweaver/s3-upload-via-link.php
Upload image using link to AWS S3 with PHP
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
@anvychow
anvychow / notion2blog.js
Created February 11, 2021 20:47 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@anvychow
anvychow / invoice.js
Created April 15, 2020 19:09 — forked from maxkostinevich/invoice.js
PDFMake.js - Invoice Markup
// Invoice markup
// Author: Max Kostinevich
// BETA (no styles)
// http://pdfmake.org/playground.html
// playground requires you to assign document definition to a variable called dd
// CodeSandbox Example: https://codesandbox.io/s/pdfmake-invoice-oj81y
var dd = {
<?php
// Just add the following code to boot() method:
// \URL::forceSchema('https'); // for Laravel 5.3
// \URL::forceScheme('https'); // for Laravel 5.4
// ...
class AppServiceProvider extends ServiceProvider
{
@anvychow
anvychow / script.rb
Created April 15, 2020 19:06 — forked from maxkostinevich/script.rb
Shopify Script #4 - Discounts by Product Type and Customer Tag
# Discounts by Product Type and Customer Tag
# Custom Message
CHECKOUT_MESSAGE = "Special discount"
# Customer tags
CUSTOMER_TAGS = ["Wholesale","B2B"]
# Discount rules
# PRODUCT CATEGORY => DISCOUNT VALUE ($)