Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Freelancing and building my own stuff.

Jeffrey van Rossum jeffreyvr

🚀
Freelancing and building my own stuff.
View GitHub Profile
@jeffreyvr
jeffreyvr / meta-box.php
Last active Oct 26, 2020
Boilerplate meta box
View meta-box.php
<?php
/**
* Class.
*
* @package a-package
*/
/**
* Class.
*/
@jeffreyvr
jeffreyvr / readme.md
Created Oct 21, 2020
Webview component
View readme.md
@jeffreyvr
jeffreyvr / PdfTopPm.php
Created Sep 9, 2020
Concept using Poppler pdftoppm for PDF image generation
View PdfTopPm.php
<?php
/**
* Concept class.
*/
class PdfTopPm
{
public $popplerPath;
public $dpi = 72;
public $quality = 100;
@jeffreyvr
jeffreyvr / README.md
Created Sep 4, 2020
Using wp.editor in widgets
View README.md

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.

/**
View is-gutenberg-active.php
<?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 Jun 22, 2020
OEmbed body parser for oscarotero/Embed.
View Oembed.php
<?php
use Exception;
use Embed\Embed;
class Oembed
{
/**
* Accepted Urls
*
@jeffreyvr
jeffreyvr / coupon-switch-based-on-logged-in.php
Created Jun 9, 2020
Simply switching a WooCommerce coupon-code if a user is logged in.
View coupon-switch-based-on-logged-in.php
<?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' );
}
}
});
@jeffreyvr
jeffreyvr / .phpcs.xml.dist
Last active May 11, 2020
WordPress Theme or Plugin setup VSCode
View .phpcs.xml.dist
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
<description>Generally-applicable sniffs for WordPress plugins.</description>
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<!-- How to scan -->
View settings.json
{
"workbench.startupEditor": "none",
"markdown.preview.fontSize": 12,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"editor.fontSize": 16,
"editor.lineHeight": 42,
"workbench.colorCustomizations": {
"[Inspired Github]": {
"editorLineNumber.foreground": "#999",
View settings.json
{
"workbench.startupEditor": "none",
"markdown.preview.fontSize": 12,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"editor.fontSize": 16,
"editor.lineHeight": 42,
"workbench.colorCustomizations": {
"[Inspired Github]": {
"editorLineNumber.foreground": "#999",
You can’t perform that action at this time.