# insert-php/2.7.7/includes/class.snippet.php

Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts, version 2.7.7. 80 lines.

- Page: https://pluginprobe.com/plugins/insert-php/2.7.7/code/includes/class.snippet.php
- Raw: https://pluginprobe.com/plugins/insert-php/2.7.7/raw/includes/class.snippet.php
- Modified: 2026-01-19T12:10:20+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/insert-php/2.7.7/code/includes/class.snippet.php#L10-L20`.

```php
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class WINP_Snippet {

	protected $id;

	protected $type;

	public function __construct( WP_Post $snippet ) {
		$this->id = $snippet->ID;

		// todo: to refactor
		$this->type = WINP_Helper::get_snippet_type( $this->id );
	}

	public static function get_snippet( $post_id ) {
		$post_id = (int) $post_id;

		if ( ! $post_id ) {
			$snippet = get_post( $post_id );

			if ( $snippet ) {
				return new self( $snippet );
			}
		}

		return null;
	}

	public function is_allowed() {
		// If the user has prohibited the insertion of unfiltered HTML,
		// we prohibit the execution of snippets.
		if ( ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
			&& ! in_array(
				$this->type,
				[
					WINP_SNIPPET_TYPE_TEXT,
					WINP_SNIPPET_TYPE_AD,
					WINP_SNIPPET_TYPE_CSS,
				] 
			) ) {
			return false;
		}

		return true;
	}

	public function get_meta( $key ) {
		return get_post_meta( $this->id, 'wbcr_inp_' . $key, true );
	}

	public function get_scope() {
		return $this->get_meta( 'snippet_scope' );
	}

	public function get_content() {
		return $this->get_meta( 'snippet_code' );
	}

	public function is_active() {
		// WPML Compatibility
		if ( defined( 'WPML_PLUGIN_FILE' ) ) {
			$wpml_langs = $this->get_meta( 'snippet_wpml_lang' );

			if ( $wpml_langs !== '' && defined( 'ICL_LANGUAGE_CODE' ) ) {
				if ( ! in_array( ICL_LANGUAGE_CODE, explode( ',', $wpml_langs ) ) ) {
					return false;
				}
			}
		}

		// todo: протестировать
		return $this->get_meta( 'snippet_activate' );
	}
}

```
