/** * @param Mlp_Relationship_Control_Data $data * @param Mlp_Updatable $updater */ public function __construct(Mlp_Relationship_Control_Data $data, Mlp_Updatable $updater) { $this->post = $data->get_source_post(); $this->remote_site_id = $data->get_remote_site_id(); $this->remote_post_id = $data->get_remote_post_id(); $this->site_id = get_current_blog_id(); $this->data = $data; $this->updater = $updater; $this->search_input_id = "mlp_post_search_{$this->remote_site_id}"; }
/** * @param Mlp_Relationship_Control_Data $data * @param Mlp_Updatable $updater */ public function __construct(Mlp_Relationship_Control_Data $data, Mlp_Updatable $updater) { $this->post = $data->get_source_post(); $this->remote_blog_id = $data->get_remote_blog_id(); $this->remote_post_id = $data->get_remote_post_id(); $this->blog_id = get_current_blog_id(); $this->data = $data; $this->updater = $updater; $this->search_input_id = "mlp_post_search_{$this->remote_blog_id}"; add_action("admin_footer-" . $GLOBALS['hook_suffix'], array($this, 'print_jquery')); }
/** * @param array $results * @return string */ private function format_results(array $results) { if (empty($results)) { return '<li>' . esc_html__('Nothing found.', 'multilingualpress') . '</li>'; } $out = ''; $blog_id = $this->data->get_remote_blog_id(); $results = $this->prepare_titles($results); /** @var WP_Post $result */ foreach ($results as $result) { $id = "id_{$blog_id}_{$result->ID}"; $name = 'mlp_add_post[' . $blog_id . ']'; $status = $this->get_translated_status($result->post_status); $out .= "<li><label for='{$id}'>" . "<input type='radio' name='{$name}' value='{$result->ID}' id='{$id}'>" . $result->post_title . " ({$status})" . '</label></li>'; } return $out; }
/** * Create the UI above the Advanced Translator metabox. * * @wp-hook mlp_translation_meta_box_bottom * @uses Mlp_Relationship_Control_Meta_Box_View * @param WP_Post $post * @param int $remote_site_id * @param WP_Post $remote_post * @return void */ public function set_up_meta_box_handlers(WP_Post $post, $remote_site_id, WP_Post $remote_post) { global $pagenow; if ('post-new.php' === $pagenow) { return; } // maybe later, for now, we work on existing posts only $this->data->set_ids(array('source_post_id' => $post->ID, 'source_site_id' => get_current_blog_id(), 'remote_site_id' => $remote_site_id, 'remote_post_id' => $remote_post->ID)); $view = new Mlp_Relationship_Control_Meta_Box_View($this->data, $this); $view->render(); }