/** * Initializes the AJAX-based live search. * * @since 3.0.0 * * @return void */ public function initialize() { add_action('wp_ajax_' . self::ACTION, function () { $context = RelationshipContext::from_request(); ob_start(); $this->search_results->render($context); wp_send_json_success(['html' => ob_get_clean(), 'remoteSiteId' => $context->remote_site_id()]); }); }
/** * Constructor. Sets up the properties. * * @since 3.0.0 * * @param ContentRelations $content_relations Content relations API object. */ public function __construct(ContentRelations $content_relations) { $this->content_relations = $content_relations; $this->context = RelationshipContext::from_request(); }