Skip to content
Open
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
2 changes: 1 addition & 1 deletion includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -3946,7 +3946,7 @@ private function store_connectivity_info( $pong, $is_connected ) {

$this->_storage->connectivity_test = array(
'is_connected' => $is_connected,
'host' => $_SERVER['HTTP_HOST'],
'host' => isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '',
'server_ip' => WP_FS__REMOTE_ADDR,
'is_active' => $is_active,
'timestamp' => WP_FS__SCRIPT_START_TIME,
Expand Down
65 changes: 61 additions & 4 deletions includes/entities/class-fs-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,22 @@ class FS_Payment extends FS_Entity {
*/
public $source = 0;

/**
* Presentment payment information for customer-facing currency display.
*
* @var object|null
*/
public $presentment;

#endregion Properties

const CURRENCY_USD = 'usd';
const CURRENCY_GBP = 'gbp';
const CURRENCY_EUR = 'eur';
const CURRENCY_ILS = 'ils';
const CURRENCY_CAD = 'cad';
const CURRENCY_AUD = 'aud';
CONST CURRENCY_PLN = 'pln';

/**
* @param object|bool $payment
Expand Down Expand Up @@ -119,6 +130,43 @@ function is_migrated() {
return ( 0 != $this->source );
}

/**
* @return bool
*/
function has_presentment() {
return (
is_object( $this->presentment ) &&
! empty( $this->presentment->currency )
);
}

/**
* @return float
*/
function get_display_gross() {
return $this->has_presentment() ?
(float) $this->presentment->gross :
(float) $this->gross;
}

/**
* @return float
*/
function get_display_vat() {
return $this->has_presentment() ?
(float) $this->presentment->vat :
(float) $this->vat;
}

/**
* @return string
*/
function get_display_currency() {
return $this->has_presentment() ?
$this->presentment->currency :
$this->currency;
}

/**
* Returns the gross in this format:
* `{symbol}{amount | 2 decimal digits} {currency | uppercase}`
Expand All @@ -132,12 +180,13 @@ function is_migrated() {
*/
function formatted_gross()
{
$price = $this->gross + $this->vat;
$price = $this->get_display_gross() + $this->get_display_vat();

return (
( $price < 0 ? '-' : '' ) .
$this->get_symbol() .
number_format( abs( $price ), 2, '.', ',' ) . ' ' .
strtoupper( $this->currency )
strtoupper( $this->get_display_currency() )
);
}

Expand All @@ -161,9 +210,17 @@ private function get_symbol() {
self::CURRENCY_USD => '$',
self::CURRENCY_GBP => '&pound;',
self::CURRENCY_EUR => '&euro;',
self::CURRENCY_ILS => '₪',
self::CURRENCY_CAD => '$',
self::CURRENCY_AUD => '$',
self::CURRENCY_PLN => 'zł',
);
}

return self::$CURRENCY_2_SYMBOL[ $this->currency ];
$currency = $this->get_display_currency();

return isset( self::$CURRENCY_2_SYMBOL[ $currency ] )
? self::$CURRENCY_2_SYMBOL[ $currency ]
: strtoupper( $currency ) . ' ';
}
}
}
19 changes: 17 additions & 2 deletions includes/managers/class-fs-contact-form-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,23 @@ public function get_standalone_link( Freemius $fs ) {
$query_params = $this->get_query_params( $fs );

$query_params['is_standalone'] = 'true';
$query_params['parent_url'] = admin_url( add_query_arg( '', '' ) );
$parent_url = admin_url();

if ( isset( $_SERVER['REQUEST_URI'] ) ) {
$request_uri = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
$admin_path = wp_parse_url( admin_url(), PHP_URL_PATH );

if ( is_string( $admin_path ) && '' !== $admin_path && 0 === strpos( $request_uri, $admin_path ) ) {
$request_uri = ltrim( substr( $request_uri, strlen( $admin_path ) ), '/' );
} else {
$request_uri = ltrim( $request_uri, '/' );
}

$parent_url = admin_url( $request_uri );
}

$query_params['parent_url'] = $parent_url;

return WP_FS__ADDRESS . '/contact/?' . http_build_query( $query_params );
}
}
}
2 changes: 1 addition & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @var string
*/
$this_sdk_version = '2.13.2';
$this_sdk_version = '2.13.2.1';

#region SDK Selection Logic --------------------------------------------------------------------

Expand Down
Loading