Prep Plugin for release on WordPress.org (#23)

* Update translation text domain
* Escape everything that should be escaped.
* Add nonce checks where needed.
* Sanitize all inputs.
* Apply Code style changes across the codebase.
* Correct many deprecation notices.
* Optimize load order of many filters.
* Add Proper Build script
* Use emojii flags
* Fix i18n deprecation  notice for translating too early
* Put all scripts in footer and load async
This commit is contained in:
David Stone
2025-04-14 11:36:46 -06:00
committed by GitHub
parent a31cfcb565
commit d88e50df38
1087 changed files with 12586 additions and 18535 deletions

View File

@ -19,16 +19,16 @@ trait Singleton {
*
* @var object
*/
public static $instance;
public static object $instance;
/**
* Returns the instance of WP_Ultimo
*
* @return object
*/
public static function get_instance() {
public static function get_instance(): object {
if ( ! static::$instance instanceof static) {
if ( ! isset(static::$instance) || ! static::$instance instanceof static) {
static::$instance = new static();
static::$instance->init();
@ -54,7 +54,7 @@ trait Singleton {
* @since 2.0.11
* @return boolean
*/
public function has_parents() {
public function has_parents(): bool {
return (bool) class_parents($this);
}

View File

@ -29,7 +29,7 @@ trait WP_Ultimo_Coupon_Deprecated {
*
* @since 2.0.0
*/
_doing_it_wrong($key, __('Discount Code keys should not be set directly.', 'wp-ultimo'), '2.0.0');
_doing_it_wrong($key, __('Discount Code keys should not be set directly.', 'wp-multisite-waas'), '2.0.0');
$this->meta[ "wpu_{$key}" ] = $value;
}
@ -55,7 +55,7 @@ trait WP_Ultimo_Coupon_Deprecated {
if (null === $value) {
// translators: the placeholder is the key.
$message = sprintf(__('Discount Codes do not have a %s parameter', 'wp-ultimo'), $key);
$message = sprintf(__('Discount Codes do not have a %s parameter', 'wp-multisite-waas'), $key);
// throw new \Exception($message);
@ -67,7 +67,7 @@ trait WP_Ultimo_Coupon_Deprecated {
*
* @since 2.0.0
*/
_doing_it_wrong($key, __('Discount Code keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
_doing_it_wrong($key, __('Discount Code keys should not be accessed directly', 'wp-multisite-waas'), '2.0.0');
return $value;
}

View File

@ -80,7 +80,7 @@ trait WP_Ultimo_Plan_Deprecated {
*
* @since 2.0.0
*/
_doing_it_wrong($key, __('Product keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
_doing_it_wrong($key, __('Product keys should not be accessed directly', 'wp-multisite-waas'), '2.0.0');
return $value;
}
@ -142,11 +142,11 @@ trait WP_Ultimo_Plan_Deprecated {
*/
if ($this->should_display_quota_on_pricing_tables('setup_fee', true)) {
if ($this->get_pricing_type() === 'contact_us') {
$pricing_table_lines['wu_product_contact_us'] = __('Contact Us to know more', 'wp-ultimo');
$pricing_table_lines['wu_product_contact_us'] = __('Contact Us to know more', 'wp-multisite-waas');
} else {
$pricing_table_lines['wu_product_setup_fee'] = $this->has_setup_fee()
? sprintf(__('Setup Fee: %s', 'wp-ultimo'), "<strong class='pricing-table-setupfee' data-value='" . $this->get_setup_fee() . "'>" . wu_format_currency($this->get_setup_fee()) . '</strong>')
: __('No Setup Fee', 'wp-ultimo');
? sprintf(__('Setup Fee: %s', 'wp-multisite-waas'), "<strong class='pricing-table-setupfee' data-value='" . $this->get_setup_fee() . "'>" . wu_format_currency($this->get_setup_fee()) . '</strong>')
: __('No Setup Fee', 'wp-multisite-waas');
}
}
@ -169,7 +169,7 @@ trait WP_Ultimo_Plan_Deprecated {
if ($this->is_post_type_disabled($pt_slug)) {
// Translators: used as "No Posts" where a post type is disabled
$pricing_table_lines[ 'wu_product_limit_post_type_' . $pt_slug ] = sprintf(__('No %s', 'wp-ultimo'), $post_type->labels->name);
$pricing_table_lines[ 'wu_product_limit_post_type_' . $pt_slug ] = sprintf(__('No %s', 'wp-multisite-waas'), $post_type->labels->name);
continue;
}
@ -180,7 +180,7 @@ trait WP_Ultimo_Plan_Deprecated {
* @var integer|string
*/
$is_unlimited = (int) $this->get_limitations()->post_types->{$pt_slug}->number === 0 || ! $this->get_limitations()->post_types->is_enabled();
$value = $is_unlimited ? __('Unlimited', 'wp-ultimo') : $this->get_limitations()->post_types->{$pt_slug}->number;
$value = $is_unlimited ? __('Unlimited', 'wp-multisite-waas') : $this->get_limitations()->post_types->{$pt_slug}->number;
// Add Line
$label = 1 == $value ? $post_type->labels->singular_name : $post_type->labels->name;
@ -196,10 +196,10 @@ trait WP_Ultimo_Plan_Deprecated {
*/
if (wu_get_setting('enable_multiple_sites') && $this->should_display_quota_on_pricing_tables('sites')) {
$is_unlimited = (int) $this->get_limitations()->sites->get_limit() === 0 || ! $this->get_limitations()->sites->is_enabled();
$value = $is_unlimited ? __('Unlimited', 'wp-ultimo') : $this->get_limitations()->sites->get_limit();
$value = $is_unlimited ? __('Unlimited', 'wp-multisite-waas') : $this->get_limitations()->sites->get_limit();
// Add Line
$pricing_table_lines['wu_product_limit_sites'] = sprintf('<strong>%s %s</strong>', $value, _n('Site', 'Sites', $this->get_limitations()->sites->get_limit(), 'wp-ultimo'));
$pricing_table_lines['wu_product_limit_sites'] = sprintf('<strong>%s %s</strong>', $value, _n('Site', 'Sites', $this->get_limitations()->sites->get_limit(), 'wp-multisite-waas'));
}
/**
@ -207,10 +207,10 @@ trait WP_Ultimo_Plan_Deprecated {
*/
if ($this->should_display_quota_on_pricing_tables('upload')) {
$is_unlimited = (int) $this->get_limitations()->disk_space->get_limit() === 0 || ! $this->get_limitations()->disk_space->is_enabled();
$disk_space = $is_unlimited ? __('Unlimited', 'wp-ultimo') : size_format(absint($this->get_limitations()->disk_space->get_limit()) * 1024 * 1024);
$disk_space = $is_unlimited ? __('Unlimited', 'wp-multisite-waas') : size_format(absint($this->get_limitations()->disk_space->get_limit()) * 1024 * 1024);
// Add Line
$pricing_table_lines['wu_product_limit_disk_space'] = ! empty($disk_space) ? sprintf(__('%s <strong>Disk Space</strong>', 'wp-ultimo'), $disk_space) : false;
$pricing_table_lines['wu_product_limit_disk_space'] = ! empty($disk_space) ? sprintf(__('%s <strong>Disk Space</strong>', 'wp-multisite-waas'), $disk_space) : false;
}
/**
@ -220,10 +220,10 @@ trait WP_Ultimo_Plan_Deprecated {
*/
if ($this->should_display_quota_on_pricing_tables('visits')) {
$is_unlimited = (int) $this->get_limitations()->visits->get_limit() === 0 || ! $this->get_limitations()->visits->is_enabled();
$value = $is_unlimited ? __('Unlimited', 'wp-ultimo') : number_format($this->get_limitations()->visits->get_limit());
$value = $is_unlimited ? __('Unlimited', 'wp-multisite-waas') : number_format($this->get_limitations()->visits->get_limit());
// Add Line
$pricing_table_lines['wu_product_limit_visits'] = sprintf('%s %s', $value, _n('Visit per month', 'Visits per month', $this->get_limitations()->visits->get_limit(), 'wp-ultimo'));
$pricing_table_lines['wu_product_limit_visits'] = sprintf('%s %s', $value, _n('Visit per month', 'Visits per month', $this->get_limitations()->visits->get_limit(), 'wp-multisite-waas'));
}
/**
@ -235,7 +235,7 @@ trait WP_Ultimo_Plan_Deprecated {
if ($trial_days > 0 || $trial_days_plan) {
$trial_days = $trial_days_plan ?: $trial_days;
$pricing_table_lines['wu_product_trial'] = ! $this->is_free() ? sprintf(__('%s day <strong>Free Trial</strong>', 'wp-ultimo'), $trial_days) : '-';
$pricing_table_lines['wu_product_trial'] = ! $this->is_free() ? sprintf(__('%s day <strong>Free Trial</strong>', 'wp-multisite-waas'), $trial_days) : '-';
}
/**

View File

@ -74,8 +74,8 @@ trait WP_Ultimo_Settings_Deprecated {
$this->add_section(
'other',
[
'title' => __('Other', 'wp-ultimo'),
'desc' => __('Other', 'wp-ultimo'),
'title' => __('Other', 'wp-multisite-waas'),
'desc' => __('Other', 'wp-multisite-waas'),
]
);

View File

@ -39,7 +39,7 @@ trait WP_Ultimo_Site_Deprecated {
*
* @since 2.0.0
*/
_doing_it_wrong($key, __('Product keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
_doing_it_wrong($key, __('Product keys should not be accessed directly', 'wp-multisite-waas'), '2.0.0');
return $value;
}

View File

@ -38,7 +38,7 @@ trait WP_Ultimo_Subscription_Deprecated {
*
* @since 2.0.0
*/
_doing_it_wrong($key, __('Membership keys should not be accessed directly', 'wp-ultimo'), '2.0.0');
_doing_it_wrong($key, __('Membership keys should not be accessed directly', 'wp-multisite-waas'), '2.0.0');
return $value;
}