registry->registry('mageplaza_blog_post'); if (!$post || !$post->getId() || !$this->authorization->isAllowed('Esun_MultiLocaleTranslation::translate_blog') ) { return []; } $config = [ 'entityType' => 'blog_post', 'entityId' => (int)$post->getId(), 'sourceStoreId' => max(0, (int)$subject->getRequest()->getParam('store')), 'storesUrl' => $subject->getUrl('localetranslate/translation/stores'), 'fieldsUrl' => $subject->getUrl('localetranslate/translation/fields'), 'applyUrl' => $subject->getUrl('localetranslate/translation/apply'), 'autoTranslateUrl' => $subject->getUrl('localetranslate/translation/autotranslate'), ]; $configJson = (string)json_encode( $config, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); $subject->addButton('localetranslate_translate', [ 'label' => __('Translate'), 'class' => 'action-secondary', 'onclick' => sprintf( "require(['Esun_MultiLocaleTranslation/js/translate-modal'], function (openModal) { openModal(%s); });", $configJson ), 'sort_order' => 30, ], 0, 30); return []; } }