id == 'user-edit') { $userId = (int) Arr::get($_REQUEST, 'user_id'); $user = get_user_by('ID', $userId); if ($userId && $user) { $crmProfile = Subscriber::where('email', $user->user_email) ->orWhere('user_id', $user->ID) ->first(); if ($crmProfile) { $crmProfileUrl = $urlBase . 'subscribers/' . $crmProfile->id; $editingUserVars = [ 'user_id' => $userId, 'crm_profile_id' => $crmProfile->id, 'crm_profile_url' => $crmProfileUrl ]; } } } wp_localize_script('fluentcrm_adminbar_search', 'fcrm_adminbar_search_vars', [ 'rest' => $this->getRestInfo(), 'links' => (new Stats)->getQuickLinks(), 'subscriber_base' => $urlBase . 'subscribers/', 'edit_user_vars' => $editingUserVars, 'trans' => [ 'Search Contacts' => __('Search Contacts', 'fluent-crm'), 'Type and press enter' => __('Type and press enter', 'fluent-crm'), 'Type to search contacts' => __('Type to search contacts', 'fluent-crm'), 'Quick Links' => __('Quick Links', 'fluent-crm'), 'Sorry no contact found' => __('Sorry no contact found', 'fluent-crm'), 'Load More' => __('Load More', 'fluent-crm'), 'Close' => __('Close', 'fluent-crm') ] ]); $args = [ 'parent' => 'top-secondary', 'id' => 'fcrm_adminbar_search', 'title' => __('Search Contacts', 'fluent-crm'), 'href' => '#', 'meta' => false ]; $adminBar->add_node($args); } protected function getRestInfo() { $app = FluentCrm(); $ns = $app->config->get('app.rest_namespace'); $v = $app->config->get('app.rest_version'); return [ 'base_url' => esc_url_raw(rest_url()), 'url' => rest_url($ns . '/' . $v), 'nonce' => wp_create_nonce('wp_rest'), 'namespace' => $ns, 'version' => $v ]; } }