Skip to content

Commit

Permalink
removed function array_key_last
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-rafi committed Jan 26, 2022
1 parent 6f714c4 commit 75d2678
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gumpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Plugin URI: https://ui-lib.com/gumpress
* Author: UI Lib
* Author URI: https://ui-lib.com
* Version: 1.0.0
* Version: 1.0.1
* License: GPL2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: uilib-gumpress
Expand Down
4 changes: 3 additions & 1 deletion includes/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ public function sync_products() {
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 ) ) {
end($product_list);
$last_key = key($product_list);
if ( $key === $last_key ) {
$admin_products_page = admin_url('edit.php?post_type=product');
echo wp_sprintf('<p>Done! Check out <a href="%s">%s</a></p>', esc_url($admin_products_page), __('Products page', 'uilib-gumpress'));
}
Expand Down
6 changes: 5 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ function ul_sanitize_variants( $variants ) {
function ul_create_product_attributes( $product_id, $attribute_name, $variants ) {
$attribute_value = "";

// GET LAST ITEM IN ARRAY
end($variants);
$last_variant = key($variants);

foreach ( $variants as $key => $variant ) {
if ( $key === array_key_last( $variants ) ) {
if ( $key === $last_variant ) {
$attribute_value .= $variant['name'];
} else {
$attribute_value .= $variant['name'] . ' | ';
Expand Down
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ to Gumroad.
### Changelog

* 1.0.0
* Initial release
* Initial release
* 1.0.1
* removed function array_key_last
16 changes: 13 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: uilib
Tags: gumroad, gumroad store, gumroad checkout, woocommerce
Requires at least: 4.7
Tested up to: 5.8
Stable tag: 1.0.0
Stable tag: 1.0.1
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -21,6 +21,9 @@ When you want to update your gumroad product (product thumbnail, description, pr
Gumpress also syncs your gumroad product versions with your woocommerce variable product.
Customers will see a price range on your woocommerce single product page and shop page as a result.

## Works with any Woocommerce theme
You can use any woocommerce theme to build your gumroad store.

## Works with woocommerce shortcodes
To display your products, you can use woocommerce short codes or simply a "Buy now" button.
Because your products are synchronized with gumroad, when a user clicks the "Buy now" button, the Gumroad checkout popup appears.
Expand All @@ -43,7 +46,14 @@ to Gumroad.

[Bug Report](https://github.com/uilibrary/gumpress/issues) | [Support](mailto:[email protected])

== Screenshots ==
1. Gumpress settings and Sync product
2. Woocommerce theme connected to gumroad

== Changelog ==

= 1.0 =
* Initial release
= 1.0.0 =
* Initial release

= 1.0.1 =
* removed function array_key_last

0 comments on commit 75d2678

Please sign in to comment.