INVP::untranslate_custom_field_names( string $meta_key )

untranslate_custom_field_names


Description Description

Removes the prefix from our post meta field keys so 'inventory_presser_make' becomes 'make'. Careful to not damage any provided key that does not start with our prefix.


Top ↑

Parameters Parameters

$meta_key

(string) (Required) The prefixed meta key.


Top ↑

Return Return

(string) The un-prefixed meta key.


Top ↑

Source Source

File: includes/class-invp.php

	public static function untranslate_custom_field_names( $meta_key )
	{
		if( empty( $meta_key ) )
		{
			return '';
		}
		$meta_key = strtolower( $meta_key );
		//prefix may start with an underscore because previous versions hid some meta keys
		$prefix = ( '_' == $meta_key[0] ? '_' : '' ) . INVP::meta_prefix();

		//does $meta_key actually start with the $prefix?
		if( $prefix == substr( $meta_key, 0, strlen( $prefix ) ) )
		{
			//remove the prefix
			return substr( $meta_key, strlen( $prefix ) );
		}

		return $meta_key;
	}