# gmap-embed/trunk/includes/traits/CommonFunctions.php

Maps Plugin using Google Maps for WordPress – WP Google Map, version trunk. 33 lines.

- Page: https://pluginprobe.com/plugins/gmap-embed/trunk/code/includes/traits/CommonFunctions.php
- Raw: https://pluginprobe.com/plugins/gmap-embed/trunk/raw/includes/traits/CommonFunctions.php
- Modified: 2025-07-09T00:25:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gmap-embed/trunk/code/includes/traits/CommonFunctions.php#L10-L20`.

```php
<?php
namespace WGMSRM\Traits;

if (!defined('ABSPATH')) {
	exit;
}
/**
 * Trait CommonFunctions
 */
trait CommonFunctions
{

	/**
	 * Update post meta
	 *
	 * @param int    $post_id
	 * @param string $field_name
	 * @param string $value
	 */
	public function wgm_update_post_meta($post_id, $field_name, $value = '')
	{
		// Sanitize and validate input before updating post meta
		$post_id = intval($post_id);
		$field_name = sanitize_key($field_name);
		// $value should be sanitized/validated before calling this function, or sanitize here if generic
		if (!get_post_meta($post_id, $field_name)) {
			add_post_meta($post_id, $field_name, $value);
		} else {
			update_post_meta($post_id, $field_name, $value);
		}
	}
}

```
