Skip to content

Instantly share code, notes, and snippets.

View ramonfincken's full-sized avatar

Ramon Fincken ramonfincken

View GitHub Profile
@goranefbl
goranefbl / functions.php
Last active December 24, 2018 09:48
Refer a friend by WPGens - Woocommerce Subscription discount
<?php
add_filter('wcs_new_order_created','gens_renewal_order_created', 10, 2 );
function gens_renewal_order_created($order, $subscription){
$_user_id = $order->get_user_id();
$user_info = get_userdata($_user_id);
$user_email = $user_info->user_email;
$args = array(
'posts_per_page' => -1,
@bekarice
bekarice / wc-custom-order-status-icon.php
Last active May 13, 2019 17:01
Add WooCommerce custom order status icon
/**
* Adds icons for any custom order statuses
* Tutorial: http://www.skyverge.com/blog/changing-woocommerce-custom-order-status-icons/
**/
add_action( 'wp_print_scripts', 'skyverge_add_custom_order_status_icon' );
function skyverge_add_custom_order_status_icon() {
if( ! is_admin() ) {
return;
}
@azaozz
azaozz / image-meta-tests.php
Last active June 20, 2019 13:24
Small WordPress plugin to display and test image meta and creation of missing image sub-sizes
<?php
/**
* Plugin Name: Image Meta Tests (Do not use in production!)
* Description: A small plugin to enable displaying and testing of image attachment meta data. The data is displayed on the Media Library list view screen.
* Version: 0.0.1-private-plugin
* Author: Andrew Ozz
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
@trepmal
trepmal / gist:1c66dbe97e8f322bc107
Created December 19, 2014 22:42
wp-cli: reset all user passwords
#!/bin/bash
for uid in $(wp user list --field=ID)
do
pass=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}`
wp user update $uid --user_pass="$pass"
done
@johnalarcon
johnalarcon / functions.php
Created October 25, 2020 07:22
Remove plugins from search results in ClassicPress dashboard
/**
* Remove plugins from search results in ClassicPress dashboard.
* A little ditty by Code Potent. https://codepotent.com
*/
// Add slugs for any individual plugins to remove.
function codepotent_plugins_to_remove() {
$slugs = [
'wordfence',
'jetpack',
@johnalarcon
johnalarcon / functions.php
Created May 12, 2021 18:32
Remove the /users/ REST API endpoint in WordPress and ClassicPress
/**
* The following code will remove access to the /users/ endpoint. This makes the
* endpoint inaccessible while not blocking access to other endpoints. This code
* works with both WordPress and ClassicPress.
*
* Why do this? The REST API is very handy, however, by default, it exposes data
* that you may not want exposed – namely, your site's usernames. With a list of
* your usernames, the success of a brut-force attack becomes more likely.
*
*/
@sergejmueller
sergejmueller / index.html
Last active December 14, 2021 09:50
Embedded Google Analytics: Fix “Leverage Browser Caching” Warning on Nginx
<html>
<!-- ... -->
<!-- Embed analytics.js as local file -->
<script src="/analytics.js"></script>
</html>
<?php
/*
Plugin Name: Programmatically add Gravity Forms
Plugin URI: https://daan.kortenba.ch/programmatically-add-gravity-forms/
Description: Programmatically add persistent Gravity Forms forms.
Author: Daan Kortenbach
Version: 0.1
Author URI: https://daan.kortenba.ch/
License: GPLv2 or later
*/
@stefanzweifel
stefanzweifel / slack.php
Created May 8, 2014 13:26
Slack.com Webhook Integration (PHP) - Simple snippet which tells you, how to build your payload array.
<?php
//Options
$token = 'YOUR_TOKEN_HERE';
$domain = 'YOUR_SLACK_DOMAIN_GOES_HERE';
$channel = '#general';
$bot_name = 'Webhook';
$icon = ':alien:';
$message = 'Your message';
@mikejolley
mikejolley / gist:d4c46102d69d4560abb6
Created March 21, 2016 11:13
WooCommerce - Allow non-admin access to backend, and enable admin_bar
/* Code goes in theme functions.php */
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
add_filter( 'woocommerce_disable_admin_bar', '__return_false' );