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 / wp-recount-comments.php
Created April 1, 2015 10:51
WordPress recount comments
<?php
/**
* Put this file in the root of your WordPress installation.
* When done remove it!
*/
include 'wp-blog-header.php';
global $wpdb;
@jeffreyvr
jeffreyvr / settings.json
Created November 9, 2019 20:58
VSC settings
{
"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",
@jeffreyvr
jeffreyvr / settings.json
Created February 1, 2020 15:35
VSC settings
{
"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",
@jeffreyvr
jeffreyvr / .phpcs.xml.dist
Last active May 11, 2020 11:12
WordPress Theme or Plugin setup VSCode
<?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 -->
@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' );
}
}
});
@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 / 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 / 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 October 21, 2020 09:36
Webview component
@jeffreyvr
jeffreyvr / meta-box.php
Last active October 26, 2020 13:42
Boilerplate meta box
<?php
/**
* Class.
*
* @package a-package
*/
/**
* Class.
*/