public function api($endpoint = '', $params = array(), $method = 'post')
 {
     // No endpoint = no query
     if (!$endpoint) {
         return;
     }
     // Parameters must be an array
     if (!is_array($params)) {
         return;
     }
     // Only valid methods allowed
     if (!in_array($method, array('post', 'get', 'delete'))) {
         return;
     }
     // Set up query URL
     $url = $this->api_url . $endpoint;
     // Set up request arguments
     $args['headers'] = array('Authorization' => 'Basic ' . base64_encode($this->settings['api_key'] . ':'));
     $args['sslverify'] = true;
     $args['timeout'] = 60;
     $args['user-agent'] = 'WooCommerce/' . WC()->version;
     // Process request based on method in use
     switch ($method) {
         case 'post':
             if (!empty($params)) {
                 $params = json_encode($params);
                 $args['body'] = $params;
                 $args['headers']['Content-Length'] = strlen($args['body']);
             }
             $args['headers']['Content-Type'] = 'application/json';
             $args['headers']['Content-Length'] = strlen($args['body']);
             $response = wp_remote_post($url, $args);
             break;
         case 'get':
             $param_string = '';
             if (!empty($params)) {
                 $params = array_map('urlencode', $params);
                 $param_string = build_query($params);
             }
             if ($param_string) {
                 $url = $url . '?' . $param_string;
             }
             $response = wp_remote_get($url, $args);
             break;
         case 'delete':
             $args['method'] = "DELETE";
             $response = wp_remote_request($url, $args);
             break;
     }
     // Return null if WP error is generated
     if (is_wp_error($response)) {
         return;
     }
     // Return null if query is not successful
     if ('200' != $response['response']['code'] || !isset($response['body']) || !$response['body']) {
         return;
     }
     // Return response object
     return json_decode($response['body']);
 }
Пример #2
0
function wp_get_cat_archives($opts, $cat)
{
    $args = wp_parse_args($opts, array('echo' => '1'));
    // default echo is 1.
    // 与えられた $opts を解析して配列に入れ、第2引数 と結合
    $echo = $args['echo'] != '0';
    // remember the original echo flag.
    $args['echo'] = 0;
    $args['cat'] = $cat;
    $archives = wp_get_archives(build_query($args));
    // アーカイブ取得 // 連想配列からページ用のクエリー文字列を作る
    $archs = explode('</li>', $archives);
    // 配列化した変数
    $links = array();
    foreach ($archs as $archive) {
        $link = preg_replace("/href='([^']+)'/", "href='\$1?cat={$cat}'", $archive);
        // 正規表現での置き換え
        array_push($links, $link);
        // 配列の末尾に値を追加
    }
    $result = implode('</li>', $links);
    // 配列を連結して1つの文字列に
    if ($echo) {
        echo $result;
    } else {
        return $result;
    }
}
 /**
  * The authorization sequence begins when your application redirects a browser to a Google URL;
  * the URL includes query parameters that indicate the type of access being requested.
  *
  * As in other scenarios, Google handles user authentication, session selection, and user consent.
  * The result is an authorization code, which Google returns to your application in a query string.
  *
  * (non-PHPdoc)
  *
  * @see PostmanAuthenticationManager::requestVerificationCode()
  */
 public function requestVerificationCode($transactionId)
 {
     $params = array('response_type' => 'code', 'redirect_uri' => urlencode($this->getCallbackUri()), 'client_id' => $this->getClientId(), 'state' => $transactionId, 'language' => get_locale());
     $authUrl = $this->getAuthorizationUrl() . '?' . build_query($params);
     $this->getLogger()->debug('Requesting verification code from Yahoo');
     PostmanUtils::redirect($authUrl);
 }
Пример #4
0
function grab_articles($f, $o, $ot, $offset, $limit)
{
    global $_time_intervals;
    global $_sortable_fields;
    list($conds, $params) = build_query($f);
    // make sure ordering params are sensible
    $o = strtolower($o);
    assert(in_array($o, $_sortable_fields));
    $ot = strtolower($ot);
    assert($ot == 'asc' || $ot == 'desc');
    $from_clause = "  FROM (article a INNER JOIN organisation o ON o.id=a.srcorg)\n";
    $where_clause = '';
    if ($conds) {
        $where_clause = '  WHERE ' . implode(' AND ', $conds) . "\n";
    }
    if ($o == 'publication') {
        $o = 'lower(o.prettyname)';
    }
    if ($o == 'byline') {
        $o = 'lower(byline)';
    }
    if ($o == 'title') {
        $o = 'lower(title)';
    }
    $order_clause = sprintf("  ORDER BY %s %s\n", $o, $ot);
    $limit_clause = sprintf("  OFFSET %d LIMIT %d\n", $offset, $limit);
    $sql = "SELECT a.id,a.title,a.byline,a.description,a.permalink, a.pubdate, a.lastscraped, " . "o.id as pub_id, o.shortname as pub_shortname, o.prettyname as pub_name, o.home_url as pub_home_url\n" . $from_clause . $where_clause . $order_clause . $limit_clause;
    $arts = db_getAll($sql, $params);
    $sql = "SELECT COUNT(*)\n" . $from_clause . $where_clause;
    $total = intval(db_getOne($sql, $params));
    return array(&$arts, $total);
}
function read_listing($params, $url = 'http://www.auto24.ee/kasutatud/nimekiri.php')
{
    $endpoint = build_query($url, $params);
    $html = scraperWiki::scrape($endpoint);
    $dom = new simple_html_dom();
    $dom->load($html);
    $totalResultsEl = $dom->find('.paginator .current-range strong');
    $totalResults = $totalResultsEl[0]->plaintext;
    $medianItem = ($totalResults + 1) / 2;
    if ($medianItem > RESULTS_PER_PAGE) {
        $listingOffset = floor($medianItem / RESULTS_PER_PAGE) * RESULTS_PER_PAGE;
        $params['ak'] = $listingOffset;
        $medianItem -= $listingOffset;
        $endpoint = build_query($url, $params);
        $html = scraperWiki::scrape($endpoint);
        $dom = new simple_html_dom();
        $dom->load($html);
    }
    $rows = $dom->find("[@id=usedVehiclesSearchResult] .result-row");
    $lPoint = floor($medianItem) - 1;
    $hPoint = ceil($medianItem) - 1;
    $a24ksi = 0;
    if ($lPoint == $hPoint) {
        $rowData = get_row_data($rows[$lPoint]);
        $a24ksi = $rowData['price'];
    } else {
        $lRowData = get_row_data($rows[$lPoint]);
        $hRowData = get_row_data($rows[$hPoint]);
        $a24ksi = round(($lRowData['price'] + $hRowData['price']) / 2);
    }
    return array('n' => $totalResults, 'val' => $a24ksi);
}
/**
 * Filter the activity loop.
 *
 * Specifically, when on the activity directory and clicking on the "Followed
 * Sites" tab.
 *
 * @param str $qs The querystring for the BP loop
 * @param str $object The current object for the querystring
 * @return str Modified querystring
 */
function bp_follow_blogs_add_activity_scope_filter($qs, $object)
{
    // not on the blogs object? stop now!
    if ($object != 'activity') {
        return $qs;
    }
    // parse querystring into an array
    $r = wp_parse_args($qs);
    if (bp_is_current_action(constant('BP_FOLLOW_BLOGS_USER_ACTIVITY_SLUG'))) {
        $r['scope'] = 'followblogs';
    }
    if (!isset($r['scope'])) {
        return $qs;
    }
    if ('followblogs' !== $r['scope']) {
        return $qs;
    }
    // get blog IDs that the user is following
    $following_ids = bp_get_following_ids(array('user_id' => bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id(), 'follow_type' => 'blogs'));
    // if $following_ids is empty, pass a negative number so no blogs can be found
    $following_ids = empty($following_ids) ? -1 : $following_ids;
    $args = array('user_id' => 0, 'object' => 'blogs', 'primary_id' => $following_ids);
    // make sure we add a separator if we have an existing querystring
    if (!empty($qs)) {
        $qs .= '&';
    }
    // add our follow parameters to the end of the querystring
    $qs .= build_query($args);
    // support BP Groupblog
    // We need to filter the WHERE SQL conditions to do this
    if (function_exists('bp_groupblog_init')) {
        add_filter('bp_activity_get_where_conditions', 'bp_follow_blogs_groupblog_activity_where_conditions', 10, 2);
    }
    return $qs;
}
 /**
  * **********************************************
  * Request Verification Code
  * https://msdn.microsoft.com/en-us/library/ff749592.aspx
  *
  * The following example shows a URL that enables
  * a user to provide consent to an application by
  * using a Windows Live ID.
  *
  * When successful, this URL returns the user to
  * your application, along with a verification
  * code.
  * **********************************************
  */
 public function requestVerificationCode($transactionId)
 {
     $params = array('response_type' => 'code', 'redirect_uri' => urlencode($this->getCallbackUri()), 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'scope' => urlencode(self::SCOPE), 'access_type' => 'offline', 'approval_prompt' => 'force');
     $authUrl = $this->getAuthorizationUrl() . '?' . build_query($params);
     $this->getLogger()->debug('Requesting verification code from Microsoft');
     PostmanUtils::redirect($authUrl);
 }
function bpdev_exclude_users($qs = false, $object = false)
{
    //list of users to exclude
    $excluded_user = '******';
    //comma separated ids of users whom you want to exclude
    /*
    // Remove the comment lines here to only disable admin listing ONLY on the members page.
    //if($object!='members')//hide for members only
    //{
    //return $qs;
    //}	
    */
    $args = wp_parse_args($qs);
    //check if we are listing friends?, do not exclude in this case
    if (!empty($args['user_id'])) {
        return $qs;
    }
    if (!empty($args['exclude'])) {
        $args['exclude'] = $args['exclude'] . ',' . $excluded_user;
    } else {
        $args['exclude'] = $excluded_user;
    }
    $qs = build_query($args);
    return $qs;
}
 /**
  * The authorization sequence begins when your application redirects a browser to a Google URL;
  * the URL includes query parameters that indicate the type of access being requested.
  *
  * As in other scenarios, Google handles user authentication, session selection, and user consent.
  * The result is an authorization code, which Google returns to your application in a query string.
  *
  * (non-PHPdoc)
  *
  * @see PostmanAuthenticationManager::requestVerificationCode()
  */
 public function requestVerificationCode($transactionId)
 {
     $params = array('response_type' => 'code', 'redirect_uri' => urlencode($this->getCallbackUri()), 'client_id' => $this->getClientId(), 'scope' => urlencode(self::SCOPE_FULL_ACCESS), 'access_type' => 'offline', 'approval_prompt' => 'force', 'state' => $transactionId, 'login_hint' => $this->senderEmail);
     $authUrl = $this->getAuthorizationUrl() . '?' . build_query($params);
     $this->getLogger()->debug('Requesting verification code from Google');
     PostmanUtils::redirect($authUrl);
 }
 /**
  * Initiate an SSO login
  * @return void
  */
 public function sso_login()
 {
     // Get SSO hash
     $hash = '';
     if (isset($_REQUEST['SSO_HASH'])) {
         $hash = $_REQUEST['SSO_HASH'];
     }
     // @codeCoverageIgnoreStart
     // Redirect for www domains
     if (preg_match('/^www\\./', parse_url(get_option('home'), PHP_URL_HOST)) && !preg_match('/^www\\./', $_SERVER['HTTP_HOST'])) {
         @wp_safe_redirect(home_url() . '?' . build_query(array('GD_COMMAND' => 'SSO_LOGIN', 'SSO_HASH' => $_REQUEST['SSO_HASH'], 'SSO_USER_ID' => $_REQUEST['SSO_USER_ID'])));
         add_filter('wp_die_handler', 'gd_system_die_handler', 10, 1);
         wp_die();
     }
     // @codeCoverageIgnoreEnd
     // Get SSO user
     $user_id = 0;
     if (isset($_REQUEST['SSO_USER_ID']) && !empty($_REQUEST['SSO_USER_ID'])) {
         $user_id = $_REQUEST['SSO_USER_ID'];
     } else {
         $user = get_users(array('role' => 'administrator', 'number' => 1));
         if (!$user[0] instanceof WP_User) {
             return;
         }
         $user_id = $user[0]->ID;
     }
     // Set the cookie
     if ($this->_is_valid_sso_login($hash)) {
         @wp_set_auth_cookie($user_id);
     }
     // Redirect to the dashboard
     @wp_safe_redirect(self_admin_url());
     add_filter('wp_die_handler', 'gd_system_die_handler', 10, 1);
     wp_die();
 }
Пример #11
0
 function get_user_followers($userid, $page, $username)
 {
     $text = "SELECT id, following_user_id AS username FROM follow WHERE follower_user_id='{$userid}' AND deleted_time=''";
     $return['query'] = build_query($text, $page);
     $return['pagination'] = get_pagination($text, $page);
     return $return;
 }
Пример #12
0
function get_total($dbc, $subject, $predicate, $object)
{
    $query = build_query($dbc, $subject, $predicate, $object, true);
    $result = mysqli_query($dbc, $query);
    $row = mysqli_fetch_array($result);
    $total = $row['count'];
    return $total;
}
Пример #13
0
function get_total($dbc, $type)
{
    $query = build_query($dbc, $type, true);
    $result = mysqli_query($dbc, $query);
    $row = mysqli_fetch_array($result);
    $total = $row['count'];
    return $total;
}
Пример #14
0
function get_total($dbc, $keywords, $active_relation, $dbc)
{
    $query = build_query($dbc, $keywords, $active_relation, true);
    $result = mysqli_query($dbc, $query);
    $row = mysqli_fetch_array($result);
    $total = $row['count'];
    return $total;
}
Пример #15
0
 /**
  * Gets a Google Analytics Campaign url for this product
  *
  * @param string $path
  * @param string $link_identifier
  * @return string The full URL
  */
 public function get_tracking_url($path = '', $link_identifier = '')
 {
     $tracking_vars = array('utm_campaign' => $this->item_name . ' licensing', 'utm_medium' => 'link', 'utm_source' => $this->item_name, 'utm_content' => $link_identifier);
     // url encode tracking vars
     $tracking_vars = urlencode_deep($tracking_vars);
     $query_string = build_query($tracking_vars);
     return $this->item_url . ltrim($path, '/') . '#' . $query_string;
 }
Пример #16
0
 function get_tag($tag, $page)
 {
     $term = make_it_safe($tag);
     $text = "SELECT DISTINCT id, time FROM quiz JOIN (SELECT quiz_id FROM tag WHERE tag='{$term}') AS hellyeah ON quiz.id=quiz_id";
     $return['query'] = build_query($text, $page);
     $return['pagination'] = get_pagination($text, $page);
     return $return;
 }
Пример #17
0
function acf_pro_get_remote_url($action = '', $args = array())
{
    // defaults
    $args['a'] = $action;
    $args['p'] = 'pro';
    // vars
    $url = "https://connect.advancedcustomfields.com/index.php?" . build_query($args);
    // return
    return $url;
}
Пример #18
0
 public function request_api($args)
 {
     $endpoint = 'https://api.thebase.in/1/search';
     $query = build_query($args);
     $response = wp_remote_get($endpoint . '?' . $query);
     if (200 !== wp_remote_retrieve_response_code($response)) {
         return null;
     }
     return json_decode(wp_remote_retrieve_body($response));
 }
    /**
     * Render main shortcode.
     * 
     * @since 1.0.0
     * @access public
     * @param array $atts 
     * @param string $content 
     * @return string
     */
    public function render_shortcode($atts, $content = null)
    {
        $atts = shortcode_atts(array(), $atts, $this->shortcode);
        // must add the third params $this->shortcode, for builder shortcode rendering
        global $query_string, $TF;
        $output = '';
        $build_query = array('post_type' => 'post');
        if (TF_Model::is_template_page()) {
            query_posts(build_query($build_query));
        } else {
            query_posts($query_string);
        }
        if (have_posts()) {
            $TF->in_archive_loop = true;
            the_post();
            ob_start();
            ?>
			<?php 
            do_action('tf_single_loop_before_post');
            ?>

			<article <?php 
            echo tf_get_attr('post', $original_atts);
            ?>
>

				<?php 
            do_action('tf_single_loop_start_post');
            ?>

				<?php 
            echo do_shortcode($content);
            ?>

				<?php 
            do_action('tf_single_loop_end_post');
            ?>

			</article>

			<?php 
            do_action('tf_single_loop_after_post');
            ?>

			<?php 
            $output .= ob_get_contents();
            ob_get_clean();
            $TF->in_archive_loop = false;
        }
        wp_reset_query();
        return $output;
    }
Пример #20
0
function wpcf7_admin_url($query = array())
{
    global $plugin_page;
    if (!isset($query['page'])) {
        $query['page'] = $plugin_page;
    }
    $path = 'admin.php';
    if ($query = build_query($query)) {
        $path .= '?' . $query;
    }
    $url = admin_url($path);
    return esc_url_raw($url);
}
Пример #21
0
 public function get_auth_dialog_url($scopes = array('read_store_profile', 'read_catalog'))
 {
     if (!is_array($scopes)) {
         return false;
     }
     $url = 'https://my.ecwid.com/api/oauth/authorize';
     $params['source'] = 'wporg';
     $params['client_id'] = get_option('ecwid_oauth_client_id');
     $params['redirect_uri'] = admin_url('admin-post.php?action=ecwid_oauth');
     $params['response_type'] = 'code';
     $params['scope'] = implode(',', $scopes);
     return $url . '?' . build_query($params);
 }
Пример #22
0
function get_competitor_products($json)
{
    $json = json_decode($json, true);
    $i = 0;
    foreach ($json['items'] as $item) {
        $query = build_query($item);
        $price = $item['price'];
        $competitor = find_product($query, $price);
        $json['items'][$i] = array_merge($item, $competitor);
        $i++;
    }
    return json_encode($json);
}
Пример #23
0
function bfox_bp_bible_directory_querystring($query_string, $object)
{
    $ref = bfox_ref();
    if ($ref->is_valid()) {
        $args = wp_parse_args($query_string);
        if (!empty($args['search_terms'])) {
            $args['search_terms'] .= ' ';
        }
        $args['search_terms'] .= $ref->get_string();
        $query_string = build_query($args);
    }
    return $query_string;
}
Пример #24
0
function wpcf7_admin_url($file, $query = array())
{
    $file = trim($file, ' /');
    if ('admin/' != substr($file, 0, 6)) {
        $file = 'admin/' . $file;
    }
    $path = 'admin.php';
    $path .= '?page=' . WPCF7_PLUGIN_NAME . '/' . $file;
    if ($query = build_query($query)) {
        $path .= '&' . $query;
    }
    $url = admin_url($path);
    return sanitize_url($url);
}
Пример #25
0
 /**
  * @param $step
  *
  * @return array
  */
 private function profile_step($step)
 {
     // build url
     $data = array('step' => $step, 'slug' => $this->plugin_slug);
     $url = add_query_arg($data, $this->url);
     $start = microtime(true);
     $response = wp_remote_get($url, array('headers' => array('Accept-Encoding' => '*', 'X-Plugin-Profiler-Action' => 'profile', 'X-Plugin-Profiler-Signature' => hash_hmac('sha1', build_query($data), AUTH_KEY))));
     // return 0 if an error occurred
     if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200) {
         return 0;
     }
     $time = microtime(true) - $start;
     return round($time, 3);
 }
 /**
  * Talk to the API endpoint
  * @param string $method
  * @param array $args
  * @param string $verb
  * @return array|WP_Error
  */
 public function make_call($method, $args = array(), $verb = 'GET')
 {
     global $gd_system_config;
     if ($gd_system_config->missing_gd_config) {
         return;
     }
     $config = $gd_system_config->get_config();
     if (!isset($config['api_url'])) {
         return;
     }
     $max_retries = 1;
     $retries = 0;
     if (!in_array($verb, array('GET', 'POST'))) {
         return new WP_Error('gd_system_api_bad_verb', sprintf(__('Unknown verb: %s. Try GET or POST', 'gd_system'), $verb));
     }
     while ($retries <= $max_retries) {
         $retries++;
         if ('GET' === $verb) {
             $url = $config['api_url'] . $method;
             if (!empty($args)) {
                 $url .= '?' . build_query($args);
             }
             add_filter('https_ssl_verify', '__return_false');
             $result = wp_remote_get($url, $this->get_args());
             remove_filter('https_ssl_verify', '__return_false');
         } elseif ('POST' === $verb) {
             $_args = $this->get_args();
             $_args['body'] = $args;
             add_filter('https_ssl_verify', '__return_false');
             $result = wp_remote_post($config['api_url'] . $method, $_args);
             remove_filter('https_ssl_verify', '__return_false');
         }
         if (is_wp_error($result)) {
             break;
         } elseif (self::_is_retryable_error($result)) {
             // The service is in a known maintenance condition, give a sec to recover
             sleep(apply_filters('gd_system_api_retry_delay', 1));
             continue;
         } else {
             break;
         }
     }
     do_action('gd_system_api_debug_request', $config['api_url'] . $method, $this->get_args());
     do_action('gd_system_api_debug_response', array('result' => $result));
     if (!is_wp_error($result) && '200' != $result['response']['code']) {
         return new WP_Error('gd_system_api_bad_status', sprintf(__('API returned bad status: %d: %s', 'gd_system'), $result['response']['code'], $result['response']['message']));
     }
     return $result;
 }
 public function plugin_action_links($links, $file, $plugin_data, $context)
 {
     if ('dropins' === $context) {
         return $links;
     }
     if ('mustuse' === $context) {
         $what = 'mustuse';
     } else {
         $what = 'plugin';
     }
     $dowload_query = build_query(array('wpd' => $what, 'object' => $file));
     $download_link = sprintf('<a href="%s">%s</a>', wp_nonce_url(admin_url('?' . $dowload_query), 'wpd-download'), $this->verb);
     array_push($links, $download_link);
     return $links;
 }
 /**
  * Retrieve records
  *
  * @param array $args
  *
  * @return array
  */
 public function get_records($args)
 {
     $headers = array('Authorization' => 'Basic ' . base64_encode($this->api_access_id . ':' . $this->api_access_key));
     $params = array('q' => '_source=spp-test-stream');
     $url = $this->api_endpoint . '?' . build_query($params);
     if (function_exists('vip_safe_wp_remote_get')) {
         $response = \vip_safe_wp_remote_get($url, array('headers' => $headers));
     } else {
         $response = \wp_remote_get($url, array('headers' => $headers));
     }
     if (is_wp_error($response)) {
         return array();
     }
     $result = json_decode($response['body']);
     return $result;
 }
Пример #29
0
 /**
  * Takes a few params and determins a pagination link structure
  * @param string $link
  * @param int $total
  * @param int $limit
  * @param int $page
  * @param int $pagesToShow
  * @return string
  */
 function em_paginate($link, $total, $limit, $page = 1, $pagesToShow = 10)
 {
     if ($limit > 0) {
         $url_parts = explode('?', $link);
         $base_link = $url_parts[0];
         //Get querystring for first page without page
         $query_arr = array();
         parse_str($url_parts[1], $query_arr);
         unset($query_arr['page']);
         unset($query_arr['pno']);
         $base_querystring = build_query($query_arr);
         if (!empty($base_querystring)) {
             $base_querystring = '?' . $base_querystring;
         }
         //calculate
         $maxPages = ceil($total / $limit);
         //Total number of pages
         $startPage = $page <= $pagesToShow ? 1 : $pagesToShow * floor($page / $pagesToShow);
         //Which page to start the pagination links from (in case we're on say page 12 and $pagesToShow is 10 pages)
         $placeholder = urlencode('%PAGE%');
         $link = str_replace('%PAGE%', $placeholder, $link);
         //To avoid url encoded/non encoded placeholders
         //Add the back and first buttons
         $string = $page > 1 && $startPage != 1 ? '<a class="prev page-numbers" href="' . str_replace($placeholder, 1, $link) . '" title="1">&lt;&lt;</a> ' : '';
         if ($page == 2) {
             $string .= ' <a class="prev page-numbers" href="' . $base_link . $base_querystring . '" title="2">&lt;</a> ';
         } elseif ($page > 2) {
             $string .= ' <a class="prev page-numbers" href="' . str_replace($placeholder, $page - 1, $link) . '" title="' . ($page - 1) . '">&lt;</a> ';
         }
         //Loop each page and create a link or just a bold number if its the current page
         for ($i = $startPage; $i < $startPage + $pagesToShow && $i <= $maxPages; $i++) {
             if ($i == $page) {
                 $string .= ' <strong><span class="page-numbers current">' . $i . '</span></strong>';
             } elseif ($i == '1') {
                 $string .= ' <a class="page-numbers" href="' . $base_link . $base_querystring . '" title="' . $i . '">' . $i . '</a> ';
             } else {
                 $string .= ' <a class="page-numbers" href="' . str_replace($placeholder, $i, $link) . '" title="' . $i . '">' . $i . '</a> ';
             }
         }
         //Add the forward and last buttons
         $string .= $page < $maxPages ? ' <a class="next page-numbers" href="' . str_replace($placeholder, $page + 1, $link) . '" title="' . ($page + 1) . '">&gt;</a> ' : ' ';
         $string .= $i - 1 < $maxPages ? ' <a class="next page-numbers" href="' . str_replace($placeholder, $maxPages, $link) . '" title="' . $maxPages . '">&gt;&gt;</a> ' : ' ';
         //Return the string
         return apply_filters('em_paginate', '<span class="em-pagination">' . $string . '</span>');
     }
 }
 /**
  * Returns the PayPal redirect URL
  *
  * @param array $data Arguments to encode with the URL
  * @return string
  * @since 3.9
  */
 public function get_redirect_url($data = array())
 {
     // Select either the Sandbox or the Live URL
     if ($this->setting->get('sandbox_mode')) {
         $url = $this->sandbox_url;
     } else {
         $url = $this->live_url;
     }
     // Common Vars
     $common = array('cmd' => '_express-checkout', 'useraction' => 'commit');
     if (wp_is_mobile()) {
         $common['cmd'] = '_express-checkout-mobile';
     }
     // Merge the two arrays
     $data = array_merge($data, $common);
     return $url . '?' . build_query($data);
 }