Use new code style
This commit is contained in:
.phpcs.xml.distcomposer.jsonconstants.phpsunrise.phpuninstall.php
inc
admin-pages
class-about-admin-page.phpclass-base-admin-page.phpclass-base-customer-facing-admin-page.phpclass-broadcast-edit-admin-page.phpclass-broadcast-list-admin-page.phpclass-checkout-form-edit-admin-page.phpclass-checkout-form-list-admin-page.phpclass-customer-edit-admin-page.phpclass-customer-list-admin-page.phpclass-customizer-admin-page.phpclass-dashboard-admin-page.phpclass-discount-code-edit-admin-page.phpclass-discount-code-list-admin-page.phpclass-domain-edit-admin-page.phpclass-domain-list-admin-page.phpclass-edit-admin-page.phpclass-email-edit-admin-page.phpclass-email-list-admin-page.phpclass-email-template-customize-admin-page.phpclass-event-list-admin-page.phpclass-event-view-admin-page.phpclass-hosting-integration-wizard-admin-page.phpclass-invoice-template-customize-admin-page.phpclass-jobs-list-admin-page.phpclass-list-admin-page.phpclass-membership-edit-admin-page.phpclass-membership-list-admin-page.phpclass-migration-alert-admin-page.phpclass-payment-edit-admin-page.phpclass-payment-list-admin-page.phpclass-placeholders-admin-page.phpclass-product-edit-admin-page.phpclass-product-list-admin-page.phpclass-settings-admin-page.phpclass-setup-wizard-admin-page.phpclass-shortcodes-admin-page.phpclass-site-edit-admin-page.phpclass-site-list-admin-page.phpclass-system-info-admin-page.phpclass-tax-rates-admin-page.phpclass-template-previewer-customize-admin-page.phpclass-top-admin-nav-menu.phpclass-view-logs-admin-page.phpclass-webhook-edit-admin-page.phpclass-webhook-list-admin-page.phpclass-wizard-admin-page.php
customer-panel
class-account-admin-page.phpclass-add-new-site-admin-page.phpclass-checkout-admin-page.phpclass-my-sites-admin-page.phpclass-template-switching-admin-page.php
debug
api
builders
block-editor
checkout
class-cart.phpclass-checkout-pages.phpclass-checkout.phpclass-legacy-checkout.phpclass-line-item.php
class-admin-notices.phpclass-admin-themes-compatibility.phpclass-ajax.phpclass-api.phpclass-async-calls.phpclass-autoloader.phpclass-cron.phpclass-current.phpclass-dashboard-statistics.phpclass-dashboard-widgets.phpclass-documentation.phpclass-domain-mapping.phpclass-faker.phpclass-geolocation.phpclass-helper.phpclass-hooks.phpclass-license.phpclass-light-ajax.phpclass-logger.phpclass-maintenance-mode.phpclass-newsletter.phpclass-requirements.phpclass-scripts.phpclass-session-cookie.phpclass-settings.phpclass-sunrise.phpclass-user-switching.phpclass-views.phpclass-whitelabel.phpclass-wp-ultimo.phpsignup-fields
class-base-signup-field.phpclass-signup-field-billing-address.phpclass-signup-field-checkbox.phpclass-signup-field-color.phpclass-signup-field-discount-code.phpclass-signup-field-email.phpclass-signup-field-hidden.phpclass-signup-field-order-bump.phpclass-signup-field-order-summary.phpclass-signup-field-password.phpclass-signup-field-payment.phpclass-signup-field-period-selection.phpclass-signup-field-pricing-table.phpclass-signup-field-products.phpclass-signup-field-select.phpclass-signup-field-shortcode.phpclass-signup-field-site-title.phpclass-signup-field-site-url.phpclass-signup-field-steps.phpclass-signup-field-submit-button.phpclass-signup-field-template-selection.phpclass-signup-field-terms-of-use.phpclass-signup-field-text.phpclass-signup-field-username.php
field-templates
class-base-field-template.php
order-bump
order-summary
period-selection
pricing-table
steps
class-clean-steps-field-template.phpclass-legacy-steps-field-template.phpclass-minimal-steps-field-template.php
template-selection
compat
class-as-admin-view.phpclass-discount-code-compat.phpclass-domain-mapping-compat.phpclass-elementor-compat.phpclass-general-compat.phpclass-gutenberg-support.phpclass-legacy-shortcodes.phpclass-multiple-accounts-compat.phpclass-product-compat.php
contracts
country
class-country-br.phpclass-country-ca.phpclass-country-cn.phpclass-country-de.phpclass-country-default.phpclass-country-es.phpclass-country-fr.phpclass-country-gb.phpclass-country-in.phpclass-country-jp.phpclass-country-mx.phpclass-country-my.phpclass-country-ne.phpclass-country-nl.phpclass-country-ru.phpclass-country-sg.phpclass-country-tr.phpclass-country-us.phpclass-country-za.phpclass-country.php
database
broadcasts
checkout-forms
class-checkout-form-query.phpclass-checkout-forms-meta-table.phpclass-checkout-forms-schema.phpclass-checkout-forms-table.php
customers
class-customer-query.phpclass-customers-meta-table.phpclass-customers-schema.phpclass-customers-table.php
discount-codes
class-discount-code-query.phpclass-discount-codes-meta-table.phpclass-discount-codes-schema.phpclass-discount-codes-table.php
domains
emails
engine
class-base.phpclass-column.phpclass-compare.phpclass-date.phpclass-enum.phpclass-meta.phpclass-query.phpclass-row.phpclass-schema.phpclass-table.php
events
memberships
class-membership-query.phpclass-membership-status.phpclass-memberships-meta-table.phpclass-memberships-schema.phpclass-memberships-table.php
payments
class-payment-query.phpclass-payment-status.phpclass-payments-meta-table.phpclass-payments-schema.phpclass-payments-table.php
posts
products
class-product-query.phpclass-product-type.phpclass-products-meta-table.phpclass-products-schema.phpclass-products-table.php
sites
class-site-query.phpclass-site-type.phpclass-sites-meta-table.phpclass-sites-schema.phpclass-sites-table.php
webhooks
debug
deprecated
development
domain-mapping
duplication
exception
functions
admin.phparray-helpers.phpassets.phpbroadcast.phpcheckout-form.phpcheckout.phpcolor.phpcountries.phpcurrency.phpcustomer.phpdanger.phpdate.phpdebug.phpdiscount-code.phpdocumentation.phpdomain.phpelement.phpemail.phpenv.phpevent.phpfinancial.phpform.phpfs.phpgateway.phpgenerator.phpgeolocation.phphelper.phphttp.phpinvoice.phplegacy.phplimitations.phpmarkup-helpers.phpmembership.phpmock.phpmodel.phpnumber-helpers.phpoptions.phppages.phppayment.phpproduct.phpreflection.phprest.phpscheduler.phpsession.phpsettings.phpsite-context.phpsite.phpsort.phpstring-helpers.phpsunrise.phptax.phptemplate.phptranslation.phpurl.phpuser.phpwebhook.php
gateways
class-base-gateway.phpclass-base-stripe-gateway.phpclass-free-gateway.phpclass-ignorable-exception.phpclass-manual-gateway.phpclass-paypal-gateway.phpclass-stripe-checkout-gateway.phpclass-stripe-gateway.php
helpers
class-arr.phpclass-hash.phpclass-screenshot.phpclass-sender.phpclass-site-duplicator.phpclass-validator.phpclass-wp-config.php
validation-rules
installers
class-base-installer.phpclass-core-installer.phpclass-default-content-installer.phpclass-migrator.php
integrations
host-providers
class-base-host-provider.phpclass-closte-host-provider.phpclass-cloudflare-host-provider.phpclass-cloudways-host-provider.phpclass-cpanel-host-provider.phpclass-gridpane-host-provider.phpclass-runcloud-host-provider.phpclass-serverpilot-host-provider.phpclass-wpengine-host-provider.phpclass-wpmudev-host-provider.php
cpanel-api
internal
invoices
limitations
class-limit-customer-user-role.phpclass-limit-disk-space.phpclass-limit-domain-mapping.phpclass-limit-plugins.phpclass-limit-post-types.phpclass-limit-site-templates.phpclass-limit-sites.phpclass-limit-subtype.phpclass-limit-themes.phpclass-limit-users.phpclass-limit-visits.phpclass-limit.php
limits
class-customer-user-role-limits.phpclass-disk-space-limits.phpclass-plugin-limits.phpclass-post-type-limits.phpclass-site-template-limits.phpclass-theme-limits.phpclass-trial-limits.php
list-tables
class-base-list-table.phpclass-broadcast-list-table.phpclass-checkout-form-list-table.phpclass-customer-list-table.phpclass-customers-membership-list-table.phpclass-customers-payment-list-table.phpclass-customers-site-list-table.phpclass-discount-code-list-table.phpclass-domain-list-table.phpclass-email-list-table.phpclass-event-list-table.phpclass-inside-events-list-table.phpclass-line-item-list-table.phpclass-membership-line-item-list-table.phpclass-membership-list-table-widget.phpclass-membership-list-table.phpclass-memberships-site-list-table.phpclass-payment-line-item-list-table.phpclass-payment-list-table-widget.phpclass-payment-list-table.phpclass-product-list-table.phpclass-site-customer-list-table.phpclass-site-list-table.phpclass-sites-domain-list-table.phpclass-webhook-list-table.php
customer-panel
loaders
managers
class-base-manager.phpclass-block-manager.phpclass-broadcast-manager.phpclass-cache-manager.phpclass-checkout-form-manager.phpclass-customer-manager.phpclass-discount-code-manager.phpclass-domain-manager.phpclass-email-manager.phpclass-event-manager.phpclass-field-templates-manager.phpclass-form-manager.phpclass-gateway-manager.phpclass-job-manager.phpclass-limitation-manager.phpclass-membership-manager.phpclass-notes-manager.phpclass-notification-manager.phpclass-payment-manager.phpclass-product-manager.phpclass-signup-fields-manager.phpclass-site-manager.phpclass-visits-manager.phpclass-webhook-manager.php
models
class-base-model.phpclass-broadcast.phpclass-checkout-form.phpclass-customer.phpclass-discount-code.phpclass-domain.phpclass-email.phpclass-event.phpclass-membership.phpclass-payment.phpclass-post-base-model.phpclass-product.phpclass-site.phpclass-webhook.php
traits
objects
site-templates
sso
tax
traits
trait-singleton.phptrait-wp-ultimo-coupon-deprecated.phptrait-wp-ultimo-deprecated.phptrait-wp-ultimo-plan-deprecated.phptrait-wp-ultimo-settings-deprecated.phptrait-wp-ultimo-site-deprecated.phptrait-wp-ultimo-subscription-deprecated.php
ui
class-account-summary-element.phpclass-base-element.phpclass-billing-info-element.phpclass-checkout-element.phpclass-current-membership-element.phpclass-current-site-element.phpclass-domain-mapping-element.phpclass-field.phpclass-form.phpclass-invoices-element.phpclass-jumper.phpclass-limits-element.phpclass-login-form-element.phpclass-my-sites-element.phpclass-payment-methods-element.phpclass-simple-text-element.phpclass-site-actions-element.phpclass-site-maintenance-element.phpclass-template-previewer.phpclass-template-switching-element.phpclass-thank-you-element.phpclass-toolbox.phpclass-tours.php
updater
tests
Admin_Pages
Gateway_Functions_Test.phpWP_Ultimo
WP_Ultimo_Test.phpbootstrap.phpviews
about.phpadmin-notices.php
wp-multisite-waas.phpadmin-pages
fields
field-code-editor.phpfield-color-picker.phpfield-dashicon.phpfield-group.phpfield-header.phpfield-hidden.phpfield-html.phpfield-image.phpfield-link.phpfield-multiselect.phpfield-note.phpfield-repeater.phpfield-select-icon.phpfield-select.phpfield-small-header.phpfield-submit.phpfield-tab-select.phpfield-text-display.phpfield-text-edit.phpfield-text.phpfield-textarea.phpfield-toggle.phpfield-wp-editor.phpform.php
partials
base
centered.php
checkout-forms
customers
dash.phpedit.phpedit
empty-state.phpfilter.phpgrid.phplist.phpproducts
responsive-table-row.phpsettings.phpsites
wizard.phpwizard
broadcast
checkout
confirmation.php
fields
field-checkbox-multi.phpfield-checkbox.phpfield-group.phpfield-hidden.phpfield-html.phpfield-note.phpfield-password.phpfield-payment-methods.phpfield-products.phpfield-radio.phpfield-select.phpfield-submit.phpfield-text.phpfield-toggle.phpform.php
form.phppartials
partials
paypal
register.phptemplates
order-bump
order-summary
period-selection
pricing-table
steps
template-selection
customers
dashboard-statistics
filter.phpwidget-countries.phpwidget-forms.phpwidget-most-visited-sites.phpwidget-mrr-growth.phpwidget-new-accounts.phpwidget-revenue.phpwidget-tax-by-code.phpwidget-tax-by-day.phpwidget-tax-graph.phpwidget-taxes.php
dashboard-widgets
account-summary.phpactivity-stream.phpbilling-info.phpcurrent-membership-product-details.phpcurrent-membership.phpcurrent-site.phpdomain-mapping.phpfirst-steps.phpinvoices.phplimits-and-quotas.phplogin-additional-forms.phplogin-form.phpmy-sites.phpsimple-text.phpsite-actions.phpsite-maintenance.phpsummary.phpthank-you.php
domain
dynamic-styles
emails
admin
customer
events
invoice
legacy
signup
limitations
memberships
payments
settings
fields
shortcodes
sites
system-info
taxes
ui
branding
container-toggle.phpjumper-trigger.phpjumper.phpselectize-templates.phptemplate-previewer.phptoolbox.phpwizards
@@ -46,8 +46,7 @@ class Field implements \JsonSerializable {
|
||||
public function __construct($id, $atts) {
|
||||
|
||||
$this->set_attributes($id, $atts);
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and the attributes passed via the constructor.
|
||||
@@ -60,57 +59,59 @@ class Field implements \JsonSerializable {
|
||||
*/
|
||||
public function set_attributes($id, $atts) {
|
||||
|
||||
$this->atts = wp_parse_args($atts, array(
|
||||
'id' => $id,
|
||||
'type' => 'text',
|
||||
'icon' => 'dashicons-wu-cog',
|
||||
'action' => false,
|
||||
'form' => false,
|
||||
'title' => false,
|
||||
'img' => false,
|
||||
'desc' => false,
|
||||
'content' => false,
|
||||
'display_value' => false,
|
||||
'default_value' => false,
|
||||
'tooltip' => false,
|
||||
'args' => false,
|
||||
'sortable' => false,
|
||||
'placeholder' => false,
|
||||
'options' => false,
|
||||
'options_template' => false,
|
||||
'require' => false,
|
||||
'button' => false,
|
||||
'width' => false,
|
||||
'rules' => false,
|
||||
'min' => false,
|
||||
'max' => false,
|
||||
'allow_html' => false,
|
||||
'append' => false,
|
||||
'order' => false,
|
||||
'dummy' => false,
|
||||
'disabled' => false,
|
||||
'capability' => false,
|
||||
'edit' => false,
|
||||
'copy' => false,
|
||||
'validation' => false,
|
||||
'meter' => false,
|
||||
'href' => false,
|
||||
'raw' => false,
|
||||
'money' => false,
|
||||
'stacked' => false, // If the field is inside a restricted container
|
||||
'columns' => 1,
|
||||
'classes' => '',
|
||||
'wrapper_classes' => '',
|
||||
'html_attr' => array(),
|
||||
'wrapper_html_attr' => array(),
|
||||
'sub_fields' => array(),
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'prefix_html_attr' => array(),
|
||||
'suffix_html_attr' => array(),
|
||||
));
|
||||
|
||||
} // end set_attributes;
|
||||
$this->atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
'id' => $id,
|
||||
'type' => 'text',
|
||||
'icon' => 'dashicons-wu-cog',
|
||||
'action' => false,
|
||||
'form' => false,
|
||||
'title' => false,
|
||||
'img' => false,
|
||||
'desc' => false,
|
||||
'content' => false,
|
||||
'display_value' => false,
|
||||
'default_value' => false,
|
||||
'tooltip' => false,
|
||||
'args' => false,
|
||||
'sortable' => false,
|
||||
'placeholder' => false,
|
||||
'options' => false,
|
||||
'options_template' => false,
|
||||
'require' => false,
|
||||
'button' => false,
|
||||
'width' => false,
|
||||
'rules' => false,
|
||||
'min' => false,
|
||||
'max' => false,
|
||||
'allow_html' => false,
|
||||
'append' => false,
|
||||
'order' => false,
|
||||
'dummy' => false,
|
||||
'disabled' => false,
|
||||
'capability' => false,
|
||||
'edit' => false,
|
||||
'copy' => false,
|
||||
'validation' => false,
|
||||
'meter' => false,
|
||||
'href' => false,
|
||||
'raw' => false,
|
||||
'money' => false,
|
||||
'stacked' => false, // If the field is inside a restricted container
|
||||
'columns' => 1,
|
||||
'classes' => '',
|
||||
'wrapper_classes' => '',
|
||||
'html_attr' => array(),
|
||||
'wrapper_html_attr' => array(),
|
||||
'sub_fields' => array(),
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'prefix_html_attr' => array(),
|
||||
'suffix_html_attr' => array(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a particular attribute.
|
||||
@@ -123,9 +124,8 @@ class Field implements \JsonSerializable {
|
||||
*/
|
||||
public function set_attribute($att, $value) {
|
||||
|
||||
$this->atts[$att] = $value;
|
||||
|
||||
} // end set_attribute;
|
||||
$this->atts[ $att ] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of field attributes.
|
||||
@@ -136,8 +136,7 @@ class Field implements \JsonSerializable {
|
||||
public function get_attributes() {
|
||||
|
||||
return $this->atts;
|
||||
|
||||
} // end get_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure old fields remain compatible.
|
||||
@@ -168,33 +167,27 @@ class Field implements \JsonSerializable {
|
||||
);
|
||||
|
||||
if (array_key_exists($this->type, $aliases)) {
|
||||
|
||||
$new_type_name = $aliases[$this->type];
|
||||
$new_type_name = $aliases[ $this->type ];
|
||||
|
||||
if (array_key_exists($this->type, $deprecated)) {
|
||||
|
||||
// translators: The %1$s placeholder is the old type name, the second, the new type name.
|
||||
_doing_it_wrong('wu_add_field', sprintf(__('The field type "%1$s" is no longer supported, use "%2$s" instead.'), $this->type, $new_type_name), '2.0.0');
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
/*
|
||||
* Back Compat for Select2 Fields
|
||||
*/
|
||||
if ($this->type === 'select2') {
|
||||
|
||||
$this->atts['html_attr']['data-selectize'] = 1;
|
||||
$this->atts['html_attr']['multiple'] = 1;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $new_type_name;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} // end get_compat_template_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the template name for a field.
|
||||
@@ -214,8 +207,7 @@ class Field implements \JsonSerializable {
|
||||
$view_name = $compat_name ? $compat_name : $this->type;
|
||||
|
||||
return str_replace('_', '-', (string) $view_name);
|
||||
|
||||
} // end get_template_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attributes as class properties.
|
||||
@@ -242,56 +234,41 @@ class Field implements \JsonSerializable {
|
||||
'img',
|
||||
);
|
||||
|
||||
$attr = isset($this->atts[$att]) ? $this->atts[$att] : false;
|
||||
$attr = isset($this->atts[ $att ]) ? $this->atts[ $att ] : false;
|
||||
|
||||
$allow_callable_prefix = is_string($attr) && strncmp($attr, 'wu_get_', strlen('wu_get_')) === 0 && is_callable($attr);
|
||||
$allow_callable_method = is_array($attr) && is_callable($attr);
|
||||
|
||||
if (in_array($att, $allowed_callable, true) && ($allow_callable_prefix || $allow_callable_method || is_a($attr, \Closure::class))) {
|
||||
|
||||
$attr = call_user_func($attr, $this);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($att === 'wrapper_classes' && isset($this->atts['wrapper_html_attr']['v-show'])) {
|
||||
|
||||
$this->atts['wrapper_classes'] = $this->atts['wrapper_classes'] . ' wu-requires-other';
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
if ($att === 'type' && $this->atts[$att] === 'submit') {
|
||||
|
||||
if ($att === 'type' && $this->atts[ $att ] === 'submit') {
|
||||
$this->atts['wrapper_classes'] = $this->atts['wrapper_classes'] . ' wu-submit-field';
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
if ($att === 'type' && $this->atts[$att] === 'tab-select') {
|
||||
|
||||
if ($att === 'type' && $this->atts[ $att ] === 'tab-select') {
|
||||
$this->atts['wrapper_classes'] = $this->atts['wrapper_classes'] . ' wu-tab-field';
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($att === 'wrapper_classes' && is_a($this->form, '\\WP_Ultimo\\UI\\Form')) {
|
||||
|
||||
return $this->form->field_wrapper_classes . ' ' . $this->atts['wrapper_classes'];
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($att === 'classes' && is_a($this->form, '\\WP_Ultimo\\UI\\Form')) {
|
||||
|
||||
return $this->form->field_classes . ' ' . $this->atts['classes'];
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($att === 'title' && $attr === false && isset($this->atts['name'])) {
|
||||
|
||||
$attr = $this->atts['name'];
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $attr;
|
||||
|
||||
} // end __get;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of sanitization callbacks for each field type
|
||||
@@ -314,8 +291,7 @@ class Field implements \JsonSerializable {
|
||||
);
|
||||
|
||||
return apply_filters('wu_settings_fields_sanitization_rules', $rules);
|
||||
|
||||
} // end sanitization_rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the setting represented by this field.
|
||||
@@ -326,8 +302,7 @@ class Field implements \JsonSerializable {
|
||||
public function get_value() {
|
||||
|
||||
return $this->value;
|
||||
|
||||
} // end get_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the settings represented by this field.
|
||||
@@ -344,15 +319,12 @@ class Field implements \JsonSerializable {
|
||||
|
||||
$this->value = $value;
|
||||
|
||||
if (!$this->raw) {
|
||||
|
||||
if ( ! $this->raw) {
|
||||
$this->sanitize();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
} // end set_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the value of the field through the sanitization callback.
|
||||
@@ -364,45 +336,37 @@ class Field implements \JsonSerializable {
|
||||
|
||||
$rules = $this->sanitization_rules();
|
||||
|
||||
$sanitize_method = isset($rules[$this->type]) ? $rules[$this->type] : $rules['text'];
|
||||
$sanitize_method = isset($rules[ $this->type ]) ? $rules[ $this->type ] : $rules['text'];
|
||||
|
||||
if ($sanitize_method) {
|
||||
|
||||
$this->value = call_user_func($sanitize_method, $this->value);
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end sanitize;
|
||||
/**
|
||||
* Sanitization callback for fields of type number.
|
||||
*
|
||||
* Checks if the new value set is between the min and max boundaries.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param int|float $value Value of the settings being represented by this field.
|
||||
* @return int|float
|
||||
*/
|
||||
protected function validate_number_field($value) {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sanitization callback for fields of type number.
|
||||
*
|
||||
* Checks if the new value set is between the min and max boundaries.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param int|float $value Value of the settings being represented by this field.
|
||||
* @return int|float
|
||||
*/
|
||||
protected function validate_number_field($value) {
|
||||
|
||||
/**
|
||||
* Check if the value respects the min/max values.
|
||||
*/
|
||||
if ($this->min && $value < $this->min) {
|
||||
|
||||
return $this->min;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($this->max && $value > $this->max) {
|
||||
|
||||
return $this->max;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
} // end validate_number_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the value submitted via a textarea or wp_editor field for database insertion.
|
||||
@@ -415,14 +379,11 @@ class Field implements \JsonSerializable {
|
||||
protected function validate_textarea_field($value) {
|
||||
|
||||
if ($this->allow_html) {
|
||||
|
||||
return stripslashes(wp_filter_post_kses(addslashes($value)));
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return wp_strip_all_tags(stripslashes($value));
|
||||
|
||||
} // end validate_textarea_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML attributes for the field.
|
||||
@@ -433,43 +394,32 @@ class Field implements \JsonSerializable {
|
||||
public function get_html_attributes() {
|
||||
|
||||
if (is_callable($this->atts['html_attr'])) {
|
||||
|
||||
$this->atts['html_attr'] = call_user_func($this->atts['html_attr']);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$attributes = $this->atts['html_attr'];
|
||||
|
||||
unset($this->atts['html_attr']['class']);
|
||||
|
||||
if ($this->type === 'number') {
|
||||
|
||||
if ($this->min !== false) {
|
||||
|
||||
$attributes['min'] = $this->min;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($this->max !== false) {
|
||||
|
||||
$attributes['max'] = $this->max;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds money formatting and masking
|
||||
*/
|
||||
if ($this->money !== false) {
|
||||
|
||||
$attributes['v-bind'] = 'money_settings';
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return wu_array_to_html_attrs($attributes);
|
||||
|
||||
} // end get_html_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML attributes for the field.
|
||||
@@ -484,8 +434,7 @@ class Field implements \JsonSerializable {
|
||||
unset($this->atts['wrapper_html_attr']['class']);
|
||||
|
||||
return wu_array_to_html_attrs($attributes);
|
||||
|
||||
} // end get_wrapper_html_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements our on json_decode version of this object. Useful for use in vue.js
|
||||
@@ -497,7 +446,5 @@ class Field implements \JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
|
||||
return $this->atts;
|
||||
|
||||
} // end jsonSerialize;
|
||||
|
||||
} // end class Field;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user