/**
  * Validate and save user input
  *
  * @param  array $data User input
  * @return bool
  */
 public function save(array $data)
 {
     if (!$this->nonce->is_valid()) {
         return FALSE;
     }
     $id = $this->get_current_blog_id($data, get_current_blog_id());
     $value = $this->get_sent_value($data);
     return update_blog_option($id, $this->option_name, $value);
 }
    /**
     * Content of 'td'.
     *
     * @param WP_User $user
     * @return void
     */
    public function show_content(WP_User $user)
    {
        $key = esc_attr($this->key);
        $current = (int) get_user_meta($user->ID, $this->key);
        $check = checked(1, $current, FALSE);
        $text = esc_html__('Do not redirect me automatically to the best matching language version.', 'multilingualpress');
        wp_nonce_field($this->nonce->get_action(), $this->nonce->get_name());
        printf('<label for="%1$s_id">
				<input type="checkbox" value="1" name="%1$s" id="%1$s_id" %2$s>
				%3$s
			</label>', $key, $check, $text);
    }
 /**
  * Is this a valid request?
  *
  * @param  int $context Post id
  * @return bool
  */
 public function is_valid($context = NULL)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return FALSE;
     }
     if ($this->is_real_revision($context)) {
         return FALSE;
     }
     if (!current_user_can('edit_post', $context)) {
         return FALSE;
     }
     return $this->nonce->is_valid();
 }
 /**
  * Save user data.
  *
  * @param  int $user_id
  * @return bool
  */
 public function save($user_id)
 {
     if (!$this->nonce->is_valid()) {
         return FALSE;
     }
     if (!current_user_can('edit_user', $user_id)) {
         return FALSE;
     }
     if (empty($_POST[$this->key]) or '' === trim($_POST[$this->key])) {
         return delete_user_meta($user_id, $this->key);
     }
     return update_user_meta($user_id, $this->key, $_POST[$this->key]);
 }
 /**
  * @param string $taxonomy
  *
  * @return bool
  */
 private function is_valid_request($taxonomy)
 {
     if (!$this->nonce->is_valid()) {
         return FALSE;
     }
     if (!in_array($taxonomy, $this->taxonomies)) {
         return FALSE;
     }
     return TRUE;
 }
 /**
  * Is the AJAX request allowed and should be processed?
  *
  * @return bool
  */
 public function is_allowed()
 {
     if (!current_user_can('edit_theme_options')) {
         return false;
     }
     if (!$this->nonce->is_valid()) {
         return false;
     }
     return !empty($_GET['mlp_sites']);
 }
 /**
  * Create the content for the extra box, a table with checkboxes.
  *
  * @return string
  */
 private function get_box_content()
 {
     $post_types = $this->get_custom_post_types();
     $options = (array) get_site_option('inpsyde_multilingual_cpt');
     $s_label = esc_html(__('Use dynamic permalinks', 'multilingual-press'));
     if (empty($post_types)) {
         return '';
     }
     $out = wp_nonce_field($this->nonce_validator->get_action(), $this->nonce_validator->get_name(), TRUE, FALSE);
     $out .= '<table><tbody>';
     foreach ($post_types as $cpt => $cpt_params) {
         $out .= $this->get_row($cpt, $cpt_params, $options, $s_label);
     }
     return "{$out}</tbody></table>";
 }
    /**
     * Create 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 = wp_nonce_field($this->nonce_validator->get_action(), $this->nonce_validator->get_name(), true, false);
        $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>';
    }
    public function render()
    {
        wp_nonce_field($this->nonce->get_action(), $this->nonce->get_name());
        $current = $this->data->get_current_option_value();
        $label = esc_attr__('Enable automatic redirection', 'multilingualpress');
        $name = $this->data->get_checkbox_name();
        $id = "{$name}_id";
        ?>
		<tr>
			<td><?php 
        esc_html_e('Redirection', 'multilingualpress');
        ?>
</td>
			<td>
				<label for="<?php 
        print $id;
        ?>
">
					<input type="checkbox" <?php 
        checked(1, $current);
        ?>
 id="<?php 
        print $id;
        ?>
" value="1" name="<?php 
        print $name;
        ?>
" />
					<?php 
        print $label;
        ?>
				</label>
			</td>
		</tr>
	<?php 
    }
 /**
  * @return string
  */
 public function get_nonce_field()
 {
     return wp_nonce_field($this->nonce->get_action(), $this->nonce->get_name(), TRUE, FALSE);
 }
    /**
     * Basic meta box frame.
     *
     * @param WP_Post $post
     * @param array   $meta_box
     * @return void
     */
    public function render(WP_Post $post, array $meta_box)
    {
        wp_nonce_field($this->nonce->get_action(), $this->nonce->get_name());
        ?>
		<!-- MultilingualPress Translation Box -->
		<div class="holder mlp_advanced_translator_metabox clear">
		<?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);
        ?>
		</div>
		<!-- /MultilingualPress Translation Box -->
	<?php 
    }
    /**
     * Basic meta box frame.
     *
     * @param WP_Post $post
     * @param array   $meta_box
     * @return void
     */
    public function render(WP_Post $post, array $meta_box)
    {
        wp_nonce_field($this->nonce->get_action(), $this->nonce->get_name());
        ?>
		<!-- MultilingualPress Translation Box -->
		<div class="holder mlp_advanced_translator_metabox clear">
		<?php 
        $data = (object) $meta_box['args'];
        /**
         * Perform additional actions on top of the translation box.
         *
         * @param WP_Post $post
         * @param int     $data->remote_blog_id
         * @param WP_Post $data->remote_post
         */
        do_action('mlp_translation_meta_box_top', $post, $data->remote_blog_id, $data->remote_post);
        /**
         * Perform additional actions on top of the translation box.
         *
         * @param WP_Post $post
         * @param int     $data->remote_blog_id
         * @param WP_Post $data->remote_post
         */
        do_action('mlp_translation_meta_box_top_' . $data->remote_blog_id, $post, $data->remote_blog_id, $data->remote_post);
        /**
         * Meta box main content.
         *
         * @param WP_Post $post
         * @param int     $data->remote_blog_id
         * @param WP_Post $data->remote_post
         */
        do_action('mlp_translation_meta_box_main', $post, $data->remote_blog_id, $data->remote_post);
        /**
         * Meta box main content.
         *
         * @param WP_Post $post
         * @param int     $data->remote_blog_id
         * @param WP_Post $data->remote_post
         */
        do_action('mlp_translation_meta_box_main_' . $data->remote_blog_id, $post, $data->remote_blog_id, $data->remote_post);
        /**
         * Perform additional actions below the translation box.
         *
         * @param WP_Post $post
         * @param int     $data->remote_blog_id
         * @param WP_Post $data->remote_post
         */
        do_action('mlp_translation_meta_box_bottom', $post, $data->remote_blog_id, $data->remote_post);
        /**
         * Perform additional actions below the translation box.
         *
         * @param WP_Post $post
         * @param int     $data->remote_blog_id
         * @param WP_Post $data->remote_post
         */
        do_action('mlp_translation_meta_box_bottom_' . $data->remote_blog_id, $post, $data->remote_blog_id, $data->remote_post);
        ?>
		</div>
		<!-- /MultilingualPress Translation Box -->
	<?php 
    }