Version Description
This update improves mobile rendering of default templates and some bug fixes.
Download this release
Release Info
Developer | amazonlinkbuilder |
Plugin | Amazon Associates Link Builder |
Version | 1.4.4 |
Comparing to | |
See all releases |
Code changes from version 1.4.3 to 1.4.4
- aalb_config.php +4 -2
- admin/aalb_admin.php +22 -5
- admin/css/aalb_admin.css +59 -2
- admin/js/aalb_admin.js +99 -7
- admin/partials/aalb_meta_box.php +25 -20
- admin/sidebar/partials/aalb_credentials.php +1 -1
- admin/sidebar/partials/aalb_templates.php +1 -1
- amazon-associates-link-builder.php +1 -1
- readme.txt +12 -2
- shortcode/aalb_shortcode.php +1 -1
- shortcode/aalb_shortcode_helper.php +2 -2
- shortcode/aalb_shortcode_text.php +1 -1
- template/ProductCarousel.mustache +38 -30
- template/ProductGrid.mustache +39 -15
aalb_config.php
CHANGED
@@ -13,7 +13,7 @@ and limitations under the License.
|
|
13 |
*/
|
14 |
|
15 |
//version
|
16 |
-
define( 'AALB_PLUGIN_CURRENT_VERSION', '1.4.
|
17 |
|
18 |
//PHP version compatible for AALB plugin
|
19 |
define('AALB_PLUGIN_MINIMUM_SUPPORTED_PHP_VERSION','5.3.0');
|
@@ -104,10 +104,12 @@ define( 'AALB_BASICS_CSS', AALB_PLUGIN_URL . 'css/aalb_basics.css' );
|
|
104 |
//Local Scripts
|
105 |
define( 'AALB_SHA2_JS', AALB_PLUGIN_URL . 'lib/js/jssha2/sha2.js' );
|
106 |
define( 'AALB_ADMIN_JS', AALB_PLUGIN_URL . 'admin/js/aalb_admin.js' );
|
107 |
-
define( 'AALB_ADMIN_ITEM_SEARCH_ITEMS_URL', AALB_PLUGIN_URL . 'aalb_admin_item_search_items.hbs' );
|
108 |
define( 'AALB_TEMPLATE_JS', AALB_PLUGIN_URL . 'admin/sidebar/js/aalb_template.js' );
|
109 |
define( 'AALB_CREDENTIALS_JS', AALB_PLUGIN_URL . 'admin/sidebar/js/aalb_credentials.js' );
|
110 |
|
|
|
|
|
|
|
111 |
//External Scripts
|
112 |
define( 'HANDLEBARS_JS', 'https://d8fd03967nrad.cloudfront.net/libs/handlebars.js/4.0.5/handlebars.min.js' );
|
113 |
define( 'CODEMIRROR_JS', 'https://d8fd03967nrad.cloudfront.net/libs/codemirror/5.13.2/codemirror.min.js' );
|
13 |
*/
|
14 |
|
15 |
//version
|
16 |
+
define( 'AALB_PLUGIN_CURRENT_VERSION', '1.4.4' );
|
17 |
|
18 |
//PHP version compatible for AALB plugin
|
19 |
define('AALB_PLUGIN_MINIMUM_SUPPORTED_PHP_VERSION','5.3.0');
|
104 |
//Local Scripts
|
105 |
define( 'AALB_SHA2_JS', AALB_PLUGIN_URL . 'lib/js/jssha2/sha2.js' );
|
106 |
define( 'AALB_ADMIN_JS', AALB_PLUGIN_URL . 'admin/js/aalb_admin.js' );
|
|
|
107 |
define( 'AALB_TEMPLATE_JS', AALB_PLUGIN_URL . 'admin/sidebar/js/aalb_template.js' );
|
108 |
define( 'AALB_CREDENTIALS_JS', AALB_PLUGIN_URL . 'admin/sidebar/js/aalb_credentials.js' );
|
109 |
|
110 |
+
//Templates
|
111 |
+
define( 'AALB_ADMIN_ITEM_SEARCH_ITEMS_URL', AALB_PLUGIN_URL . 'aalb_admin_item_search_items.hbs?ver=' . AALB_PLUGIN_CURRENT_VERSION );
|
112 |
+
|
113 |
//External Scripts
|
114 |
define( 'HANDLEBARS_JS', 'https://d8fd03967nrad.cloudfront.net/libs/handlebars.js/4.0.5/handlebars.min.js' );
|
115 |
define( 'CODEMIRROR_JS', 'https://d8fd03967nrad.cloudfront.net/libs/codemirror/5.13.2/codemirror.min.js' );
|
admin/aalb_admin.php
CHANGED
@@ -66,8 +66,8 @@ class Aalb_Admin {
|
|
66 |
if ( WP_POST != $hook && WP_POST_NEW != $hook ) {
|
67 |
return;
|
68 |
}
|
69 |
-
wp_enqueue_style( 'aalb_basics_css', AALB_BASICS_CSS );
|
70 |
-
wp_enqueue_style( 'aalb_admin_css', AALB_ADMIN_CSS );
|
71 |
wp_enqueue_style( 'font_awesome_css', FONT_AWESOME_CSS );
|
72 |
wp_enqueue_style( 'thickbox' );
|
73 |
}
|
@@ -86,12 +86,13 @@ class Aalb_Admin {
|
|
86 |
wp_enqueue_style( 'thickbox' );
|
87 |
wp_enqueue_script( 'jquery' );
|
88 |
wp_enqueue_script( 'handlebars_js', HANDLEBARS_JS );
|
89 |
-
wp_enqueue_script( 'aalb_sha2_js', AALB_SHA2_JS );
|
90 |
|
91 |
-
wp_enqueue_script( 'aalb_admin_js', AALB_ADMIN_JS, array( 'handlebars_js', 'jquery', 'aalb_sha2_js' ) );
|
92 |
wp_enqueue_style( 'thickbox' );
|
93 |
wp_localize_script( 'aalb_admin_js', 'api_pref', $this->get_paapi_pref() );
|
94 |
-
|
|
|
95 |
|
96 |
/**
|
97 |
* Returns data to be localized in the script.
|
@@ -114,6 +115,22 @@ class Aalb_Admin {
|
|
114 |
);
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
/**
|
118 |
* Checks if the plugin has been updated and calls required method
|
119 |
*
|
66 |
if ( WP_POST != $hook && WP_POST_NEW != $hook ) {
|
67 |
return;
|
68 |
}
|
69 |
+
wp_enqueue_style( 'aalb_basics_css', AALB_BASICS_CSS, array(), AALB_PLUGIN_CURRENT_VERSION );
|
70 |
+
wp_enqueue_style( 'aalb_admin_css', AALB_ADMIN_CSS, array(), AALB_PLUGIN_CURRENT_VERSION );
|
71 |
wp_enqueue_style( 'font_awesome_css', FONT_AWESOME_CSS );
|
72 |
wp_enqueue_style( 'thickbox' );
|
73 |
}
|
86 |
wp_enqueue_style( 'thickbox' );
|
87 |
wp_enqueue_script( 'jquery' );
|
88 |
wp_enqueue_script( 'handlebars_js', HANDLEBARS_JS );
|
89 |
+
wp_enqueue_script( 'aalb_sha2_js', AALB_SHA2_JS, array(), AALB_PLUGIN_CURRENT_VERSION );
|
90 |
|
91 |
+
wp_enqueue_script( 'aalb_admin_js', AALB_ADMIN_JS, array( 'handlebars_js', 'jquery', 'aalb_sha2_js' ), AALB_PLUGIN_CURRENT_VERSION );
|
92 |
wp_enqueue_style( 'thickbox' );
|
93 |
wp_localize_script( 'aalb_admin_js', 'api_pref', $this->get_paapi_pref() );
|
94 |
+
wp_localize_script( 'aalb_admin_js', 'aalb_strings', $this->get_aalb_strings() );
|
95 |
+
}
|
96 |
|
97 |
/**
|
98 |
* Returns data to be localized in the script.
|
115 |
);
|
116 |
}
|
117 |
|
118 |
+
/**
|
119 |
+
* Returns constant strings to be used in aalb_admin.js
|
120 |
+
* Makes the variable values in PHP to be used in Javascript.
|
121 |
+
*
|
122 |
+
* @since 1.4.4
|
123 |
+
* @return array Data to be localized in the script
|
124 |
+
**/
|
125 |
+
private function get_aalb_strings() {
|
126 |
+
return array(
|
127 |
+
"template_asin_error" => "Only one product can be selected for template",
|
128 |
+
"no_asin_selected_error" => "Please select at least one product for display",
|
129 |
+
"empty_product_search_bar" => "Please Enter a Product Name ",
|
130 |
+
"short_code_create_failure" => "Failed to create Text Link shortcode. Editor has some text selected. Only one item can be selected while adding text links"
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
/**
|
135 |
* Checks if the plugin has been updated and calls required method
|
136 |
*
|
admin/css/aalb_admin.css
CHANGED
@@ -25,6 +25,7 @@ input.aalb-admin-input-search {
|
|
25 |
margin-left: 3px;
|
26 |
margin-right: 3px;
|
27 |
height: 28px;
|
|
|
28 |
}
|
29 |
|
30 |
.aalb-admin-searchbox a.aalb-admin-button-create-amazon-shortcode {
|
@@ -65,10 +66,11 @@ html, body {
|
|
65 |
#aalb-admin-popup-container {
|
66 |
height: 100%;
|
67 |
width: 100%;
|
|
|
68 |
}
|
69 |
|
70 |
#aalb-admin-popup-content {
|
71 |
-
padding-top:
|
72 |
height: 50%;
|
73 |
width: 100%;
|
74 |
}
|
@@ -124,7 +126,6 @@ html, body {
|
|
124 |
width: 100%;
|
125 |
height: 90%;
|
126 |
display: none;
|
127 |
-
padding-top: 3%;
|
128 |
}
|
129 |
|
130 |
.aalb-admin-item-search-items {
|
@@ -138,6 +139,7 @@ html, body {
|
|
138 |
-moz-column-count: 3;
|
139 |
-webkit-column-count: 3;
|
140 |
column-count: 3;
|
|
|
141 |
}
|
142 |
|
143 |
.aalb-admin-item-search-items-item {
|
@@ -228,6 +230,24 @@ and(-webkit-min-device-pixel-ratio: 0) {
|
|
228 |
}
|
229 |
}
|
230 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
.aalb-admin-item-search-items-item-price {
|
233 |
font-size: 1em;
|
@@ -244,6 +264,8 @@ and(-webkit-min-device-pixel-ratio: 0) {
|
|
244 |
.aalb-admin-popup-shortocde-wrapper {
|
245 |
display: block;
|
246 |
width: 100%;
|
|
|
|
|
247 |
}
|
248 |
|
249 |
.aalb-admin-popup-shortcode-options {
|
@@ -276,6 +298,8 @@ and(-webkit-min-device-pixel-ratio: 0) {
|
|
276 |
|
277 |
.aalb-add-shortcode-button {
|
278 |
padding-top: 20px;
|
|
|
|
|
279 |
}
|
280 |
|
281 |
.aalb-admin-popup-options {
|
@@ -289,6 +313,7 @@ and(-webkit-min-device-pixel-ratio: 0) {
|
|
289 |
margin-top: 1%;
|
290 |
height: 33px;
|
291 |
vertical-align: middle;
|
|
|
292 |
}
|
293 |
|
294 |
#aalb-admin-popup-search-button {
|
@@ -381,3 +406,35 @@ and(-webkit-min-device-pixel-ratio: 0) {
|
|
381 |
.aalb-selected-asin {
|
382 |
display: none;
|
383 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
margin-left: 3px;
|
26 |
margin-right: 3px;
|
27 |
height: 28px;
|
28 |
+
border: 1px solid #F0C14B;
|
29 |
}
|
30 |
|
31 |
.aalb-admin-searchbox a.aalb-admin-button-create-amazon-shortcode {
|
66 |
#aalb-admin-popup-container {
|
67 |
height: 100%;
|
68 |
width: 100%;
|
69 |
+
display: none;
|
70 |
}
|
71 |
|
72 |
#aalb-admin-popup-content {
|
73 |
+
padding-top: 5px;
|
74 |
height: 50%;
|
75 |
width: 100%;
|
76 |
}
|
126 |
width: 100%;
|
127 |
height: 90%;
|
128 |
display: none;
|
|
|
129 |
}
|
130 |
|
131 |
.aalb-admin-item-search-items {
|
139 |
-moz-column-count: 3;
|
140 |
-webkit-column-count: 3;
|
141 |
column-count: 3;
|
142 |
+
overflow: scroll;
|
143 |
}
|
144 |
|
145 |
.aalb-admin-item-search-items-item {
|
230 |
}
|
231 |
}
|
232 |
}
|
233 |
+
/* fix for safari 10.1 */
|
234 |
+
@media not all and (min-resolution:.001dpcm) {
|
235 |
+
@media {
|
236 |
+
.aalb-admin-item-search-items-item-title {
|
237 |
+
position: initial;
|
238 |
+
margin-left: 2em;
|
239 |
+
margin-right: 0em;
|
240 |
+
font-weight: bold;
|
241 |
+
word-break: break-all;
|
242 |
+
font-size: 1em;
|
243 |
+
overflow: hidden;
|
244 |
+
position: relative;
|
245 |
+
line-height: 1.2em;
|
246 |
+
max-height: 2.4em;
|
247 |
+
text-align: justify;
|
248 |
+
}
|
249 |
+
|
250 |
+
}}
|
251 |
|
252 |
.aalb-admin-item-search-items-item-price {
|
253 |
font-size: 1em;
|
264 |
.aalb-admin-popup-shortocde-wrapper {
|
265 |
display: block;
|
266 |
width: 100%;
|
267 |
+
margin-top: 10px;
|
268 |
+
padding-top: 5px;
|
269 |
}
|
270 |
|
271 |
.aalb-admin-popup-shortcode-options {
|
298 |
|
299 |
.aalb-add-shortcode-button {
|
300 |
padding-top: 20px;
|
301 |
+
bottom: 2px;
|
302 |
+
position: absolute;
|
303 |
}
|
304 |
|
305 |
.aalb-admin-popup-options {
|
313 |
margin-top: 1%;
|
314 |
height: 33px;
|
315 |
vertical-align: middle;
|
316 |
+
border: 1px solid #F0C14B;
|
317 |
}
|
318 |
|
319 |
#aalb-admin-popup-search-button {
|
406 |
.aalb-selected-asin {
|
407 |
display: none;
|
408 |
}
|
409 |
+
|
410 |
+
.aalb-admin-searchbox.aalb-admin-popup-options {
|
411 |
+
margin-bottom: 15px;
|
412 |
+
}
|
413 |
+
|
414 |
+
#aalb-add-asin-error {
|
415 |
+
padding: 2px;
|
416 |
+
display: inline;
|
417 |
+
padding-left: 10px;
|
418 |
+
float: right;
|
419 |
+
}
|
420 |
+
|
421 |
+
#aalb-add-template-asin-error {
|
422 |
+
color: #FF0000;
|
423 |
+
font-size: 12px;
|
424 |
+
display: block;
|
425 |
+
}
|
426 |
+
|
427 |
+
#aalb_template_names_list , #aalb-admin-popup-store-id , #aalb_marketplace_names_list {
|
428 |
+
width: 100%;
|
429 |
+
}
|
430 |
+
|
431 |
+
input.aalb-admin-input-search:focus {
|
432 |
+
box-shadow: #F0C14B;
|
433 |
+
}
|
434 |
+
|
435 |
+
#aalb-add-shortcode-button:disabled {
|
436 |
+
cursor : not-allowed;
|
437 |
+
background : transparent;
|
438 |
+
opacity : 0.2;
|
439 |
+
}
|
440 |
+
|
admin/js/aalb_admin.js
CHANGED
@@ -16,6 +16,13 @@ var tb_remove;
|
|
16 |
var link_id = "";
|
17 |
var AALB_SHORTCODE_AMAZON_LINK = api_pref.AALB_SHORTCODE_AMAZON_LINK; //constant value from server side is reused here
|
18 |
var AALB_SHORTCODE_AMAZON_TEXT = api_pref.AALB_SHORTCODE_AMAZON_TEXT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
jQuery( document ).ready( function() {
|
21 |
// http://stackoverflow.com/questions/5557641/how-can-i-reset-div-to-its-original-state-after-it-has-been-modified-by-java
|
@@ -34,6 +41,9 @@ jQuery( document ).ready( function() {
|
|
34 |
|
35 |
//Custom tb_remove function
|
36 |
tb_remove = function() {
|
|
|
|
|
|
|
37 |
//call actual tb_remove
|
38 |
old_tb_remove();
|
39 |
//custom actions to execute
|
@@ -41,6 +51,24 @@ jQuery( document ).ready( function() {
|
|
41 |
aalb_remove_selected_item( this );
|
42 |
} );
|
43 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
} );
|
45 |
|
46 |
/**
|
@@ -122,7 +150,7 @@ function aalb_admin_show_create_shortcode_popup( search_button ) {
|
|
122 |
editor_search_box_input.attr( 'value', search_keywords );
|
123 |
|
124 |
} else {
|
125 |
-
alert(
|
126 |
editor_search_box_input.focus();
|
127 |
}
|
128 |
}
|
@@ -139,7 +167,7 @@ function aalb_admin_popup_search_items() {
|
|
139 |
jQuery( "#aalb-admin-popup-input-search" ).attr( 'value', keywords );
|
140 |
|
141 |
} else {
|
142 |
-
alert(
|
143 |
jQuery( "#aalb-admin-popup-input-search" ).focus();
|
144 |
}
|
145 |
}
|
@@ -182,13 +210,18 @@ function aalb_admin_get_item_search_items( keywords ) {
|
|
182 |
jQuery( ".aalb-admin-item-search-loading" ).slideUp( "slow" );
|
183 |
jQuery( ".aalb-admin-item-search" ).fadeIn( "slow" );
|
184 |
jQuery( ".aalb-admin-item-search-items-item" ).on( "click", function() {
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
186 |
var productImage = jQuery( this ).find( "img" ).attr( "src" );
|
187 |
var productTitle = jQuery( this ).find( "div.aalb-admin-item-search-items-item-title" ).text();
|
188 |
var productPrice = jQuery( this ).find( "div.aalb-admin-item-search-items-item-price" ).text();
|
189 |
|
190 |
-
var selectedAsinHTML = '<div class="aalb-selected-item" onclick="
|
191 |
-
selectedAsinHTML += ' data-asin="' +
|
192 |
selectedAsinHTML += '<div class="aalb-selected-item-img-wrap"><span class="aalb-selected-item-close">×</span>';
|
193 |
selectedAsinHTML += '<img class="aalb-selected-item-img" src="' + productImage + '"></img></div>';
|
194 |
selectedAsinHTML += '<div class="aalb-selected-item-title"><h3>' + productTitle + '</h3>';
|
@@ -217,7 +250,7 @@ function aalb_admin_get_item_search_items( keywords ) {
|
|
217 |
/* If there was some text selected in the wordpress post editor. Implies amazon_textlink */
|
218 |
var selectedAsinsLength = selectedAsins.split( "," ).length;
|
219 |
if ( selectedAsinsLength > 1 ) {
|
220 |
-
alert(
|
221 |
} else {
|
222 |
jQuery( "#aalb-add-shortcode-alert" ).fadeTo( "fast", 1 );
|
223 |
aalb_add_shortcode( AALB_SHORTCODE_AMAZON_TEXT );
|
@@ -227,7 +260,7 @@ function aalb_admin_get_item_search_items( keywords ) {
|
|
227 |
aalb_add_shortcode( AALB_SHORTCODE_AMAZON_LINK );
|
228 |
}
|
229 |
} else {
|
230 |
-
alert(
|
231 |
}
|
232 |
} );
|
233 |
}
|
@@ -406,3 +439,62 @@ function aalb_get_selected_text_from_editor() {
|
|
406 |
return null;
|
407 |
}
|
408 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
var link_id = "";
|
17 |
var AALB_SHORTCODE_AMAZON_LINK = api_pref.AALB_SHORTCODE_AMAZON_LINK; //constant value from server side is reused here
|
18 |
var AALB_SHORTCODE_AMAZON_TEXT = api_pref.AALB_SHORTCODE_AMAZON_TEXT;
|
19 |
+
//object used as map to check duplicate asin selected by admin
|
20 |
+
var asin_map = {};
|
21 |
+
var SINGLE_ASIN_TEMPLATE = {
|
22 |
+
PriceLink : 'true',
|
23 |
+
ProductAd : 'true',
|
24 |
+
ProductLink: 'true'
|
25 |
+
};
|
26 |
|
27 |
jQuery( document ).ready( function() {
|
28 |
// http://stackoverflow.com/questions/5557641/how-can-i-reset-div-to-its-original-state-after-it-has-been-modified-by-java
|
41 |
|
42 |
//Custom tb_remove function
|
43 |
tb_remove = function() {
|
44 |
+
aalb_reset_add_short_button_and_error_warnings();
|
45 |
+
//re initializing asin_map on window remove
|
46 |
+
asin_map = {};
|
47 |
//call actual tb_remove
|
48 |
old_tb_remove();
|
49 |
//custom actions to execute
|
51 |
aalb_remove_selected_item( this );
|
52 |
} );
|
53 |
};
|
54 |
+
|
55 |
+
/**
|
56 |
+
* TO check the number of selected products on template change
|
57 |
+
**/
|
58 |
+
jQuery( '#aalb_template_names_list' ).on( 'change', function() {
|
59 |
+
var user_selected_template = aalb_get_selected_template();
|
60 |
+
var selected_products = jQuery( 'div.aalb-selected-item[data-asin]' ).length || 0;
|
61 |
+
var aalb_add_short_code_button = jQuery( '#aalb-add-shortcode-button' );
|
62 |
+
//checking for user selected template and number of products selected by user
|
63 |
+
if( ( selected_products > 1 ) && SINGLE_ASIN_TEMPLATE[ user_selected_template ] ) {
|
64 |
+
jQuery( '#aalb-add-template-asin-error' ).text( aalb_strings.template_asin_error + ' ' + user_selected_template );
|
65 |
+
aalb_add_short_code_button.prop( 'disabled', true );
|
66 |
+
|
67 |
+
} else {
|
68 |
+
aalb_add_short_code_button.prop( 'disabled', false );
|
69 |
+
jQuery( '#aalb-add-template-asin-error' ).text( '' );
|
70 |
+
}
|
71 |
+
} );
|
72 |
} );
|
73 |
|
74 |
/**
|
150 |
editor_search_box_input.attr( 'value', search_keywords );
|
151 |
|
152 |
} else {
|
153 |
+
alert( aalb_strings.empty_product_search_bar );
|
154 |
editor_search_box_input.focus();
|
155 |
}
|
156 |
}
|
167 |
jQuery( "#aalb-admin-popup-input-search" ).attr( 'value', keywords );
|
168 |
|
169 |
} else {
|
170 |
+
alert( aalb_strings.empty_product_search_bar );
|
171 |
jQuery( "#aalb-admin-popup-input-search" ).focus();
|
172 |
}
|
173 |
}
|
210 |
jQuery( ".aalb-admin-item-search-loading" ).slideUp( "slow" );
|
211 |
jQuery( ".aalb-admin-item-search" ).fadeIn( "slow" );
|
212 |
jQuery( ".aalb-admin-item-search-items-item" ).on( "click", function() {
|
213 |
+
|
214 |
+
var data_asin = jQuery( this ).attr( "data-asin" );
|
215 |
+
//return on duplicate asin selected
|
216 |
+
if( !aalb_validate_asins( data_asin, 'add' ) ) {
|
217 |
+
return;
|
218 |
+
}
|
219 |
var productImage = jQuery( this ).find( "img" ).attr( "src" );
|
220 |
var productTitle = jQuery( this ).find( "div.aalb-admin-item-search-items-item-title" ).text();
|
221 |
var productPrice = jQuery( this ).find( "div.aalb-admin-item-search-items-item-price" ).text();
|
222 |
|
223 |
+
var selectedAsinHTML = '<div class="aalb-selected-item" onclick="aalb_remove_asin(this)"';
|
224 |
+
selectedAsinHTML += ' data-asin="' + data_asin + '">';
|
225 |
selectedAsinHTML += '<div class="aalb-selected-item-img-wrap"><span class="aalb-selected-item-close">×</span>';
|
226 |
selectedAsinHTML += '<img class="aalb-selected-item-img" src="' + productImage + '"></img></div>';
|
227 |
selectedAsinHTML += '<div class="aalb-selected-item-title"><h3>' + productTitle + '</h3>';
|
250 |
/* If there was some text selected in the wordpress post editor. Implies amazon_textlink */
|
251 |
var selectedAsinsLength = selectedAsins.split( "," ).length;
|
252 |
if ( selectedAsinsLength > 1 ) {
|
253 |
+
alert( aalb_strings.short_code_create_failure );
|
254 |
} else {
|
255 |
jQuery( "#aalb-add-shortcode-alert" ).fadeTo( "fast", 1 );
|
256 |
aalb_add_shortcode( AALB_SHORTCODE_AMAZON_TEXT );
|
260 |
aalb_add_shortcode( AALB_SHORTCODE_AMAZON_LINK );
|
261 |
}
|
262 |
} else {
|
263 |
+
alert( aalb_strings.no_asin_selected_error );
|
264 |
}
|
265 |
} );
|
266 |
}
|
439 |
return null;
|
440 |
}
|
441 |
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* To check the validity of ASIN based on different actions
|
445 |
+
*
|
446 |
+
* @param String Asin ASIN of Product selected by Admin
|
447 |
+
* @param String action Admin action either 'add' or 'remove'
|
448 |
+
*
|
449 |
+
* @return Boolean true if single ASIN is selected or false on multiple ASIN selected
|
450 |
+
**/
|
451 |
+
function aalb_validate_asins( asin, action ) {
|
452 |
+
var count_of_selected_items = jQuery( '.aalb-selected-item' ).length;
|
453 |
+
var selected_template = aalb_get_selected_template();
|
454 |
+
var aalb_add_short_code_button = jQuery( '#aalb-add-shortcode-button' );
|
455 |
+
var max_allowed_items;
|
456 |
+
if( action === 'add' ) {
|
457 |
+
max_allowed_items = 0;
|
458 |
+
|
459 |
+
//if ASIN is already present no need to add the ASIN
|
460 |
+
if( !asin_map[ asin ] ) {
|
461 |
+
asin_map[ asin ] = 1;
|
462 |
+
} else {
|
463 |
+
return false;
|
464 |
+
}
|
465 |
+
} else if( action === 'remove' ) {
|
466 |
+
max_allowed_items = 1;
|
467 |
+
delete asin_map[ asin ];
|
468 |
+
}
|
469 |
+
|
470 |
+
var template_asin_error = ( count_of_selected_items > max_allowed_items ) && SINGLE_ASIN_TEMPLATE[ selected_template ];
|
471 |
+
|
472 |
+
if( ( !template_asin_error ) ) {
|
473 |
+
aalb_reset_add_short_button_and_error_warnings();
|
474 |
+
} else {
|
475 |
+
jQuery( '#aalb-add-template-asin-error' ).text( aalb_strings.template_asin_error + ' ' + selected_template );
|
476 |
+
aalb_add_short_code_button.prop( 'disabled', true );
|
477 |
+
}
|
478 |
+
return true;
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* To remove ASIN element from list
|
483 |
+
*
|
484 |
+
* @param element HTMLDivElement
|
485 |
+
**/
|
486 |
+
function aalb_remove_asin( element ) {
|
487 |
+
var removed_product_asin = element.getAttribute( 'data-asin' );
|
488 |
+
jQuery( element ).remove();
|
489 |
+
aalb_validate_asins( removed_product_asin , 'remove' );
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* To enable add short code button and remove template asin error
|
494 |
+
**/
|
495 |
+
function aalb_reset_add_short_button_and_error_warnings() {
|
496 |
+
var aalb_add_short_code_button = jQuery( '#aalb-add-shortcode-button' );
|
497 |
+
aalb_add_short_code_button.prop( 'disabled', false );
|
498 |
+
jQuery( '#aalb-add-template-asin-error' ).text( '' );
|
499 |
+
}
|
500 |
+
|
admin/partials/aalb_meta_box.php
CHANGED
@@ -24,36 +24,22 @@ $aalb_marketplace_names = $config_loader->fetch_marketplaces();
|
|
24 |
$helper = new Aalb_Helper();
|
25 |
$aalb_store_id_names = $helper->get_store_ids_array();
|
26 |
?>
|
27 |
-
|
28 |
<div id="aalb-admin-popup-container" style="display:none;">
|
29 |
-
|
30 |
<input type="text" id="aalb-admin-popup-input-search" name="aalb-admin-popup-input-search"
|
31 |
placeholder="Enter keyword(s)" onkeypress='aalb_submit_event(event,"aalb-btn-primary",this)'/>
|
32 |
<button class="aalb-btn aalb-btn-primary" id="aalb-admin-popup-search-button" type="button"
|
33 |
onclick="aalb_admin_popup_search_items()" style="margin-top:1%">Search
|
34 |
</button>
|
35 |
</div><!--end .aalb-admin-popup-options-->
|
36 |
-
|
37 |
-
<div class="aalb-admin-alert aalb-admin-alert-info aalb-admin-item-search-loading">
|
38 |
-
<div class="aalb-admin-icon"><i class="fa fa-spinner fa-pulse"></i></div>
|
39 |
-
Searching relevant products from Amazon
|
40 |
-
</div><!--end .aalb-admin-item-search-loading-->
|
41 |
-
<div class="aalb-admin-item-search">
|
42 |
-
Click to select product(s) to advertise
|
43 |
-
<div class="aalb-admin-item-search-items"></div>
|
44 |
-
<a href="#" target="_blank" id="aalb-admin-popup-more-results" class="pull-right">Check more search results
|
45 |
-
on Amazon</a>
|
46 |
-
</div><!--end .aalb-admin-item-serch-->
|
47 |
-
</div><!--end .aalb-admin-popup-content-->
|
48 |
-
<div class="aalb-selected">
|
49 |
-
<label>List of Selected Products</label>
|
50 |
-
</div>
|
51 |
<div class="aalb-admin-popup-shortocde-wrapper">
|
52 |
<div class="aalb-admin-popup-shortcode-options">
|
53 |
<div class="aalb-admin-item-search-templates">
|
54 |
<label>Ad Template</label>
|
55 |
<?php $aalb_default_template = get_option( AALB_DEFAULT_TEMPLATE, AALB_DEFAULT_TEMPLATE_NAME ); ?>
|
56 |
-
<select id="aalb_template_names_list" name="aalb_template_names_list"
|
57 |
<?php foreach ( $aalb_template_names as $aalb_template_name ) { ?>
|
58 |
<option value="<?= $aalb_template_name ?>" <?php selected( $aalb_default_template, $aalb_template_name ); ?>><?= $aalb_template_name ?></option>
|
59 |
<?php } ?>
|
@@ -62,7 +48,7 @@ $aalb_store_id_names = $helper->get_store_ids_array();
|
|
62 |
<div class="aalb-admin-popup-store">
|
63 |
<label>Associate ID</label>
|
64 |
<?php $aalb_default_store_id = get_option( AALB_DEFAULT_STORE_ID, AALB_DEFAULT_STORE_ID_NAME ); ?>
|
65 |
-
<select id="aalb-admin-popup-store-id" name="aalb-admin-popup-store-id"
|
66 |
<?php foreach ( $aalb_store_id_names as $aalb_store_id ) { ?>
|
67 |
<option value="<?= $aalb_store_id ?>" <?php selected( $aalb_default_store_id, $aalb_store_id ); ?>> <?= $aalb_store_id ?> </option>
|
68 |
<?php } ?>
|
@@ -71,7 +57,7 @@ $aalb_store_id_names = $helper->get_store_ids_array();
|
|
71 |
<div class="aalb-admin-item-search-marketplaces">
|
72 |
<label>Marketplace</label>
|
73 |
<?php $aalb_default_marketplace = get_option( AALB_DEFAULT_MARKETPLACE, AALB_DEFAULT_MARKETPLACE_NAME ); ?>
|
74 |
-
<select id="aalb_marketplace_names_list" name="aalb_marketplace_names_list"
|
75 |
<?php foreach ( $aalb_marketplace_names as $aalb_marketplace => $aalb_marketplace_abbr ) { ?>
|
76 |
<option value="<?= $aalb_marketplace ?>" <?php selected( $aalb_default_marketplace, $aalb_marketplace_abbr ); ?>><?= $aalb_marketplace_abbr ?></option>
|
77 |
<?php } ?>
|
@@ -79,12 +65,31 @@ $aalb_store_id_names = $helper->get_store_ids_array();
|
|
79 |
</div>
|
80 |
</div>
|
81 |
</div><!--end .aalb-admin-popup-shortcode-options-->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
<div class="aalb-add-shortcode-button">
|
83 |
<button class="aalb-btn aalb-btn-primary" id="aalb-add-shortcode-button" type="button">Add Shortcode</button>
|
84 |
<div id="aalb-add-shortcode-alert">
|
85 |
<div class="aalb-admin-icon"><i class="fa fa-spinner fa-pulse"></i></div>
|
86 |
Creating shortcode. Please wait....
|
87 |
</div>
|
|
|
|
|
|
|
88 |
</div><!--end .aalb-add-shortcode-button-->
|
89 |
</div><!--end .aalb-admin-popup-container-->
|
90 |
<?php
|
24 |
$helper = new Aalb_Helper();
|
25 |
$aalb_store_id_names = $helper->get_store_ids_array();
|
26 |
?>
|
27 |
+
<!-- keeping css inline as css file does not load at plugin initialization -->
|
28 |
<div id="aalb-admin-popup-container" style="display:none;">
|
29 |
+
<div class="aalb-admin-searchbox aalb-admin-popup-options">
|
30 |
<input type="text" id="aalb-admin-popup-input-search" name="aalb-admin-popup-input-search"
|
31 |
placeholder="Enter keyword(s)" onkeypress='aalb_submit_event(event,"aalb-btn-primary",this)'/>
|
32 |
<button class="aalb-btn aalb-btn-primary" id="aalb-admin-popup-search-button" type="button"
|
33 |
onclick="aalb_admin_popup_search_items()" style="margin-top:1%">Search
|
34 |
</button>
|
35 |
</div><!--end .aalb-admin-popup-options-->
|
36 |
+
<!-- start: aalb-admin-popup-shortcode-options-->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
<div class="aalb-admin-popup-shortocde-wrapper">
|
38 |
<div class="aalb-admin-popup-shortcode-options">
|
39 |
<div class="aalb-admin-item-search-templates">
|
40 |
<label>Ad Template</label>
|
41 |
<?php $aalb_default_template = get_option( AALB_DEFAULT_TEMPLATE, AALB_DEFAULT_TEMPLATE_NAME ); ?>
|
42 |
+
<select id="aalb_template_names_list" name="aalb_template_names_list" >
|
43 |
<?php foreach ( $aalb_template_names as $aalb_template_name ) { ?>
|
44 |
<option value="<?= $aalb_template_name ?>" <?php selected( $aalb_default_template, $aalb_template_name ); ?>><?= $aalb_template_name ?></option>
|
45 |
<?php } ?>
|
48 |
<div class="aalb-admin-popup-store">
|
49 |
<label>Associate ID</label>
|
50 |
<?php $aalb_default_store_id = get_option( AALB_DEFAULT_STORE_ID, AALB_DEFAULT_STORE_ID_NAME ); ?>
|
51 |
+
<select id="aalb-admin-popup-store-id" name="aalb-admin-popup-store-id" >
|
52 |
<?php foreach ( $aalb_store_id_names as $aalb_store_id ) { ?>
|
53 |
<option value="<?= $aalb_store_id ?>" <?php selected( $aalb_default_store_id, $aalb_store_id ); ?>> <?= $aalb_store_id ?> </option>
|
54 |
<?php } ?>
|
57 |
<div class="aalb-admin-item-search-marketplaces">
|
58 |
<label>Marketplace</label>
|
59 |
<?php $aalb_default_marketplace = get_option( AALB_DEFAULT_MARKETPLACE, AALB_DEFAULT_MARKETPLACE_NAME ); ?>
|
60 |
+
<select id="aalb_marketplace_names_list" name="aalb_marketplace_names_list" >
|
61 |
<?php foreach ( $aalb_marketplace_names as $aalb_marketplace => $aalb_marketplace_abbr ) { ?>
|
62 |
<option value="<?= $aalb_marketplace ?>" <?php selected( $aalb_default_marketplace, $aalb_marketplace_abbr ); ?>><?= $aalb_marketplace_abbr ?></option>
|
63 |
<?php } ?>
|
65 |
</div>
|
66 |
</div>
|
67 |
</div><!--end .aalb-admin-popup-shortcode-options-->
|
68 |
+
<div id="aalb-admin-popup-content">
|
69 |
+
<div class="aalb-admin-alert aalb-admin-alert-info aalb-admin-item-search-loading">
|
70 |
+
<div class="aalb-admin-icon"><i class="fa fa-spinner fa-pulse"></i></div>
|
71 |
+
Searching relevant products from Amazon
|
72 |
+
</div><!--end .aalb-admin-item-search-loading-->
|
73 |
+
<div class="aalb-admin-item-search">
|
74 |
+
Click to select product(s) to advertise
|
75 |
+
<div class="aalb-admin-item-search-items"></div>
|
76 |
+
<a href="#" target="_blank" id="aalb-admin-popup-more-results" class="pull-right">Check more search results
|
77 |
+
on Amazon</a>
|
78 |
+
</div><!--end .aalb-admin-item-serch-->
|
79 |
+
</div><!--end .aalb-admin-popup-content-->
|
80 |
+
<div class="aalb-selected">
|
81 |
+
<label>List of Selected Products</label>
|
82 |
+
</div>
|
83 |
+
|
84 |
<div class="aalb-add-shortcode-button">
|
85 |
<button class="aalb-btn aalb-btn-primary" id="aalb-add-shortcode-button" type="button">Add Shortcode</button>
|
86 |
<div id="aalb-add-shortcode-alert">
|
87 |
<div class="aalb-admin-icon"><i class="fa fa-spinner fa-pulse"></i></div>
|
88 |
Creating shortcode. Please wait....
|
89 |
</div>
|
90 |
+
<div id="aalb-add-asin-error">
|
91 |
+
<div id="aalb-add-template-asin-error"></div>
|
92 |
+
</div>
|
93 |
</div><!--end .aalb-add-shortcode-button-->
|
94 |
</div><!--end .aalb-admin-popup-container-->
|
95 |
<?php
|
admin/sidebar/partials/aalb_credentials.php
CHANGED
@@ -16,7 +16,7 @@ include 'aalb_admin_ui_common.php';
|
|
16 |
$helper = new Aalb_Helper();
|
17 |
$aalb_store_id_names = $helper->get_store_ids_array();
|
18 |
wp_enqueue_script( 'jquery' );
|
19 |
-
wp_enqueue_script( 'aalb_credentials_js', AALB_CREDENTIALS_JS, array( 'jquery' ) );
|
20 |
wp_localize_script( 'aalb_credentials_js', 'wp_opt', array( 'plugin_url' => AALB_PLUGIN_URL ) );
|
21 |
?>
|
22 |
|
16 |
$helper = new Aalb_Helper();
|
17 |
$aalb_store_id_names = $helper->get_store_ids_array();
|
18 |
wp_enqueue_script( 'jquery' );
|
19 |
+
wp_enqueue_script( 'aalb_credentials_js', AALB_CREDENTIALS_JS, array( 'jquery' ), AALB_PLUGIN_CURRENT_VERSION );
|
20 |
wp_localize_script( 'aalb_credentials_js', 'wp_opt', array( 'plugin_url' => AALB_PLUGIN_URL ) );
|
21 |
?>
|
22 |
|
admin/sidebar/partials/aalb_templates.php
CHANGED
@@ -194,7 +194,7 @@ wp_enqueue_script( 'codemirror_mode_xml_js', CODEMIRROR_MODE_XML_JS );
|
|
194 |
wp_enqueue_script( 'codemirror_mode_css_js', CODEMIRROR_MODE_CSS_JS );
|
195 |
wp_enqueue_style( 'codemirror_css', CODEMIRROR_CSS );
|
196 |
|
197 |
-
wp_enqueue_script( 'aalb_template_js', AALB_TEMPLATE_JS, array( 'jquery', 'codemirror_js', 'codemirror_mode_xml_js', 'codemirror_mode_css_js' ) );
|
198 |
wp_localize_script( 'aalb_template_js', 'wp_opt', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'upload_url' => $helper->get_template_upload_directory(), 'plugin_url' => AALB_PLUGIN_URL, 'aalb_default_templates' => AALB_AMAZON_TEMPLATE_NAMES ) );
|
199 |
|
200 |
?>
|
194 |
wp_enqueue_script( 'codemirror_mode_css_js', CODEMIRROR_MODE_CSS_JS );
|
195 |
wp_enqueue_style( 'codemirror_css', CODEMIRROR_CSS );
|
196 |
|
197 |
+
wp_enqueue_script( 'aalb_template_js', AALB_TEMPLATE_JS, array( 'jquery', 'codemirror_js', 'codemirror_mode_xml_js', 'codemirror_mode_css_js' ), AALB_PLUGIN_CURRENT_VERSION );
|
198 |
wp_localize_script( 'aalb_template_js', 'wp_opt', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'upload_url' => $helper->get_template_upload_directory(), 'plugin_url' => AALB_PLUGIN_URL, 'aalb_default_templates' => AALB_AMAZON_TEMPLATE_NAMES ) );
|
199 |
|
200 |
?>
|
amazon-associates-link-builder.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
/*
|
8 |
Plugin Name: Amazon Associates Link Builder
|
9 |
Description: Amazon Associates Link Builder is the official free Amazon Associates Program plugin for WordPress. The plugin enables you to search for products in the Amazon catalog, access real-time price and availability information, and easily create links in your posts to products on Amazon.com. You will be able to generate text links, create custom ad units, or take advantage of out-of-the-box widgets that we’ve designed and included with the plugin.
|
10 |
-
Version: 1.4.
|
11 |
Author: Amazon Associates Program
|
12 |
Author URI: https://affiliate-program.amazon.com/
|
13 |
License: GPLv2
|
7 |
/*
|
8 |
Plugin Name: Amazon Associates Link Builder
|
9 |
Description: Amazon Associates Link Builder is the official free Amazon Associates Program plugin for WordPress. The plugin enables you to search for products in the Amazon catalog, access real-time price and availability information, and easily create links in your posts to products on Amazon.com. You will be able to generate text links, create custom ad units, or take advantage of out-of-the-box widgets that we’ve designed and included with the plugin.
|
10 |
+
Version: 1.4.4
|
11 |
Author: Amazon Associates Program
|
12 |
Author URI: https://affiliate-program.amazon.com/
|
13 |
License: GPLv2
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: amazonlinkbuilder
|
3 |
Tags: Amazon, Affiliate, Associates, Amazon Associates, Amazon Associate, Product Advertising API, Amazon API, Amazon Link, Amazon Ad, Amazon Affiliate, eCommerce
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 4.7.
|
6 |
-
Stable tag: 1.4.
|
7 |
License: GPLv2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -94,6 +94,13 @@ You can search products using keywords in any supported country, but you have to
|
|
94 |
|
95 |
== Changelog ==
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
= 1.4.3 - April 19, 2017 =
|
98 |
* Fix: Add shortcode button not clickable for some users after version 1.4.2.
|
99 |
|
@@ -140,6 +147,9 @@ You can search products using keywords in any supported country, but you have to
|
|
140 |
* Plugin released for beta testing
|
141 |
|
142 |
== Upgrade Notice ==
|
|
|
|
|
|
|
143 |
= 1.4.3 =
|
144 |
This update fixes the issue of add shortcode button not clickable for some users after v1.4.2.
|
145 |
|
2 |
Contributors: amazonlinkbuilder
|
3 |
Tags: Amazon, Affiliate, Associates, Amazon Associates, Amazon Associate, Product Advertising API, Amazon API, Amazon Link, Amazon Ad, Amazon Affiliate, eCommerce
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 4.7.5
|
6 |
+
Stable tag: 1.4.4
|
7 |
License: GPLv2
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
94 |
|
95 |
== Changelog ==
|
96 |
|
97 |
+
= 1.4.4 - May 25, 2017 =
|
98 |
+
* Default Templates provided by the plugin will now render correctly on mobile devices. Your existing posts with default templates will reflect these changes after update. This does not affect custom templates and they will continue to render as before.
|
99 |
+
* UI Change: Template, Country and Associate ID select boxes are now at the top of the 'Add Shortcode' dialog box to better reflect the order of operations.
|
100 |
+
* PriceLink, ProductAd & ProductLink templates will now allow only a single product to be added. This does not affect existing posts. To add more than one product to the single product templates, create a custom template by cloning the original one.
|
101 |
+
* A shortcode can now contain only one instance of a specific product. This does not affect existing posts.
|
102 |
+
* Fix: After plugin update, changes not being reflected due to browser caching.
|
103 |
+
|
104 |
= 1.4.3 - April 19, 2017 =
|
105 |
* Fix: Add shortcode button not clickable for some users after version 1.4.2.
|
106 |
|
147 |
* Plugin released for beta testing
|
148 |
|
149 |
== Upgrade Notice ==
|
150 |
+
= 1.4.4 =
|
151 |
+
This update improves mobile rendering of default templates and some bug fixes.
|
152 |
+
|
153 |
= 1.4.3 =
|
154 |
This update fixes the issue of add shortcode button not clickable for some users after v1.4.2.
|
155 |
|
shortcode/aalb_shortcode.php
CHANGED
@@ -42,7 +42,7 @@ class Aalb_Shortcode {
|
|
42 |
* @since 1.0.0
|
43 |
*/
|
44 |
public function enqueue_styles() {
|
45 |
-
wp_enqueue_style( 'aalb_basics_css', AALB_BASICS_CSS );
|
46 |
}
|
47 |
|
48 |
/**
|
42 |
* @since 1.0.0
|
43 |
*/
|
44 |
public function enqueue_styles() {
|
45 |
+
wp_enqueue_style( 'aalb_basics_css', AALB_BASICS_CSS, array(), AALB_PLUGIN_CURRENT_VERSION );
|
46 |
}
|
47 |
|
48 |
/**
|
shortcode/aalb_shortcode_helper.php
CHANGED
@@ -41,10 +41,10 @@ class Aalb_Shortcode_Helper {
|
|
41 |
public function enqueue_template_styles( $template_name ) {
|
42 |
$aalb_default_templates = explode( ",", AALB_AMAZON_TEMPLATE_NAMES );
|
43 |
if ( in_array( $template_name, $aalb_default_templates ) ) {
|
44 |
-
wp_enqueue_style( 'aalb_template' . $template_name . '_css', AALB_TEMPLATE_URL . $template_name . '.css' );
|
45 |
} else {
|
46 |
$aalb_template_upload_url = $this->helper->get_template_upload_directory_url();
|
47 |
-
wp_enqueue_style( 'aalb_template' . $template_name . '_css', $aalb_template_upload_url . $template_name . '.css' );
|
48 |
}
|
49 |
}
|
50 |
|
41 |
public function enqueue_template_styles( $template_name ) {
|
42 |
$aalb_default_templates = explode( ",", AALB_AMAZON_TEMPLATE_NAMES );
|
43 |
if ( in_array( $template_name, $aalb_default_templates ) ) {
|
44 |
+
wp_enqueue_style( 'aalb_template' . $template_name . '_css', AALB_TEMPLATE_URL . $template_name . '.css', array(), AALB_PLUGIN_CURRENT_VERSION );
|
45 |
} else {
|
46 |
$aalb_template_upload_url = $this->helper->get_template_upload_directory_url();
|
47 |
+
wp_enqueue_style( 'aalb_template' . $template_name . '_css', $aalb_template_upload_url . $template_name . '.css', array(), AALB_PLUGIN_CURRENT_VERSION );
|
48 |
}
|
49 |
}
|
50 |
|
shortcode/aalb_shortcode_text.php
CHANGED
@@ -43,7 +43,7 @@ class Aalb_Shortcode_Text {
|
|
43 |
* @since 1.4
|
44 |
*/
|
45 |
public function enqueue_styles() {
|
46 |
-
wp_enqueue_style( 'aalb_basics_css', AALB_BASICS_CSS );
|
47 |
}
|
48 |
|
49 |
/**
|
43 |
* @since 1.4
|
44 |
*/
|
45 |
public function enqueue_styles() {
|
46 |
+
wp_enqueue_style( 'aalb_basics_css', AALB_BASICS_CSS, array(), AALB_PLUGIN_CURRENT_VERSION );
|
47 |
}
|
48 |
|
49 |
/**
|
template/ProductCarousel.mustache
CHANGED
@@ -81,15 +81,14 @@
|
|
81 |
return true;
|
82 |
}
|
83 |
|
84 |
-
var rows = $adUnit.find('input[name=rows]').length && parseInt($adUnit.find('input[name=rows]').val(), 10)
|
85 |
-
|
86 |
-
disableCarousel = $adUnit.find('input[name=disable-carousel]').length || rows || columns;
|
87 |
|
88 |
-
if
|
89 |
var productContainerMinWidth = columns * (CONSTANTS.productMinWidth + CONSTANTS.productMargin) + 'px';
|
90 |
-
$adUnit.css('min-width', productContainerMinWidth);
|
91 |
-
$productContainer.css('min-width', productContainerMinWidth);
|
92 |
-
$products.filter(':nth-child(' + columns + 'n + 1)').css('clear', 'both');
|
93 |
}
|
94 |
|
95 |
if (rows && columns) {
|
@@ -98,30 +97,39 @@
|
|
98 |
}
|
99 |
|
100 |
function updateLayout() {
|
101 |
-
var wrapperWidth
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
$productContainer.jCarouselLite({
|
113 |
-
btnNext : '#' + $adUnit.attr('id') + ' .aalb-pc-btn-next',
|
114 |
-
btnPrev : '#' + $adUnit.attr('id') + ' .aalb-pc-btn-prev',
|
115 |
-
visible : actualColumns,
|
116 |
-
circular : false
|
117 |
-
});
|
118 |
-
} else {
|
119 |
-
$productContainer.css('width', 'auto');
|
120 |
-
$productList.css('width', 'auto');
|
121 |
-
$btnNext.css('visibility', 'hidden').unbind('click');
|
122 |
-
$btnPrev.css('visibility', 'hidden').unbind('click');
|
123 |
-
}
|
124 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
|
127 |
updateLayout();
|
81 |
return true;
|
82 |
}
|
83 |
|
84 |
+
var rows = $adUnit.find('input[name=rows]').length && parseInt($adUnit.find('input[name=rows]').val(), 10);
|
85 |
+
var columns = $adUnit.find('input[name=columns]').length && parseInt($adUnit.find('input[name=columns]').val(), 10);
|
|
|
86 |
|
87 |
+
if( columns ) {
|
88 |
var productContainerMinWidth = columns * (CONSTANTS.productMinWidth + CONSTANTS.productMargin) + 'px';
|
89 |
+
$adUnit.css( 'min-width', productContainerMinWidth );
|
90 |
+
$productContainer.css( 'min-width', productContainerMinWidth );
|
91 |
+
$products.filter( ':nth-child(' + columns + 'n + 1)' ).css( 'clear', 'both' );
|
92 |
}
|
93 |
|
94 |
if (rows && columns) {
|
97 |
}
|
98 |
|
99 |
function updateLayout() {
|
100 |
+
var wrapperWidth = $wrapper.width();
|
101 |
+
var possibleColumns = columns || parseInt( wrapperWidth / (CONSTANTS.productMinWidth + CONSTANTS.productMargin), 10 );
|
102 |
+
var actualColumns = columns || possibleColumns < productCount ? possibleColumns : productCount;
|
103 |
+
|
104 |
+
/**
|
105 |
+
* The actual columns can be zero when the wraperwidth is less than sum of CONSTANTS.productMinWidth and
|
106 |
+
* CONSTANTS.productMargin.The parseInt will use floor function and converts any value less than 1 to
|
107 |
+
* zero.Therefore making actual columns 1 .
|
108 |
+
**/
|
109 |
+
if( actualColumns == 0 ) {
|
110 |
+
actualColumns = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
112 |
+
|
113 |
+
var productWidth = parseInt( wrapperWidth / actualColumns, 10 ) - CONSTANTS.productMargin;
|
114 |
+
|
115 |
+
$products.css( 'width', productWidth + 'px' );
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Removing the Carousel navigation button when the number of products selected by admin is less
|
119 |
+
* than the actual columns (the number of products) can be shown on screen
|
120 |
+
**/
|
121 |
+
if( productCount > actualColumns ) {
|
122 |
+
$btnNext.css( 'visibility', 'visible' ).removeClass( 'disabled' ).unbind( 'click' );
|
123 |
+
$btnPrev.css( 'visibility', 'visible' ).removeClass( 'disabled' ).unbind( 'click' );
|
124 |
+
}
|
125 |
+
$productContainer.jCarouselLite( {
|
126 |
+
btnNext : '#' + $adUnit.attr( 'id' ) + ' .aalb-pc-btn-next',
|
127 |
+
btnPrev : '#' + $adUnit.attr( 'id' ) + ' .aalb-pc-btn-prev',
|
128 |
+
visible : actualColumns,
|
129 |
+
circular: false
|
130 |
+
} );
|
131 |
+
|
132 |
+
|
133 |
}
|
134 |
|
135 |
updateLayout();
|
template/ProductGrid.mustache
CHANGED
@@ -83,29 +83,53 @@
|
|
83 |
return true;
|
84 |
}
|
85 |
|
86 |
-
var rows
|
87 |
-
|
88 |
-
|
89 |
|
90 |
-
if
|
91 |
var productContainerMinWidth = columns * (CONSTANTS.productMinWidth + CONSTANTS.productMargin) + 'px';
|
92 |
-
$adUnit.css('min-width', productContainerMinWidth);
|
93 |
-
$productContainer.css('min-width', productContainerMinWidth);
|
94 |
-
$products.filter(':nth-child(' + columns + 'n + 1)').css('clear', 'both');
|
95 |
}
|
96 |
|
97 |
-
if
|
98 |
var cutOffIndex = (rows * columns) - 1;
|
99 |
-
$products.filter(':gt(' + cutOffIndex + ')').remove();
|
100 |
}
|
101 |
|
102 |
function updateLayout() {
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
productWidth = parseInt(wrapperWidth / actualColumns, 10) - CONSTANTS.productMargin;
|
107 |
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
if (!disableCarousel) {
|
111 |
if ((productCount * productWidth > wrapperWidth) && actualColumns !== 1) {
|
@@ -141,4 +165,4 @@
|
|
141 |
!function(a){a.jCarouselLite={version:"1.1"},a.fn.jCarouselLite=function(b){return b=a.extend({},a.fn.jCarouselLite.options,b||{}),this.each(function(){function c(a){return n||(clearTimeout(A),z=a,b.beforeStart&&b.beforeStart.call(this,i()),b.circular?j(a):k(a),m({start:function(){n=!0},done:function(){b.afterEnd&&b.afterEnd.call(this,i()),b.auto&&h(),n=!1}}),b.circular||l()),!1}function d(){if(n=!1,o=b.vertical?"top":"left",p=b.vertical?"height":"width",q=B.find(">ul"),r=q.find(">li"),x=r.size(),w=x<b.visible?x:b.visible,b.circular){var c=r.slice(x-w).clone(),d=r.slice(0,w).clone();q.prepend(c).append(d),b.start+=w}s=a("li",q),y=s.size(),z=b.start}function e(){B.css("visibility","visible"),s.css({overflow:"hidden","float":b.vertical?"none":"left"}),q.css({margin:"0",padding:"0",position:"relative","list-style":"none","z-index":"1"}),B.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"}),!b.circular&&b.btnPrev&&0==b.start&&a(b.btnPrev).addClass("disabled")}function f(){t=b.vertical?s.outerHeight(!0):s.outerWidth(!0),u=t*y,v=t*w,s.css({width:s.width(),height:s.height()}),q.css(p,u+"px").css(o,-(z*t)),B.css(p,v+"px")}function g(){b.btnPrev&&a(b.btnPrev).click(function(){return c(z-b.scroll)}),b.btnNext&&a(b.btnNext).click(function(){return c(z+b.scroll)}),b.btnGo&&a.each(b.btnGo,function(d,e){a(e).click(function(){return c(b.circular?w+d:d)})}),b.mouseWheel&&B.mousewheel&&B.mousewheel(function(a,d){return c(d>0?z-b.scroll:z+b.scroll)}),b.auto&&h()}function h(){A=setTimeout(function(){c(z+b.scroll)},b.auto)}function i(){return s.slice(z).slice(0,w)}function j(a){var c;a<=b.start-w-1?(c=a+x+b.scroll,q.css(o,-(c*t)+"px"),z=c-b.scroll):a>=y-w+1&&(c=a-x-b.scroll,q.css(o,-(c*t)+"px"),z=c+b.scroll)}function k(a){0>a?z=0:a>y-w&&(z=y-w)}function l(){a(b.btnPrev+","+b.btnNext).removeClass("disabled"),a(z-b.scroll<0&&b.btnPrev||z+b.scroll>y-w&&b.btnNext||[]).addClass("disabled")}function m(c){n=!0,q.animate("left"==o?{left:-(z*t)}:{top:-(z*t)},a.extend({duration:b.speed,easing:b.easing},c))}var n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a(this);d(),e(),f(),g()})},a.fn.jCarouselLite.options={btnPrev:null,btnNext:null,btnGo:null,mouseWheel:!1,auto:null,speed:200,easing:null,vertical:!1,circular:!0,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null}}(jQuery);
|
142 |
|
143 |
|
144 |
-
</script>
|
83 |
return true;
|
84 |
}
|
85 |
|
86 |
+
var rows = $adUnit.find( 'input[name=rows]' ).length && parseInt( $adUnit.find( 'input[name=rows]' ).val(), 10 );
|
87 |
+
var columns = $adUnit.find( 'input[name=columns]' ).length && parseInt( $adUnit.find( 'input[name=columns]' ).val(), 10 );
|
88 |
+
var disableCarousel = $adUnit.find( 'input[name=disable-carousel]' ).length || rows || columns;
|
89 |
|
90 |
+
if( columns ) {
|
91 |
var productContainerMinWidth = columns * (CONSTANTS.productMinWidth + CONSTANTS.productMargin) + 'px';
|
92 |
+
$adUnit.css( 'min-width', productContainerMinWidth );
|
93 |
+
$productContainer.css( 'min-width', productContainerMinWidth );
|
94 |
+
$products.filter( ':nth-child(' + columns + 'n + 1)' ).css( 'clear', 'both' );
|
95 |
}
|
96 |
|
97 |
+
if( rows && columns ) {
|
98 |
var cutOffIndex = (rows * columns) - 1;
|
99 |
+
$products.filter( ':gt(' + cutOffIndex + ')' ).remove();
|
100 |
}
|
101 |
|
102 |
function updateLayout() {
|
103 |
+
//removing residual styles on screen resize
|
104 |
+
$products.removeAttr("style");
|
105 |
+
var wrapperWidth = $wrapper.width();
|
|
|
106 |
|
107 |
+
var possibleColumns = parseInt( wrapperWidth / (CONSTANTS.productMinWidth + CONSTANTS.productMargin), 10 ) || columns;
|
108 |
+
var actualColumns = possibleColumns < productCount ? possibleColumns : productCount || columns;
|
109 |
+
var productWidth = parseInt( wrapperWidth / actualColumns, 10 ) - CONSTANTS.productMargin;
|
110 |
+
|
111 |
+
/**
|
112 |
+
* calculating productContainerMinWidth and assigning it as min-width to adUnit ,ProductContainer and
|
113 |
+
* products of ADUnit displayed on updateLayout as to override the values coming from closure.Becuase of
|
114 |
+
* closure the wrapper width was having values generated when the screen was rendered at first time.
|
115 |
+
*/
|
116 |
+
var productContainerMinWidth = actualColumns * (CONSTANTS.productMinWidth + CONSTANTS.productMargin) + 'px';
|
117 |
+
$adUnit.css( 'min-width', productContainerMinWidth );
|
118 |
+
$productContainer.css( 'min-width', productContainerMinWidth );
|
119 |
+
$products.filter( ':nth-child(' + actualColumns + 'n + 1)' ).css( 'clear', 'both' );
|
120 |
+
|
121 |
+
/**
|
122 |
+
* When actualColumns is 1 ,the images tend to move towards right of wrapper area.Therefore assigning the
|
123 |
+
* productContainerMinWidth to product when actualColumns is 1
|
124 |
+
**/
|
125 |
+
if( actualColumns == 1 ) {
|
126 |
+
$products.css( 'width', productContainerMinWidth + 'px' );
|
127 |
+
var productImage = jQuery('.aalb-pg-product-image');
|
128 |
+
productImage.css('margin-left','0px');
|
129 |
+
}
|
130 |
+
else {
|
131 |
+
$products.css( 'width', productWidth + 'px' );
|
132 |
+
}
|
133 |
|
134 |
if (!disableCarousel) {
|
135 |
if ((productCount * productWidth > wrapperWidth) && actualColumns !== 1) {
|
165 |
!function(a){a.jCarouselLite={version:"1.1"},a.fn.jCarouselLite=function(b){return b=a.extend({},a.fn.jCarouselLite.options,b||{}),this.each(function(){function c(a){return n||(clearTimeout(A),z=a,b.beforeStart&&b.beforeStart.call(this,i()),b.circular?j(a):k(a),m({start:function(){n=!0},done:function(){b.afterEnd&&b.afterEnd.call(this,i()),b.auto&&h(),n=!1}}),b.circular||l()),!1}function d(){if(n=!1,o=b.vertical?"top":"left",p=b.vertical?"height":"width",q=B.find(">ul"),r=q.find(">li"),x=r.size(),w=x<b.visible?x:b.visible,b.circular){var c=r.slice(x-w).clone(),d=r.slice(0,w).clone();q.prepend(c).append(d),b.start+=w}s=a("li",q),y=s.size(),z=b.start}function e(){B.css("visibility","visible"),s.css({overflow:"hidden","float":b.vertical?"none":"left"}),q.css({margin:"0",padding:"0",position:"relative","list-style":"none","z-index":"1"}),B.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"}),!b.circular&&b.btnPrev&&0==b.start&&a(b.btnPrev).addClass("disabled")}function f(){t=b.vertical?s.outerHeight(!0):s.outerWidth(!0),u=t*y,v=t*w,s.css({width:s.width(),height:s.height()}),q.css(p,u+"px").css(o,-(z*t)),B.css(p,v+"px")}function g(){b.btnPrev&&a(b.btnPrev).click(function(){return c(z-b.scroll)}),b.btnNext&&a(b.btnNext).click(function(){return c(z+b.scroll)}),b.btnGo&&a.each(b.btnGo,function(d,e){a(e).click(function(){return c(b.circular?w+d:d)})}),b.mouseWheel&&B.mousewheel&&B.mousewheel(function(a,d){return c(d>0?z-b.scroll:z+b.scroll)}),b.auto&&h()}function h(){A=setTimeout(function(){c(z+b.scroll)},b.auto)}function i(){return s.slice(z).slice(0,w)}function j(a){var c;a<=b.start-w-1?(c=a+x+b.scroll,q.css(o,-(c*t)+"px"),z=c-b.scroll):a>=y-w+1&&(c=a-x-b.scroll,q.css(o,-(c*t)+"px"),z=c+b.scroll)}function k(a){0>a?z=0:a>y-w&&(z=y-w)}function l(){a(b.btnPrev+","+b.btnNext).removeClass("disabled"),a(z-b.scroll<0&&b.btnPrev||z+b.scroll>y-w&&b.btnNext||[]).addClass("disabled")}function m(c){n=!0,q.animate("left"==o?{left:-(z*t)}:{top:-(z*t)},a.extend({duration:b.speed,easing:b.easing},c))}var n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a(this);d(),e(),f(),g()})},a.fn.jCarouselLite.options={btnPrev:null,btnNext:null,btnGo:null,mouseWheel:!1,auto:null,speed:200,easing:null,vertical:!1,circular:!0,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null}}(jQuery);
|
166 |
|
167 |
|
168 |
+
</script>
|