$current_user->user_email, 'first_name' => $current_user->user_firstname, 'last_name' => $current_user->user_lastname, 'id' => $current_user->ID, ); } /** * Generates a random GUID. * * @return string The generated GUID. */ public static function new_guid() { if ( function_exists( 'com_create_guid' ) === true ) { return trim( com_create_guid(), '{}' ); } return sprintf( '%04X%04X-%04X-%04X-%04X-%04X%04X%04X', wp_rand( 0, 65535 ), wp_rand( 0, 65535 ), wp_rand( 0, 65535 ), wp_rand( 16384, 20479 ), wp_rand( 32768, 49151 ), wp_rand( 0, 65535 ), wp_rand( 0, 65535 ), wp_rand( 0, 65535 ) ); } /** * All standard WordPress user roles are considered internal * unless they have the Subscriber role. * WooCommerce uses the 'read' capability for its customer role. * Also check for the 'upload_files' capability to account for the * shop_worker and shop_vendor roles in Easy Digital Downloads. * https://wordpress.org/support/article/roles-and-capabilities * * @return bool */ public static function is_internal_user() { return current_user_can( 'edit_posts' ) || current_user_can( 'upload_files' ); } /** * Checks if a string ends with a specified substring. * * @param string $haystack The string to search in. * @param string $needle The substring to search for at the * end of $haystack. * @return bool True if $haystack ends with $needle, false otherwise. */ public static function ends_with( $haystack, $needle ) { $length = strlen( $needle ); if ( ! $length ) { return false; } return substr( $haystack, -$length ) === $needle; } /** * Checks if a string contains a specified substring. * * @param string $haystack The string to search in. * @param string $needle The substring to search for within $haystack. * @return bool True if $haystack contains $needle, false otherwise. */ public static function string_contains( $haystack, $needle ) { return (bool) strstr( $haystack, $needle ); } }