*/ /** * The class contains a number of utility methods that may be needed by various * parts of WPSearch */ class Compassion_Utility { /** * Sets a Wordpress option * @param string $name The name of the option to set * @param string $value The value of the option to set */ public static function setOption($name, $value) { if($value != '') { if (get_option($name) !== FALSE) { update_option($name, $value); } else { $deprecated = ''; $autoload = 'no'; add_option($name, $value, $deprecated, $autoload); } } } /** * Gets a Wordpress option * @param string $name The name of the option * @param mixed $default The default value to return if one doesn't exist * @return string The value if the option does exist */ public static function getOption($name, $default = FALSE) { $value = get_option($name); if( $value !== FALSE ) return stripslashes ($value); return $default; } /** * Get a value from an associative array. The specified key may or may * not exist. * @param array $array Array to grab the value from * @param mixed $key The key to check the array * @param mixed $default A value to return if the key doesn't exist int he array (default is FALSE) * @return mixed The value if the key exists, and the default if it doesn't */ public static function arrayGet($array, $key, $default = FALSE) { if(array_key_exists($key, $array)) return $array[$key]; else return $default; } }