/** * Hash a given text. * * Called whenever a tag must be hashed when a function insert an * atomic element in the text stream. Passing $text to through this * function gives a unique text-token which will be reverted back when * calling unhash. * * @param string $text The text to be hashed * * @return string Return a unique text-token which will be * reverted back when calling unhash. */ protected function hash($text) { static $counter = 0; // Swap back any tag hash found in $text so we do not have to `unhash` // multiple times at the end. $text = $this->unhash($text); // Then hash the block $key = implode("A", array('shortcodes', $this->page->id(), ++$counter, 'S')); $this->hashes[$key] = $text; // String that will replace the tag return $key; }