post_type ) || ! Languages::targets() || ! Roles::can_translate() ) { return; } $asset_file = TRANSLATEPLUS_DIR . 'build/editor.asset.php'; if ( ! is_readable( $asset_file ) ) { return; } $asset = require $asset_file; wp_enqueue_script( 'translateplus-editor', TRANSLATEPLUS_URL . 'build/editor.js', $asset['dependencies'], $asset['version'], true ); wp_add_inline_script( 'translateplus-editor', 'window.translateplusRest = ' . wp_json_encode( array( 'root' => esc_url_raw( rest_url() ) ) ) . ';', 'before' ); wp_add_inline_script( 'translateplus-editor', 'window.translateplusLogo = ' . wp_json_encode( TRANSLATEPLUS_URL . 'assets/images/logo.png' ) . ';', 'before' ); if ( is_readable( TRANSLATEPLUS_DIR . 'build/editor.css' ) ) { wp_enqueue_style( 'translateplus-editor', TRANSLATEPLUS_URL . 'build/editor.css', array(), $asset['version'] ); } wp_set_script_translations( 'translateplus-editor', 'translateplus', TRANSLATEPLUS_DIR . 'languages' ); } /** * Classic editor only; the block editor uses the sidebar panel. * * @param string $post_type Post type. * @param \WP_Post $post Post. */ public function meta_box( $post_type, $post ): void { if ( ! PostTypes::is_translatable( (string) $post_type ) || ! Languages::targets() || ! Roles::can_translate() ) { return; } add_meta_box( 'translateplus', __( 'Translations', 'translateplus' ), array( $this, 'render_meta_box' ), $post_type, 'side', 'high', array( '__back_compat_meta_box' => true ) ); } public function render_meta_box( \WP_Post $post ): void { if ( 'auto-draft' === $post->post_status ) { echo '
' . esc_html__( 'Save the post to translate it.', 'translateplus' ) . '
'; return; } $status = TranslationsController::post_status( $post ); if ( $status['is_translation'] ) { printf( '%s %s
', /* translators: %s: language */ esc_html( sprintf( __( '%s translation of', 'translateplus' ), Languages::name( $status['language'] ) ) ), esc_url( (string) $status['source_edit_url'] ), esc_html( $status['source_title'] ) ); $url = admin_url( 'admin.php?page=translateplus-editor&post=' . $status['source_id'] . '&lang=' . rawurlencode( $status['language'] ) ); echo '' . esc_html__( 'Open side-by-side editor', 'translateplus' ) . '
'; return; } $labels = array( 'translated' => __( 'Translated', 'translateplus' ), 'outdated' => __( 'Outdated', 'translateplus' ), 'review' => __( 'Needs review', 'translateplus' ), 'manual' => __( 'Edited manually', 'translateplus' ), 'missing' => __( 'Not translated', 'translateplus' ), ); echo '