/** * Renders the setting markup. * * @since 3.0.0 * @wp-hook post_submitbox_misc_actions * * @param WP_Post $post Post object. * * @return void */ public function render(WP_Post $post) { $id = 'mlp-trasher'; ?> <div class="misc-pub-section misc-pub-mlp-trasher"> <?php echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); ?> <label for="<?php echo esc_attr($id); ?> "> <input type="checkbox" name="<?php echo esc_attr(TrasherSettingRepository::META_KEY); ?> " value="1" id="<?php echo esc_attr($id); ?> " <?php checked($this->setting_repository->get($post->ID)); ?> > <?php _e('Send all the translations to trash when this post is trashed.', 'multilingual-press'); ?> </label> </div> <?php }
/** * Content of 'td'. * * @param WP_User $user * * @return string */ public function markup(WP_User $user) { $id = "{$this->key}_id"; ob_start(); ?> <label for="<?php echo esc_attr($id); ?> "> <input type="checkbox" name="<?php echo esc_attr($this->key); ?> " value="1" id="<?php echo esc_attr($id); ?> " <?php checked(1, (int) get_user_meta($user->ID, $this->key)); ?> > <?php esc_html_e('Do not redirect me automatically to the best matching language version.', 'multilingual-press'); echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); ?> </label> <?php return ob_get_clean(); }
/** * Returns the markup for the user setting. * * @since 3.0.0 * * @param WP_User $user User object. * * @return string The markup for the user setting. */ public function markup(WP_User $user) { $languages = get_available_languages(); if (!$languages) { return esc_html__('No languages available.', 'multilingual-press'); } // Add English manually, because it won't get added by WordPress itself. $languages[] = 'en_US'; return sprintf('<select name="%2$s" id="%2$s" autocomplete="off">%1$s</select>%3$s', $this->get_language_options($languages, $this->language_repository->get_user_language($user->ID)), esc_attr($this->meta_key), \Inpsyde\MultilingualPress\nonce_field($this->nonce)); }
/** * Renders the markup. * * @since 3.0.0 * * @return void */ public function render() { $this->asset_manager->enqueue_style('multilingualpress-admin'); $action = PluginSettingsUpdater::ACTION; ?> <div class="wrap"> <h1><?php echo esc_html(get_admin_page_title()); ?> </h1> <form method="post" action="<?php echo admin_url("admin-post.php?action={$action}"); ?> " id="multilingualpress-modules"> <?php echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); ?> <table class="mlp-module-list"> <?php foreach ($this->module_manager->get_modules() as $id => $module) { /** * Filters if the module should be listed on the settings page. * * @since 3.0.0 * * @param bool $show_module Whether or not the module should be listed on the settings page. */ if (apply_filters("multilingualpress.show_module_{$id}", true)) { $this->render_module($module); } } /** * Fires at the end of but still inside the module list on the settings page. * * @since 3.0.0 */ do_action('multilingualpress.in_module_list'); ?> </table> <?php /** * Fires right after after the module list on the settings page. * * @since 3.0.0 */ do_action('multilingualpress.after_module_list'); submit_button(__('Save Changes', 'multilingual-press')); ?> </form> </div> <?php }
/** * Returns the markup for the settings box. * * @since 3.0.0 * * @return string The markup for the settings box. */ public function markup() { if (!$this->post_types) { return ''; } $settings = (array) get_site_option('inpsyde_multilingual_cpt', []); $settings = empty($settings['post_types']) ? [] : (array) $settings['post_types']; $markup = \Inpsyde\MultilingualPress\nonce_field($this->nonce) . '<table><tbody>'; ob_start(); array_walk($this->post_types, [$this, 'render_table_row'], $settings); $markup .= ob_get_clean() . '</tbody></table>'; return $markup; }
/** * Callback for page output. * */ public function render() { $current_page = $this->pagination_data->get_current_page(); ?> <div class="wrap"> <h1><?php echo esc_html($this->setting->title()); ?> </h1> <?php $this->watcher->update('before_form'); ?> <form action="<?php echo esc_url($this->setting->url()); ?> " method="post"> <input type="hidden" name="action" value="<?php echo esc_attr($this->setting->action()); ?> "> <input type="hidden" name="paged" value="<?php echo esc_attr($current_page); ?> "> <?php echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); ?> <?php $this->watcher->update('before_table'); ?> <?php $this->watcher->update('show_table'); ?> <?php $this->watcher->update('after_table'); ?> <?php submit_button(esc_attr__('Save changes', 'multilingual-press'), 'primary', 'save', false, ['style' => 'float:left']); ?> <?php $this->watcher->update('after_form_submit_button'); ?> </form> <?php $this->watcher->update('after_form'); ?> </div> <?php }
/** * Renders the setting markup. * * @since 3.0.0 * @wp-hook post_submitbox_misc_actions * * @param WP_Post $post Post object. * * @return void */ public function render(WP_Post $post) { $post_id = $post->ID; $translated = $this->post_repository->is_post_translated($post_id); /** * Filters whether or not the checkbox for the current post should be rendered. * * @since 3.0.0 * * @param bool $show_checkbox Whether or not to show the checkbox. * @param int $post_id Post ID. * @param bool $translated Whether or not the post is translated. */ if (!apply_filters('multilingualpress.show_translation_completed_checkbox', true, $post_id, $translated)) { return; } $id = 'mlp-translation-completed'; ?> <div class="misc-pub-section misc-pub-mlp-translation-completed"> <?php echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); ?> <label for="<?php echo esc_attr($id); ?> "> <input type="checkbox" name="<?php echo esc_attr(PostRepository::META_KEY); ?> " value="1" id="<?php echo esc_attr($id); ?> " <?php checked($translated); ?> > <?php _e('Translation completed', 'multilingual-press'); ?> </label> </div> <?php }
/** * 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 }
public function render() { $name = $this->data->get_checkbox_name(); $id = "{$name}_id"; ?> <tr class="form-field"> <th scope="row"><?php esc_html_e('Redirection', 'multilingual-press'); ?> </th> <td> <label for="<?php echo esc_attr($id); ?> "> <input type="checkbox" name="<?php echo esc_attr($name); ?> " value="1" id="<?php echo esc_attr($id); ?> " <?php checked(1, $this->data->get_current_option_value()); ?> > <?php esc_html_e('Enable automatic redirection', 'multilingual-press'); ?> <?php echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); ?> </label> </td> </tr> <?php }
/** * Creates the content for the extra box, four illustrated checkboxes. * * @return string */ private function get_box_content() { $positions = $this->get_position_names(); $current = $this->get_current_position($positions); $out = \Inpsyde\MultilingualPress\nonce_field($this->nonce); $out .= '<p id="mlp-quicklink-positions">'; foreach ($positions as $key => $label) { $checked = checked($current, $key, false); $out .= sprintf(' <label for="mlp-%1$s-id" class="quicklink-position-label quicklink-position-%1$s"> <input type="radio" name="quicklink-position" value="%1$s" id="mlp-%1$s-id" %2$s> %3$s </label>', $key, $checked, $label); } return $out . '</p>'; }
/** * Basic meta box frame. * * @param WP_Post $post * @param array $meta_box * @return void */ public function render(WP_Post $post, array $meta_box) { ?> <!-- MultilingualPress Translation Box --> <div class="holder mlp-translation-meta-box"> <?php $data = (object) $meta_box['args']; /** * Runs before the main content of the meta box. * * @param WP_Post $post Post object. * @param int $remote_blog_id Remote blog ID. * @param WP_Post $remote_post Remote post object. */ do_action('mlp_translation_meta_box_top', $post, $data->remote_blog_id, $data->remote_post); /** * Runs before the main content of the meta box. * * @param WP_Post $post Post object. * @param int $remote_blog_id Remote blog ID. * @param WP_Post $remote_post Remote post object. */ do_action("mlp_translation_meta_box_top_{$data->remote_blog_id}", $post, $data->remote_blog_id, $data->remote_post); /** * Runs with the main content of the meta box. * * @param WP_Post $post Post object. * @param int $remote_blog_id Remote blog ID. * @param WP_Post $remote_post Remote post object. */ do_action('mlp_translation_meta_box_main', $post, $data->remote_blog_id, $data->remote_post); /** * Runs with the main content of the meta box. * * @param WP_Post $post Post object. * @param int $remote_blog_id Remote blog ID. * @param WP_Post $remote_post Remote post object. */ do_action("mlp_translation_meta_box_main_{$data->remote_blog_id}", $post, $data->remote_blog_id, $data->remote_post); /** * Runs before the main content of the meta box. * * @param WP_Post $post Post object. * @param int $remote_blog_id Remote blog ID. * @param WP_Post $remote_post Remote post object. */ do_action('mlp_translation_meta_box_bottom', $post, $data->remote_blog_id, $data->remote_post); /** * Runs before the main content of the meta box. * * @param WP_Post $post Post object. * @param int $remote_blog_id Remote blog ID. * @param WP_Post $remote_post Remote post object. */ do_action("mlp_translation_meta_box_bottom_{$data->remote_blog_id}", $post, $data->remote_blog_id, $data->remote_post); echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); ?> </div> <!-- /MultilingualPress Translation Box --> <?php }
/** * @return bool */ public function print_table() { if (empty($this->related_sites)) { return FALSE; } echo \Inpsyde\MultilingualPress\nonce_field($this->nonce); $this->print_style(); ?> <table id="mlp-term-translations"> <?php foreach ($this->related_sites as $site_id => $language) { ?> <?php $key = $this->presenter->get_key_base($site_id); $label_id = $this->get_label_id($key); $terms = $this->presenter->get_terms_for_site($site_id); $current_term = $this->get_current_term($site_id); $empty_option_value = $current_term > 0 ? 0 : -1; ?> <tr> <th> <label for="<?php echo esc_attr($label_id); ?> "><?php echo esc_html($language); ?> </label> </th> <td> <?php if (empty($terms)) { ?> <?php echo $this->get_no_terms_found_message($site_id); ?> <?php } else { ?> <select name="<?php echo esc_attr($key); ?> " id="<?php echo esc_attr($label_id); ?> " autocomplete="off"> <option value="<?php echo esc_attr($empty_option_value); ?> " class="mlp_empty_option"> <?php esc_html_e('No translation', 'multilingual-press'); ?> </option> <?php $this->print_term_options($terms, $current_term, $site_id); ?> </select> <?php } ?> </td> </tr> <?php } ?> </table> <?php return TRUE; }