Skip to content

Commit

Permalink
v7.3.0 - Added User Profile option to Your eBay Listings tool
Browse files Browse the repository at this point in the history
  • Loading branch information
morehawes committed Jan 22, 2025
1 parent c01d872 commit baf731e
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 83 deletions.
97 changes: 22 additions & 75 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,36 +104,16 @@ function an_alt_inputs() {
});
}

function an_create_tool_data(shortcode_data) {
var tool_data = {
item: {},
profile: {},
feedback: {},
};
function an_create_item_data(shortcode_data = []) {
var item_data = [];

for (data_key in shortcode_data) {
switch (0) {
case data_key.indexOf("item_"):
tool_data["item"][data_key.replace("item_", "")] =
shortcode_data[data_key];

break;

case data_key.indexOf("profile_"):
tool_data["profile"][data_key.replace("profile_", "")] =
shortcode_data[data_key];

break;

case data_key.indexOf("feedback_"):
tool_data["feedback"][data_key.replace("feedback_", "")] =
shortcode_data[data_key];

break;
if (data_key.indexOf("item_") !== -1) {
item_data[data_key.replace("item_", "")] = shortcode_data[data_key];
}
}

return tool_data;
return item_data;
}

//Tooltips
Expand Down Expand Up @@ -162,30 +142,22 @@ function an_setup_tooltips() {
});
}

function an_build_shortcode(tool_key = "item", tool_data = {}) {
//Legacy
tool_key = tool_key == "item" ? "listings" : tool_key;

var out = '[auction-nudge tool="' + tool_key + '"';
for (attr_key in tool_data) {
out += " " + attr_key.toLowerCase() + '="' + tool_data[attr_key] + '"';
function an_build_item_shortcode(item_data = []) {
var out = '[auction-nudge tool="listings"';
for (attr_key in item_data) {
out += " " + attr_key.toLowerCase() + '="' + item_data[attr_key] + '"';
}
out += "]";

return out;
}

function an_update_tool_snippets(tool_data = []) {
for (tool_key in tool_data) {
var shortcode = an_build_shortcode(tool_key, tool_data[tool_key]);
function an_update_item_snippets(item_data = []) {
var shortcode = an_build_item_shortcode(item_data);

var shortcode_container = jQuery("#an-shortcode-" + tool_key);
var shortcode_container = jQuery("#an-shortcode-item");

shortcode_container.html(shortcode);

// var font_size = 120 / (shortcode.length / 4 );
// shortcode_container.css('fontSize', font_size + 'px');
}
shortcode_container.html(shortcode);
}

function an_shortcode_input_value(data_key, input) {
Expand All @@ -203,23 +175,11 @@ function an_setup_settings_ui() {
return;
}

//Legacy Tab
// var legacy_options = jQuery('#an-settings-legacy table', body);
// //Legacy tab, but no legacy options
// if(! legacy_options.length) {
// var document_location = document.location.toString();
//
// if(document_location.toString().indexOf('tab=legacy') !== -1) {
// document.location = document_location.replace('tab=legacy', 'tab=general');
// }
// }

//Shortcode form
var container = jQuery("#an-shortcode-form-container", body);
if (container.length) {
var default_data = [];
var shortcode_data = [];
var tool_data = {};

//Update Shortcode
var update_shortcode = function (input) {
Expand All @@ -244,8 +204,8 @@ function an_setup_settings_ui() {
}

//Update snippet
tool_data = an_create_tool_data(shortcode_data);
an_update_tool_snippets(tool_data);
var item_data = an_create_item_data(shortcode_data);
an_update_item_snippets(item_data);
};

//Username check
Expand All @@ -262,12 +222,8 @@ function an_setup_settings_ui() {
}
};

var check_form = function (tool_key, form) {
if (tool_key == "item") {
var input = jQuery('input[name="item_SellerID"]', form);
} else {
var input = jQuery('input[name="' + tool_key + '_UserID"]', form);
}
var check_form = function (form) {
var input = jQuery('input[name="item_SellerID"]', form);

var success = check_input(input);
var button = jQuery('input[type="submit"]', form);
Expand All @@ -284,20 +240,17 @@ function an_setup_settings_ui() {
var form = jQuery("#an-shortcode-form");

//Initial
check_form("item", form);
check_form(form);

//Form submit
form.on("submit", function () {
check_form("item", form);
check_form(form);
});

//Input change
var inputs = jQuery(
'input[name="item_SellerID"], input[name="profile_UserID"], input[name="feedback_UserID"]',
container,
);
inputs.on("keypress change", function () {
check_form("item", form);
var inputs = jQuery('input[name="item_SellerID"]', container);
inputs.on("change keyup", function () {
check_form(form);
});
};

Expand All @@ -308,12 +261,6 @@ function an_setup_settings_ui() {
inputs.each(function () {
var input = jQuery(this);

// switch(input.attr('id')) {
// case 'SellerID' :
//
// break;
// }

//On change
input.on("change", function () {
update_shortcode(jQuery(this));
Expand Down
2 changes: 1 addition & 1 deletion auctionnudge.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: Auction Nudge
Plugin URI: https://www.auctionnudge.com/wordpress-plugin
Description: Set a default eBay Username in Settings, then display Your eBay Listings with the Shortcode [auction-nudge tool="listings"].
Version: 7.2.1
Version: 7.3.0
Author: Joe Hawes
Author URI: https://www.auctionnudge.com/
License: GPL2
Expand Down
24 changes: 21 additions & 3 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ function an_options_page() {

$tab_url = 'options-general.php?page=an_options_page&tab=shortcodes';

// Override defaults
$override_defaults = [];
$override_defaults['item_user_profile'] = '1';

//Preview submitted?
$request_params = an_request_parameters_from_assoc_array($tool_key, $_POST);
if (sizeof($request_params)) {
Expand All @@ -336,9 +340,14 @@ function an_options_page() {
} elseif (isset($an_settings['an_ebay_user']) && ! empty($an_settings['an_ebay_user'])) {
echo ' <div id="an-shortcode-preview" class="an-tab-left an-tab-content">' . "\n";

echo an_build_shortcode($tool_key, an_request_parameters_defaults($tool_key, true));
// Default parameters
$request_params = an_request_parameters_defaults($tool_key, true);

// Merge with any overrides
$request_params = array_merge($request_params, $override_defaults);

echo an_build_snippet($tool_key, an_request_parameters_defaults($tool_key, true));
echo an_build_shortcode($tool_key, $request_params);
echo an_build_snippet($tool_key, $request_params);

echo ' </div>' . "\n";
//Nothing to Preview - Welcome screen
Expand All @@ -354,8 +363,17 @@ function an_options_page() {
echo ' <h2>Shortcode Generator</h2>' . "\n";
echo ' <p>Add Shortcodes anywhere they are supported.</p>' . "\n";

// Get POST data (if any)
$post_data = $_POST;

// If empty - i.e. not yet submitted
if(! sizeof($post_data)) {
// Merge with any overrides
$post_data = array_merge($post_data, $override_defaults);
}

//Display form, propogated with any user submitted values
echo an_create_shortcode_form($_POST, $tool_key);
echo an_create_shortcode_form($post_data, $tool_key);
echo ' <input class="button button-primary" name="preview_tools" type="submit" value="Preview" />' . "\n";

echo ' </form>' . "\n";
Expand Down
16 changes: 15 additions & 1 deletion inc/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$an_plugin_config = [
'plugin_name' => 'Auction Nudge',
'plugin_version' => '7.2.1',
'plugin_version' => '7.3.0',
'custom_field_prefix' => 'an',
'shortcode' => 'auction-nudge',
'tool_keys' => ['item', 'ad', 'profile', 'feedback'],
Expand Down Expand Up @@ -286,6 +286,20 @@
'preg_replace("/[^0-9]/", "", $param_value);',
],
],
'item_user_profile' => [
'name' => 'item_user_profile',
'id' => 'item_user_profile',
'tip' => 'If enabled, your eBay Username, positive feedback percentage, feedback score and feedback star (if applicable) will be displayed above your listings.',

'type' => 'radio',
'group' => 'display',
'title' => 'Show User Profile?',
'default' => '0',
'options' => [
'1' => 'Yes',
'0' => 'No',
],
],
//Advanced
'item_sortOrder' => [
'name' => 'item_sortOrder',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Auction Nudge",
"version": "7.2.1",
"version": "7.3.0",
"homepage": "https://www.auctionnudge.com/wordpress-plugin/about",
"description": "Auction Nudge for WordPress",
"author": "Joe Hawes",
Expand Down
14 changes: 13 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Requires at least:** 3.2
**Tested up to:** 6.7
**Requires PHP:** 5.2
**Stable tag:** 7.2.1
**Stable tag:** 7.3.0
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -62,6 +62,7 @@ Add the Auction Nudge Shortcode anywhere that Shortcodes are supported:
* **Show Search Box?** - Allow your site visitors to search all of your active eBay items by keyword
* **Open Links in New Tab?** - Decide if your visitors should be taken to eBay in a new tab or the current one
* **Image Size** - Large item images can be displayed (up to 500px by 500px)
* **User Profile** - Display your eBay username, positive feedback percentage, feedback score and feedback star (if applicable) at the top of the Your eBay Listings tool

### Advanced Options ###

Expand Down Expand Up @@ -162,6 +163,17 @@ More information can be found <a href="https://www.auctionnudge.com/changes#v202

## Changelog ##

### 7.3.0 ###

Added the option to display a user's eBay profile information at the top of the Your eBay Listings tool. This includes:

* eBay Username
* Positive feedback percentage
* Feedback score
* Feedback star (if applicable)

This option is available in the Display Options section when creating your snippet, or through the `user_profile="1"` Shortcode parameter.

### 7.2.1 ###

Admin form Cross Site Scripting (XSS) vulnerability fix. Thanks to <a href="https://patchstack.com/database/researcher/e8b26d85-211b-4078-9d62-d56faa6d7f8a">b4orvn</a> for reporting this via <a href="https://patchstack.com">Patchstack</a>.
Expand Down
14 changes: 13 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: ebay, item, listing, embed, store
Requires at least: 3.2
Tested up to: 6.7
Requires PHP: 5.2
Stable tag: 7.2.1
Stable tag: 7.3.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -62,6 +62,7 @@ Add the Auction Nudge Shortcode anywhere that Shortcodes are supported:
* **Show Search Box?** - Allow your site visitors to search all of your active eBay items by keyword
* **Open Links in New Tab?** - Decide if your visitors should be taken to eBay in a new tab or the current one
* **Image Size** - Large item images can be displayed (up to 500px by 500px)
* **User Profile** - Display your eBay username, positive feedback percentage, feedback score and feedback star (if applicable) at the top of the Your eBay Listings tool

= Advanced Options =

Expand Down Expand Up @@ -154,6 +155,17 @@ More information can be found <a href="https://www.auctionnudge.com/changes#v202

== Changelog ==

= 7.3.0 =

Added the option to display a user's eBay profile information at the top of the Your eBay Listings tool. This includes:

* eBay Username
* Positive feedback percentage
* Feedback score
* Feedback star (if applicable)

This option is available in the Display Options section when creating your snippet, or through the `user_profile="1"` Shortcode parameter.

= 7.2.1 =

Admin form Cross Site Scripting (XSS) vulnerability fix. Thanks to <a href="https://patchstack.com/database/researcher/e8b26d85-211b-4078-9d62-d56faa6d7f8a">b4orvn</a> for reporting this via <a href="https://patchstack.com">Patchstack</a>.
Expand Down

0 comments on commit baf731e

Please sign in to comment.