Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Moving bits and bytes around the globe

Niels Lange nielslange

👨‍💻
Moving bits and bytes around the globe
View GitHub Profile
@nielslange
nielslange / functions.php
Created Sep 17, 2020
Reorder EU VAT field on checkout page
View functions.php
<?php
/**
* Reorder EU VAT field on checkout page
*
* @param $fields array The original array with the checkout fields
* @return $fields array The updated array with the checkout fields
* @see https://woocommerce.com/products/eu-vat-number/
*/
function smntcs_reorder_eu_vat_field( $fields ) {
$fields['billing']['billing_vat_number']['priority'] = 35;
@nielslange
nielslange / functions.php
Last active May 8, 2020
WordPress: Check enqueued scripts and styles
View functions.php
<?php
// Check enqueued scripts
add_action('wp_enqueue_scripts', 'nl_check_enqueued_scripts', 99999);
function nl_check_enqueued_scripts() {
global $wp_scripts;
var_dump($wp_scripts);
}
// Check enqueued styles
@nielslange
nielslange / wp-theme-stats.js
Created Apr 4, 2020
Get all WordPress.org themes with more than 100.000 active installs
View wp-theme-stats.js
let url = 'https://api.wordpress.org/themes/info/1.2/?action=query_themes&request[search]=%20&request[fields][downloaded]=true&request[fields][active_installs]=true&request[per_page]=-1';
let downloads = 0;
let installs = 0;
let installed = 100000;
let themes_all;
let themes_filtered;
let theme;
fetch( url )
.then( response => {
View find_uniq.php
<?php
function find_uniq($a) {
sort($a);
return ($a[0] === $a[1]) ? end($a) : current($a);
}
View find_uniq.php
<?php
function find_uniq(array $array): int {
sort($array);
if ( $array[0] === $array[1] ) rsort($array);
return $array[0];
}
@nielslange
nielslange / query.sql
Last active Nov 9, 2019
Set maximum character length of function GROUP_CONCAT() to 10000.
View query.sql
# Set maximum character length of function GROUP_CONCAT() to 10000.
SET SESSION group_concat_max_len = 10000;
View style.css
/* Replace site logo based on language | NL-***-hc */
html[lang="en-US"] .custom-logo-link {
background: url(IMAGE-URL);
height: 150px;
width: 300px;
display: block;
margin: auto;
}
html[lang="en-US"] .custom-logo-link img.custom-logo {
display: none;
@nielslange
nielslange / stats.js
Last active Apr 18, 2020
Fetch total downloads and installs of all WordPress plugins
View stats.js
let url = 'https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[fields][banners]=true&request[search]=SMNTCS';
let downloads = 0;
let installs = 0;
let plugins;
let plugin;
fetch( url )
.then( response => {
return response.json()
} )
View Adjust post title visibility
/* Adjust post title visibility */
.headline {
display: none;
}
View style.css
/* Adjust post title font color */
.headline {
color: #fff;
}
You can’t perform that action at this time.