コード例 #1
0
 public static function display_settings_field_secret_key($args)
 {
     if (defined('EASYAZON_SECRET_KEY')) {
         printf('<p class="description">%s</p>', __('You have defined this value in your <code>wp-config.php</code> file with the <code>EASYAZON_SECRET_KEY</code> constant'));
     } else {
         printf('<input type="text" class="code large-text" id="%s" name="%s" value="%s" />', esc_attr(easyazon_get_setting_field_id('secret_key')), esc_attr(easyazon_get_setting_field_name('secret_key')), esc_attr(easyazon_get_setting('secret_key', '')));
     }
 }
コード例 #2
0
 public static function enqueue_scripts($settings)
 {
     wp_enqueue_script('knockout', plugins_url('vendor/knockout.js', EASYAZON_PLUGIN_FILE), array(), '3.2.0', true);
     wp_enqueue_script('easyazon-popup', plugins_url('resources/popup.js', __FILE__), array('jquery', 'knockout'), EASYAZON_VERSION, true);
     wp_enqueue_style('easyazon-popup', plugins_url('resources/popup.css', __FILE__), array('media'), EASYAZON_VERSION);
     wp_localize_script('easyazon-popup', 'EasyAzon_Popup', apply_filters('easyazon_popup_localize', array('attributes' => easyazon_get_attributes(), 'stateName' => 'iframe:easyazon', 'stateTitle' => __('EasyAzon'), 'tagNone' => __('None'), 'tagNoneValue' => '', 'tags' => array('BR' => array_filter(array(easyazon_get_setting('associates_br'))), 'CA' => array_filter(array(easyazon_get_setting('associates_ca'))), 'CN' => array_filter(array(easyazon_get_setting('associates_cn'))), 'DE' => array_filter(array(easyazon_get_setting('associates_de'))), 'ES' => array_filter(array(easyazon_get_setting('associates_es'))), 'FR' => array_filter(array(easyazon_get_setting('associates_fr'))), 'IN' => array_filter(array(easyazon_get_setting('associates_in'))), 'IT' => array_filter(array(easyazon_get_setting('associates_it'))), 'JP' => array_filter(array(easyazon_get_setting('associates_jp'))), 'UK' => array_filter(array(easyazon_get_setting('associates_uk'))), 'US' => array_filter(array(easyazon_get_setting('associates_us')))))));
     do_action('easyazon_popup_enqueue_scripts');
 }
コード例 #3
0
 public static function display_settings_field_default_search_locale($args)
 {
     $options = array();
     $default = easyazon_get_setting('default_search_locale');
     $locales = easyazon_get_locales();
     foreach ($locales as $locale => $locale_name) {
         $options[] = sprintf('<option %s value="%s">%s</option>', $default === $locale ? 'selected="selected"' : '', esc_attr($locale), esc_html($locale_name));
     }
     printf('<select id="%s" name="%s">%s</select>', easyazon_get_setting_field_id('default_search_locale'), easyazon_get_setting_field_name('default_search_locale'), implode('', $options));
 }
コード例 #4
0
 public static function shortcode_atts($sanitized, $atts)
 {
     // Identifier is always needed
     $sanitized['identifier'] = isset($atts['identifier']) ? $atts['identifier'] : false;
     $sanitized['identifier'] = false === $sanitized['identifier'] && isset($atts['asin']) ? $atts['asin'] : $sanitized['identifier'];
     // Locale is always needed
     $sanitized['locale'] = isset($atts['locale']) ? $atts['locale'] : easyazon_get_setting('default_search_locale');
     // Tag is always available, although it is optional
     $sanitized['tag'] = isset($atts['tag']) ? $atts['tag'] : false;
     // New window is always available, although it is optional and sometimes depends on the settings
     $sanitized['nw'] = isset($atts['nw']) ? $atts['nw'] : false;
     $sanitized['nw'] = false === $sanitized['nw'] && isset($atts['new_window']) ? $atts['new_window'] : $sanitized['nw'];
     $sanitized['nw'] = str_replace(array('yes', 'no'), array('y', 'n'), $sanitized['nw']);
     $sanitized['nw'] = in_array($sanitized['nw'], array('y', 'n')) ? $sanitized['nw'] : easyazon_get_setting('link_nw');
     // No follow is always available, although it is optional and sometimes depends on the settings
     $sanitized['nf'] = isset($atts['nf']) ? $atts['nf'] : false;
     $sanitized['nf'] = false === $sanitized['nf'] && isset($atts['nofollow']) ? $atts['nofollow'] : $sanitized['nf'];
     $sanitized['nf'] = str_replace(array('yes', 'no'), array('y', 'n'), $sanitized['nf']);
     $sanitized['nf'] = in_array($sanitized['nf'], array('y', 'n')) ? $sanitized['nf'] : easyazon_get_setting('link_nf');
     return $sanitized;
 }
コード例 #5
0
 public static function enqueue_scripts()
 {
     wp_enqueue_script('easyazon-popup-states-search', plugins_url('resources/popup-state.js', __FILE__), array('easyazon-popup'), EASYAZON_VERSION, true);
     wp_enqueue_style('easyazon-popup-states-search', plugins_url('resources/popup-state.css', __FILE__), array('easyazon-popup'), EASYAZON_VERSION);
     wp_localize_script('easyazon-popup-states-search', 'EasyAzon_PopupStates_Search', array('ajaxActionQueryProducts' => 'easyazon_query_products', 'locale' => easyazon_get_setting('default_search_locale')));
 }
コード例 #6
0
function easyazon_api_request_sign($url)
{
    // Decode anything already encoded
    $url = urldecode($url);
    // Parse the URL into $urlparts
    $urlparts = parse_url($url);
    // Build $params with each name/value pair
    foreach (explode('&', $urlparts['query']) as $part) {
        if (strpos($part, '=')) {
            list($name, $value) = explode('=', $part);
        } else {
            $name = $part;
            $value = '';
        }
        $params[$name] = $value;
    }
    // Sort the array by key
    ksort($params);
    // Build the canonical query string
    $canonical = '';
    foreach ($params as $key => $val) {
        $canonical .= "{$key}=" . rawurlencode($val) . '&';
    }
    // Remove the trailing ampersand
    $canonical = preg_replace("/&\$/", '', $canonical);
    // Some common replacements and ones that Amazon specifically mentions
    $canonical = str_replace(array(' ', '+', ', ', ';'), array('%20', '%20', urlencode(','), urlencode(':')), $canonical);
    // Build the si
    $string_to_sign = "GET\n{$urlparts['host']}\n{$urlparts['path']}\n{$canonical}";
    // Calculate our actual signature and base64 encode it
    $signature = base64_encode(hash_hmac('sha256', $string_to_sign, easyazon_get_setting('secret_key'), true));
    // Finally re-build the URL with the proper string and include the Signature
    return "{$urlparts['scheme']}://{$urlparts['host']}{$urlparts['path']}?{$canonical}&Signature=" . rawurlencode($signature);
}
コード例 #7
0
 public static function display_settings_field_associates_us($args)
 {
     printf('<input type="text" class="code regular-text" id="%s" name="%s" value="%s" /> <a href="%s" target="_blank">%s</a>', esc_attr(easyazon_get_setting_field_id('associates_us')), esc_attr(easyazon_get_setting_field_name('associates_us')), esc_attr(easyazon_get_setting('associates_us')), easyazon_get_locale_associate_signup_url('US'), __('Sign up'));
     printf('<p class="description">%s</p>', __('(i.e. yourtrackingid-20'));
 }
コード例 #8
0
 public static function display_settings_field_link_nf($args)
 {
     printf('<input type="hidden" name="%s" value="no" />', easyazon_get_setting_field_name('link_nf'));
     printf('<label><input type="checkbox" %s id="%s" name="%s" value="y" /> %s</label>', 'y' === easyazon_get_setting('link_nf') ? 'checked="checked"' : '', easyazon_get_setting_field_id('link_nf'), easyazon_get_setting_field_name('link_nf'), __('I want the <code>nofollow</code> attribute applied to EasyAzon links by default'));
 }