RG Helper Functions // A set of helper functions used by Gravity Forms, cleaned up to better conform with WordPress coding standards.
<?php
if( ! function_exists( 'rgget' ) ) {
function rgget( $name, $array = null ) {
if( ! isset( $array ) )
$array = $_GET;
if( isset( $array[$name] ) )
return $array[$name];
return '';
}
}
if( ! function_exists( 'rgpost' ) ) {
function rgpost( $name, $do_stripslashes = true ) {
if( isset( $_POST[$name] ) )
return $do_stripslashes ? stripslashes_deep( $_POST[$name] ) : $_POST[$name];
return '';
}
}
if( ! function_exists( 'rgar' ) ) {
function rgar( $array, $name ) {
if( isset( $array[$name] ) )
return $array[$name];
return '';
}
}
if( ! function_exists( 'rgars' ) ) {
function rgars( $array, $name ) {
$names = explode( '/', $name );
$val = $array;
foreach( $names as $current_name ){
$val = rgar( $val, $current_name );
}
return $val;
}
}
if( ! function_exists( 'rgempty' ) ) {
function rgempty( $name, $array = null ) {
if( is_array( $name ) )
return empty( $name );
if( ! $array )
$array = $_POST;
$val = rgar( $array, $name );
return empty( $val );
}
}
/*
For use with classes.
public function get_base_url() {
$folder = basename( dirname( __file__ ) );
return plugins_url( $folder );
}
public function get_base_path() {
$folder = basename( dirname( __file__ ) );
return WP_PLUGIN_DIR . '/' . $folder;
}
*/