Skip to content

Instantly share code, notes, and snippets.

View hiranthi's full-sized avatar

Hiranthi Herlaar hiranthi

View GitHub Profile
@hiranthi
hiranthi / customize-wishlist-button.php
Last active December 14, 2015 01:09
Customizing the placement of the "add-to-wishlist" button/link for the Wishlist Pro plugin for Shopp.
<?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 February 21, 2013 11:11
Get the "Wishlist" link (Wishlist Pro plugin for Shopp).
@hiranthi
hiranthi / ajax.js
Last active December 14, 2015 02:29
Adding products to the wishlist through AJAX so customers don't leave the current page (for Shopp - Wishlist Pro from Shopplugin.nl).
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 March 4, 2013 11:34
Add autoembed functionality to Shopp product description & summary
<?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 April 9, 2013 08:31
Add a product to the wishlist from the cart page.
<?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
Last active May 22, 2019 12:50
Een combinatie van PHP & .htaccess om ongewenste bezoekers aan je wp-login.php (zoals de brute force attackers) weg te leiden van je wp-login.phpCheck http://onexa.nl/wordpress/brute-force-attacks-wp-login-php-verminderen/ voor meer uitleg hier over.
### Blocking Spammers Section ###
# Stop protected folders from being narked. Also helps with spammers
ErrorDocument 401 /401.html # this file should be added, check http://halfelf.org/2013/wp-login-protection-htaccess/
# Stop spam attack logins and comments - http://halfelf.org/2013/wp-login-protection-htaccess/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .(wp-comments-post|wp-login)\.php*
@hiranthi
hiranthi / .htaccess
Created June 11, 2013 10:15
See my post on http://onexa.nl/wordpress/aangepaste-url-voor-wp-admin/ for the use of this code (Dutch website)
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 -->
# 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]
function onx_reset_faceted_menus ()
{
if ( isset( $_GET['reset'] ) && class_exists( 'Shopp' ) )
{
// the part of the Shopp Object that holds the facet filtering info, make it empty
ShoppStorefront()->browsing = array();
// get the current url
$url = explode( '?', onx_full_url() );
@hiranthi
hiranthi / breadcrumbs.php
Created January 3, 2014 16:01
Shopp breadcrumbs with schema.org stuff added.
<p>
<?php
$bc = array(
'separator' => '&nbsp;/&nbsp;',
'wrap' => '<p class=”breadcrumb”><span xmlns:v="http://rdf.data-vocabulary.org/#"><span typeof="v:Breadcrumb"><a href="http://liefdevol-opgroeien.nl" rel="v:url" property="v:title">Home</a></span> / ',
'endwrap' => '</p>',
'before' => '<span typeof="v:Breadcrumb"><span property="v:title">',
'after' => '</span></span>'
);
shopp( 'storefront.breadcrumb', $bc );