Astra_Ext_Advanced_Hooks_Meta::enable_php_markup( object $post )
Markup for checkbox for execute php snippet.
Description
Parameters
- $post
-
(object) (Required) Post Object.
Source
File: addons/advanced-hooks/classes/class-astra-ext-advanced-hooks-meta.php
public function enable_php_markup( $post ) {
if ( ! $post ) {
global $post;
}
$editor_type = get_post_meta( $post->ID, 'editor_type', true );
if ( ASTRA_ADVANCED_HOOKS_POST_TYPE == $post->post_type ) {
wp_nonce_field( basename( __FILE__ ), ASTRA_ADVANCED_HOOKS_POST_TYPE );
$stored = get_post_meta( $post->ID );
// Set stored and override defaults.
foreach ( $stored as $key => $value ) {
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
}
// Get defaults.
$meta = self::get_meta_option();
/**
* Get options.
*/
$with_php = ( isset( $meta['ast-advanced-hook-with-php']['default'] ) ) ? $meta['ast-advanced-hook-with-php']['default'] : '';
$editor_type = ( isset( $meta['editor_type']['default'] ) ) ? $meta['editor_type']['default'] : 'wordpress_editor';
$enable_label = __( 'Enable Code Editor', 'astra-addon' );
$disable_label = __( 'Enable WordPress Editor', 'astra-addon' );
global $pagenow;
$icon = 'dashicons-editor-code';
$label = $enable_label;
if ( ( 'post-new.php' === $pagenow && isset( $_GET['code_editor'] ) ) || isset( $_GET['code_editor'] ) || 'enabled' === $with_php ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$editor_type = 'code_editor';
$icon = 'dashicons-edit';
$label = $disable_label;
}
if ( isset( $_GET['wordpress_editor'] ) || 'wordpress_editor' === $editor_type ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$editor_type = 'wordpress_editor';
$icon = 'dashicons-editor-code';
$label = $enable_label;
}
?>
<div class="ast-advanced-hook-enable-php-wrapper">
<button type="button" class="ast-advanced-hook-enable-php-btn button button-primary button-large" data-enable-text="<?php echo esc_attr( $enable_label ); ?>" data-editor-type="<?php echo esc_attr( $editor_type ); ?>" data-disable-text="<?php echo esc_attr( $disable_label ); ?>" >
<i class="dashicons <?php echo esc_attr( $icon ); ?>"></i>
<span class="ast-btn-title"><?php echo esc_html( $label ); ?></span>
<input type="hidden" class="ast-advanced-hook-with-php" name="ast-advanced-hook-with-php" value="<?php echo esc_attr( $with_php ); ?>" />
</button>
</div>
<?php
}
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |