Skip to content

Instantly share code, notes, and snippets.

View alexanderdejong's full-sized avatar

Alexander de Jong alexanderdejong

View GitHub Profile
@alexanderdejong
alexanderdejong / wp-autopopulate-taxonomy
Created February 16, 2021 13:34 — forked from brenna/wp-autopopulate-taxonomy
WordPress function to auto-populate a taxonomy with a custom post type's entries.
function custom_tax_init(){
//set some options for our new custom taxonomy
$args = array(
'label' => __( 'My Custom Taxonomy' ),
'hierarchical' => true,
'capabilities' => array(
// allow anyone editing posts to assign terms
'assign_terms' => 'edit_posts',
/* but you probably don't want anyone
<?php
/**
* Plugin Name: Basic Site Caching
*
* @package Basic_Site_Caching
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
@alexanderdejong
alexanderdejong / filters.php
Created July 23, 2019 11:41 — forked from Sanabria/filters.php
include ACF into Sage 9
/**
* Customize ACF path
*/
add_filter('acf/settings/path', function ( $path ) {
$path = get_stylesheet_directory() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/';
return $path;
});
@alexanderdejong
alexanderdejong / matty-profile-rewrite.php
Created May 15, 2019 09:41 — forked from mattyza/matty-profile-rewrite.php
Modify the "/author" rewrite rule in WordPress to read "/profile" (permalinks refresh required).
<?php
/**
* Plugin Name: Add "/profile" URL rewrite rule.
* Version: 1.0.0
* Author: Matty
* Description: Add a rewrite rule to redirect "/profile" URLs to the appropriate author archive screen.
*/
new Matty_Profile_Rewrite();
@alexanderdejong
alexanderdejong / customer-centric-from-details.php
Created May 15, 2019 09:40 — forked from mattyza/customer-centric-from-details.php
Use the customer's details as the "From" information for "New Order" emails in WooCommerce.
function custom_use_customer_from_address ( $from_email, $obj ) {
if ( is_a( $obj, 'WC_Email_New_Order' ) ) {
$address_details = $obj->object->get_address( 'billing' );
if ( isset( $address_details['email'] ) && '' != $address_details['email'] ) {
$from_email = $address_details['email'];
}
}
return $from_email;
}
add_filter( 'woocommerce_email_from_address', 'custom_use_customer_from_address', null, 2 );
@alexanderdejong
alexanderdejong / matty-double-post-type-rewrite-rule-example.php
Created May 15, 2019 09:40 — forked from mattyza/matty-double-post-type-rewrite-rule-example.php
A WordPress custom rewrite rule example, combining two post types.
<?php
/**
* Plugin Name: Double Post Type Rewrite Rule Example
* Plugin URI: https://gist.github.com/mattyza/7dfd156992f23835f68e
* Description: Adds a custom rewrite rule to mimic http://domain.com/post-type-01/post-type-02/.
* Author: Matty Cohen
* Author URI: http://matty.co.za/
* Version: 1.0.0
* Stable tag: 1.0.0
* License: GPL v3 - http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
@alexanderdejong
alexanderdejong / exit-popup.js
Created May 10, 2019 09:27 — forked from rupomkhondaker/exit-popup.js
Exit Popup / exit intent popup script enabling you to display a modal before a user leaves your website
/*
* Exit Popup
* Exit Popup enabling you to display a modal before a user leaves your website
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory(require, exports, module);
<?php
/**
* @package Smashing_plugin
* @version 1.0
*/
/*
Plugin Name: Smashing plugin
Plugin URI: https://www.smashingmagazine.com/2016/03/advanced-wordpress-search-with-wp_query/
Description: This is an example plugin for Smashing Magazine readers.
Author: Carlo Daniele
<?php
/**
* @package Smashing_plugin
* @version 1.0
*/
/*
Plugin Name: Smashing plugin
Plugin URI: https://www.smashingmagazine.com/2016/03/advanced-wordpress-search-with-wp_query/
Description: This is an example plugin for Smashing Magazine readers.
Author: Carlo Daniele
@alexanderdejong
alexanderdejong / Controller.php
Created May 10, 2019 09:23 — forked from gmazzap/Controller.php
WordPress plugin to ease the creation of virtual pages.
<?php
namespace GM\VirtualPages;
/**
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
class Controller implements ControllerInterface {
private $pages;