public function new_content()
 {
     if ($this->translate_link_target_global_state->should_fix_content()) {
         if (!$this->do_new_content()) {
             $this->translate_link_target_global_state->set_rescan_required();
         }
     }
 }
 public function run()
 {
     if (wp_verify_nonce($this->post_data['nonce'], 'WPML_Ajax_Update_Link_Targets')) {
         $this->translate_link_target_global_state->clear_rescan_required();
         $last_processed = $this->translate_link_targets->fix($this->post_data['last_processed'], $this->post_data['number_to_process']);
         return new WPML_Ajax_Response(true, array('last_processed' => (int) $last_processed, 'number_left' => $last_processed ? $this->translate_link_targets->get_number_to_be_fixed($last_processed + 1) : 0, 'links_fixed' => $this->translate_link_targets->get_number_of_links_that_were_fixed()));
     } else {
         return new WPML_Ajax_Response(false, 'wrong nonce');
     }
 }
    public function build_content_mcs()
    {
        /**
         * included by menu translation-management.php
         *
         * @uses TranslationManagement
         */
        global $sitepress, $iclTranslationManagement, $wpdb, $ICL_Pro_Translation;
        $doc_translation_method = isset($iclTranslationManagement->settings['doc_translation_method']) ? (int) $iclTranslationManagement->settings['doc_translation_method'] : ICL_TM_TMETHOD_MANUAL;
        $translate_link_targets_ui = new WPML_Translate_Link_Targets_UI('ml-content-setup-sec-10', __('Translate Link Targets', 'wpml-translation-management'), $wpdb, $sitepress, $ICL_Pro_Translation);
        $translate_link_targets = new WPML_Translate_Link_Target_Global_State($sitepress);
        if ($translate_link_targets->is_rescan_required()) {
            ?>
			    <div class="update-nag">
				    <p><i class="otgs-ico-warning"></i> <?php 
            echo esc_html__('There is new translated content on this site. You can scan posts and strings to adjust links to point to translated content.', 'wpml-translation-management');
            ?>
</p>
				    <p><?php 
            $translate_link_targets_ui->render_top_link();
            ?>
</p>
			    </div>
		    <?php 
        }
        ?>

        <ul class="wpml-navigation-links js-wpml-navigation-links">
            <li><a href="#ml-content-setup-sec-1"><?php 
        _e('How to translate posts and pages', 'wpml-translation-management');
        ?>
</a></li>
            <li><a href="#ml-content-setup-sec-2"><?php 
        _e('Posts and pages synchronization', 'wpml-translation-management');
        ?>
</a></li>
            <li>
                <a href="#ml-content-setup-sec-3"><?php 
        _e('Translated documents options', 'wpml-translation-management');
        ?>
</a>
            </li>
            <?php 
        if (defined('WPML_ST_VERSION')) {
            ?>
                <li>
                    <a href="#ml-content-setup-sec-4"><?php 
            _e('Custom posts slug translation options', 'wpml-string-translation');
            ?>
</a>
                </li>
            <?php 
        }
        ?>
            <li>
                <a href="#ml-content-setup-sec-5"><?php 
        _e('Translation pickup mode', 'wpml-translation-management');
        ?>
</a>
            </li>
                <li><a href="#ml-content-setup-sec-5-1"><?php 
        _e('XLIFF file options', 'wpml-xliff');
        ?>
</a></li>
            <li>
                <a href="#ml-content-setup-sec-cf"><?php 
        _e('Custom fields translation', 'wpml-translation-management');
        ?>
</a>
            </li>
            <?php 
        $custom_posts = array();
        $this->post_types = $sitepress->get_translatable_documents(true);
        foreach ($this->post_types as $k => $v) {
            if (!in_array($k, array('post', 'page'))) {
                $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'));
        ?>
            <?php 
        if ($custom_posts) {
            ?>
                <li><a href="#ml-content-setup-sec-7"><?php 
            _e('Custom posts', 'wpml-translation-management');
            ?>
</a>
                </li>
            <?php 
        }
        ?>
            <?php 
        if ($custom_taxonomies) {
            ?>
                <li><a href="#ml-content-setup-sec-8"><?php 
            _e('Custom taxonomies', 'wpml-translation-management');
            ?>
</a>
                </li>
            <?php 
        }
        ?>
            <?php 
        if (!empty($iclTranslationManagement->admin_texts_to_translate) && function_exists('icl_register_string')) {
            ?>
                <li>
                    <a href="#ml-content-setup-sec-9"><?php 
            _e('Admin Strings to Translate', 'wpml-translation-management');
            ?>
</a>
                </li>
            <?php 
        }
        ?>
	        <li>
	            <?php 
        $translate_link_targets_ui->render_top_link();
        ?>
	        </li>
        </ul>

        <div class="wpml-section wpml-section-notice">
            <div class="updated below-h2">
                <p>
                    <?php 
        _e("WPML can read a configuration file that tells it what needs translation in themes and plugins. The file is named wpml-config.xml and it's placed in the root folder of the plugin or theme.", 'wpml-translation-management');
        ?>
                </p>

                <p>
                    <a href="https://wpml.org/?page_id=5526"><?php 
        _e('Learn more', 'wpml-translation-management');
        ?>
</a>
                </p>
            </div>
        </div>

        <div class="wpml-section" id="ml-content-setup-sec-1">

            <div class="wpml-section-header">
                <h3><?php 
        _e('How to translate posts and pages', 'wpml-translation-management');
        ?>
</h3>
            </div>

            <div class="wpml-section-content">

                <form id="icl_doc_translation_method" name="icl_doc_translation_method" action="">
                    <?php 
        wp_nonce_field('icl_doc_translation_method_nonce', '_icl_nonce');
        ?>

                    <ul class="t_method">
                        <li>
	                        <label>
		                        <input type="radio" name="t_method" value="<?php 
        echo ICL_TM_TMETHOD_MANUAL;
        ?>
"
		                               <?php 
        if (!$doc_translation_method) {
            ?>
checked="checked"<?php 
        }
        ?>
 />
		                        <?php 
        _e('Create translations manually', 'wpml-translation-management');
        ?>
	                        </label>
                        </li>
	                    <li>
		                    <label>
			                    <input type="radio" name="t_method" value="<?php 
        echo ICL_TM_TMETHOD_EDITOR;
        ?>
"
			                           <?php 
        if ($doc_translation_method) {
            ?>
checked="checked"<?php 
        }
        ?>
 />
			                    <?php 
        _e('Use the translation editor', 'wpml-translation-management');
        ?>
		                    </label>
	                    </li>
                    </ul>

	                <?php 
        do_action('wpml_doc_translation_method_below');
        ?>

	                <p id="tm_block_retranslating_terms"><label>
                            <input name="tm_block_retranslating_terms"
                                   value="1" <?php 
        checked(icl_get_setting('tm_block_retranslating_terms'), "1");
        ?>
                                   type="checkbox"/>
                            <?php 
        esc_html_e("Don't include already translated terms in the translation editor", 'wpml-translation-management');
        ?>
                        </label>
                    </p>

                    <p>
                        <label>
                            <input name="how_to_translate"
                                   value="1" <?php 
        checked(icl_get_setting('hide_how_to_translate'), false);
        ?>
                                   type="checkbox"/>
                            <?php 
        _e('Show translation instructions in the list of pages', 'wpml-translation-management');
        ?>
                        </label>
                    </p>
	                
	                <?php 
        do_action('wpml_how_to_translate_posts_and_pages');
        ?>

	                <?php 
        do_action('wpml_how_to_translate_posts_and_pages_below');
        ?>

                    <p>
                        <a href="https://wpml.org/?page_id=3416"
                           target="_blank"><?php 
        _e('Learn more about the different translation options', 'wpml-translation-management');
        ?>
</a>
                    </p>

                    <p class="buttons-wrap">
                        <span class="icl_ajx_response" id="icl_ajx_response_dtm"></span>
                        <input type="submit" class="button-primary"
                               value="<?php 
        _e('Save', 'wpml-translation-management');
        ?>
"/>
                    </p>

                </form>
            </div>
            <!-- .wpml-section-content -->

        </div> <!-- .wpml-section -->

        <?php 
        include ICL_PLUGIN_PATH . '/menu/_posts_sync_options.php';
        ?>

        <div class="wpml-section" id="ml-content-setup-sec-3">

            <div class="wpml-section-header">
                <h3><?php 
        _e('Translated documents options', 'wpml-translation-management');
        ?>
</h3>
            </div>

            <div class="wpml-section-content">

                <form name="icl_tdo_options" id="icl_tdo_options" action="">
                    <?php 
        wp_nonce_field('icl_tdo_options_nonce', '_icl_nonce');
        ?>

                    <div class="wpml-section-content-inner">
                        <h4>
                            <?php 
        _e('Document status', 'wpml-translation-management');
        ?>
                        </h4>
                        <ul>
                            <li>
                                <label>
                                    <input type="radio" name="icl_translated_document_status" value="0"
	                                    <?php 
        checked((bool) icl_get_setting('translated_document_status'), false);
        ?>
 />
                                    <?php 
        _e('Draft', 'wpml-translation-management');
        ?>
                                </label>
                            </li>
                            <li>
                                <label>
                                    <input type="radio" name="icl_translated_document_status" value="1"
	                                    <?php 
        checked((bool) icl_get_setting('translated_document_status'), true);
        ?>
 />
                                    <?php 
        _e('Same as the original document', 'wpml-translation-management');
        ?>
                                </label>
                            </li>
                        </ul>
                        <p class="explanation-text">
                            <?php 
        _e('Choose if translations should be published when received. Note: If Publish is selected, the translation will only be published if the original document is published when the translation is received.', 'wpml-translation-management');
        ?>
                        </p>
                    </div>

                    <div class="wpml-section-content-inner">
                        <h4>
                            <?php 
        _e('Page URL', 'wpml-translation-management');
        ?>
                        </h4>
                        <ul>
                            <li>
                                <label><input type="radio" name="icl_translated_document_page_url" value="auto-generate"
                                              <?php 
        if (empty($sitepress_settings['translated_document_page_url']) || $sitepress_settings['translated_document_page_url'] == 'auto-generate') {
            ?>
checked="checked"<?php 
        }
        ?>
 />
                                    <?php 
        _e('Auto-generate from title (default)', 'wpml-translation-management');
        ?>
                                </label>
                            </li>
                            <li>
                                <label><input type="radio" name="icl_translated_document_page_url" value="translate"
                                              <?php 
        if ($sitepress_settings['translated_document_page_url'] == 'translate') {
            ?>
checked="checked"<?php 
        }
        ?>
 />
                                    <?php 
        _e('Translate (this will include the slug in the translation and not create it automatically from the title)', 'wpml-translation-management');
        ?>
                                </label>
                            </li>
                            <li>
                                <label><input type="radio" name="icl_translated_document_page_url" value="copy-encoded"
                                              <?php 
        if ($sitepress_settings['translated_document_page_url'] == 'copy-encoded') {
            ?>
checked="checked"<?php 
        }
        ?>
 />
                                    <?php 
        _e('Copy from original language if translation language uses encoded URLs', 'wpml-translation-management');
        ?>
                                </label>
                            </li>
                        </ul>
                    </div>

                    <div class="wpml-section-content-inner">
                        <p class="buttons-wrap">
                            <span class="icl_ajx_response" id="icl_ajx_response_tdo"></span>
                            <input type="submit" class="button-primary"
                                   value="<?php 
        _e('Save', 'wpml-translation-management');
        ?>
"/>
                        </p>
                    </div>

                </form>
            </div>
            <!-- .wpml-section-content -->

        </div> <!-- .wpml-section -->

        <?php 
        if (defined('WPML_ST_VERSION')) {
            include WPML_ST_PATH . '/menu/_slug-translation-options.php';
        }
        ?>

        <div class="wpml-section" id="ml-content-setup-sec-5">

            <div class="wpml-section-header">
                <h3><?php 
        _e('Translation pickup mode', 'wpml-translation-management');
        ?>
</h3>
            </div>

            <div class="wpml-section-content">

                <form id="icl_translation_pickup_mode" name="icl_translation_pickup_mode" action="">
                    <?php 
        wp_nonce_field('set_pickup_mode_nonce', '_icl_nonce');
        ?>

                    <p>
                        <?php 
        echo __('How should the site receive completed translations from Translation Service?', 'wpml-translation-management');
        ?>
                    </p>

                    <p>
                        <label>
                            <input type="radio" name="icl_translation_pickup_method"
                                   value="<?php 
        echo ICL_PRO_TRANSLATION_PICKUP_XMLRPC;
        ?>
"
                                   <?php 
        if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_XMLRPC) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
                            <?php 
        echo __('Translation Service will deliver translations automatically using XML-RPC', 'wpml-translation-management');
        ?>
                        </label>
                    </p>

                    <p>
                        <label>
                            <input type="radio" name="icl_translation_pickup_method"
                                   value="<?php 
        echo ICL_PRO_TRANSLATION_PICKUP_POLLING;
        ?>
"
                                   <?php 
        if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_POLLING) {
            ?>
checked="checked"<?php 
        }
        ?>
 />
                            <?php 
        _e('The site will fetch translations manually', 'wpml-translation-management');
        ?>
                        </label>
                    </p>


                    <p class="buttons-wrap">
                        <span class="icl_ajx_response" id="icl_ajx_response_tpm"></span>
                        <input class="button-primary" name="save"
                               value="<?php 
        _e('Save', 'wpml-translation-management');
        ?>
" type="submit"/>
                    </p>

                    <?php 
        $this->build_content_dashboard_fetch_translations_box();
        ?>
                </form>

            </div>
            <!-- .wpml-section-content -->

        </div> <!-- .wpml-section -->

        <?php 
        include WPML_TM_PATH . '/menu/xliff-options.php';
        $this->build_content_mcs_custom_fields();
        include ICL_PLUGIN_PATH . '/menu/_custom_types_translation.php';
        ?>

        <?php 
        if (!empty($iclTranslationManagement->admin_texts_to_translate) && function_exists('icl_register_string')) {
            //available only with the String Translation plugin
            ?>
        <div class="wpml-section" id="ml-content-setup-sec-9">

            <div class="wpml-section-header">
                <h3><?php 
            _e('Admin Strings to Translate', 'wpml-translation-management');
            ?>
</h3>
            </div>

            <div class="wpml-section-content">
                <table class="widefat">
                    <thead>
                    <tr>
                        <th colspan="3">
                            <?php 
            _e('Admin Strings', 'wpml-translation-management');
            ?>
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>
                            <?php 
            foreach ($iclTranslationManagement->admin_texts_to_translate as $option_name => $option_value) {
                $iclTranslationManagement->render_option_writes($option_name, $option_value);
            }
            ?>
                            <br/>

                            <p><a class="button-secondary"
                                  href="<?php 
            echo admin_url('admin.php?page=' . WPML_ST_FOLDER . '/menu/string-translation.php');
            ?>
"><?php 
            _e('Edit translatable strings', 'wpml-translation-management');
            ?>
</a>
                            </p>
                        </td>
                    </tr>
                    </tbody>
                </table>

            </div>
            <!-- .wpml-section-content -->

        </div> <!-- .wpml-section -->
    <?php 
        }
        $translate_link_targets_ui->render();
        wp_enqueue_script('wpml-tm-mcs');
        wp_enqueue_script('wpml-tm-mcs-translate-link-targets');
    }