# code-snippets/3.10.2/php/Flat_Files/Handlers/Content_Snippet_Handler.php

Code Snippets, version 3.10.2. 41 lines.

- Page: https://pluginprobe.com/plugins/code-snippets/3.10.2/code/php/Flat_Files/Handlers/Content_Snippet_Handler.php
- Raw: https://pluginprobe.com/plugins/code-snippets/3.10.2/raw/php/Flat_Files/Handlers/Content_Snippet_Handler.php
- Modified: 2026-06-19T15:56:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-snippets/3.10.2/code/php/Flat_Files/Handlers/Content_Snippet_Handler.php#L10-L20`.

```php
<?php

namespace Code_Snippets\Flat_Files\Handlers;

use Code_Snippets\Flat_Files\Interfaces\Snippet_Type_Handler;

/**
 * Snippet type handler for content snippets.
 */
class Content_Snippet_Handler implements Snippet_Type_Handler {

	/**
	 * Set 'php' as the file extension for content snippets, as they can contain embedded PHP code.
	 *
	 * @return string
	 */
	public function get_file_extension(): string {
		return 'php';
	}

	/**
	 * Store content snippets in an 'html' directory.
	 *
	 * @return string
	 */
	public function get_dir_name(): string {
		return 'html';
	}

	/**
	 * Wrap content snippets by adding a header that disallows direct access.
	 *
	 * @param string $code Content snippet code.
	 *
	 * @return string Content snippet code with header prepended.
	 */
	public function wrap_code( string $code ): string {
		return "<?php\n\nif ( ! defined( 'ABSPATH' ) ) { return; }\n\n?>\n\n" . $code;
	}
}

```
