admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'aistma_content_editor_nonce' ), 'editorType' => $this->detect_editor_type(), ] ); } /** * Enqueue assets specifically for Block Editor */ public function enqueue_block_editor_assets() { // Check if the JavaScript file exists $js_file = AISTMA_PATH . 'admin/js/block-editor-integration.js'; if ( ! file_exists( $js_file ) ) { // Log missing file for debugging using WordPress logging if ( defined( 'WP_DEBUG' ) && WP_DEBUG && function_exists( 'wp_debug_log' ) ) { wp_debug_log( 'AI Content Editor: JavaScript file not found: ' . $js_file ); } return; } wp_enqueue_script( 'aistma-block-editor-js', AISTMA_URL . 'admin/js/block-editor-integration.js', [ 'wp-plugins', 'wp-edit-post', 'wp-element', 'wp-components', 'wp-data', 'wp-compose' ], filemtime( AISTMA_PATH . 'admin/js/block-editor-integration.js' ), true ); wp_localize_script( 'aistma-block-editor-js', 'aistmaBlockEditor', [ 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'aistma_content_editor_nonce' ), ] ); } /** * Add meta box for Classic Editor * * @param string $post_type Current post type */ public function add_classic_editor_meta_box( $post_type ) { if ( ! in_array( $post_type, [ 'post', 'page' ], true ) ) { return; } add_meta_box( 'aistma-content-editor', 'AI Content Editor', [ $this, 'render_classic_editor_panel' ], $post_type, 'side', 'high' ); } /** * Render Classic Editor panel * * @param \WP_Post $post Current post object */ public function render_classic_editor_panel( $post ) { ?>

Select text in the editor to start improving with AI

is_block_editor() ) { return 'block'; } // Fallback: check if classic editor is forced if ( function_exists( 'classic_editor_replace' ) ) { return 'classic'; } // Default to block editor for WordPress 5.0+ return 'block'; } }