/**
     * @param array $site_option
     * @return void
     */
    private function show_blog_relationships($site_option)
    {
        if (!is_array($site_option)) {
            return;
        }
        unset($site_option[$this->blog_id]);
        if (empty($site_option)) {
            return;
        }
        ?>
		<tr>
			<td><?php 
        esc_html_e('Relationships', 'multilingualpress');
        ?>
</td>
			<td>
		<?php 
        foreach ($site_option as $blog_id => $meta) {
            $blog_id = (int) $blog_id;
            // Get blog display name
            switch_to_blog($blog_id);
            $blog_name = esc_html(get_bloginfo('Name'));
            restore_current_blog();
            // Get current settings
            $related_blogs = $this->relations->get_related_sites($this->blog_id, FALSE);
            $checked = checked(TRUE, in_array($blog_id, $related_blogs), FALSE);
            $id = "related_blog_{$blog_id}";
            ?>
			<p>
				<label for="<?php 
            echo $id;
            ?>
">
					<input id="<?php 
            echo $id;
            ?>
" <?php 
            echo $checked;
            ?>
 type="checkbox" name="related_blogs[]" value="<?php 
            echo $blog_id;
            ?>
" />
					<?php 
            echo $blog_name;
            ?>
 - <?php 
            echo Mlp_Helpers::get_blog_language($blog_id);
            ?>
				</label>
			</p>
			<?php 
        }
        ?>
		<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.', 'multilingualpress');
        ?>
		</p>
			</td>
		</tr>
		<?php 
    }
Пример #2
0
    /**
     * Print tab content and provide two hooks.
     *
     * @return void
     */
    public function render_content()
    {
        $languages = $this->language_api->get_db()->get_items(array('page' => -1));
        ob_start();
        ?>
		<h3>MultilingualPress</h3>
		<table class="form-table">
			<tr class="form-field">
				<td>
					<label for="inpsyde_multilingual_lang">
						<?php 
        esc_html_e('Language', 'multilingualpress');
        ?>
					</label>
				</td>
				<td>
					<select name="inpsyde_multilingual_lang" id="inpsyde_multilingual_lang">
						<option value="-1"><?php 
        esc_html_e('Choose language', 'multilingualpress');
        ?>
</option>
						<?php 
        foreach ($languages as $language) {
            // missing HTTP code
            if (empty($language->http_name)) {
                continue;
            }
            echo '<option value="' . esc_attr($language->http_name) . '">' . $language->english_name . '/' . $language->native_name . '</option>';
        }
        ?>
					</select>
				</td>
			</tr>
			<tr class="form-field">
				<td>
					<label for="inpsyde_multilingual_text">
						<?php 
        esc_html_e('Alternative language title', 'multilingualpress');
        ?>
					</label>
				</td>
				<td>
					<input class="regular-text" type="text" id="inpsyde_multilingual_text" name="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")', 'multilingualpress');
        ?>
</p>
				</td>
			</tr>
			<tr class="form-field">
				<td>
					<label for="inpsyde_multilingual_text">
						<?php 
        esc_html_e('Relationships', 'multilingualpress');
        ?>
					</label>
				</td>
				<td><?php 
        $site_option = get_site_option('inpsyde_multilingual', array());
        foreach ($site_option as $blog_id => $meta) {
            $blog_id = (int) $blog_id;
            // Get blog display name
            switch_to_blog($blog_id);
            $blog_name = esc_html(get_bloginfo('Name'));
            restore_current_blog();
            $id = "related_blog_{$blog_id}";
            ?>
						<p>
							<label for="<?php 
            echo $id;
            ?>
">
								<input style="width:auto;" id="<?php 
            echo $id;
            ?>
" type="checkbox" name="related_blogs[]" value="<?php 
            echo $blog_id;
            ?>
" />
								<?php 
            echo $blog_name;
            ?>
 - <?php 
            echo Mlp_Helpers::get_blog_language($blog_id);
            ?>
							</label>
						</p>
						<?php 
        }
        ?>
					<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.', 'multilingualpress');
        ?>
					</p>
				</td>
			</tr>

			<?php 
        do_action('mlp_after_new_blog_fields');
        ?>
		</table>
		<?php 
        $template = ob_get_contents();
        ob_end_clean();
        ?>
		<script>
			( function( $ ) {
				$(document).ready( function(){

					var submit      = $( 'form' ).find( '.submit' ),
						template    = '<?php 
        echo str_replace("\n", "", $template);
        ?>
'
					;

					submit.before( template );

				} );
			} )( jQuery );
		</script>

		<?php 
    }
/**
 * get the blog language
 *
 * @since	0.7
 * @return	string Second part of language identifier
 */
function get_blog_language($blog_id = 0)
{
    return Mlp_Helpers::get_blog_language($blog_id);
}
Пример #4
0
/**
 * get the blog language
 *
 * @param  int  $blog_id
 * @param  bool $short Return only the first part of the language code.
 * @return string Second part of language identifier
 */
function get_blog_language($blog_id = 0, $short = TRUE)
{
    return Mlp_Helpers::get_blog_language($blog_id, $short);
}
    /**
     * Renders the relationship settings.
     *
     * @return void
     */
    private function render_relationships()
    {
        $sites = get_site_option('inpsyde_multilingual', array());
        foreach (array_keys($sites) as $site_id) {
            $site_id = (int) $site_id;
            $id = "related_blog_{$site_id}";
            switch_to_blog($site_id);
            $blog_name = get_bloginfo('name');
            restore_current_blog();
            ?>
			<p>
				<label for="<?php 
            echo $id;
            ?>
">
					<input type="checkbox" name="related_blogs[]" value="<?php 
            echo $site_id;
            ?>
"
						id="<?php 
            echo $id;
            ?>
">
					<?php 
            echo esc_html($blog_name) . '-' . Mlp_Helpers::get_blog_language($site_id);
            ?>
				</label>
			</p>
			<?php 
        }
    }
Пример #6
0
 /**
  * Deprecated! Return the language for the given blog.
  *
  * @param int  $blog_id Blog ID.
  * @param bool $short   Return only the first part of the language code?
  *
  * @return string
  */
 function get_blog_language($blog_id = 0, $short = TRUE)
 {
     _deprecated_function(__FUNCTION__, '2.2.0', 'mlp_get_blog_language');
     return Mlp_Helpers::get_blog_language($blog_id, $short);
 }