Skip to content
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]
},
"require-dev": {
"wp-coding-standards/wpcs": "^2.3",
"wp-coding-standards/wpcs": "^3.4.1",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"squizlabs/php_codesniffer": "^3.7",
"phpcompatibility/php-compatibility": "^9.3",
Expand Down
510 changes: 393 additions & 117 deletions composer.lock

Large diffs are not rendered by default.

68 changes: 27 additions & 41 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -4540,28 +4540,6 @@ function dynamic_init( array $plugin_info ) {
}

if ( $this->is_user_in_admin() ) {
if ( $this->is_registered() && fs_request_has( 'purchase_completed' ) ) {
$this->_admin_notices->add_sticky(
sprintf(
/* translators: %s: License type (e.g. you have a professional license) */
$this->get_text_inline( 'You have purchased a %s license.', 'you-have-x-license' ),
fs_request_get( 'purchased_plan' )
) .
sprintf(
$this->get_text_inline(" The %s's %sdownload link%s, license key, and installation instructions have been sent to %s. If you can't find the email after 5 min, please check your spam box.", 'post-purchase-email-sent-message' ),
$this->get_module_label( true ),
( FS_Plugin::is_valid_id( $this->get_bundle_id() ) ? "products' " : '' ),
( FS_Plugin::is_valid_id( $this->get_bundle_id() ) ? 's' : '' ),
sprintf(
'<strong>%s</strong>',
fs_request_get( 'purchase_email' )
)
),
'plan_purchased',
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
);
}

if ( $this->is_addon() ) {
if ( ! $this->is_parent_plugin_installed() ) {
$parent_name = $this->get_option( $plugin_info, 'parent_name', null );
Expand Down Expand Up @@ -4863,9 +4841,10 @@ private function get_api_error_message( $result ) {
) {
$code = empty( $result->error->code ) ? '' : " Code: {$result->error->code}";

$error_message .= "<b>{$result->error->message}{$code}</b>";
// We do not send HTML from exceptions from Freemius servers, but we escape it nonetheless.
$error_message .= "<b>" . esc_html( $result->error->message . $code ) . "</b>";
} else {
$error_message .= var_export( $result, true );
$error_message .= esc_html( var_export( $result, true ) );
}

return $error_message;
Expand Down Expand Up @@ -6797,9 +6776,11 @@ function _add_pending_activation_notice(
$email_address = $current_user->user_email;
}

$escaped_email_address = esc_html( $email_address );

$formatted_message_args = array(
"<b>{$this->get_plugin_name()}</b>",
"<b>{$email_address}</b>",
"<b>{$escaped_email_address}</b>",
);

if ( ! $has_upgrade_context || ! fs_is_network_admin() ) {
Expand Down Expand Up @@ -6844,7 +6825,7 @@ function _add_pending_activation_notice(
}

$formatted_message_args[] = ( ! empty( $support_email_address ) ) ?
( "<b>{$support_email_address}</b>" ) :
( "<b>" . esc_html( $support_email_address ) . "</b>" ) :
$this->get_text_x_inline(
"the product's support email address",
'Part of the message that tells the user to check their spam folder for a specific email.',
Expand Down Expand Up @@ -17564,6 +17545,11 @@ function _install_with_new_user() {
return;
}

// Only site administrators who can activate plugins may opt-in.
if ( ! $this->is_user_admin() ) {
return;
}

$has_pending_activation_confirmation_param = fs_request_has( 'pending_activation' );

$this->update_license_required_permissions_if_anonymous();
Expand Down Expand Up @@ -18143,7 +18129,7 @@ private function create_installs_with_user(
if ( ! $silent ) {
$this->_admin_notices->add(
sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $result->error->message . '</b>',
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . esc_html( $result->error->message ) . '</b>',
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
'error'
);
Expand Down Expand Up @@ -18263,7 +18249,7 @@ private function _activate_addon_account(

$this->_admin_notices->add(
sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $error_message . '</b>',
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . esc_html( $error_message ) . '</b>',
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
'error'
);
Expand Down Expand Up @@ -18440,7 +18426,7 @@ private function activate_parent_account( Freemius $parent_fs ) {
if ( isset( $parent_install->error ) ) {
$this->_admin_notices->add(
sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $parent_install->error->message . '</b>',
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . esc_html( $parent_install->error->message ) . '</b>',
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
'error'
);
Expand Down Expand Up @@ -21158,7 +21144,7 @@ private function _sync_plugin_license(
} else if ( is_object( $result ) ) {
// Authentication params are broken.
$this->_admin_notices->add(
$this->get_text_inline( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.', 'wrong-authentication-param-message' ) . '<br> ' . $this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . var_export( $result->error, true ),
$this->get_text_inline( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.', 'wrong-authentication-param-message' ) . '<br> ' . $this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . esc_html( var_export( $result->error, true ) ),
'',
'error'
);
Expand Down Expand Up @@ -21479,7 +21465,7 @@ private function _sync_plugin_license(
$this->get_text_inline( 'Your license has been cancelled. If you think it\'s a mistake, please contact support.', 'license-cancelled' ) . ' ' .
sprintf(
'<a href="%s">%s</a>',
$this->contact_url( 'bug' ),
esc_url( $this->contact_url( 'bug' ) ),
$this->get_text_inline( 'Please contact us here', 'contact-us-here' )
),
$hmm_text,
Expand Down Expand Up @@ -21572,7 +21558,7 @@ private function generate_api_blocked_notice_message_from_result( $result ) {
"<div>{$error_message}</div>" .
'<div class="fs-api-request-error-details" style="display: none">' .
'<strong>' . $this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . '</strong><br>' .
$result->error->message .
esc_html( $result->error->message ) .
'</div>';

return $error_message;
Expand Down Expand Up @@ -21677,10 +21663,10 @@ protected function _activate_license( $background = false, $premium_license = nu
'%s %s',
$this->get_text_inline( 'It looks like the license could not be activated.', 'license-activation-failed-message' ),
( is_object( $license ) && isset( $license->error ) ?
$license->error->message :
esc_html( $license->error->message ) :
sprintf( '%s<br><code>%s</code>',
$this->get_text_inline( 'Error received from the server:', 'server-error-message' ),
var_export( $license, true )
esc_html( var_export( $license, true ) )
)
)
),
Expand Down Expand Up @@ -21768,7 +21754,7 @@ private function handle_license_deactivation_result( $license, $hmm_text = false
if ( isset( $license->error ) ) {
$this->_admin_notices->add(
$this->get_text_inline( 'It looks like the license deactivation failed.', 'license-deactivation-failed-message' ) . '<br> ' .
$this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . ' ' . var_export( $license->error, true ),
$this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . ' ' . esc_html( var_export( $license->error, true ) ),
$hmm_text,
'error'
);
Expand Down Expand Up @@ -22417,7 +22403,7 @@ private function check_updates( $background = false, $plugin_id = false, $flush
$update->version,
sprintf(
'<a href="%s" target="_blank" rel="noopener">%s</a>',
$this->get_account_url( 'download_latest' ),
esc_url( $this->get_account_url( 'download_latest' ) ),
sprintf(
/* translators: %s: plan name (e.g. latest "Professional" version) */
$this->get_text_inline( 'the latest %s version here', 'latest-x-version' ),
Expand Down Expand Up @@ -22835,7 +22821,7 @@ private function verify_email() {
if ( ! isset( $result->error ) ) {
$this->_admin_notices->add( sprintf(
$this->get_text_inline( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.', 'verification-email-sent-message' ),
sprintf( '<a href="mailto:%1$s">%2$s</a>', esc_url( $this->_user->email ), $this->_user->email )
sprintf( '<a href="mailto:%1$s">%2$s</a>', esc_url( $this->_user->email ), esc_html( $this->_user->email ) )
) );
} else {
// handle different error cases.
Expand Down Expand Up @@ -23159,9 +23145,9 @@ private function _handle_account_edits() {

if ( $this->init_change_owner( $candidate_email, $transfer_type ) ) {
if ( 'transfer' === $transfer_type ) {
$this->_admin_notices->add( sprintf( $this->get_text_inline( 'A confirmation email was just sent to %s. The email owner must confirm the update within the next 4 hours.', 'change-owner-request-sent-x-transfer' ), '<b>' . $this->_user->email . '</b>' ) );
$this->_admin_notices->add( sprintf( $this->get_text_inline( 'A confirmation email was just sent to %s. The email owner must confirm the update within the next 4 hours.', 'change-owner-request-sent-x-transfer' ), '<b>' . esc_html( $this->_user->email ) . '</b>' ) );
} else {
$this->_admin_notices->add( sprintf( $this->get_text_inline( 'A confirmation email was just sent to %s. You must confirm the update within the next 4 hours. If you cannot find the email, please check your spam folder.', 'change-owner-request-sent-x' ), '<b>' . $this->_user->email . '</b>' ) );
$this->_admin_notices->add( sprintf( $this->get_text_inline( 'A confirmation email was just sent to %s. You must confirm the update within the next 4 hours. If you cannot find the email, please check your spam folder.', 'change-owner-request-sent-x' ), '<b>' . esc_html( $this->_user->email ) . '</b>' ) );
}
}
break;
Expand All @@ -23173,13 +23159,13 @@ private function _handle_account_edits() {
return;
}

$this->_admin_notices->add( sprintf( $this->get_text_inline( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.', 'change-owner-request_owner-confirmed' ), '<b>' . $candidate_email . '</b>' ) );
$this->_admin_notices->add( sprintf( $this->get_text_inline( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.', 'change-owner-request_owner-confirmed' ), '<b>' . esc_html( $candidate_email ) . '</b>' ) );
break;
case 'candidate_confirmed':
// We do not need to validate the authenticity of this request here, because the `complete_change_owner` does that for us through API calls.
if ( $this->complete_change_owner() ) {
$this->_admin_notices->add_sticky(
sprintf( $this->get_text_inline( '%s is the new owner of the account.', 'change-owner-request_candidate-confirmed' ), '<b>' . $this->_user->email . '</b>' ),
sprintf( $this->get_text_inline( '%s is the new owner of the account.', 'change-owner-request_candidate-confirmed' ), '<b>' . esc_html( $this->_user->email ) . '</b>' ),
'ownership_changed',
$this->get_text_x_inline( 'Congrats', 'as congratulations', 'congrats' ) . '!'
);
Expand Down
16 changes: 8 additions & 8 deletions includes/managers/class-fs-clone-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1223,16 +1223,16 @@ private function add_manual_clone_resolution_admin_notice(
);

foreach ( $product_titles as $product_title ) {
$products_list .= sprintf( '<li>%s</li>', $product_title );
$products_list .= sprintf( '<li>%s</li>', esc_html( $product_title ) );
}

$products_list = '<ol>' . $products_list . '</ol>';

foreach ( $site_urls as $site_url ) {
$sites_list .= sprintf(
'<li><a href="%s" target="_blank">%s</a></li>',
$site_url,
fs_strip_url_protocol( $site_url )
esc_url( $site_url ),
esc_html( fs_strip_url_protocol( $site_url ) )
);
}

Expand All @@ -1242,15 +1242,15 @@ private function add_manual_clone_resolution_admin_notice(
$remote_site_link = '<b>' . (1 === $total_sites ?
sprintf(
'<a href="%s" target="_blank">%s</a>',
$site_urls[0],
fs_strip_url_protocol( $site_urls[0] )
esc_url( $site_urls[0] ),
esc_html( fs_strip_url_protocol( $site_urls[0] ) )
) :
fs_text_inline( 'the above-mentioned sites', 'above-mentioned-sites' )) . '</b>';

$current_site_link = sprintf(
'<b><a href="%s" target="_blank">%s</a></b>',
$current_url,
fs_strip_url_protocol( $current_url )
esc_url( $current_url ),
esc_html( fs_strip_url_protocol( $current_url ) )
);

$button_template = '<button class="button" data-clone-action="%s">%s</button>';
Expand Down Expand Up @@ -1323,7 +1323,7 @@ private function add_manual_clone_resolution_admin_notice(
sprintf( '<div class="fs-clone-documentation-container">Unsure what to do? <a href="%s" target="_blank">Read more here</a>.</div>', $doc_url ),
// %1$s
( 1 === $total_products ?
sprintf( '<b>%s</b>', $product_titles[0] ) :
sprintf( '<b>%s</b>', esc_html( $product_titles[0] ) ) :
( 1 === $total_sites ?
sprintf( '<div>%s</div>', $products_list ) :
sprintf( '<div><p><strong>%s</strong>:</p>%s</div>', fs_esc_html_x_inline( 'Products', 'Clone resolution admin notice products list label', 'products' ), $products_list ) )
Expand Down
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.4';
$this_sdk_version = '2.13.5';

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

Expand Down
12 changes: 6 additions & 6 deletions templates/add-ons.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@

$open_addon = ( $open_addon || ( $open_addon_slug === $addon->slug ) );

$price = 0;
$has_trial = false;
$price = 0;
$min_price = 999999;
$has_trial = false;
$has_free_plan = false;
$has_paid_plan = false;

Expand All @@ -141,11 +142,9 @@
continue;
}


$has_paid_plan = true;
$has_trial = $has_trial || ( is_numeric( $plan->trial_period ) && ( $plan->trial_period > 0 ) );

$min_price = 999999;
foreach ( $plan->pricing as $pricing ) {
$pricing = new FS_Pricing( $pricing );

Expand All @@ -163,13 +162,14 @@
$min_price = min( $min_price, $pricing->annual_price );
} else if ( $pricing->has_monthly() ) {
$min_price = min( $min_price, 12 * $pricing->monthly_price );
}
} else if ( $pricing->has_lifetime() ) {
$min_price = min( $min_price, $pricing->lifetime_price );
}
}

if ( $min_price < 999999 ) {
$price = $min_price;
}

}
}

Expand Down
Loading
Loading