Skip to content

Commit

Permalink
Add prefix argument
Browse files Browse the repository at this point in the history
  • Loading branch information
alwaysblank committed Oct 1, 2020
1 parent 86f57c6 commit 3cf729b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,20 @@ private function installEcptsWarning()
EOT;
});
}

/**
* Prefix a string w/ the post type string.
* Optionally pass a second argument to override the default "_" separator.
*
* This is especially useful for things like field naming.
*
* @param string $string
* @param string $separator
*
* @return string
*/
public function prefix(string $string, string $separator = "_"): string
{
return sprintf("%s%s%s", $this->type, $separator, $string);
}
}

0 comments on commit 3cf729b

Please sign in to comment.