Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:1119f025ad896c05e2f5
Last active April 6, 2017 15:07
AffiliateWP - Custom logout redirect for Affiliates
<?php
/**
* AffiliateWP - Custom logout redirect for Affiliates
* By default, a user is sent to the wp-login.php?loggedout=true page
* Affiliates are logged out to the affiliate dashboard login screen
* Normal WP users are logged out and redirected to the site URL
*/
function affwp_custom_logout_redirect( $logout_url, $redirect ) {
@FrostyX
FrostyX / FacebookDebugger.php
Last active December 11, 2024 20:33
Facebook API - Force facebook to reload cache from your website
<?php
class FacebookDebugger
{
/*
* https://developers.facebook.com/docs/opengraph/using-objects
*
* Updating Objects
*
* When an action is published, or a Like button pointing to the object clicked,
* Facebook will 'scrape' the HTML page of the object and read the meta tags.
@lmartins
lmartins / functions.php
Last active November 3, 2023 19:28 — forked from woogist/functions.php
By default WooCommerce redirects the user to the My Account page after a successful login. You may change this and use a custom URL based on the user role, like the Dashboard for admins and My Account page for customers. To do this, add this code at the end of the file functions.php located in wp-content/themes/your-theme-name/ https://support.w…
<?php
/**
* Redirect users to custom URL based on their role after login
*
* @param string $redirect
* @param object $user
* @return string
*/
function wc_custom_user_redirect( $redirect, $user ) {
// Get the first of all the roles assigned to the user
@phpmaps
phpmaps / list_terms_exclusions
Created February 6, 2015 06:32
list_terms_exclusions plugin
<?php
/*
Plugin Name: Pancake v. 1.1
Plugin URI: http://phpmaps.github.io/me/
Description: Hides wordpress categories that Johnny finds annoying when working in the admin!
Version: 1.1 rev 1 (Sea Gull)
Author: Doogs
Author URI: http://phpmaps.github.io/me/
*/
@TimBHowe
TimBHowe / remove_orders
Last active January 31, 2017 12:47
Remove all orders from WordPress WooCommerce. This is ideally for clearing out orders on a staging/beta version of a WooCommerce site where the order information is not needed or should not be stored.
DELETE FROM wp_postmeta
WHERE post_id IN(SELECT ID FROM wp_posts WHERE post_type = 'shop_order');
DELETE FROM wp_posts WHERE post_type = 'shop_order';
@paulcollett
paulcollett / functions.php
Last active October 16, 2025 21:28
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin”
// For Yoast SEO Plugin Version: 14.1+ add to your Wordpress Theme's functions.php...
// Remove All Yoast HTML Comments
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076
// Credit @devendrabhandari (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-3303423)
add_filter( 'wpseo_debug_markers', '__return_false' );
// For Yoast SEO Plugin Version: < 14.1 add to your Wordpress Theme's functions.php...
@quasel
quasel / acf-fields.php
Created December 28, 2015 19:36 — forked from hereswhatidid/acf-fields.php
Create custom product details tabs within WooCommerce using an ACF (Advanced Custom Fields) Repeater field.
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'acf_product_options',
'title' => 'Product Options',
'fields' => array (
array (
'key' => 'acf_product_options_tabbedcontent_label',
'label' => 'Tabbed Content',
@carlodaniele
carlodaniele / food-example-plugin.php
Last active August 22, 2021 09:00
An example plugin for WPMU DEV readers
<?php
/**
* @package Food_example_plugin
* @version 1.0
*/
/*
Plugin Name: Food example plugin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin for WPMU DEV readers
Author: Carlo Daniele
@TimBHowe
TimBHowe / functions.php
Created March 8, 2016 17:54
Forcibly remove the tax line item and calculation from the cart. (suggest just using the GEO setting in WooCommerce)
<?php
// Remove the Tax Line item from the cart.
function wc_remove_cart_tax_totals( $tax_totals, $instance ) {
if( is_cart() ) {
$tax_totals = array();
}
return $tax_totals;
}
@ControlledChaos
ControlledChaos / .maintenance
Last active November 5, 2024 10:06 — forked from mikemanger/.maintenance
Example WordPress .maintenance file. maintenance.php is optional but useful for styling the message the public will see (it is also used when updating WordPress components), drop it in your wp-content folder.
<?php
function is_user_logged_in() {
$loggedin = false;
foreach ( (array) $_COOKIE as $cookie => $value ) {
if ( stristr( $cookie, 'wordpress_logged_in_' ) ) {
$loggedin = true;
}
}
return $loggedin;
}