Skip to content

Instantly share code, notes, and snippets.

View jeffreyvr's full-sized avatar
🎸
Freelancing and building my own stuff.

Jeffrey van Rossum jeffreyvr

🎸
Freelancing and building my own stuff.
View GitHub Profile
@jeffreyvr
jeffreyvr / settings.json
Created August 16, 2023 14:55
VScode Apc Customize++ settings
{
"window.titleBarStyle": "native",
"workbench.colorCustomizations": {
"[Example Theme]": {
"sideBar.background": "#00000000"
}
},
"apc.electron": {
@jeffreyvr
jeffreyvr / README.md
Created December 21, 2021 21:13
TailPress - Gutenberg Blocks with Laravel Mix

An example of creating custom blocks from a TailPress theme using Laravel Mix.

Webpack file

Example of a block in your webpack.mix.js file:

mix.js('/resources/blocks/example/block.js', '/blocks/example/block.build.js').react();
@jeffreyvr
jeffreyvr / functions.php
Last active November 13, 2020 09:57
Disable WooCommerce Mollie payment gateway for pickup shipping
<?php
/**
* There seems to be no option to disable the Mollie gateway based
* on the selected shipping method. This filter removes
* Mollie when the shipping method contains 'pickup'.
*
* @param array $available_gateways The available gateways.
*
* @return array
*/
@jeffreyvr
jeffreyvr / meta-box.php
Last active October 26, 2020 13:42
Boilerplate meta box
<?php
/**
* Class.
*
* @package a-package
*/
/**
* Class.
*/
@jeffreyvr
jeffreyvr / readme.md
Created October 21, 2020 09:36
Webview component
@jeffreyvr
jeffreyvr / PdfTopPm.php
Created September 9, 2020 14:49
Concept using Poppler pdftoppm for PDF image generation
<?php
/**
* Concept class.
*/
class PdfTopPm
{
public $popplerPath;
public $dpi = 72;
public $quality = 100;
@jeffreyvr
jeffreyvr / README.md
Created September 4, 2020 09:33
Using wp.editor in widgets

Within your widget, you can include a editor with a textarea and the class custom-widget-wp-editor.

 <textarea id="<?php echo $this->get_field_id( 'header' ); ?>" name="<?php echo $this->get_field_name( 'header' ); ?>" class="custom-widget-wp-editor"><?php echo $header; ?></textarea>

Make sure you include the JS-file within the widgets and customizer view.

/**
@jeffreyvr
jeffreyvr / is-gutenberg-active.php
Created August 18, 2020 11:49
Is Gutenberg active
<?php
function prefix_is_gutenberg_active() {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
$is_gutenberg = has_filter( 'replace_editor', 'gutenberg_init' ) || version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );
$is_classic_editor = is_plugin_active( 'classic-editor/classic-editor.php' ) && get_option( 'classic-editor-replace' ) === 'no-replace';
if ( $is_gutenberg && ! $is_classic_editor ) {
return true;
@jeffreyvr
jeffreyvr / Oembed.php
Last active June 22, 2020 18:27
OEmbed body parser for oscarotero/Embed.
<?php
use Exception;
use Embed\Embed;
class Oembed
{
/**
* Accepted Urls
*
@jeffreyvr
jeffreyvr / coupon-switch-based-on-logged-in.php
Created June 9, 2020 12:30
Simply switching a WooCommerce coupon-code if a user is logged in.
<?php
add_action( 'woocommerce_before_calculate_totals', function () {
if ( is_user_logged_in() ) {
if ( in_array( 'highdiscount', WC()->cart->get_applied_coupons() ) ) {
WC()->cart->remove_coupon( 'highdiscount' );
WC()->cart->add_discount( 'lowdiscount' );
}
}
});