/**
  * Search for taxonomy terms and echo json
  *
  * @since 1.0.0
  */
 public function json_search_terms()
 {
     check_ajax_referer('search-terms', 'security');
     $term = (string) wc_clean(stripslashes(SV_WC_Helper::get_request('term')));
     $taxonomy = (string) wc_clean(SV_WC_Helper::get_request('taxonomy'));
     if (empty($term) || empty($taxonomy)) {
         die;
     }
     if (is_numeric($term)) {
         $args = array('hide_empty' => false, 'include' => array(0, $term));
     } else {
         $args = array('hide_empty' => false, 'search' => $term);
     }
     $terms = get_terms(array($taxonomy), $args);
     $found_terms = array();
     if ($terms) {
         foreach ($terms as $term) {
             $found_terms[$term->term_id] = $term->name;
         }
     }
     /**
      * Filter terms found for JSON (AJAX) search
      *
      * @since 1.0.0
      * @param array $found_terms Array of the found terms
      */
     $found_terms = apply_filters('wc_memberships_json_search_found_terms', $found_terms);
     wp_send_json($found_terms);
 }
 /**
  * Returns true if the current page is the admin configuration page for the
  * gateway with class name $gateway_class_name
  *
  * Temporary home for this function, until all payment gateways are brought into the frameworked fold
  *
  * @since 3.0.0
  * @param string $gateway_class_name the gateway class name
  * @return boolean true if the current page is the admin configuration page for the gateway
  */
 public static function is_payment_gateway_configuration_page($gateway_class_name)
 {
     return 'wc-settings' == SV_WC_Helper::get_request('page') && 'checkout' == SV_WC_Helper::get_request('tab') && strtolower($gateway_class_name) == SV_WC_Helper::get_request('section');
 }
 /**
  * Refresh the tokens list via AJAX.
  *
  * @since 4.3.0
  */
 public function ajax_refresh_tokens()
 {
     check_ajax_referer('wc_payment_gateway_admin_refresh_payment_tokens', 'security');
     $user_id = SV_WC_Helper::get_request('user_id');
     if ($user_id) {
         ob_start();
         $this->display_tokens($user_id);
         $html = ob_get_clean();
         wp_send_json_success(trim($html));
     } else {
         wp_send_json_error();
     }
 }