Skip to content

Commit

Permalink
fixed: esc issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-rafi committed Jan 18, 2022
1 parent 7e49760 commit 00d5422
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions includes/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function __construct() {
*/
public function woocommerce_before_add_to_cart_button_callback() {
$url = get_post_meta(get_the_ID(), 'gumroad_product_url', true);
echo "<a href='$url' class='button product_type_variable add_to_cart_button'>Buy now</a>";
echo '<a href="' . esc_url($url) . '" class="gumpress-button button add_to_cart_button">' . __('Buy now', 'uilib-gumpress') . '</a>';
}

/**
Expand All @@ -34,6 +34,6 @@ public function woocommerce_before_add_to_cart_button_callback() {
*/
public function modify_add_to_cart_button($quantity, $product) {
$url = get_post_meta($product->id, 'gumroad_product_url', true);
return "<a href='$url' class='gumpress-button button product_type_variable add_to_cart_button'>Buy now</a>";
return '<a href="' . esc_url($url) . '" class="gumpress-button button add_to_cart_button">' . __('Buy now', 'uilib-gumpress') . '</a>';
}
}
12 changes: 9 additions & 3 deletions includes/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function sync_products() {
foreach ( $product_list as $key => $gumroad_product ) {
$variants = [];
$is_variable_product = $gumroad_product['variants'][0] ? true : false;
$is_updated = false;

if($is_variable_product) {
$variants = $gumroad_product['variants'][0]['options'];
Expand Down Expand Up @@ -140,19 +141,24 @@ public function sync_products() {
$gumroad_product
);

// Update PRODUCT VARIATIONS
// UPDATE PRODUCT VARIATIONS
if($is_variable_product) {
ul_create_product_variation( $woo_product_id, [
'base_price' => $gumroad_product['price'],
'variants' => $variants,
], true);
}
$is_updated = true;
}

echo "<p> {$gumroad_product['name']} - <span style='color: var(--wc-highlight)'>updated!</span></p>";
// SHOW UPDATED/IMPORTED MESSAGE
$update_message = $is_updated ? __('Updated', 'uilib-gumpress') : __('Imported', 'uilib-gumpress');
echo wp_sprintf('<p> %s - <span style="color: var(--wc-highlight)">%s</span></p>', esc_html($gumroad_product['name']), $update_message);

// SHOW PRODUCTS PAGE LINK
if ( $key === array_key_last( $product_list ) ) {
$admin_products_page = admin_url('edit.php?post_type=product');
echo "<p>Done! Check out <a href='{$admin_products_page}'>product page</a></p>";
echo wp_sprintf('<p>Done! Check out <a href="%s">%s</a></p>', esc_url($admin_products_page), __('Products page', 'uilib-gumpress'));
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ function ul_create_product_attributes( $product_id, $attribute_name, $variants )
}

$attribute_data = array( $attribute_name => array(
"name" => $attribute_name,
'value' => $attribute_value,
'position' => 0,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 0,
"name" => $attribute_name,
'value' => $attribute_value,
'position' => 0,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 0,
) );

return update_post_meta( $product_id, '_product_attributes', $attribute_data );
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: uilib
Tags: gumroad, woocommerce
Requires at least: 4.7
Tested up to: 5.4
Stable tag: 1.0
Tested up to: 5.8
Stable tag: 1.0.0
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down

0 comments on commit 00d5422

Please sign in to comment.