Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak: for release 4.0.12 #1489

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions Lib/Appsero/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WeDevs\Wpuf\Lib\Appsero;

use WP_Error;

/**
* Appsero Client
*
Expand Down Expand Up @@ -110,13 +112,9 @@ public function __construct( $hash, $name, $file ) {
/**
* Initialize insights class
*
* @return Appsero\Insights
* @return object
*/
public function insights() {
if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) {
require_once __DIR__ . '/Insights.php';
}

// if already instantiated, return the cached one
if ( $this->insights ) {
return $this->insights;
Expand All @@ -130,13 +128,9 @@ public function insights() {
/**
* Initialize license checker
*
* @return Appsero\License
* @return object
*/
public function license() {
if ( ! class_exists( __NAMESPACE__ . '\License' ) ) {
require_once __DIR__ . '/License.php';
}

// if already instantiated, return the cached one
if ( $this->license ) {
return $this->license;
Expand Down
12 changes: 2 additions & 10 deletions Lib/WeDevs_Insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace WeDevs\Wpuf\Lib;

if ( ! class_exists( 'WPUF_WeDevs_Insights' ) ) :
if ( ! class_exists( 'WeDevs_Insights' ) ) :

/**
* weDevs Tracker
Expand All @@ -17,26 +17,18 @@
*/
class WeDevs_Insights {
/**
* @var object|Appsero\Insights|Insights
* @var object|Appsero\Insights
*/
public $insights;

/**
* Initialize the class
*/
public function __construct( $file ) {
if ( ! class_exists( 'Appsero\Client' ) ) {
require_once WPUF_ROOT . '/Lib/Appsero/Client.php';
}

$client = new Appsero\Client( '958afc63-99f8-4b98-b321-fcbc5cf95694', 'WP User Frontend', $file );
$this->insights = $client->insights();
$this->insights->client = $client;
$this->insights->init();

// $client = new Appsero\Client( '958afc63-99f8-4b98-b321-fcbc5cf95694', 'WP User Frontend', $file );
// $this->insights = $client->insights();
// $this->insights->init();
}
Comment on lines 28 to 32
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Appsero Library Inclusion May Be Incomplete

The Appsero library isn't listed in composer.json, and no global require or include statements were found. Ensure that the Appsero library is correctly autoloaded through another mechanism or consider adding it as a Composer dependency to prevent potential runtime issues.

🔗 Analysis chain

Verify Appsero library inclusion and simplify constructor.

The constructor has been simplified by removing the conditional check for Appsero\Client and the require_once statement. While this improves code cleanliness, it's crucial to ensure that the Appsero library is properly included elsewhere in the project.

Please confirm that the Appsero library is included in the project's autoloading mechanism or through another means. Run the following script to check for Appsero inclusion:

The removal of commented-out code for redundant initialization is a good practice and improves code readability.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Appsero library inclusion

# Test 1: Search for Appsero autoloading or inclusion
echo "Searching for Appsero autoloading or inclusion:"
rg --type php -i '(require|include|use).*appsero'

# Test 2: Check if Appsero is included in composer.json (if exists)
if [ -f "composer.json" ]; then
    echo "Checking composer.json for Appsero:"
    jq '.require | select(has("appsero/client"))' composer.json
fi

Length of output: 1016

}

Expand Down
4 changes: 0 additions & 4 deletions includes/Ajax/Frontend_Form_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class Frontend_Form_Ajax {
private $expired_post_status = 'wpuf-expired_post_status';

private $post_expiration_message = 'wpuf-post_expiration_message';
/**
* @var array
*/
private $form_fields;

/**
* @var array
Expand Down
8 changes: 7 additions & 1 deletion includes/Setup_Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ public function __construct() {
* @return void
*/
public function custom_admin_bar_styles() {
if ( is_admin_bar_showing() ) {
if ( ! is_admin_bar_showing() ) {
return;
}

if ( function_exists( 'wp_enqueue_admin_bar_header_styles' ) ) {
wp_enqueue_admin_bar_header_styles();
} else {
wp_admin_bar_header();
}
}

Expand Down
4 changes: 2 additions & 2 deletions includes/Traits/TaxableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ function wpuf_tax_rate_country_state( $country, $state ) {
continue;
}
if ( $rate['state'] === $state && $rate['country'] === $country ) {
$tax_amount = $rate['rate'];
$tax_amount = ! empty( $rate['rate'] ) ? $rate['rate'] : 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Potential issue with handling zero tax rates

At line 387, the condition ! empty( $rate['rate'] ) will evaluate to false if $rate['rate'] is zero. This means that a tax rate of zero will be treated the same as an unset or empty rate, and $tax_amount will be set to 0. If a zero tax rate is valid and should be distinguished from an unset rate, consider using isset( $rate['rate'] ) instead of ! empty( $rate['rate'] ) to ensure zero values are correctly handled.

}

if ( intval( $tax_amount ) === 0 && $rate['country'] === $country && 'country_wide' === $rate['state'] ) {
$tax_amount = $rate['rate'];
$tax_amount = ! empty( $rate['rate'] ) ? $rate['rate'] : 0;
}
}

Expand Down
Loading
Loading