%2F * - & -> & * - & -> & (avoids double "&" encoding) * * @author oncletom * @version 1.0 * @since 1.1 beta * @return $encoded_uri String Encoded URI * @param $uri String Uri to encode */ protected static function encodeParameters($uri) { $parsed_uri = parse_url($uri); $qs_original = $parsed_uri['query']; $qs = str_replace(array('/', '&', '&'), array('%2F', '&', '&'), $qs_original); return str_replace($qs_original, $qs, $uri); } /** * Filter an hexa code to return it with a prefix, if needed * * @author oncletom * @version 2.0 * @since 1.3 * @return $color String * @param $color String Hexadecimal color to filter * @param $prefix Boolean[optional] Add a hash prefix or not * * @todo add a better filter which checks hexa code and more */ protected static function getHexadecimalFromString($color, $prefix = true) { // no need to go further if (!$color) { return ''; } $color = preg_replace('/[^a-fA-F0-9]/U', '', $color); $prefix = (bool)$prefix && $color ? '#' : ''; return $prefix.$color; } /** * Render a tracking image thanks to some parameters * * @author oncletom * @version 1.0 * @since 1.3 * @return String Tracking image HTML code * @param Array $options * @param Array $params * @param Boolean $render[optional] */ protected static function getTrackingImage($options, $params, $render = null) { $render = is_null($render) ? (bool)get_option('awshortcode_tracking_image') : (bool)$render; $query_string = array(); if (function_exists('http_build_query')) { $query_string = http_build_query($params, '', '&'); } $uri = sprintf( 'http://www.assoc-amazon.%s/e/ir?%s', $options['tld'], $query_string ); return ''; } /** * Converts a shortcode as HTML * * @author oncletom * @version 2.0 * @since 1.3 * @return $html String Shortcode HTML * @param $attributes Array * @param $value String[optional] */ abstract public function render(array $attributes, $value = null); }