Skip to content

Instantly share code, notes, and snippets.

View multiplehats's full-sized avatar
🎯
Focusing

Chris Jayden multiplehats

🎯
Focusing
View GitHub Profile
@hlashbrooke
hlashbrooke / class.php
Created February 28, 2014 08:37
A complete, versatile options page class for any WordPress plugin
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
class WordPress_Plugin_Template_Settings {
private $dir;
private $file;
private $assets_dir;
private $assets_url;
private $settings_base;
@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
@butlerblog
butlerblog / auto-login-from-reg-email.php
Last active November 5, 2021 15:44
WordPress auto login from native registration email
<?php
/*
This code snippet can be added to your functions.php file (without the <?php)
to add a query string to the login link emailed to the user upon registration
which when clicked will validate the user, log them in, and direct them to
the home page.
*/
/**
* This first function is hooked to the 'user_register' action which fires
@EvanHerman
EvanHerman / redirect-user-back-to-product.php
Created November 13, 2015 16:30
WooCommerce - After login, redirect the user back to the last viewed product
<?php
/*
* Add a hidden field to our WooCommerce login form - passing in the refering page URL
* Note: the input (hidden) field doesn't actually get created unless the user was directed
* to this page from a single product page
*/
function redirect_user_back_to_product() {
// check for a referer
$referer = wp_get_referer();
// if there was a referer..
@yoren
yoren / functions.php
Last active March 21, 2023 23:15
Parent Post From Another Post Type And A New URL Structure In WordPress
<?php
// Flush rewrite rules after switch theme
function my_rewrite_flush() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );
// A little help so we can get the stylesheet from parent theme
// Remove line 10-19 if this is not a child theme
function my_enqueue_styles() {
$ = jQuery;
/*
* jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
@thenbrent
thenbrent / wcs-test-retry-rules.php
Last active September 8, 2020 14:02
WooCommerce Subscriptions Failed Payment Retry Rules for Testing: Replace the default WooCommerce Subscriptions failed payment retry rules with rules that run every few minutes (not days) and always send dunning emails to help with testing.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Failed Payment Retry Rules for Testing
* Plugin URI:
* Description: Replace the default WooCommerce Subscriptions failed payment retry rules with rules that run every few minutes (not days) and always send dunning emails to help with testing.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.0
*
* Copyright 2016 Prospress, Inc. (email : freedoms@prospress.com)
@glueckpress
glueckpress / wp-rocket-affiliatewp-cookies-cache.php
Last active March 26, 2019 21:24
[WordPress][WP Rocket] Creates cached files based on dynamic cookies for AffiliateWP. (WP Rocket 2.7+ required.)
<?php
/**
* Plugin Name: WP Rocket | AffiliateWP Cookie Cache
* Description: Creates a specific cache for each affiliate ref ID.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* Plugin URI: https://gist.github.com/glueckpress/d379c5534708f440942523fe205ec840
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
form[data-drip-embedded-form] {
background: #fff url(data:image/gif;base64,R0lGODlhAQADAIABAMzMzP///yH/C1hNUCBEYXRhWE1QPD94cGFja…wbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAEAAAEALAAAAAABAAMAAAICRFIAOw==) repeat-y center top;
font-family: "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif;
line-height: 1.5em;
overflow: hidden;
color: #666;
font-size: 16px;
border-top: solid 20px #3071b0;
border-top-color: #3071b0;
border-bottom: solid 10px #3d3d3d;
@wpscholar
wpscholar / pantheon-wp-config.php
Last active March 26, 2021 05:34
My Pantheon wp-config.php template.
<?php
define( 'SITE_LIVE_DOMAIN', SITE_LIVE_DOMAIN );
define( 'WP_ENV', isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ? $_ENV['PANTHEON_ENVIRONMENT'] : 'local' );
define( 'SCHEME', isset( $_SERVER['HTTP_USER_AGENT_HTTPS'] ) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON' ? 'https' : 'http' );
// Redirect all traffic on live site to the correct domain
if ( 'live' === WP_ENV && php_sapi_name() !== 'cli' ) {
if ( $_SERVER['HTTP_HOST'] !== SITE_LIVE_DOMAIN ) {