Skip to content

Instantly share code, notes, and snippets.

View vdwijngaert's full-sized avatar

Koen Van den Wijngaert vdwijngaert

View GitHub Profile
@vdwijngaert
vdwijngaert / wpml_helper.php
Created July 19, 2022 05:19
Check whether WPML is active for current site in a Multisite environment
<?php
/**
* Check whether WPML is active for current site. Checking for the availability of the SitePress class is not enough,
* because the plugin can be deactivated for a certain site. Also, this behavior is not consistent when switching blogs.
*
* How *NOT* to do it:
* - `class_exists( 'SitePress' )`
* - `defined('ICL_LANGUAGE_CODE')`
* - ...
*/
@vdwijngaert
vdwijngaert / openvpn3_sso.sh
Last active November 25, 2022 02:42
Helper function to automate openvpn3 connections that need SSO capabilities
# Helper function to automate openvpn3 connections that need SSO capabilities.
# Add it to your ~/.bashrc file using following code (and make sure to edit $OPENVPN3_CONFIG_NAME):
# source /path/to/openvpn3_sso.sh
# If using zsh, you can also save this to the `$ZSH/custom/openvpn3_sso.zsh` file.
# You can automatically have this run by calling ovpn3_sso_connect in your ~/.bashrc or ~/.zshrc file.
# WARNING: This has currently only been tested on zsh and bash.
# (c) Koen Van den Wijngaert <koen@neok.be>
### Keybase proof
I hereby claim:
* I am vdwijngaert on github.
* I am vdwijngaert (https://keybase.io/vdwijngaert) on keybase.
* I have a public key ASDcPQMBWUfa2dF_H-x8p856-k9Q476umGClgNmW05X__Ao
To claim this, I am signing this object:
@vdwijngaert
vdwijngaert / undo_tab_removal.php
Created May 28, 2019 08:44
Undo WooCommerce tab removal
<?php
/**
* @param string $tab
* @param int $offendingPriority
*/
function my_prefix_undoTabRemoval($tab, $offendingPriority = 10)
{
static $filterName = 'woocommerce_product_tabs';
// Accessible variable for the tab content.
@vdwijngaert
vdwijngaert / acf-select-wc-attributes.php
Created March 15, 2017 10:38
Populate ACF Select Field with WooCommerce Attributes.
<?php
/**
* Populate ACF Select Field with WooCommerce Attributes.
*/
add_filter('acf/load_field/name=featured_attributes', function($field) {
$taxonomies = get_taxonomies([
'public' => false,
'_builtin' => false
], 'objects');
<?php
class P4D_Siblings extends WP_Widget
{
/**
* Sets up the widgets name etc
*/
public function __construct()
{
$widget_ops = array('classname' => 'p4d_siblings', 'description' => __('Use this widget to display a list of page siblings.'));
/*!
* ProdChecker
*
* Copyright(c) Koen Van den Wijngaert
*/
/*jshint node: true */
'use strict';
var http = require('http');
@vdwijngaert
vdwijngaert / wpml-export-strings.js
Created July 6, 2015 08:20
Export WPML String translations
var $ = jQuery,
strings = [];
$("#icl_string_translations").find(">tbody>tr").each(function() {
var $tr = $(this),
$tds = $tr.find("td"),
trans = {};
trans.context = $tds.get(1).innerText;