Skip to content

Instantly share code, notes, and snippets.

View hiranthi's full-sized avatar

Hiranthi Herlaar hiranthi

View GitHub Profile
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 );
@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 / 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 / zipcode-2.php
Created January 23, 2019 19:55
Zipcode validation for Gravity Forms (5 digits, 2 approaches).
<?php
# just add the needed form IDs to the array
$forms = array( '6', '7' );
# looping through the array to add an 'add_filter' for each
foreach ( $forms as $i => $form )
add_filter( "gform_field_validation_{$form}", 'custom_zip_validation', 10, 4 );
# the function
@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 / elementor-redirect.php
Created March 13, 2019 11:03
Redirect Editors & Authors from the 'edit page' page to the Elementor editor. Helps keeping the Elementor-stuff intact :)
<?php
function onx_redirect_edit_page_to_elementor()
{
global $post, $pagenow;
if ( ! isset( $post->ID ) || current_user_can( 'manage_options' ) ) return;
if ( ( ( $pagenow == 'post.php' ) && ( get_post_type() == 'page' ) ) && ( current_user_can( 'editor' ) || current_user_can( 'author' ) ) )
{
@hiranthi
hiranthi / mu-plugin-file.php
Created March 22, 2019 18:55
Pretend another theme is active in the WP dashboard to maintain access to everything when something in your theme messes everything up (or whatevs).
<?php
add_filter( 'template', 'onx_change_theme' );
add_filter( 'option_template', 'onx_change_theme' );
add_filter( 'option_stylesheet', 'onx_change_theme' );
add_filter( 'pre_option_stylesheet', 'onx_change_theme' );
function onx_change_theme( $theme )
{
if ( is_admin() && ( function_exists( 'wp_get_current_user' ) ) )
{
@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 / 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 );