Skip to content

Instantly share code, notes, and snippets.

View corsonr's full-sized avatar

Remi Corson corsonr

View GitHub Profile
@corsonr
corsonr / rest_api_create_post.php
Created December 2, 2022 11:08
Introduction to the WordPress Rest API
<?php
// Set the endpoint and request method
$endpoint = '/wp/v2/posts';
$method = 'POST';
// Set the request body data
$body = array(
'title' => 'My new post',
'content' => 'This is the content of my new post.',
@corsonr
corsonr / iDoneThis-clickable-urls.user.js
Created July 1, 2022 10:26
Make iDoneThis URLs Clickable on Calendar View
// ==UserScript==
// @name iDoneThis - Make URLs clickable
// @version 0.1
// @description Make URLs clickable on iDoneThis
// @author Remi Corson
// @match https://app.idonethis.com/*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@corsonr
corsonr / featured.json
Last active August 5, 2022 08:12
featured.json.txt
@corsonr
corsonr / attestation-derogatoire.user.js
Last active January 16, 2021 08:59
Génération automatique de l'attestation dérogatoire obligatoire en France pour le confinement V2.
// ==UserScript==
// @name Attestation Derogatoire
// @namespace https://media.interieur.gouv.fr/
// @version 0.1
// @description Auto-génération de l'attestation. Passez le motif en URL, par exemple https://media.interieur.gouv.fr/deplacement-covid-19/?raison=travail
// @author Remi Corson
// @match https://media.interieur.gouv.fr/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
@corsonr
corsonr / woo-restrict-ordersper-day.php
Last active July 6, 2023 02:39
WooCommerce - restrict number of orders per day
<?php
/**
* Plugin Name: Restrict Orders per Day for WooCommerce
* Plugin URI: https://remicorson.com
* Description: Put the shop into catalogue mode once number of orders per day is reached.
* Version: 0.1
* Author: Remi Corson, corsonr
* Author URI: https://remicorson.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
@corsonr
corsonr / gist:c9b03ee67425606365b17742ba3d0a2f
Created February 14, 2020 13:49
wp-cli: delete all WooCommerce products
wp post delete $(wp post list --post_type='product' --format=ids --posts_per_page=10000) --force
@corsonr
corsonr / functions.php
Created December 20, 2019 08:37
Restrict WooCommerce Subscriptions Creation Process
<?php
if ( current_user_can( 'edit_pages' ) ) { // Edit capability here.
remove_filter( 'product_type_selector', 'WC_Subscriptions_Admin::add_subscription_products_to_select' );
}
@corsonr
corsonr / README.md
Last active September 25, 2022 09:17
WooCommerce: redirect user upon coupon removal

WooCommerce: Redirect user to a specific page after removing a coupon

This snippet gives the ability to redirect a user after removing a coupon. You can place the code in functions.php.

@corsonr
corsonr / functions.php
Created January 28, 2019 12:02
WooCommerce: display products discounted price in cart table
<?php
/*
* Display discounted products prices in the cart table.
*
* Modification of code provided here https://businessbloomer.com/woocommerce-display-cart-item-subtotal-coupon-discount/.
*/
add_filter( 'woocommerce_cart_item_subtotal', 'if_coupon_slash_item_subtotal', 99, 3 );
add_filter( 'woocommerce_cart_item_price', 'if_coupon_slash_item_subtotal', 99, 3 );
/**
@corsonr
corsonr / functions.php
Last active September 14, 2018 09:02
WooCommerce: set price to zero
<?php
function make_it_free() {
echo '<table class="variations" cellspacing="0">
<tbody>
<tr>
<td class="label"><label>Make this free!</label></td>
<td class="value">
<label><input type="checkbox" name="option_free" value="YES" /> Set price to zero</label>
</td>
</tr>