HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpamazingsecret/wp-content/plugins_/send-users-email/helpers/functions.php
<?php

if ( ! function_exists( 'sue_get_roles' ) ) {
	function sue_get_roles( $remove_roles = [] ) {
		global $wp_roles;

		$all_roles = $wp_roles->roles;
		$rolesArr  = [];
		foreach ( $all_roles as $role_Slug => $role_detail ) {
			$rolesArr[ $role_Slug ] = $role_detail['name'];
		}

		// Remove un-necessary roles
		foreach ( $remove_roles as $remove_role ) {
			unset( $rolesArr[ $remove_role ] );
		}

		ksort( $rolesArr );

		return $rolesArr;
	}
}

if ( ! function_exists( 'sue_get_selected_roles' ) ) {
	function sue_get_selected_roles() {
		$options        = get_option( 'sue_send_users_email' );
		$selected_roles = $options['email_send_roles'] ?? '';

		$selected_roles   = explode( ',', $selected_roles );
		$selected_roles[] = 'administrator';

		return $selected_roles;
	}
}

if ( ! function_exists( 'sue_add_email_capability_to_roles' ) ) {
	function sue_add_email_capability_to_roles( $new_roles ) {
		$all_roles = sue_get_roles( [ 'administrator' ] );
		$new_roles = explode( ',', $new_roles );

		// First remove capability from all roles except administrator
		foreach ( $all_roles as $role_slug => $name ) {
			$role = get_role( $role_slug );
			if ( $role ) {
				$role->remove_cap( SEND_USERS_EMAIL_SEND_MAIL_CAPABILITY );
			}
		}

		// Now add capability to new roles
		foreach ( $new_roles as $new_role ) {
			$role = get_role( $new_role );
			if ( $role ) {
				$role->add_cap( SEND_USERS_EMAIL_SEND_MAIL_CAPABILITY );
			}
		}
	}
}