static function tagSubsections( $content, $id ) {
		$parent = get_post( $id );
		if ( empty( $parent ) ) {
			return false;
		}
		if ( stripos( $content, '<h1' ) === false ) {
			return false;
		}

		$type = $parent->post_type;
		$s = 1;

		$doc = new HtmlParser();
		$dom = $doc->loadHTML( $content );
		$sections = $dom->getElementsByTagName( 'h1' );
		foreach ( $sections as $section ) {
			/** @var $section \DOMElement */
			$old_id = $section->getAttribute( 'id' );
			$old_class = $section->getAttribute( 'class' );
			$new_id = "{$type}-{$id}-section-" . $s++;
			$new_class = trim( "section-header {$old_class} {$old_id}" );
			$section->setAttribute( 'id', $new_id );
			$section->setAttribute( 'class', $new_class );
		}

		return $doc->saveHTML( $dom );
	}
static function tagSubsections( $content, $id ) {
		$parent = get_post( $id );
		if ( empty( $parent ) ) {
			return false;
		}
		if ( stripos( $content, '<h1' ) === false ) {
			return false;
		}

		$type = $parent->post_type;
		$s = 1;

		$doc = new HtmlParser();
		$dom = $doc->loadHTML( $content );
		$sections = $dom->getElementsByTagName( 'h1' );
		foreach ( $sections as $section ) {
			/** @var $section \DOMElement */
			$old_id = $section->getAttribute( 'id' );
			$old_class = $section->getAttribute( 'class' );
			$new_id = "{$type}-{$id}-section-" . $s++;
			$new_class = trim( "section-header {$old_class} {$old_id}" );
			$section->setAttribute( 'id', $new_id );
			$section->setAttribute( 'class', $new_class );
		}

		return $doc->saveHTML( $dom );
	}
static function tagSubsections ( $ content , $ id ) { $ parent = get_post ( $ id ) ; if ( empty ( $ parent ) ) { return false ; } if ( stripos ( $ content , '<h1' ) === false ) { return false ; } $ type = $ parent -> post_type ; $ s = 1 ; $ doc = new HtmlParser ( ) ; $ dom = $ doc -> loadHTML ( $ content ) ; $ sections = $ dom -> getElementsByTagName ( 'h1' ) ; foreach ( $ sections as $ section ) { /** @var $section \DOMElement */ $ old_id = $ section -> getAttribute ( 'id' ) ; $ old_class = $ section -> getAttribute ( 'class' ) ; $ new_id = "{$type}-{$id}-section-" . $ s ++ ; $ new_class = trim ( "section-header {$old_class} {$old_id}" ) ; $ section -> setAttribute ( 'id' , $ new_id ) ; $ section -> setAttribute ( 'class' , $ new_class ) ; } return $ doc -> saveHTML ( $ dom ) ; }
Returns chapter, front or back matter content with section ID and classes added.

@param string $content
@param int $id

@return string|false
Returns chapter front or back matter content with section ID and classes added .