badah
3/16/2016 - 11:26 PM

WP - wpallimport[plugin], fill parent term in taxonomy

WP - wpallimport[plugin], fill parent term in taxonomy

<?php
/*
* WpAllImport - Fill parent term in taxonomy
* Ex:
* 1 - [match_pattern({grauacadmico[1]}, array("string1","string2"), "Parent Term")]
* 2 - [match_pattern({grauacadmico[1]}, array("string1","string2"))]
*
*/
function match_pattern($my_field, $my_array, $parent = null) {
	$result = "";
	
	foreach ($my_array as $item) {
		$result += preg_match('/'.$item.'$/im', $my_field);
	}
	
	if ($parent && $result) {
		return $parent;
	}
	
	if (!$parent && $result) {
		return $my_field;
	}
}

?>