예제 #1
0
 /**
  * @covers \PressBooks\Sanitize\sanitize_xml_id
  */
 public function test_sanitize_xml_id()
 {
     $var = "Hello-World!";
     $test = $this->_generateControlCharacters() . $var;
     $test = \PressBooks\Sanitize\sanitize_xml_id($test);
     $this->assertEquals('Hello-World', $test);
     $var = " Héllö Wôrld! ";
     $test = \PressBooks\Sanitize\sanitize_xml_id($var);
     $this->assertEquals('HelloWorld', $test);
     $var = '123';
     $test = \PressBooks\Sanitize\sanitize_xml_id($var);
     $this->assertStringStartsWith('slug-123', $test);
     $var = "こんにちは世界!";
     $test = \PressBooks\Sanitize\sanitize_xml_id($var);
     $this->assertStringStartsWith('slug-', $test);
 }
예제 #2
0
 /**
  * Check a post_name against a list of reserved IDs, sanitize for use as an XML ID.
  *
  * @param string $id
  *
  * @return string
  */
 protected function preProcessPostName($id)
 {
     if (in_array($id, $this->reservedIds)) {
         $id = uniqid("{$id}-");
     }
     return \PressBooks\Sanitize\sanitize_xml_id($id);
 }