init_navigation_links();
}
private function init_navigation_links() {
/**
* @var SitePress $sitepress
* @var TranslationManagement $iclTranslationManagement
*/
global $sitepress, $iclTranslationManagement;
$is_admin = current_user_can( 'manage_options' );
$this->mcsetup_sections['ml-content-setup-sec-1'] = esc_html__( 'How to translate posts and pages', 'wpml-translation-management' );
if ( $is_admin ) {
$this->mcsetup_sections['ml-content-setup-sec-2'] = esc_html__( 'Posts and pages synchronization', 'wpml-translation-management' );
$this->mcsetup_sections['ml-content-setup-sec-3'] = esc_html__( 'Translated documents options', 'wpml-translation-management' );
$this->mcsetup_sections['ml-content-setup-sec-wp-login'] = esc_html__( 'Login and registration pages', 'wpml-translation-management' );
if ( defined( 'WPML_ST_VERSION' ) ) {
$this->mcsetup_sections['ml-content-setup-sec-4'] = esc_html__( 'Custom posts slug translation options', 'wpml-translation-management' );
}
if ( TranslationProxy::is_current_service_active_and_authenticated() ) {
$this->mcsetup_sections['ml-content-setup-sec-5'] = esc_html__( 'Translation pickup mode', 'wpml-translation-management' );
}
}
$this->mcsetup_sections['ml-content-setup-sec-5-1'] = esc_html__( 'XLIFF file options', 'wpml-translation-management' );
if ( $is_admin ) {
$this->mcsetup_sections['ml-content-setup-sec-cf'] = esc_html__( 'Custom Fields Translation', 'wpml-translation-management' );
$this->mcsetup_sections['ml-content-setup-sec-tcf'] = esc_html__( 'Custom Term Meta Translation', 'wpml-translation-management' );
$custom_posts = array();
$this->post_types = $sitepress->get_translatable_documents( true );
foreach ( $this->post_types as $k => $v ) {
$custom_posts[ $k ] = $v;
}
global $wp_taxonomies;
$custom_taxonomies = array_diff( array_keys( (array) $wp_taxonomies ), array( 'post_tag', 'category', 'nav_menu', 'link_category', 'post_format' ) );
if ( $custom_posts ) {
$this->mcsetup_sections['ml-content-setup-sec-7'] = esc_html__( 'Post Types Translation', 'wpml-translation-management' );
}
if ( $custom_taxonomies ) {
$this->mcsetup_sections['ml-content-setup-sec-8'] = esc_html__( 'Taxonomies Translation', 'wpml-translation-management' );
}
if ( ! empty( $iclTranslationManagement->admin_texts_to_translate ) && function_exists( 'icl_register_string' ) ) {
$this->mcsetup_sections['ml-content-setup-sec-9'] = esc_html__( 'Admin Strings to Translate', 'wpml-translation-management' );
}
}
$this->get_translate_link_targets_ui()->add_hooks();
$this->mcsetup_sections = apply_filters( 'wpml_mcsetup_navigation_links', $this->mcsetup_sections, $sitepress, $iclTranslationManagement );
}
protected function render_main() {
?>
build_tab_items();
$this->render_items();
?>
build_mcs_item();
$this->build_translation_notifications_item();
$this->tab_items = apply_filters( 'wpml_tm_tab_items', $this->tab_items );
}
private function build_mcs_item() {
global $sitepress;
$this->tab_items['mcsetup']['caption'] = esc_html__( 'Multilingual Content Setup', 'wpml-translation-management' );
$translate_link_targets = new WPML_Translate_Link_Target_Global_State( $sitepress );
if ( $translate_link_targets->is_rescan_required() ) {
$this->tab_items['mcsetup']['caption'] = '' . esc_html( $this->tab_items['mcsetup']['caption'] );
}
$this->tab_items['mcsetup']['callback'] = array( $this, 'build_content_mcs' );
$this->tab_items['mcsetup']['current_user_can'] = array( 'manage_options', WPML_Manage_Translations_Role::CAPABILITY );
}
private function build_translation_notifications_item() {
$this->tab_items['notifications'] = array(
'caption' => esc_html__( 'Translation Notifications', 'wpml-translation-management' ),
'current_user_can' => WPML_Manage_Translations_Role::CAPABILITY,
'callback' => array( $this, 'build_content_translation_notifications' ),
);
}
public function build_content_mcs() {
/**
* included by menu translation-management.php
*
* @var TranslationManagement $iclTranslationManagement
*/
global $sitepress, $sitepress_settings, $iclTranslationManagement;
$translate_link_targets = new WPML_Translate_Link_Target_Global_State( $sitepress );
if ( $translate_link_targets->is_rescan_required() ) {
?>
get_navigation_link( $this->get_translate_link_targets_ui()->get_id() ); ?>
render_mcsetup_navigation_links();
?>
should_show_mcsetup_section( 'ml-content-setup-sec-1' ) ) : ?>
settings['doc_translation_method'] ) ) {
$doc_translation_method = $iclTranslationManagement->settings['doc_translation_method'];
}
$isClassicEditor = (string) ICL_TM_TMETHOD_EDITOR === (string) $doc_translation_method;
$isATEEditor = (string) ICL_TM_TMETHOD_ATE === (string) $doc_translation_method;
?>
should_show_mcsetup_section( 'ml-content-setup-sec-2' ) ) : ?>
should_show_mcsetup_section( 'ml-content-setup-sec-3' ) ) : ?>
should_show_mcsetup_section( 'ml-content-setup-sec-wp-login' ) ) {
include ICL_PLUGIN_PATH . '/menu/_login_translation_options.php';
}
?>
should_show_mcsetup_section( 'ml-content-setup-sec-4' ) ) : ?>
should_show_mcsetup_section( 'ml-content-setup-sec-5' ) ) : ?>
should_show_mcsetup_section( 'ml-content-setup-sec-5-1' ) ) : ?>
build_content_mcs_custom_fields(); ?>
should_show_mcsetup_section( 'ml-content-setup-sec-7' ) ) : ?>
should_show_mcsetup_section( 'ml-content-setup-sec-9' ) ) : ?>
|
|
admin_texts_to_translate as $option_name =>
$option_value
) {
$iclTranslationManagement->render_option_writes( $option_name, $option_value );
}
?>
href="
">
|
should_show_mcsetup_section( $this->get_translate_link_targets_ui()->get_id() ) ) : ?>
get_translate_link_targets_ui()->render(); ?>
should_show_mcsetup_section( 'ml-content-setup-sec-cf' ) ) {
$menu_item_posts = $factory->create_post();
$menu_item_posts->init_data();
echo $menu_item_posts->render();
}
if ( ! empty( $wpdb->termmeta ) && $this->should_show_mcsetup_section( 'ml-content-setup-sec-tcf' ) ) {
$menu_item_terms = $factory->create_term();
$menu_item_terms->init_data();
echo $menu_item_terms->render();
}
}
public function build_content_translation_notifications() {
?>
';
foreach ( $this->mcsetup_sections as $anchor => $title ) {
echo '' . $this->get_navigation_link( $anchor ) . '';
}
echo '';
}
private function get_navigation_link( $anchor ) {
if ( array_key_exists( $anchor, $this->mcsetup_sections ) ) {
return '' . $this->mcsetup_sections[ $anchor ] . '';
}
}
/** @return bool */
private function should_show_mcsetup_section( $anchor ) {
return array_key_exists( $anchor, $this->mcsetup_sections );
}
/** @return WPML_Translate_Link_Targets_UI */
private function get_translate_link_targets_ui() {
/**
* @var SitePress $sitepress
* @var wpdb $wpdb
* @var $ICL_Pro_Translation
*/
global $sitepress, $wpdb, $ICL_Pro_Translation;
if ( ! $this->translate_link_targets_ui ) {
$this->translate_link_targets_ui = new WPML_Translate_Link_Targets_UI(
__( 'Translate Link Targets', 'wpml-translation-management' ),
$wpdb,
$sitepress,
$ICL_Pro_Translation
);
}
return $this->translate_link_targets_ui;
}
}