public function attachment_fields_to_edit($fields, $post) { if ($GLOBALS['pagenow'] == 'post.php') { return $fields; } // don't add anything on edit media panel for WP 3.5+ since we have the metabox $post_id = $post->ID; $lang = $this->model->get_post_language($post_id); $dropdown = new PLL_Walker_Dropdown(); $fields['language'] = array('label' => __('Language', 'polylang'), 'input' => 'html', 'html' => $dropdown->walk($this->model->get_languages_list(), array('name' => sprintf('attachments[%d][language]', $post_id), 'class' => 'media_lang_choice', 'selected' => $lang ? $lang->slug : ''))); return $fields; }
public function edit_term_form($tag) { $term_id = $tag->term_id; $lang = $this->model->get_term_language($term_id); $taxonomy = $tag->taxonomy; $post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; $dropdown = new PLL_Walker_Dropdown(); printf(' <tr class="form-field"> <th scope="row"> <label for="term_lang_choice">%s</label> </th> <td> %s<br /> <span class="description">%s</span> </td> </tr>', __('Language', 'polylang'), $dropdown->walk($this->model->get_languages_list(), array('name' => 'term_lang_choice', 'value' => 'term_id', 'selected' => $lang ? $lang->term_id : '')), __('Sets the language', 'polylang')); echo '<tr id="term-translations" class="form-field">'; if ($lang) { include PLL_ADMIN_INC . '/view-translations-term.php'; } echo '</tr>' . "\n"; }
public function post_language() { global $post_ID; $post_id = $post_ID; $post_type = get_post_type($post_ID); $lang = ($lg = $this->model->get_post_language($post_ID)) ? $lg : (isset($_GET['new_lang']) ? $this->model->get_language($_GET['new_lang']) : $this->pref_lang); $dropdown = new PLL_Walker_Dropdown(); wp_nonce_field('pll_language', '_pll_nonce'); // NOTE: the class "tags-input" allows to include the field in the autosave $_POST (see autosave.js) printf(' <p><strong>%s</strong></p> <div id="select-%s-language">%s</div> <div id="post-translations" class="translations">', __('Language', 'polylang'), $post_type == 'attachment' ? 'media' : 'post', $dropdown->walk($this->model->get_languages_list(), array('name' => $post_type == 'attachment' ? sprintf('attachments[%d][language]', $post_ID) : 'post_lang_choice', 'class' => $post_type == 'attachment' ? 'media_lang_choice' : 'tags-input', 'selected' => $lang ? $lang->slug : '', 'flag' => true))); if ($lang) { include PLL_ADMIN_INC . '/view-translations-' . ($post_type == 'attachment' ? 'media' : 'post') . '.php'; } echo '</div>' . "\n"; }
public function quick_edit_custom_box($column, $type) { if ($column == $this->get_first_language_column()) { $elements = $this->model->get_languages_list(); if (current_filter() == 'bulk_edit_custom_box') { array_unshift($elements, (object) array('slug' => -1, 'name' => __('— No Change —'))); } $dropdown = new PLL_Walker_Dropdown(); // the hidden field 'old_lang' allows to pass the old language to ajax request printf('<fieldset class="inline-edit-col-left"> <div class="inline-edit-col"> <label class="alignleft"> <span class="title">%s</span> %s </label> </div> </fieldset>', __('Language', 'polylang'), $dropdown->walk($elements, array('name' => 'inline_lang_choice', 'id' => ''))); } return $column; }
public function edit_term_form($tag) { $term_id = $tag->term_id; $lang = $this->model->get_term_language($term_id); $taxonomy = $tag->taxonomy; $post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; if (!post_type_exists($post_type)) { return; } $dropdown = new PLL_Walker_Dropdown(); // disable the language dropdown and the translations input fields for default categories to prevent removal $disabled = in_array(get_option('default_category'), $this->model->get_translations('term', $term_id)); wp_nonce_field('pll_language', '_pll_nonce'); printf(' <tr class="form-field"> <th scope="row"> <label for="term_lang_choice">%s</label> </th> <td id="select-edit-term-language"> %s<br /> <span class="description">%s</span> </td> </tr>', __('Language', 'polylang'), $dropdown->walk($this->model->get_languages_list(), array('name' => 'term_lang_choice', 'value' => 'term_id', 'selected' => $lang ? $lang->term_id : '', 'disabled' => $disabled, 'flag' => true)), __('Sets the language', 'polylang')); echo '<tr id="term-translations" class="form-field">'; if ($lang) { include PLL_ADMIN_INC . '/view-translations-term.php'; } echo '</tr>' . "\n"; }
public function personal_options($profileuser) { $dropdown = new PLL_Walker_Dropdown(); printf(' <tr> <th><label for="user_lang">%s</label></th> <td>%s</td> </tr>', __('Admin language', 'polylang'), $dropdown->walk(array_merge(array((object) array('locale' => 0, 'name' => __('Wordpress default', 'polylang'))), $this->model->get_languages_list()), array('name' => 'user_lang', 'value' => 'locale', 'selected' => get_user_meta($profileuser->ID, 'user_lang', true)))); // hidden informations to modify the biography form with js foreach ($this->model->get_languages_list() as $lang) { $meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug; $description = apply_filters('user_description', get_user_meta($profileuser->ID, $meta, true)); // applies WP default filter wp_kses_data printf('<input type="hidden" class="biography" name="%s-%s" value="%s" />', esc_attr($lang->slug), esc_attr($lang->name), esc_attr($description)); } }
/** * displays the Languages metabox in the 'Edit Post' and 'Edit Page' panels * * @since 0.1 */ public function post_language() { global $post_ID; $post_id = $post_ID; $post_type = get_post_type($post_ID); $lang = ($lg = $this->model->post->get_language($post_ID)) ? $lg : (isset($_GET['new_lang']) ? $this->model->get_language($_GET['new_lang']) : $this->pref_lang); $dropdown = new PLL_Walker_Dropdown(); wp_nonce_field('pll_language', '_pll_nonce'); // NOTE: the class "tags-input" allows to include the field in the autosave $_POST ( see autosave.js ) printf(' <p><strong>%1$s</strong></p> <label class="screen-reader-text" for="%2$s">%1$s</label> <div id="select-%3$s-language">%4$s</div>', __('Language', 'polylang'), $id = 'attachment' === $post_type ? sprintf('attachments[%d][language]', $post_ID) : 'post_lang_choice', 'attachment' === $post_type ? 'media' : 'post', $dropdown->walk($this->model->get_languages_list(), array('name' => $id, 'class' => 'post_lang_choice tags-input', 'selected' => $lang ? $lang->slug : '', 'flag' => true))); /** * Fires before displaying the list of translations in the Languages metabox for posts * * @since 1.8 */ do_action('pll_before_post_translations', $post_type); echo '<div id="post-translations" class="translations">'; if ($lang) { include PLL_ADMIN_INC . '/view-translations-' . ('attachment' == $post_type ? 'media' : 'post') . '.php'; } echo '</div>' . "\n"; }
?> <input type="hidden" name="pll_action" value="options" /> <table class="form-table"> <tr> <th <?php echo $content_with_no_languages ? 'rowspan=2' : ''; ?> > <label for='default_lang'><?php _e('Default language', 'polylang'); ?> </label> </th> <td><?php $dropdown = new PLL_Walker_Dropdown(); echo $dropdown->walk($listlanguages, array('name' => 'default_lang', 'selected' => $this->options['default_lang'])); ?> </td> </tr><?php // posts or terms without language set if ($content_with_no_languages) { ?> <tr> <td> <label style="color: red"><?php printf('<input name="fill_languages" type="checkbox" value="1" /> %s', __('There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?', 'polylang')); ?> </label> </td> </tr><?php
/** * Form for language user preference in user profile * * @since 0.4 * * @param object $profileuser */ public function personal_options($profileuser) { // FIXME: Backward compatibility with WP < 4.7 if (version_compare($GLOBALS['wp_version'], '4.7alpha', '<')) { $dropdown = new PLL_Walker_Dropdown(); printf(' <tr> <th><label for="user_lang">%s</label></th> <td>%s</td> </tr>', esc_html__('Admin language', 'polylang'), $dropdown->walk(array_merge(array((object) array('locale' => 0, 'name' => __('WordPress default', 'polylang'))), $this->model->get_languages_list()), array('name' => 'user_lang', 'value' => 'locale', 'selected' => get_user_meta($profileuser->ID, 'locale', true)))); } // Hidden informations to modify the biography form with js foreach ($this->model->get_languages_list() as $lang) { $meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug; /** This filter is documented in wp-includes/user.php */ $description = apply_filters('user_description', get_user_meta($profileuser->ID, $meta, true)); // Applies WP default filter wp_kses_data printf('<input type="hidden" class="biography" name="%s___%s" value="%s" />', esc_attr($lang->slug), esc_attr($lang->name), esc_attr($description)); } }