This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Astra_Ext_Advanced_Hooks_Meta::maybe_render_snippet_state_notice( int $post_id )
Explain the stored snippet’s front-end state when it is not the obvious one.
Description
Parameters
- $post_id
-
(int) (Required) Post Id.
Return
(void)
Source
File: addons/advanced-hooks/classes/class-astra-ext-advanced-hooks-meta.php
private function maybe_render_snippet_state_notice( $post_id ) {
// Code meta is retained when a layout switches to the WordPress editor, so this would
// otherwise fire on layouts that have no code editor at all.
if ( ! ASTRA_WITH_EXTENDED_FUNCTIONALITY || ! astra_addon_is_code_editor_layout( $post_id ) ) {
return;
}
$code = get_post_meta( $post_id, 'ast-advanced-hook-php-code', true );
if ( ! is_string( $code ) || '' === $code ) {
return;
}
$author_id = (int) get_post_field( 'post_author', $post_id );
// Same predicate as the front end, so this cannot disagree with what actually runs.
if ( astra_addon_is_snippet_executable() ) {
if ( user_can( $author_id, 'manage_options' ) ) {
return;
}
$detail = get_userdata( $author_id )
? __( 'The user it is assigned to is no longer an administrator.', 'astra-addon' )
: __( 'The user it was assigned to no longer exists.', 'astra-addon' );
?>
<div class="notice notice-info inline ast-advanced-hook-snippet-orphaned">
<p>
<strong><?php esc_html_e( 'This snippet is running.', 'astra-addon' ); ?></strong>
<?php echo esc_html( $detail ); ?>
<?php esc_html_e( 'Only administrators can create or edit these layouts, so this code is still trusted and runs. Review it below and clear it if it should no longer run.', 'astra-addon' ); ?>
</p>
</div>
<?php
return;
}
?>
<div class="notice notice-warning inline ast-advanced-hook-snippet-inactive">
<p>
<strong><?php esc_html_e( 'This snippet is not running.', 'astra-addon' ); ?></strong>
<?php esc_html_e( 'PHP execution is disabled on this site, so the code is not executed and is stripped from the front end.', 'astra-addon' ); ?>
</p>
</div>
<?php
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 4.13.8 | Introduced. |