/**
     * Print tab content and provide two hooks.
     *
     * @return void
     */
    public function render_content()
    {
        ?>
		<form action="<?php 
        echo $this->setting->url();
        ?>
" method="post">
			<input type="hidden" name="action" value="<?php 
        echo esc_attr($this->setting->action());
        ?>
" />
			<input type="hidden" name="id" value="<?php 
        echo esc_attr($this->blog_id);
        ?>
" />
			<?php 
        echo \Inpsyde\MultilingualPress\nonce_field($this->nonce);
        $siteoption = get_site_option('inpsyde_multilingual', []);
        echo '<table class="form-table mlp-admin-settings-table">';
        $this->show_language_options($siteoption, $this->languages->get_all_languages());
        $this->show_blog_relationships($siteoption);
        /**
         * Runs at the end of but still inside the site settings table.
         *
         * @param int $blog_id Blog ID.
         */
        do_action('mlp_blogs_add_fields', $this->blog_id);
        if (has_action('mlp_blogs_add_fields_secondary')) {
            _doing_it_wrong('mlp_blogs_add_fields_secondary', 'mlp_blogs_add_fields_secondary is deprecated, use mlp_blogs_add_fields instead.', '2.1');
        }
        /**
         * @see mlp_blogs_add_fields
         * @deprecated
         */
        do_action('mlp_blogs_add_fields_secondary', $this->blog_id);
        echo '</table>';
        submit_button();
        ?>
		</form>
		<?php 
    }
    /**
     * @return void
     */
    private function print_tbody()
    {
        $rows = $this->languages->get_languages(['number' => $this->pagination_data->get_items_per_page(), 'page' => $this->pagination_data->get_current_page()]);
        if (!$rows) {
            ?>
			<tr>
				<td colspan="<?php 
            echo count($this->columns);
            ?>
">
					<p>
						<?php 
            _e('No items found. We recommend to reinstall this plugin.', 'multilingual-press');
            ?>
					</p>
				</td>
			</tr>
			<?php 
            return;
        }
        foreach ($rows as $id => $row) {
            $this->print_row($id, $row);
        }
    }
 /**
  * Update option WPLANG in DB for new sites.
  *
  * @param   int $blog_id
  * @return  void
  */
 private function update_wplang($blog_id)
 {
     $posted = $this->get_posted_language();
     if (!$posted) {
         return;
     }
     $available_language = $this->languages->get_languages(['fields' => 'wp_locale', 'conditions' => [['field' => 'http_name', 'value' => $posted]]]);
     // no results found? -> return
     if (empty($available_language)) {
         return;
     }
     // getting the first wp_locale
     $wp_locale = $available_language[0]->wp_locale;
     $available_lang_files = get_available_languages();
     if (!in_array($wp_locale, $available_lang_files, true)) {
         return;
     }
     update_blog_option($blog_id, 'WPLANG', $wp_locale);
 }
    /**
     * Renders the MultilingualPress table, and fires an action to inject markup.
     *
     * @wp-hook network_site_new_form
     *
     * @return void
     */
    public function render()
    {
        $languages = $this->languages->get_all_languages();
        ?>
		<h2>
			<?php 
        esc_html_e('MultilingualPress', 'multilingual-press');
        ?>
		</h2>
		<table class="form-table">
			<tr class="form-field">
				<th scope="row">
					<label for="mlp-site-language">
						<?php 
        esc_html_e('Language', 'multilingual-press');
        ?>
					</label>
				</th>
				<td>
					<select name="inpsyde_multilingual_lang" id="mlp-site-language" autocomplete="off">
						<option value="-1">
							<?php 
        esc_html_e('Choose language', 'multilingual-press');
        ?>
						</option>
						<?php 
        foreach ($languages as $language) {
            ?>
							<?php 
            $this->render_language_option($language);
            ?>
						<?php 
        }
        ?>
					</select>
				</td>
			</tr>
			<tr class="form-field">
				<th scope="row">
					<label for="inpsyde_multilingual_text">
						<?php 
        esc_html_e('Alternative language title', 'multilingual-press');
        ?>
					</label>
				</th>
				<td>
					<input type="text" name="inpsyde_multilingual_text" class="regular-text"
						id="inpsyde_multilingual_text">
					<p class="description">
						<?php 
        esc_html_e('Enter a title here that you want to be displayed in the frontend instead of the default one (i.e. "My English Site")', 'multilingual-press');
        ?>
					</p>
				</td>
			</tr>
			<tr class="form-field">
				<th scope="row">
					<label for="inpsyde_multilingual_text">
						<?php 
        esc_html_e('Relationships', 'multilingual-press');
        ?>
					</label>
				</th>
				<td>
					<?php 
        $this->render_relationships();
        ?>
					<p class="description">
						<?php 
        esc_html_e('You can connect this site only to sites with an assigned language. Other sites will not show up here.', 'multilingual-press');
        ?>
					</p>
				</td>
			</tr>
			<?php 
        /**
         * Fires at the end of but still inside the MultilingualPress table on the Add New Site admin page.
         */
        do_action('mlp_after_new_blog_fields');
        ?>
		</table>
		<?php 
    }