$value ) { if ( is_array( $value ) ) { $arrays++; $this->count_elements_only( $value ); } // End of array check } // End of $array foreach $count = $recur - $arrays; } // End of $array empty check return $count; } // End of count_elements_only() /** * Find a user by their meta data * * The metakey and metavalue are used with get_users to fins the user by that data. * If no match is found, it returns FALSE. * If a match is found, it returns the user's ID. * * @uses get_users * * @param int $metakey The key for the meta data to search by * @param string $metavalue The value of the key to search by * * @return int The user's ID or FALSE if the user doesn't exist */ public function get_user_by_metadata( $metakey, $metavalue ) { $users = get_users( array( 'meta_key' => $metakey, 'meta_value' => $metavalue ) ); if ( empty( $users ) ) { return FALSE; } else { foreach ($users as $user) { $id = $user->ID; return $id; } // End of $users foreach } // End of $user empty check } // End of get_user_by_metadata() /** * Convert a string into an array * * @param string $string String of data to convert * * @return mixed If the param is a string, returns an array, otherwise returns FALSE */ public function make_array( $string ) { if ( !empty( $string ) && is_string( $string ) ) { if ( substr( $string, -1 ) == ',' ) { $array = explode( ',', $string, -1 ); } else { $array = explode( ',', $string ); } // End of comma check return $array; } else { return FALSE; } // End of empty check } // End of make_array() /** * Converts an array and into a comma-separated string. * * @param array $array The array of data to convert to a string * * @return string A comma-separated string, or FALSE if the $array param is empty */ public function make_string( $array ) { return ( !empty( $array ) ? implode( ',', $array ) : FALSE ); } // End of get_user_by_metadata() /** * Check for the existence of a meta data item * * Call get_users to find any students with the meta data passed into the function * If the list of users is empty, it returns FALSE, otherwise it return TRUE * * @uses get_users * * @param array $params $meta = the meta key to check, $data = the data to check * * @return bool TRUE if it finds a student, FALSE if not */ public function meta_exists( $params ) { extract( $params ); $users = get_users( array( 'meta_key' => $meta, 'meta_value' => $data ) ); $exists = ( empty( $users ) ? FALSE : TRUE ); return $exists; } // End of meta_exists() /** * Check if an input needs to be made plural * * Long Description * * * @params string $params $compare = item to compare, $match = item to compare against, $word = word to plural * * @return string $output Either the word or the word with an 's' at the end */ public function pluralize( $params ) { extract( $params ); switch ( $b ) { case '==' : $compare = $a == $c; break; case '>=' : $compare = $a >= $c; break; case '<=' : $compare = $a <= $c; break; case '>' : $compare = $a > $c; break; case '<' : $compare = $a < $c; break; } // End of $b switch $output = ( isset( $compare ) ? $word : $word . 's' ); return $output; } // End of pluralize() /** * Display an array in a nice format * * param array The array you wish to view */ public function print_array( $array ) { echo '
';
		  print_r( $array );
		  echo '
'; } /** * Replaces spaces in string with underscores * * Replaces any spaces found in the $input string with an underscore * * @param string input The string * * @return string The $input string with words separatd by underscores */ public function replace_spaces( $input, $with ) { return str_replace( ' ', $with, $input); } // End of replace_spaces() /** * Sort by last name, then by first name * * It sorts the found users array by last name. If there is * more than one of that last name, it sorts by the first name so the report is * sorted by last name, then first name when displayed. * * param array $a * param array $b * * return array $retval Returns the sorted names, by last name, then first name (if needed) */ public function sort_by_name( $a, $b ) { $retval = strnatcmp( $a['slushman_staff_dir_last_name'], $b['slushman_staff_dir_last_name'] ); if ( !$retval ) { return strnatcmp( $a['slushman_staff_dir_first_name'], $b['slushman_staff_dir_first_name'] ); } return $retval; } // End of sort_by_name() } // End of Slushman_Toolkit class } // End of class_exists check ?>