Skip to content

Instantly share code, notes, and snippets.

Avatar

Hiranthi Herlaar hiranthi

View GitHub Profile
@hiranthi
hiranthi / pre-submission-gf.php
Last active Aug 29, 2015
The "Better Pre-submission Confirmation" from Gravity Wiz, with a few adjustments (support for Gravitate Encryption and a little adjustment on the Order (products) table).
View pre-submission-gf.php
<?php
/**
* Better Pre-submission Confirmation
* http://gravitywiz.com/2012/08/04/better-pre-submission-confirmation/
*/
class GWPreviewConfirmation {
private static $lead;
@hiranthi
hiranthi / functions.php
Last active Aug 29, 2015
Put Shopp in maintenance mode, without kicking loggedin users out too.
View functions.php
<?php
new HiddenShopp;
class HiddenShopp
{
/**
* Construct everything
*
* @author Hiranthi Molhoek-Herlaar
@hiranthi
hiranthi / view-all.php
Last active Aug 29, 2015
View all products of the current category (Shopp)
View view-all.php
<?php
/**
* Filter $load_options
*/
function onx_custom_filter($load_options)
{
if ( is_admin() ) return $load_options;
if ( isset($_REQUEST['viewall']) || isset($_REQUEST['view-all']) )
@hiranthi
hiranthi / customize-wishlist-button.php
Last active Dec 14, 2015
Customizing the placement of the "add-to-wishlist" button/link for the Wishlist Pro plugin for Shopp.
View customize-wishlist-button.php
<?php
/**
* Disable auto-placement of "add to wishlist buttons/links"
*/
function custom_sw_shopp_init()
{
$sw = new ShoppWishlist()
remove_filter('shopp_product_description',array(&$sw, 'button_product'), 99); // disable the auto-placement in product description
@hiranthi
hiranthi / account-link.php
Created Feb 21, 2013
Get the "Wishlist" link (Wishlist Pro plugin for Shopp).
View account-link.php
@hiranthi
hiranthi / ajax.js
Last active Dec 14, 2015
Adding products to the wishlist through AJAX so customers don't leave the current page (for Shopp - Wishlist Pro from Shopplugin.nl).
View ajax.js
jQuery(document).ready(function($) {
// the add-to-wishlist links should be inside an id="edit-wishlist-pro", ie a div or a span
$('#edit-wishlist-pro a').click(function(e) {
e.preventDefault();
// the surrounding grandparent should have a rel attached that holds the ID of the product (ie rel="12")
var product = $(this).parent().parent().attr('rel');
// the parent (<p>) doesn't have a 'remove' class, so we're adding to the wishlist
@hiranthi
hiranthi / autoembed.php
Created Mar 4, 2013
Add autoembed functionality to Shopp product description & summary
View autoembed.php
<?php
global $wp_embed;
add_filter( 'shopp_product_description', array( $wp_embed, 'autoembed' ), 999 );
add_filter( 'shopp_product_summary', array( $wp_embed, 'autoembed' ), 999 );
?>
@hiranthi
hiranthi / add2wishlist-cart.php
Created Apr 9, 2013
Add a product to the wishlist from the cart page.
View add2wishlist-cart.php
<?php
// load product, should be inside the cartitem loop
shopp('storefront','product','load=true&id=' . shopp('cartitem','product','return=true'));
// then place the add-to-wishlist link/checkbox where you want it -> inside that same loop (options below)
shopp('wishlist-pro','add-button','options');
// Options:
# type - link | checkbox
# before - add something before the link/checkbox
@hiranthi
hiranthi / .htaccess
Created Jun 11, 2013
See my post on http://onexa.nl/wordpress/aangepaste-url-voor-wp-admin/ for the use of this code (Dutch website)
View .htaccess
RewriteEngine on
RewriteBase /
# WP automatically redirects domain.com/admin to the correct wp-admin URL, we want to stop this so we're sending the visitor to the homepage
RewriteRule ^admin/?(.*?) http://www.domain.com [R=301,L]
# Cloaking the wp-admin folder and changing it to domain.com/my-administration/
RewriteRule ^my-administration/(.*?) wp-admin/$1?%{QUERY_STRING} [L]
# Default WP stuff goes here -->
View .htaccess
# Place this below the .htaccess code from https://onexa.nl/nieuwsberichten/brute-force-attacks-wp-login-php-verminderen/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{QUERY_STRING} !(^|&)secure=XXXXXXXXX($|&)
RewriteCond %{REQUEST_URI} .wp-admin* [OR]
RewriteCond %{REQUEST_URI} .wp-login\.php*
RewriteCond %{HTTP_REFERER} !.*domain.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/ [R=301,L]