/**
  * Starts output buffering and call "render_callback".
  *
  * @return void
  */
 public function start_buffer()
 {
     ob_start(array($this, 'reorder_output'));
     if (!$this->is_active_page()) {
         return;
     }
     echo $this->marker;
     $this->watcher->update('create_tab_content');
     echo $this->marker;
 }
    /**
     * 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 
    }
 /**
  * Get allowed post types from controller.
  *
  * Not sure if this is a good solution.
  *
  * @return array
  */
 private function get_custom_post_types()
 {
     if (empty($this->post_types)) {
         $this->post_types = $this->update->update('custom.post-type.list');
     }
     return $this->post_types;
 }
    /**
     * Callback for page output.
     *
     */
    public function render()
    {
        ?>
		<div class="wrap">
			<?php 
        print '<h2>' . $this->page_data->get_title() . '</h2>';
        $this->watcher->update('before_form');
        ?>
			<form action="<?php 
        echo $this->page_data->get_form_action();
        ?>
" method="post">
				<input type="hidden" name="action" value="<?php 
        echo $this->page_data->get_action_name();
        ?>
" />
				<input type="hidden" name="paged" value="<?php 
        echo $this->pagination_data->get_current_page();
        ?>
" />
			<?php 
        wp_nonce_field($this->page_data->get_nonce_action(), $this->page_data->get_nonce_name());
        $this->watcher->update('before_table');
        $this->watcher->update('show_table');
        $this->watcher->update('after_table');
        submit_button(esc_attr__('Save changes', 'multilingualpress'), 'primary', 'save', FALSE, array('style' => 'float:left'));
        $this->watcher->update('after_form_submit_button');
        ?>
			</form>
			<?php 
        $this->watcher->update('after_form');
        ?>
		</div>
		<?php 
    }
    /**
     * Template for an extra field in the "Add new term" form.
     *
     * @return void
     */
    public function add_term()
    {
        ?>
		<fieldset class="form-field"
			id="<?php 
        echo esc_attr($this->updatable->update(self::ADD_TERM_FIELDSET_ID));
        ?>
">
			<legend><?php 
        echo esc_html($this->updatable->update(self::ADD_TERM_TITLE));
        ?>
</legend>
			<?php 
        $this->updatable->update(self::ADD_TERM_FIELDS);
        ?>
		</fieldset>
		<?php 
    }
    /**
     * Template for an extra field in the "Add new term" form.
     *
     * @return void
     */
    public function add_term()
    {
        $this->updatable->update(self::ADD_TERM_BEFORE);
        ?>
		<fieldset id="<?php 
        $this->updatable->update(self::ADD_TERM_FIELDSET_ID);
        ?>
">
			<legend><?php 
        $this->updatable->update(self::ADD_TERM_TITLE);
        ?>
</legend>
			<?php 
        $this->updatable->update(self::ADD_TERM_FIELDS);
        ?>
		</fieldset>
		<?php 
        $this->updatable->update(self::ADD_TERM_AFTER);
    }
    public function render()
    {
        $this->localize_script();
        $action_selector_id = "mlp_rsc_action_container_{$this->remote_site_id}";
        $search_selector_id = "mlp_rsc_search_container_{$this->remote_site_id}";
        ?>
		<div class="mlp-relationship-control-box"
			 style="margin: .5em 0 .5em auto ">
			<?php 
        printf('<button type="button" class="button secondary mlp-rsc-button mlp-click-toggler" name="mlp_rsc_%2$d"
					data-toggle-target="#%3$s" data-search_box_id="%4$s">%1$s</button>', esc_html__('Change relationship', 'multilingual-press'), $this->remote_site_id, $action_selector_id, $search_selector_id);
        ?>
			<div id="<?php 
        print $action_selector_id;
        ?>
" class='hidden'>
				<div class="mlp-rc-settings">
					<div class="mlp-rc-actions" style="float: left; width: 20em;">
						<?php 
        $actions = array('stay' => esc_html__('Leave as is', 'multilingual-press'), 'new' => esc_html__('Create new post', 'multilingual-press'));
        if ($this->remote_post_id) {
            $actions['disconnect'] = esc_html__('Remove relationship', 'multilingual-press');
        }
        foreach ($actions as $key => $label) {
            print '<p>' . $this->get_radio($key, $label, 'stay', 'mlp-rc-action[' . $this->remote_site_id . ']', 'mlp-rc-input-id-' . $this->remote_site_id) . '</p>';
        }
        ?>
					<p>
						<label for="mlp-rc-input-id-<?php 
        print $this->remote_site_id;
        ?>
-search">
							<input
								type="radio"
								name="mlp-rc-action[<?php 
        print $this->remote_site_id;
        ?>
]"
								value="search"
								class="mlp-state-toggler"
								id="mlp-rc-input-id-<?php 
        print $this->remote_site_id;
        ?>
-search"
								data-toggle-target="#<?php 
        print $search_selector_id;
        ?>
">
							<?php 
        esc_html_e('Select existing post &hellip;', 'multilingual-press');
        ?>
						</label>
					</p>
				</div>

					<div id="<?php 
        print $search_selector_id;
        ?>
"
						 style="display:none;float:left;max-width:30em">

						<label for="<?php 
        print $this->search_input_id;
        ?>
">
							<?php 
        esc_html_e('Live search', 'multilingual-press');
        ?>
						</label>
						<?php 
        print $this->get_search_input($this->search_input_id);
        ?>

						<ul class="mlp-search-results"
							id="mlp-search-results-<?php 
        print $this->remote_site_id;
        ?>
">
							<?php 
        $this->updater->update('default.remote.posts');
        ?>
						</ul>
					</div>
				</div>
				<p>
					<?php 
        $data_attrs = $this->add_id_values('');
        ?>
					<input type="button"
						   class="button button-primary mlp-save-relationship-button"
						   value="<?php 
        esc_attr_e('Save and reload this page', 'multilingual-press');
        ?>
" <?php 
        print $data_attrs;
        ?>
>
					<span class="description"><?php 
        esc_html_e('Please save other changes first separately.', 'multilingual-press');
        ?>
</span>
				</p>
			</div>
		</div>
	<?php 
    }
    public function render()
    {
        $action_selector_id = "mlp_rsc_action_container_{$this->remote_blog_id}";
        $search_selector_id = "mlp_rsc_search_container_{$this->remote_blog_id}";
        ?>
		<div class="mlp-relationship-control-box"
			 style="margin: .5em 0 .5em auto ">
			<?php 
        submit_button(esc_attr__('Change relationship', 'multilingualpress'), 'secondary mlp-rsc-button mlp_toggler', "mlp_rsc_{$this->remote_blog_id}", FALSE, array('data-toggle_selector' => "#{$action_selector_id}", 'data-search_box_id' => $search_selector_id));
        ?>
			<div id="<?php 
        print $action_selector_id;
        ?>
" class='hidden'>
				<div class="mlp_rsc_action_list" style="float:left;width:20em;">
					<?php 
        $actions = array('stay' => esc_html__('Leave as is', 'multilingualpress'), 'new' => esc_html__('Create new post', 'multilingualpress'));
        if ($this->remote_post_id) {
            $actions['disconnect'] = esc_html__('Remove relationship', 'multilingualpress');
        }
        foreach ($actions as $key => $label) {
            print '<p>' . $this->get_radio($key, $label, 'stay', 'mlp_rsc_action[' . $this->remote_blog_id . ']', 'mlp_rsc_input_id_' . $this->remote_blog_id) . '</p>';
        }
        ?>
					<p>
						<label
							for="mlp_rsc_input_id_<?php 
        print $this->remote_blog_id;
        ?>
_search"
							class="mlp_toggler"
							data-toggle_selector="#<?php 
        print $search_selector_id;
        ?>
"
							>
							<input
								type="radio"
								name="mlp_rsc_action[<?php 
        print $this->remote_blog_id;
        ?>
]"
								value="search"
								id="mlp_rsc_input_id_<?php 
        print $this->remote_blog_id;
        ?>
_search"
								>
							<?php 
        esc_html_e('Select existing post &hellip;', 'multilingualpress');
        ?>
						</label>
					</p>
				</div>

				<div id="<?php 
        print $search_selector_id;
        ?>
"
					 style="display:none;float:left;max-width:30em">

					<label for="<?php 
        print $this->search_input_id;
        ?>
">
						<?php 
        esc_html_e('Live search', 'multilingualpress');
        ?>
					</label>
					<?php 
        print $this->get_search_input($this->search_input_id);
        ?>

					<ul class="mlp_search_results"
						id="mlp_search_results_<?php 
        print $this->remote_blog_id;
        ?>
">
						<?php 
        $this->updater->update('default.remote.posts');
        ?>
					</ul>
				</div>
				<p class="clear">
					<?php 
        $data_attrs = $this->add_id_values('');
        ?>
					<input type="submit"
						   class="button button-primary mlp_rsc_save_reload"
						   value="<?php 
        esc_attr_e('Save and reload this page', 'multilingualpress');
        ?>
" <?php 
        print $data_attrs;
        ?>
">
					<span class="description"><?php 
        esc_html_e('Please save other changes first separately.', 'multilingualpress');
        ?>
</span>
				</p>
			</div>
		</div>
	<?php 
    }