Astra_Ext_Advanced_Hooks_Meta::add_navigation_button( object $post )
Add navigatory button to WP-Gutenberg editor.
Description
Parameters
- $post
-
(object) (Required) Post Object.
Source
File: addons/advanced-hooks/classes/class-astra-ext-advanced-hooks-meta.php
public function add_navigation_button( $post ) { if ( ! $post ) { global $post; } if ( isset( $_GET['wordpress_editor'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended update_post_meta( $post->ID, 'editor_type', 'wordpress_editor' ); } elseif ( isset( $_GET['code_editor'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended update_post_meta( $post->ID, 'editor_type', 'code_editor' ); } global $pagenow; $screen = get_current_screen(); $editor_type = get_post_meta( $post->ID, 'editor_type', true ); if ( 'code_editor' === $editor_type ) { return; } if ( ( 'post-new.php' === $pagenow ) && ASTRA_ADVANCED_HOOKS_POST_TYPE === $screen->post_type ) { $editor_type = 'wordpress_editor'; } $start_wrapper = '<script id="astra-editor-button-switch-mode" type="text/html" >'; $end_wrapper = '</script>'; $label = __( 'Enable Code Editor', 'astra-addon' ); $icon = 'dashicons-editor-code'; echo $start_wrapper; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> <div class="ast-advanced-hook-enable-php-wrapper"> <button type="button" class="ast-advanced-hook-enable-php-btn button button-primary button-large" data-editor-type="<?php echo esc_attr( $editor_type ); ?>" data-label="<?php echo esc_attr( $label ); ?>" > <i class="dashicons <?php echo esc_attr( $icon ); ?>"></i> <span class="ast-btn-title"><?php echo esc_html( $label ); ?></span> </button> </div> <?php echo $end_wrapper; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |