astra_addon_get_php_snippet( int $post_id )

Get PHP snippet if enabled.


Description


Parameters

$post_id

(int) (Required) Post Id.


Return

(bool|html)


Source

File: classes/astra-addon-extended-functionality.php

function astra_addon_get_php_snippet( $post_id ) {
	$php_enabled = get_post_meta( $post_id, 'editor_type', true );
	if ( 'code_editor' === $php_enabled ) {
		$code = get_post_meta( $post_id, 'ast-advanced-hook-php-code', true );
		if ( defined( 'ASTRA_ADVANCED_HOOKS_DISABLE_PHP' ) ) {
			return $code;
		}
		ob_start();
		// @codingStandardsIgnoreStart
		eval( '?>' . $code . '<?php ' ); // phpcs:ignore Squiz.PHP.Eval.Discouraged -- Ignored PHP standards to execute PHP code snipett.
		// @codingStandardsIgnoreEnd
		return ob_get_clean();
	}
	return false;
}

Changelog

Changelog
Version Description
4.1.1 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.