Skip to content

Instantly share code, notes, and snippets.

View hiranthi's full-sized avatar

Hiranthi Herlaar hiranthi

View GitHub Profile
@hiranthi
hiranthi / functions.php
Last active November 21, 2019 21:06
New encryption with Gravity Forms
<?php
function my_custom_gravityforms_encrypt( $to_encrypt )
{
if ( '' === $to_encrypt ) return null;
if ( function_exists('openssl_encrypt') && function_exists('openssl_random_pseudo_bytes') )
{
$iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( 'aes-256-cbc' ) );
$encrypted = openssl_encrypt( $to_encrypt, 'aes-256-cbc', MY_CUSTOM_GF_ENCRYPTION_KEY, 0, $iv );
<?php
# Check: https://onexa.nl/wordpress/toolbar-link-redis-object-cache/
/**
* Add a link to the Admin Toolbar to easily flush the Redis cache (Redis Object Cache plugin)
*
* @author Hiranthi Herlaar, onexa.nl
* @version 2.0
*
@hiranthi
hiranthi / woo-checkout.php
Last active August 26, 2021 00:52
WooCommerce checkout steps
<?php
/**
* Display the checkout steps so the customer knows where they are.
*
* The output uses classes of Bootstrap 4 and the icons of FontAwesome (Free)
**/
function onx_woocommerce_checkout_steps()
{
echo '<nav id="woo-checkout-steps" class="nav nav-pills nav-justified mb-4" role="navigation">';
@hiranthi
hiranthi / decrypt-2.php
Last active January 30, 2019 15:07
Encrypt & decrypt Gravity Forms velden
<?php
# Like on: https://docs.gravityforms.com/gform_get_input_value/
add_filter( 'gform_get_input_value', 'gf_custom_decode_field', 10, 4 );
function gf_custom_decrypt_field( $value, $entry, $field, $input_id )
{
return GFCommon::decrypt( $value );
}
// end gf_custom_decrypt_field
@hiranthi
hiranthi / functions.php
Created February 17, 2018 10:51
Get current WP sidebar
<?php
if ( ! function_exists( 'get_current_sidebar' ) )
{
function get_current_sidebar ( $widget_id )
{
$sidebars_widgets = get_option('sidebars_widgets', array());
if ( is_array( $sidebars_widgets ) && isset( $sidebars_widgets['array_version'] ) )
unset( $sidebars_widgets['array_version'] );
@hiranthi
hiranthi / functions.php
Created December 7, 2017 14:02
WordPress image_sizes voor responsive header
<?php
add_action( 'init', 'onx_register_image_sizes' );
function onx_register_image_sizes()
{
add_image_size( 'header_screen_large', 2000, 1200, array( 'center', 'center' ), true );
add_image_size( 'header_screen', 991, 700, array( 'center', 'center' ), true );
add_image_size( 'header_tablet', 767, 550, array( 'center', 'center' ) );
add_image_size( 'header_mobile', 479, 400, array( 'center', 'center' ) );
} // end onx_register_image_sizes
@hiranthi
hiranthi / view-all.php
Last active August 29, 2015 14:06
View all products of the current category (Shopp)
<?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 / functions.php
Last active August 29, 2015 14:01
Put Shopp in maintenance mode, without kicking loggedin users out too.
<?php
new HiddenShopp;
class HiddenShopp
{
/**
* Construct everything
*
* @author Hiranthi Molhoek-Herlaar
@hiranthi
hiranthi / pre-submission-gf.php
Last active August 29, 2015 13:57
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).
<?php
/**
* Better Pre-submission Confirmation
* http://gravitywiz.com/2012/08/04/better-pre-submission-confirmation/
*/
class GWPreviewConfirmation {
private static $lead;
@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 );