Skip to content

Instantly share code, notes, and snippets.

View stgoos's full-sized avatar

Steven stgoos

  • The Netherlands
View GitHub Profile
@Jon007
Jon007 / functions.php
Last active December 4, 2023 08:17
Add default Product Attributes to all WooCommerce products
/*
* Example adds certain named Product Attribute fields to the product Edit screen ready for completion.
* (Pre-requisite )
* This saves the Shop Admin having to add them manually.
*
* Why might you want to do this instead of adding Custom fields? There's plenty of nice documentation on adding custom fields
* for example: http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
*
* Well a Product Attributes are a built in WooCommerce feature, using Terms which are a built in Wordpress feature.
* - no add-ons required
@r-k-b
r-k-b / power-query-iso-week-year.md
Last active October 21, 2025 18:39 — forked from robkb/power-query-iso-week-year.md
M functions to convert between ISO 8601 Week & Year ⇄ dates (e.g., `2014-12-29` ⇄ `"2015-W01-1"`)
@carlodaniele
carlodaniele / kinsta-share-users.php
Last active December 11, 2023 15:34
A plugin to share users and usermeta tables between independent WordPress installations. This plugin requires CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE defined into wp-config file
<?php
/**
* @package Kinsta_Share_Users
* @version 1.0
*/
/*
Plugin Name: Kinsta Share Users
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin for Kinsta blog readers
Author: Carlo Daniele
@anttiviljami
anttiviljami / allow-email-as-username.php
Created March 3, 2016 09:19
A wordpress mu-plugin that allows you to create users with email-addresses as usernames in multisite
<?php
/**
* Plugin name: Allow email as WordPress Network/Multisite username
* Description: A wordpress mu-plugin that allows you to create users with email-addresses as usernames in multisite
* Version: 1.0
* Author: @anttiviljami
* License: GPLv3
*/
add_filter( 'wpmu_validate_user_signup', '_signup_allow_email_as_username' );
@bappi-d-great
bappi-d-great / code.php
Created January 1, 2016 14:49
Unique display name and nickname in wordpress
<?php
// A dirty script by Ash
add_action( 'personal_options_update', 'check_display_name' );
add_action( 'edit_user_profile_update', 'check_display_name' );
function check_display_name( $user_id ) {
global $wpdb;
// Getting user data and user meta data
$err['display'] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->users WHERE display_name = %s AND ID <> %d", $_POST['display_name'], $_POST['user_id'] ) );
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active April 28, 2026 15:21
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@mattclements
mattclements / function.php
Last active May 11, 2026 01:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@JudeRosario
JudeRosario / Custom Upload Dirs.php
Created October 12, 2015 13:43
Custom Upload Dirs
/*
Plugin Name: Custom Upload Dirs
Description: Changes the upload directory to what we would like, instead of what WordPress likes.
Author: Mark
Version: 1.0
Author URI: http://google.com
*/
add_action( 'init', 'change_upload_dir' ) ;
@ankurk91
ankurk91 / power-wordpress-tweaks.php
Last active October 9, 2024 00:37
Power WordPress Tweaks [Use at your own risk] ⚠️
<?php
/*
Plugin Name: Power WP Tweaks
Plugin URI: http://ankurk91.github.io/
Description: Some common tweaks to optimize WP Site
Version: 1.0
Author: ankurk91
Author URI: http://ankurk91.github.io/
License: MIT
*/
@JustThomas
JustThomas / wordpress-multisite-internal-redirect-loop.md
Last active May 6, 2026 20:52
WordPress Multisite: How to fix error "too many redirects"

WordPress Multisite: How to fix error "Request exceeded the limit of 10 internal redirects"

I am running a WordPress multisite network with sub-directory setup. When I check my error.log file, it is full of entries like this one:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'Limit InternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

The problem was, in my case, one specific rewrite rule in the .htaccess file.

Problem description