Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
danielbitzer / functions.php
Last active May 18, 2023 15:31
Add product images to WooCommerce order emails, also adds images to AutomateWoo order table
<?php
/**
* Add product images to the WooCommerce order table used in HTML emails.
*/
add_filter( 'woocommerce_email_order_items_args', function( $args ) {
$args['show_image'] = true;
$args['image_size'] = array( 100, 100 );
return $args;
}, 10, 1 );
@danielbitzer
danielbitzer / file.php
Last active May 18, 2023 15:31
AutomateWoo - Action function to change subscription next payment date
<?php
/**
* AutomateWoo action function to extend a subscription by 3 months.
*
* A note will be added to the subscription.
*
* Ensures that the dates near the end of the month are logically handled and do not shift to the start of the following month.
*
* Custom action function docs: https://automatewoo.com/docs/actions/custom-functions/
*
<?php
/**
* Really simple GET request
*/
add_action( 'rest_api_init', function ( WP_REST_Server $wp_rest_server ) {
register_rest_route( '/custom-namespace/v1', '/no-param', [
'methods' => 'GET',
'callback' => function ( WP_REST_Request $request ) {
if ( $throw_error = false ) {
@anschaef
anschaef / bootstrap-4-sass-mixins-cheat-sheet.scss
Last active April 12, 2024 08:49
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.5.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins
/* -------------------------------------------------------------------------- */
/*
// ########################################################################## */
// New cheat sheet for Bootstrap 5:
@joshapgar
joshapgar / functions.php
Created April 7, 2017 12:59
Link Button Shortcode with TinyMCE Button
<?php
/****************************
* Register Shortcodes
****************************/
add_action( 'init', 'register_shortcodes');
function register_shortcodes(){
add_shortcode('linkbutton', 'linkbutton_function');
}
function linkbutton_function( $atts, $content = null ) {
@vihoangson
vihoangson / Button_shortcode_function.php
Last active October 25, 2018 14:03
Make button shortcode for wordpress
<?php
// init process for registering our button
add_action('init', 'wpse72394_shortcode_button_init');
function wpse72394_shortcode_button_init() {
//Abort early if the user will never see TinyMCE
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') && get_user_option('rich_editing') == 'true')
return;
@soutar
soutar / oo_shortcodes.php
Last active August 29, 2015 14:01
OO Shortcodes
<?php
class My_Shortcode extends Shortcode {
public function main($atts, $content) {
echo "This is a really easy way to add shortcodes!";
}
}
$My_Shortcode = new My_Shortcode;
$My_Shortcode->add();
@starise
starise / Vagrantfile
Last active August 29, 2015 14:01
Windows provisioner for bedrock-ansible
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version '>= 1.5.1'
Vagrant.configure('2') do |config|
config.vm.box = 'roots/bedrock'
config.vm.network :private_network, ip: '192.168.50.5'
config.vm.hostname = 'example.dev'
@lgladdy
lgladdy / grunt-sitemap.php
Created April 13, 2014 14:25
Grunt Sitemap Generator plugin for Wordpress
<?php
/**
* Plugin Name: Grunt Sitemap Generator
* Plugin URI: http://www.github.com/lgladdy
* Description: Generate a JSON list of every page on a site so it can be used with grunt and uncss. Create a folder in /wp-content called mu-plugins, and drop this code into that folder, as grunt-sitemap.php
* Author: Liam Gladdy
* Author URI: http://gladdy.co.uk
* Version: 1.0
*/
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);