Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -145,21 +145,21 @@ class Account_Summary_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('About this Site', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -183,12 +183,12 @@ class Account_Summary_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'Account',
|
||||
'Summary',
|
||||
'WP Multisite WaaS',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,9 +207,9 @@ class Account_Summary_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'title' => __('About this Site', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +218,7 @@ class Account_Summary_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->site = WP_Ultimo()->currents->get_site();
|
||||
|
||||
@ -242,14 +242,14 @@ class Account_Summary_Element extends Base_Element {
|
||||
|
||||
is_multisite() && restore_current_blog();
|
||||
|
||||
$this->atts = array(
|
||||
$this->atts = [
|
||||
'site_trial' => 0, // @todo: fix this
|
||||
'space_used' => $space_used,
|
||||
'space_allowed' => $space_allowed,
|
||||
'percentage' => $percentage,
|
||||
'unlimited_space' => $unlimited_space,
|
||||
'message' => $message,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,7 +258,7 @@ class Account_Summary_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
|
||||
@ -269,14 +269,14 @@ class Account_Summary_Element extends Base_Element {
|
||||
$unlimited_space = get_site_option('upload_space_check_disabled');
|
||||
$message = $unlimited_space ? '%s' : '%s / %s';
|
||||
|
||||
$this->atts = array(
|
||||
$this->atts = [
|
||||
'site_trial' => 30, // @todo: fix this
|
||||
'space_used' => 120 * MB_IN_BYTES,
|
||||
'space_allowed' => 1 * GB_IN_BYTES,
|
||||
'percentage' => 120 * MB_IN_BYTES / 1 * GB_IN_BYTES,
|
||||
'unlimited_space' => $unlimited_space,
|
||||
'message' => $message,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ abstract class Base_Element {
|
||||
* @since 2.0.24
|
||||
* @var boolean
|
||||
*/
|
||||
protected static $public_elements = array();
|
||||
protected static $public_elements = [];
|
||||
|
||||
/**
|
||||
* If the element exists, we pre-load the parameters.
|
||||
@ -217,25 +217,25 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('plugins_loaded', array($this, 'register_form'));
|
||||
add_action('plugins_loaded', [$this, 'register_form']);
|
||||
|
||||
add_action('init', array($this, 'register_shortcode'));
|
||||
add_action('init', [$this, 'register_shortcode']);
|
||||
|
||||
add_action('wp_enqueue_scripts', array($this, 'enqueue_element_scripts'));
|
||||
add_action('wp_enqueue_scripts', [$this, 'enqueue_element_scripts']);
|
||||
|
||||
add_action("wu_{$this->id}_scripts", array($this, 'register_default_scripts'));
|
||||
add_action("wu_{$this->id}_scripts", [$this, 'register_default_scripts']);
|
||||
|
||||
add_action("wu_{$this->id}_scripts", array($this, 'register_scripts'));
|
||||
add_action("wu_{$this->id}_scripts", [$this, 'register_scripts']);
|
||||
|
||||
add_action('wp', array($this, 'maybe_setup'));
|
||||
add_action('wp', [$this, 'maybe_setup']);
|
||||
|
||||
add_action('admin_head', array($this, 'setup_for_admin'), 100);
|
||||
add_action('admin_head', [$this, 'setup_for_admin'], 100);
|
||||
|
||||
add_filter('pre_render_block', array($this, 'setup_for_block_editor'), 100, 2);
|
||||
add_filter('pre_render_block', [$this, 'setup_for_block_editor'], 100, 2);
|
||||
|
||||
add_action('wu_element_preview', array($this, 'setup_preview'));
|
||||
add_action('wu_element_preview', [$this, 'setup_preview']);
|
||||
|
||||
// Init should be the correct time to call this to avoid the deprecated notice from I18N.
|
||||
// But it doesn't work for some reason, fix later.
|
||||
@ -255,7 +255,7 @@ abstract class Base_Element {
|
||||
* @param mixed $element The element instance to be registered.
|
||||
* @return void
|
||||
*/
|
||||
public static function register_public_element($element) {
|
||||
public static function register_public_element($element): void {
|
||||
|
||||
static::$public_elements[] = $element;
|
||||
}
|
||||
@ -296,10 +296,10 @@ abstract class Base_Element {
|
||||
*/
|
||||
$blocks_to_check = apply_filters(
|
||||
'wu_element_block_types_to_check',
|
||||
array(
|
||||
[
|
||||
'core/shortcode',
|
||||
'core/paragraph',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (in_array($block['blockName'], $blocks_to_check, true)) {
|
||||
@ -352,7 +352,7 @@ abstract class Base_Element {
|
||||
|
||||
$contains_metaboxes = wu_get_isset($wp_meta_boxes, $screen->id) || wu_get_isset($wp_meta_boxes, $pagenow);
|
||||
|
||||
$elements_to_cache = array();
|
||||
$elements_to_cache = [];
|
||||
|
||||
$found = false;
|
||||
|
||||
@ -384,7 +384,7 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_for_admin() {
|
||||
public function setup_for_admin(): void {
|
||||
|
||||
if ($this->loaded === true) {
|
||||
return;
|
||||
@ -406,7 +406,7 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_setup() {
|
||||
public function maybe_setup(): void {
|
||||
|
||||
global $post;
|
||||
|
||||
@ -534,7 +534,7 @@ abstract class Base_Element {
|
||||
* Tries to parse the shortcode out of the content
|
||||
* passed using the WordPress shortcode regex.
|
||||
*/
|
||||
$shortcode_regex = get_shortcode_regex(array($this->get_shortcode_id()));
|
||||
$shortcode_regex = get_shortcode_regex([$this->get_shortcode_id()]);
|
||||
|
||||
preg_match_all('/' . $shortcode_regex . '/', $content, $matches, PREG_SET_ORDER);
|
||||
|
||||
@ -573,7 +573,7 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_element_scripts() {
|
||||
public function enqueue_element_scripts(): void {
|
||||
|
||||
global $post;
|
||||
|
||||
@ -626,13 +626,13 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_shortcode() {
|
||||
public function register_shortcode(): void {
|
||||
|
||||
if (wu_get_current_site()->get_type() === Site_Type::CUSTOMER_OWNED && is_admin() === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_shortcode($this->get_shortcode_id(), array($this, 'display'));
|
||||
add_shortcode($this->get_shortcode_id(), [$this, 'display']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -641,17 +641,17 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_form() {
|
||||
public function register_form(): void {
|
||||
/*
|
||||
* Add Generator Forms
|
||||
*/
|
||||
wu_register_form(
|
||||
"shortcode_{$this->id}",
|
||||
array(
|
||||
'render' => array($this, 'render_generator_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_generator_modal'],
|
||||
'handler' => '__return_empty_string',
|
||||
'capability' => 'manage_network',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -659,11 +659,11 @@ abstract class Base_Element {
|
||||
*/
|
||||
wu_register_form(
|
||||
"customize_{$this->id}",
|
||||
array(
|
||||
'render' => array($this, 'render_customize_modal'),
|
||||
'handler' => array($this, 'handle_customize_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_customize_modal'],
|
||||
'handler' => [$this, 'handle_customize_modal'],
|
||||
'capability' => 'manage_network',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -673,13 +673,13 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_generator_modal() {
|
||||
public function render_generator_modal(): void {
|
||||
|
||||
$fields = $this->fields();
|
||||
|
||||
$defaults = $this->defaults();
|
||||
|
||||
$state = array();
|
||||
$state = [];
|
||||
|
||||
foreach ($fields as $field_slug => &$field) {
|
||||
if ($field['type'] === 'header' || $field['type'] === 'note') {
|
||||
@ -695,13 +695,13 @@ abstract class Base_Element {
|
||||
* specially when we're dealing with
|
||||
* complex fields, such as group.
|
||||
*/
|
||||
$additional_state = array();
|
||||
$additional_state = [];
|
||||
|
||||
if ($field['type'] === 'group') {
|
||||
foreach ($field['fields'] as $sub_field_slug => &$sub_field) {
|
||||
$sub_field['html_attr'] = array(
|
||||
$sub_field['html_attr'] = [
|
||||
'v-model.lazy' => "attributes.{$sub_field_slug}",
|
||||
);
|
||||
];
|
||||
|
||||
$additional_state[ $sub_field_slug ] = wu_request($sub_field_slug, wu_get_isset($defaults, $sub_field_slug));
|
||||
}
|
||||
@ -712,14 +712,14 @@ abstract class Base_Element {
|
||||
/*
|
||||
* Set v-model
|
||||
*/
|
||||
$field['html_attr'] = array(
|
||||
$field['html_attr'] = [
|
||||
'v-model.lazy' => "attributes.{$field_slug}",
|
||||
);
|
||||
];
|
||||
|
||||
$required = wu_get_isset($field, 'required');
|
||||
|
||||
if (wu_get_isset($field, 'required')) {
|
||||
$shows = array();
|
||||
$shows = [];
|
||||
|
||||
foreach ($required as $key => $value) {
|
||||
$value = is_string($value) ? "\"$value\"" : $value;
|
||||
@ -727,9 +727,9 @@ abstract class Base_Element {
|
||||
$shows[] = "attributes.{$key} == $value";
|
||||
}
|
||||
|
||||
$field['wrapper_html_attr'] = array(
|
||||
$field['wrapper_html_attr'] = [
|
||||
'v-show' => implode(' && ', $shows),
|
||||
);
|
||||
];
|
||||
|
||||
$state[ $field_slug . '_shortcode_requires' ] = $required;
|
||||
}
|
||||
@ -737,42 +737,42 @@ abstract class Base_Element {
|
||||
$state[ $field_slug ] = wu_request($field_slug, wu_get_isset($defaults, $field_slug));
|
||||
}
|
||||
|
||||
$fields['shortcode_result'] = array(
|
||||
$fields['shortcode_result'] = [
|
||||
'type' => 'note',
|
||||
'wrapper_classes' => 'sm:wu-block',
|
||||
'desc' => '<div class="wu-w-full"><span class="wu-my-1 wu-text-2xs wu-uppercase wu-font-bold wu-block">' . __('Result', 'wp-ultimo') . '</span><pre v-html="shortcode" id="wu-shortcode" style="overflow-x: scroll !important;" class="wu-text-center wu-p-4 wu-m-0 wu-mt-2 wu-rounded wu-content-center wu-bg-gray-800 wu-text-white wu-font-mono wu-border wu-border-solid wu-border-gray-300 wu-max-h-screen wu-overflow-x-scroll"></pre></div>',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['submit_copy'] = array(
|
||||
$fields['submit_copy'] = [
|
||||
'type' => 'submit',
|
||||
'title' => __('Copy Shortcode', 'wp-ultimo'),
|
||||
'value' => 'edit',
|
||||
'classes' => 'button button-primary wu-w-full wu-copy',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-clipboard-action' => 'copy',
|
||||
'data-clipboard-target' => '#wu-shortcode',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
$this->id,
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0 wu-w-full',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => "{$this->id}_generator",
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'id' => $this->get_shortcode_id(),
|
||||
'defaults' => $defaults,
|
||||
'attributes' => $state,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
echo '<div class="wu-styling">';
|
||||
@ -788,18 +788,18 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_customize_modal() {
|
||||
public function render_customize_modal(): void {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['hide'] = array(
|
||||
$fields['hide'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Hide Element', 'wp-ultimo'),
|
||||
'desc' => __('Be careful. Hiding an element from the account page might remove important functionality from your customers\' reach.', 'wp-ultimo'),
|
||||
'value' => $this->hidden_by_default,
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
);
|
||||
];
|
||||
|
||||
$fields = array_merge($fields, $this->fields());
|
||||
|
||||
@ -823,40 +823,40 @@ abstract class Base_Element {
|
||||
}
|
||||
}
|
||||
|
||||
$fields['save_line'] = array(
|
||||
$fields['save_line'] = [
|
||||
'type' => 'group',
|
||||
'classes' => 'wu-justify-between',
|
||||
'wrapper_classes' => 'wu-bg-gray-100',
|
||||
'fields' => array(
|
||||
'restore' => array(
|
||||
'fields' => [
|
||||
'restore' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Reset Settings', 'wp-ultimo'),
|
||||
'value' => 'edit',
|
||||
'classes' => 'button',
|
||||
'wrapper_classes' => 'wu-mb-0',
|
||||
),
|
||||
'submit' => array(
|
||||
],
|
||||
'submit' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Save Changes', 'wp-ultimo'),
|
||||
'value' => 'edit',
|
||||
'classes' => 'button button-primary',
|
||||
'wrapper_classes' => 'wu-mb-0',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
$this->id,
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => "{$this->id}_customize",
|
||||
'data-state' => wu_convert_to_state($state),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
echo '<div class="wu-styling">';
|
||||
@ -872,16 +872,16 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_customize_modal() {
|
||||
public function handle_customize_modal(): void {
|
||||
|
||||
$settings = array();
|
||||
$settings = [];
|
||||
|
||||
if (wu_request('submit') !== 'restore') {
|
||||
$fields = $this->fields();
|
||||
|
||||
$fields['hide'] = array(
|
||||
$fields['hide'] = [
|
||||
'type' => 'toggle',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($fields as $field_slug => $field) {
|
||||
$setting = wu_request($field_slug, false);
|
||||
@ -895,14 +895,14 @@ abstract class Base_Element {
|
||||
$this->save_widget_settings($settings);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'send' => array(
|
||||
[
|
||||
'send' => [
|
||||
'scope' => 'window',
|
||||
'function_name' => 'wu_block_ui',
|
||||
'data' => '#wpcontent',
|
||||
),
|
||||
],
|
||||
'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -912,7 +912,7 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_default_scripts() {
|
||||
public function register_default_scripts(): void {
|
||||
|
||||
wp_enqueue_style('wu-admin');
|
||||
}
|
||||
@ -984,7 +984,7 @@ abstract class Base_Element {
|
||||
*/
|
||||
$atts['element'] = $this;
|
||||
|
||||
return call_user_func(array($this, 'output'), $atts);
|
||||
return call_user_func([$this, 'output'], $atts);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1002,20 +1002,20 @@ abstract class Base_Element {
|
||||
$content = $this->display($atts);
|
||||
|
||||
$content = str_replace(
|
||||
array(
|
||||
[
|
||||
'v-',
|
||||
'data-wu',
|
||||
'data-state',
|
||||
),
|
||||
],
|
||||
'inactive-',
|
||||
$content
|
||||
);
|
||||
|
||||
$content = str_replace(
|
||||
array(
|
||||
[
|
||||
'{{',
|
||||
'}}',
|
||||
),
|
||||
],
|
||||
'',
|
||||
$content
|
||||
);
|
||||
@ -1045,7 +1045,7 @@ abstract class Base_Element {
|
||||
* @param array $atts Array containing the shortcode attributes.
|
||||
* @return void
|
||||
*/
|
||||
public function as_inline_content($screen_id, $hook = 'admin_notices', $atts = array()) {
|
||||
public function as_inline_content($screen_id, $hook = 'admin_notices', $atts = []): void {
|
||||
|
||||
if ( ! function_exists('get_current_screen')) {
|
||||
_doing_it_wrong(__METHOD__, __('An element can not be loaded as inline content unless the get_current_screen() function is already available.', 'wp-ultimo'), '2.0.0');
|
||||
@ -1112,7 +1112,7 @@ abstract class Base_Element {
|
||||
* @param array $settings The settings to save. Key => value array.
|
||||
* @return void
|
||||
*/
|
||||
public function save_widget_settings($settings) {
|
||||
public function save_widget_settings($settings): void {
|
||||
|
||||
$key = wu_replace_dashes($this->id);
|
||||
|
||||
@ -1129,7 +1129,7 @@ abstract class Base_Element {
|
||||
|
||||
$key = wu_replace_dashes($this->id);
|
||||
|
||||
return wu_get_setting("widget_{$key}_settings", array());
|
||||
return wu_get_setting("widget_{$key}_settings", []);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1142,7 +1142,7 @@ abstract class Base_Element {
|
||||
* @param array $atts Array containing the shortcode attributes.
|
||||
* @return void
|
||||
*/
|
||||
public function as_metabox($screen_id, $position = 'normal', $atts = array()) {
|
||||
public function as_metabox($screen_id, $position = 'normal', $atts = []): void {
|
||||
|
||||
$this->setup();
|
||||
|
||||
@ -1195,7 +1195,7 @@ abstract class Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function super_admin_notice() {
|
||||
public function super_admin_notice(): void {
|
||||
|
||||
$should_display = $this->should_display_customize_controls();
|
||||
|
||||
@ -1264,7 +1264,7 @@ abstract class Base_Element {
|
||||
* @param boolean $display Controls whether or not the widget and element should display.
|
||||
* @return void
|
||||
*/
|
||||
public function set_display($display) {
|
||||
public function set_display($display): void {
|
||||
|
||||
$this->display = $display;
|
||||
}
|
||||
|
@ -84,17 +84,17 @@ class Billing_Info_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
wu_register_form(
|
||||
'update_billing_address',
|
||||
array(
|
||||
'render' => array($this, 'render_update_billing_address'),
|
||||
'handler' => array($this, 'handle_update_billing_address'),
|
||||
[
|
||||
'render' => [$this, 'render_update_billing_address'],
|
||||
'handler' => [$this, 'handle_update_billing_address'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ class Billing_Info_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
add_wubox();
|
||||
}
|
||||
@ -159,21 +159,21 @@ class Billing_Info_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('Billing Address', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -197,13 +197,13 @@ class Billing_Info_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Billing Information',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -222,9 +222,9 @@ class Billing_Info_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'title' => __('Billing Address', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,7 +233,7 @@ class Billing_Info_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->membership = WP_Ultimo()->currents->get_membership();
|
||||
|
||||
@ -250,7 +250,7 @@ class Billing_Info_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
|
||||
@ -278,10 +278,10 @@ class Billing_Info_Element extends Base_Element {
|
||||
|
||||
$atts['update_billing_address_link'] = wu_get_form_url(
|
||||
'update_billing_address',
|
||||
array(
|
||||
[
|
||||
'membership' => $this->membership->get_hash(),
|
||||
'width' => 500,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return wu_get_template_contents('dashboard-widgets/billing-info', $atts);
|
||||
@ -320,45 +320,45 @@ class Billing_Info_Element extends Base_Element {
|
||||
|
||||
$billing_address = $membership->get_billing_address();
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['billing-title'] = array(
|
||||
$fields['billing-title'] = [
|
||||
'type' => 'header',
|
||||
'order' => 1,
|
||||
'title' => __('Your Address', 'wp-ultimo'),
|
||||
'desc' => __('Enter your billing address here. This info will be used on your invoices.', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-col-span-2',
|
||||
);
|
||||
];
|
||||
|
||||
$billing_fields = $this->apply_placeholders($billing_address->get_fields());
|
||||
|
||||
$fields = array_merge($fields, $billing_fields);
|
||||
|
||||
$fields['submit'] = array(
|
||||
$fields['submit'] = [
|
||||
'type' => 'submit',
|
||||
'title' => __('Save Changes', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-col-span-2',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['membership'] = array(
|
||||
$fields['membership'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('membership'),
|
||||
);
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'edit_site',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0 wu-grid-cols-2 wu-grid',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid wu-grid-col-span-2',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'edit_site',
|
||||
'data-state' => wu_convert_to_state(),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -370,7 +370,7 @@ class Billing_Info_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_update_billing_address() {
|
||||
public function handle_update_billing_address(): void {
|
||||
|
||||
$membership = wu_get_membership_by_hash(wu_request('membership'));
|
||||
|
||||
@ -399,9 +399,9 @@ class Billing_Info_Element extends Base_Element {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('updated', (int) $saved, $_SERVER['HTTP_REFERER']),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -146,19 +146,19 @@ class Checkout_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['slug'] = array(
|
||||
$fields['slug'] = [
|
||||
'title' => __('Slug', 'wp-ultimo'),
|
||||
'desc' => __('The checkout form slug.', 'wp-ultimo'),
|
||||
'type' => 'text',
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -182,13 +182,13 @@ class Checkout_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Checkout',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,12 +207,12 @@ class Checkout_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'slug' => 'main-form',
|
||||
'step' => false,
|
||||
'display_title' => false,
|
||||
'membership_limitations' => array(),
|
||||
);
|
||||
'membership_limitations' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,7 +232,7 @@ class Checkout_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
if ($this->is_thank_you_page()) {
|
||||
\WP_Ultimo\UI\Thank_You_Element::get_instance()->setup();
|
||||
@ -251,7 +251,7 @@ class Checkout_Element extends Base_Element {
|
||||
* @param \WP_Ultimo\Models\Checkout_Form $checkout_form The current checkout form.
|
||||
* @return void
|
||||
*/
|
||||
public function print_custom_css($checkout_form) {
|
||||
public function print_custom_css($checkout_form): void {
|
||||
|
||||
$scss = new Compiler();
|
||||
|
||||
@ -339,9 +339,9 @@ class Checkout_Element extends Base_Element {
|
||||
$message = sprintf(__('Hi %s. You have a pending payment for your membership!', 'wp-ultimo'), $customer->get_display_name());
|
||||
|
||||
$payment_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'payment' => $pending_payment->get_hash(),
|
||||
),
|
||||
],
|
||||
wu_get_registration_url()
|
||||
);
|
||||
|
||||
@ -360,9 +360,9 @@ class Checkout_Element extends Base_Element {
|
||||
return apply_filters('wu_checkout_pending_payment_error_message', $message, $membership, $customer);
|
||||
}
|
||||
|
||||
$membership_blocked_forms = array(
|
||||
$membership_blocked_forms = [
|
||||
'wu-add-new-site',
|
||||
);
|
||||
];
|
||||
|
||||
if ( ! $membership->is_active() && $membership->get_status() !== Membership_Status::TRIALING && in_array($atts['slug'], $membership_blocked_forms, true)) {
|
||||
|
||||
@ -373,20 +373,20 @@ class Checkout_Element extends Base_Element {
|
||||
/**
|
||||
* Enqueue thank you page scripts to handle resend email verification link
|
||||
*/
|
||||
wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), array(), wu_get_version());
|
||||
wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), [], wu_get_version());
|
||||
|
||||
wp_localize_script(
|
||||
'wu-thank-you',
|
||||
'wu_thank_you',
|
||||
array(
|
||||
[
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'resend_verification_email_nonce' => wp_create_nonce('wu_resend_verification_email_nonce'),
|
||||
'membership_hash' => $membership->get_hash(),
|
||||
'i18n' => array(
|
||||
'i18n' => [
|
||||
'resending_verification_email' => __('Resending verification email...', 'wp-ultimo'),
|
||||
'email_sent' => __('Verification email sent!', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-thank-you');
|
||||
@ -416,10 +416,10 @@ class Checkout_Element extends Base_Element {
|
||||
*/
|
||||
$allowed_forms = apply_filters(
|
||||
'wu_get_membership_allowed_forms',
|
||||
array(
|
||||
[
|
||||
'wu-checkout',
|
||||
'wu-add-new-site',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! in_array($slug, $allowed_forms, true) && ! wu_request('payment')) {
|
||||
@ -502,9 +502,9 @@ class Checkout_Element extends Base_Element {
|
||||
|
||||
if ($update_url) {
|
||||
$update_link = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'membership' => $membership->get_hash(),
|
||||
),
|
||||
],
|
||||
$update_url
|
||||
);
|
||||
} elseif (is_admin()) {
|
||||
@ -590,14 +590,14 @@ class Checkout_Element extends Base_Element {
|
||||
|
||||
$step = $checkout_form->get_step($atts['step'], true);
|
||||
|
||||
$this->step = $step ? $step : current($this->steps);
|
||||
$this->step = $step ?: current($this->steps);
|
||||
|
||||
$this->step = wp_parse_args(
|
||||
$this->step,
|
||||
array(
|
||||
[
|
||||
'classes' => '',
|
||||
'fields' => array(),
|
||||
)
|
||||
'fields' => [],
|
||||
]
|
||||
);
|
||||
|
||||
$this->step_name = $this->step['id'] ?? '';
|
||||
@ -634,14 +634,14 @@ class Checkout_Element extends Base_Element {
|
||||
/*
|
||||
* Adds the product fields to keep them.
|
||||
*/
|
||||
$final_fields['products[]'] = array(
|
||||
$final_fields['products[]'] = [
|
||||
'type' => 'hidden',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-for' => '(product, index) in unique_products',
|
||||
'v-model' => 'products[index]',
|
||||
'v-bind:id' => '"products-" + index',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->inject_inline_auto_submittable_field($auto_submittable_field);
|
||||
|
||||
@ -649,14 +649,14 @@ class Checkout_Element extends Base_Element {
|
||||
|
||||
return wu_get_template_contents(
|
||||
'checkout/form',
|
||||
array(
|
||||
[
|
||||
'step' => $this->step,
|
||||
'step_name' => $this->step_name,
|
||||
'checkout_form_name' => $atts['slug'],
|
||||
'errors' => $checkout->errors,
|
||||
'display_title' => $atts['display_title'],
|
||||
'final_fields' => $final_fields,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ class Checkout_Element extends Base_Element {
|
||||
* @param string $auto_submittable_field The auto-submittable field.
|
||||
* @return void
|
||||
*/
|
||||
public function inject_inline_auto_submittable_field($auto_submittable_field) {
|
||||
public function inject_inline_auto_submittable_field($auto_submittable_field): void {
|
||||
|
||||
$callback = function () use ($auto_submittable_field) {
|
||||
|
||||
@ -712,20 +712,20 @@ class Checkout_Element extends Base_Element {
|
||||
public function output($atts, $content = null) {
|
||||
|
||||
if (wu_is_update_page()) {
|
||||
$atts = array(
|
||||
$atts = [
|
||||
'slug' => apply_filters('wu_membership_update_form', 'wu-checkout'),
|
||||
'step' => false,
|
||||
'display_title' => false,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (wu_is_new_site_page()) {
|
||||
$atts = array(
|
||||
$atts = [
|
||||
'slug' => apply_filters('wu_membership_new_site_form', 'wu-add-new-site'),
|
||||
'step' => false,
|
||||
'display_title' => false,
|
||||
'membership_limitations' => array('sites'),
|
||||
);
|
||||
'membership_limitations' => ['sites'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->is_thank_you_page()) {
|
||||
@ -739,25 +739,25 @@ class Checkout_Element extends Base_Element {
|
||||
*/
|
||||
$update_forms = apply_filters(
|
||||
'wu_membership_update_forms',
|
||||
array(
|
||||
[
|
||||
'wu-checkout',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! in_array($atts['slug'], $update_forms, true) && (wu_request('payment') || wu_request('payment_id'))) {
|
||||
$atts = array(
|
||||
$atts = [
|
||||
'slug' => 'wu-finish-checkout',
|
||||
'step' => false,
|
||||
'display_title' => false,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (wu_request('wu_form') && in_array(wu_request('wu_form'), $update_forms, true)) {
|
||||
$atts = array(
|
||||
$atts = [
|
||||
'slug' => wu_request('wu_form'),
|
||||
'step' => false,
|
||||
'display_title' => false,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $this->output_form($atts, $content);
|
||||
|
@ -69,25 +69,25 @@ class Current_Membership_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
wu_register_form(
|
||||
'see_product_details',
|
||||
array(
|
||||
'render' => array($this, 'render_product_details'),
|
||||
[
|
||||
'render' => [$this, 'render_product_details'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'edit_membership_product_modal',
|
||||
array(
|
||||
'render' => array($this, 'render_edit_membership_product_modal'),
|
||||
'handler' => array($this, 'handle_edit_membership_product_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_edit_membership_product_modal'],
|
||||
'handler' => [$this, 'handle_edit_membership_product_modal'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ class Current_Membership_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
add_wubox();
|
||||
}
|
||||
@ -167,31 +167,31 @@ class Current_Membership_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('Your Membership', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['display_images'] = array(
|
||||
$fields['display_images'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Product Images?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the product images on the element.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['columns'] = array(
|
||||
$fields['columns'] = [
|
||||
'type' => 'number',
|
||||
'title' => __('Columns', 'wp-ultimo'),
|
||||
'desc' => __('How many columns to use.', 'wp-ultimo'),
|
||||
@ -199,7 +199,7 @@ class Current_Membership_Element extends Base_Element {
|
||||
'value' => 2,
|
||||
'min' => 1,
|
||||
'max' => 5,
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -223,13 +223,13 @@ class Current_Membership_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Membership',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,11 +248,11 @@ class Current_Membership_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'title' => __('Your Membership', 'wp-ultimo'),
|
||||
'display_images' => 1,
|
||||
'columns' => 2,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,7 +261,7 @@ class Current_Membership_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->membership = WP_Ultimo()->currents->get_membership();
|
||||
|
||||
@ -280,7 +280,7 @@ class Current_Membership_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->membership = wu_mock_membership();
|
||||
|
||||
@ -320,10 +320,10 @@ class Current_Membership_Element extends Base_Element {
|
||||
$swap_membership = (clone $this->membership)->swap($pending_swap_order->order);
|
||||
|
||||
$pending_products = array_map(
|
||||
fn($product) => array(
|
||||
fn($product) => [
|
||||
'id' => $product['product']->get_id(),
|
||||
'quantity' => $product['quantity'],
|
||||
),
|
||||
],
|
||||
$swap_membership->get_all_products()
|
||||
);
|
||||
|
||||
@ -343,7 +343,7 @@ class Current_Membership_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_product_details() {
|
||||
public function render_product_details(): void {
|
||||
|
||||
$product = wu_get_product_by_slug(wu_request('product'));
|
||||
|
||||
@ -362,7 +362,7 @@ class Current_Membership_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_edit_membership_product_modal() {
|
||||
public function render_edit_membership_product_modal(): void {
|
||||
|
||||
$membership = wu_get_membership_by_hash(wu_request('membership'));
|
||||
|
||||
@ -385,21 +385,21 @@ class Current_Membership_Element extends Base_Element {
|
||||
}
|
||||
|
||||
if ( ! empty($error)) {
|
||||
$error_field = array(
|
||||
'error_message' => array(
|
||||
$error_field = [
|
||||
'error_message' => [
|
||||
'type' => 'note',
|
||||
'desc' => $error,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'cancel_payment_method',
|
||||
$error_field,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -427,56 +427,56 @@ class Current_Membership_Element extends Base_Element {
|
||||
|
||||
$existing_quantity = array_filter($membership->get_addon_products(), fn($item) => $item['product']->get_id() === $product->get_id())[0]['quantity'];
|
||||
|
||||
$fields = array(
|
||||
'membership' => array(
|
||||
$fields = [
|
||||
'membership' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('membership'),
|
||||
),
|
||||
'product' => array(
|
||||
],
|
||||
'product' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('product'),
|
||||
),
|
||||
'quantity' => array(
|
||||
],
|
||||
'quantity' => [
|
||||
'type' => 'number',
|
||||
'title' => __('Quantity to Cancel', 'wp-ultimo'),
|
||||
'value' => 1,
|
||||
'placeholder' => 1,
|
||||
'wrapper_classes' => 'wu-w-1/2',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'min' => 1,
|
||||
'max' => $existing_quantity,
|
||||
'required' => 'required',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => $existing_quantity > 1 ? 'true' : 'false',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
'confirm' => array(
|
||||
],
|
||||
],
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Product Cancellation', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'update_note' => array(
|
||||
],
|
||||
],
|
||||
'update_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => $gateway_message,
|
||||
'classes' => 'sm:wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Cancel Product Subscription', 'wp-ultimo'),
|
||||
'placeholder' => __('Cancel Product Subscription', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'wu-w-full button button-primary',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ( ! $gateway_message) {
|
||||
unset($fields['update_note']);
|
||||
@ -485,19 +485,19 @@ class Current_Membership_Element extends Base_Element {
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'edit_membership_product',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'edit_membership_product',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -509,7 +509,7 @@ class Current_Membership_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_edit_membership_product_modal() {
|
||||
public function handle_edit_membership_product_modal(): void {
|
||||
|
||||
if ( ! wu_request('confirm')) {
|
||||
$error = new \WP_Error('not-confirmed', __('Please confirm the cancellation.', 'wp-ultimo'));
|
||||
@ -605,9 +605,9 @@ class Current_Membership_Element extends Base_Element {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -84,17 +84,17 @@ class Current_Site_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
wu_register_form(
|
||||
'edit_site',
|
||||
array(
|
||||
'render' => array($this, 'render_edit_site'),
|
||||
'handler' => array($this, 'handle_edit_site'),
|
||||
[
|
||||
'render' => [$this, 'render_edit_site'],
|
||||
'handler' => [$this, 'handle_edit_site'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -148,61 +148,61 @@ class Current_Site_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['display_breadcrumbs'] = array(
|
||||
$fields['display_breadcrumbs'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Breadcrumbs?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the breadcrumbs block.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$pages = get_pages(
|
||||
array(
|
||||
'exclude' => array(get_the_ID()),
|
||||
)
|
||||
[
|
||||
'exclude' => [get_the_ID()],
|
||||
]
|
||||
);
|
||||
|
||||
$pages = $pages ? $pages : array();
|
||||
$pages = $pages ?: [];
|
||||
|
||||
$pages_list = array(0 => __('Current Page', 'wp-ultimo'));
|
||||
$pages_list = [0 => __('Current Page', 'wp-ultimo')];
|
||||
|
||||
foreach ($pages as $page) {
|
||||
$pages_list[ $page->ID ] = $page->post_title;
|
||||
}
|
||||
|
||||
$fields['breadcrumbs_my_sites_page'] = array(
|
||||
$fields['breadcrumbs_my_sites_page'] = [
|
||||
'type' => 'select',
|
||||
'title' => __('My Sites Page', 'wp-ultimo'),
|
||||
'value' => 0,
|
||||
'desc' => __('The page with the customer sites list.', 'wp-ultimo'),
|
||||
'options' => $pages_list,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['display_description'] = array(
|
||||
$fields['display_description'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Site Description?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the site description on the element.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['display_image'] = array(
|
||||
$fields['display_image'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Site Screenshot?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the site screenshots on the element.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['screenshot_size'] = array(
|
||||
$fields['screenshot_size'] = [
|
||||
'type' => 'number',
|
||||
'title' => __('Screenshot Size', 'wp-ultimo'),
|
||||
'desc' => '',
|
||||
@ -210,33 +210,33 @@ class Current_Site_Element extends Base_Element {
|
||||
'value' => 200,
|
||||
'min' => 100,
|
||||
'max' => 400,
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'display_image' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['screenshot_position'] = array(
|
||||
$fields['screenshot_position'] = [
|
||||
'type' => 'select',
|
||||
'title' => __('Screenshot Position', 'wp-ultimo'),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'right' => __('Right', 'wp-ultimo'),
|
||||
'left' => __('Left', 'wp-ultimo'),
|
||||
),
|
||||
],
|
||||
'desc' => '',
|
||||
'tooltip' => '',
|
||||
'value' => 'right',
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'display_image' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['show_admin_link'] = array(
|
||||
$fields['show_admin_link'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Show Admin Link?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the WP admin link on the element.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -260,13 +260,13 @@ class Current_Site_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Site',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,7 +285,7 @@ class Current_Site_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'display_image' => 1,
|
||||
'display_breadcrumbs' => 1,
|
||||
'display_description' => 0,
|
||||
@ -293,7 +293,7 @@ class Current_Site_Element extends Base_Element {
|
||||
'screenshot_position' => 'right',
|
||||
'breadcrumbs_my_sites_page' => 0,
|
||||
'show_admin_link' => 1,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,7 +302,7 @@ class Current_Site_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->site = WP_Ultimo()->currents->get_site();
|
||||
|
||||
@ -321,7 +321,7 @@ class Current_Site_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
|
||||
@ -334,7 +334,7 @@ class Current_Site_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
add_wubox();
|
||||
}
|
||||
@ -354,33 +354,33 @@ class Current_Site_Element extends Base_Element {
|
||||
*/
|
||||
public function output($atts, $content = null) {
|
||||
|
||||
$actions = array(
|
||||
'visit_site' => array(
|
||||
$actions = [
|
||||
'visit_site' => [
|
||||
'label' => __('Visit Site', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-browser wu-align-text-bottom',
|
||||
'classes' => '',
|
||||
'href' => $this->site->get_active_site_url(),
|
||||
),
|
||||
'edit_site' => array(
|
||||
],
|
||||
'edit_site' => [
|
||||
'label' => __('Edit Site', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-edit wu-align-text-bottom',
|
||||
'classes' => 'wubox',
|
||||
'href' => wu_get_form_url(
|
||||
'edit_site',
|
||||
array(
|
||||
[
|
||||
'site' => $this->site->get_hash(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($atts['show_admin_link']) {
|
||||
$actions['site_admin'] = array(
|
||||
$actions['site_admin'] = [
|
||||
'label' => __('Admin Panel', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-grid wu-align-text-bottom',
|
||||
'classes' => '',
|
||||
'href' => get_admin_url($this->site->get_id()),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$atts['actions'] = apply_filters('wu_current_site_actions', $actions, $this->site);
|
||||
@ -410,59 +410,59 @@ class Current_Site_Element extends Base_Element {
|
||||
return '';
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'site_title' => array(
|
||||
$fields = [
|
||||
'site_title' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Site Title', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. My Awesome Site', 'wp-ultimo'),
|
||||
'value' => $site->get_title(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'site_title',
|
||||
),
|
||||
),
|
||||
'site_description' => array(
|
||||
],
|
||||
],
|
||||
'site_description' => [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Site Description', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. My Awesome Site description.', 'wp-ultimo'),
|
||||
'value' => $site->get_description(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 5,
|
||||
),
|
||||
),
|
||||
'site' => array(
|
||||
],
|
||||
],
|
||||
'site' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('site'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Save Changes', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!site_title.length',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$fields = apply_filters('wu_form_edit_site', $fields, $this);
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'edit_site',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'edit_site',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'site_title' => $site->get_title(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -474,7 +474,7 @@ class Current_Site_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_edit_site() {
|
||||
public function handle_edit_site(): void {
|
||||
|
||||
$site = wu_get_site_by_hash(wu_request('site'));
|
||||
|
||||
@ -497,9 +497,9 @@ class Current_Site_Element extends Base_Element {
|
||||
$status_desc = update_blog_option($site->get_id(), 'blogdescription', wu_request('site_description'));
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('updated', (int) $status, $_SERVER['HTTP_REFERER']),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -132,21 +132,21 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('Domains', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -170,11 +170,11 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Domain',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,9 +193,9 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'title' => __('Domains', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,7 +204,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
@ -226,7 +226,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
$this->set_display(false);
|
||||
}
|
||||
|
||||
add_action('plugins_loaded', array($this, 'register_forms'));
|
||||
add_action('plugins_loaded', [$this, 'register_forms']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +235,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
add_wubox();
|
||||
}
|
||||
@ -246,35 +246,35 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add new Domain
|
||||
*/
|
||||
wu_register_form(
|
||||
'user_add_new_domain',
|
||||
array(
|
||||
'render' => array($this, 'render_user_add_new_domain_modal'),
|
||||
'handler' => array($this, 'handle_user_add_new_domain_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_user_add_new_domain_modal'],
|
||||
'handler' => [$this, 'handle_user_add_new_domain_modal'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'user_make_domain_primary',
|
||||
array(
|
||||
'render' => array($this, 'render_user_make_domain_primary_modal'),
|
||||
'handler' => array($this, 'handle_user_make_domain_primary_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_user_make_domain_primary_modal'],
|
||||
'handler' => [$this, 'handle_user_make_domain_primary_modal'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'user_delete_domain_modal',
|
||||
array(
|
||||
'render' => array($this, 'render_user_delete_domain_modal'),
|
||||
'handler' => array($this, 'handle_user_delete_domain_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_user_delete_domain_modal'],
|
||||
'handler' => [$this, 'handle_user_delete_domain_modal'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -284,107 +284,107 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_user_add_new_domain_modal() {
|
||||
public function render_user_add_new_domain_modal(): void {
|
||||
|
||||
$instructions = \WP_Ultimo\Managers\Domain_Manager::get_instance()->get_domain_mapping_instructions();
|
||||
|
||||
$fields = array(
|
||||
'instructions_note' => array(
|
||||
$fields = [
|
||||
'instructions_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => sprintf('<a href="#" class="wu-no-underline" v-on:click.prevent="ready = false">%s</a>', __('← Back to the Instructions', 'wp-ultimo')),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => 'ready',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
'instructions' => array(
|
||||
],
|
||||
],
|
||||
'instructions' => [
|
||||
'type' => 'text-display',
|
||||
'copy' => false,
|
||||
'title' => __('Instructions', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'display_value' => sprintf('<div class="wu--mt-2 wu--mb-2">%s</div>', wpautop($instructions)),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => '!ready',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'ready' => array(
|
||||
],
|
||||
],
|
||||
'ready' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Next Step →', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-on:click.prevent' => 'ready = true',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => '!ready',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'current_site' => array(
|
||||
],
|
||||
],
|
||||
'current_site' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('current_site'),
|
||||
),
|
||||
'domain' => array(
|
||||
],
|
||||
'domain' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Domain', 'wp-ultimo'),
|
||||
'placeholder' => __('mydomain.com', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'ready',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'primary_domain' => array(
|
||||
],
|
||||
],
|
||||
'primary_domain' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Primary Domain', 'wp-ultimo'),
|
||||
'desc' => __('Check to set this domain as the primary', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'primary_domain',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'ready',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'primary_note' => array(
|
||||
],
|
||||
],
|
||||
'primary_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('By making this the primary domain, we will convert the previous primary domain for this site, if one exists, into an alias domain.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => "require('primary_domain', true) && ready",
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'submit_button_new' => array(
|
||||
],
|
||||
],
|
||||
'submit_button_new' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Add Domain', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'ready',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'add_new_domain',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'add_new_domain',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'ready' => 0,
|
||||
'primary_domain' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -396,7 +396,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_user_add_new_domain_modal() {
|
||||
public function handle_user_add_new_domain_modal(): void {
|
||||
|
||||
$current_user_id = get_current_user_id();
|
||||
|
||||
@ -416,11 +416,11 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* Tries to create the domain
|
||||
*/
|
||||
$domain = wu_create_domain(
|
||||
array(
|
||||
[
|
||||
'domain' => wu_request('domain'),
|
||||
'blog_id' => absint($current_site_id),
|
||||
'primary_domain' => (bool) wu_request('primary_domain'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($domain)) {
|
||||
@ -429,21 +429,21 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
|
||||
if (wu_request('primary_domain')) {
|
||||
$old_primary_domains = wu_get_domains(
|
||||
array(
|
||||
[
|
||||
'primary_domain' => true,
|
||||
'blog_id' => $current_site_id,
|
||||
'id__not_in' => array($domain->get_id()),
|
||||
'id__not_in' => [$domain->get_id()],
|
||||
'fields' => 'ids',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Trigger async action to update the old primary domains.
|
||||
*/
|
||||
do_action_ref_array('wu_async_remove_old_primary_domains', array($old_primary_domains));
|
||||
do_action_ref_array('wu_async_remove_old_primary_domains', [$old_primary_domains]);
|
||||
}
|
||||
|
||||
wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $domain->get_id()), 'domain');
|
||||
wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $domain->get_id()], 'domain');
|
||||
|
||||
/**
|
||||
* Triggers when a new domain mapping is added.
|
||||
@ -451,9 +451,9 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
do_action('wu_domain_created', $domain, $domain->get_site(), $domain->get_site()->get_membership());
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_get_current_url(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
exit;
|
||||
@ -465,50 +465,50 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_user_delete_domain_modal() {
|
||||
public function render_user_delete_domain_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'confirm' => array(
|
||||
$fields = [
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Deletion', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'domain_id' => array(
|
||||
],
|
||||
],
|
||||
'domain_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('domain_id'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Delete', 'wp-ultimo'),
|
||||
'placeholder' => __('Delete', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'user_delete_domain_modal',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'user_delete_domain_modal',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -520,7 +520,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_user_delete_domain_modal() {
|
||||
public function handle_user_delete_domain_modal(): void {
|
||||
|
||||
if (wu_request('user_id')) {
|
||||
$customer = wu_get_customer_by_user_id(wu_request('user_id'));
|
||||
@ -537,9 +537,9 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_get_current_url(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -549,50 +549,50 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_user_make_domain_primary_modal() {
|
||||
public function render_user_make_domain_primary_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'confirm' => array(
|
||||
$fields = [
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Action', 'wp-ultimo'),
|
||||
'desc' => __('This action will also convert the previous primary domain (if any) to an alias to prevent unexpected behavior.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'domain_id' => array(
|
||||
],
|
||||
],
|
||||
'domain_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('domain_id'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Make it Primary', 'wp-ultimo'),
|
||||
'placeholder' => __('Make it Primary', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'user_delete_domain_modal',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'user_delete_domain_modal',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -604,7 +604,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_user_make_domain_primary_modal() {
|
||||
public function handle_user_make_domain_primary_modal(): void {
|
||||
|
||||
$current_site = wu_request('current_site');
|
||||
|
||||
@ -622,23 +622,23 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
}
|
||||
|
||||
$old_primary_domains = wu_get_domains(
|
||||
array(
|
||||
[
|
||||
'primary_domain' => true,
|
||||
'blog_id' => $domain->get_blog_id(),
|
||||
'id__not_in' => array($domain->get_id()),
|
||||
'id__not_in' => [$domain->get_id()],
|
||||
'fields' => 'ids',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
* Trigger async action to update the old primary domains.
|
||||
*/
|
||||
do_action_ref_array('wu_async_remove_old_primary_domains', array($old_primary_domains));
|
||||
do_action_ref_array('wu_async_remove_old_primary_domains', [$old_primary_domains]);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => is_main_site() ? wu_get_current_url() : get_admin_url($current_site),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -651,7 +651,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->site = WP_Ultimo()->currents->get_site();
|
||||
|
||||
@ -673,7 +673,7 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
|
||||
@ -698,14 +698,14 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
$current_site = $this->site;
|
||||
|
||||
$all_domains = wu_get_domains(
|
||||
array(
|
||||
[
|
||||
'blog_id' => $current_site->get_id(),
|
||||
'orderby' => 'primary_domain',
|
||||
'order' => 'DESC',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$domains = array();
|
||||
$domains = [];
|
||||
|
||||
foreach ($all_domains as $key => $domain) {
|
||||
$stage = new Domain_Stage($domain->get_stage());
|
||||
@ -720,15 +720,15 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
$secure_message = __('Domain secured with HTTPS', 'wp-ultimo');
|
||||
}
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'current_site' => $current_site->get_id(),
|
||||
'domain_id' => $domain->get_id(),
|
||||
);
|
||||
];
|
||||
|
||||
$delete_url = wu_get_form_url('user_delete_domain_modal', $url_atts);
|
||||
$primary_url = wu_get_form_url('user_make_domain_primary', $url_atts);
|
||||
|
||||
$domains[ $key ] = array(
|
||||
$domains[ $key ] = [
|
||||
'id' => $domain->get_id(),
|
||||
'domain_object' => $domain,
|
||||
'domain' => $domain->get_domain(),
|
||||
@ -739,22 +739,22 @@ class Domain_Mapping_Element extends Base_Element {
|
||||
'secure_message' => $secure_message,
|
||||
'delete_link' => $delete_url,
|
||||
'primary_link' => $primary_url,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'current_site' => $current_site->get_ID(),
|
||||
);
|
||||
];
|
||||
|
||||
$other_atts = array(
|
||||
$other_atts = [
|
||||
'domains' => $domains,
|
||||
'modal' => array(
|
||||
'modal' => [
|
||||
'label' => __('Add Domain', 'wp-ultimo'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('user_add_new_domain', $url_atts),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$atts = array_merge($other_atts, $atts);
|
||||
|
||||
|
@ -25,7 +25,7 @@ class Field implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $atts = array();
|
||||
protected $atts = [];
|
||||
|
||||
/**
|
||||
* Holds the value of the settings represented by this field.
|
||||
@ -57,11 +57,11 @@ class Field implements \JsonSerializable {
|
||||
* @param array $atts Field attributes.
|
||||
* @return void
|
||||
*/
|
||||
public function set_attributes($id, $atts) {
|
||||
public function set_attributes($id, $atts): void {
|
||||
|
||||
$this->atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'id' => $id,
|
||||
'type' => 'text',
|
||||
'icon' => 'dashicons-wu-cog',
|
||||
@ -102,14 +102,14 @@ class Field implements \JsonSerializable {
|
||||
'columns' => 1,
|
||||
'classes' => '',
|
||||
'wrapper_classes' => '',
|
||||
'html_attr' => array(),
|
||||
'wrapper_html_attr' => array(),
|
||||
'sub_fields' => array(),
|
||||
'html_attr' => [],
|
||||
'wrapper_html_attr' => [],
|
||||
'sub_fields' => [],
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'prefix_html_attr' => array(),
|
||||
'suffix_html_attr' => array(),
|
||||
)
|
||||
'prefix_html_attr' => [],
|
||||
'suffix_html_attr' => [],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ class Field implements \JsonSerializable {
|
||||
* @param mixed $value The new attribute value.
|
||||
* @return void
|
||||
*/
|
||||
public function set_attribute($att, $value) {
|
||||
public function set_attribute($att, $value): void {
|
||||
|
||||
$this->atts[ $att ] = $value;
|
||||
}
|
||||
@ -153,18 +153,18 @@ class Field implements \JsonSerializable {
|
||||
*/
|
||||
public function get_compat_template_name() {
|
||||
|
||||
$aliases = array(
|
||||
$aliases = [
|
||||
'heading' => 'header',
|
||||
'heading_collapsible' => 'header',
|
||||
'select2' => 'select',
|
||||
'checkbox' => 'toggle',
|
||||
);
|
||||
];
|
||||
|
||||
$deprecated = array(
|
||||
$deprecated = [
|
||||
'heading',
|
||||
'heading_collapsible',
|
||||
'select2',
|
||||
);
|
||||
];
|
||||
|
||||
if (array_key_exists($this->type, $aliases)) {
|
||||
$new_type_name = $aliases[ $this->type ];
|
||||
@ -204,7 +204,7 @@ class Field implements \JsonSerializable {
|
||||
|
||||
$compat_name = $this->get_compat_template_name();
|
||||
|
||||
$view_name = $compat_name ? $compat_name : $this->type;
|
||||
$view_name = $compat_name ?: $this->type;
|
||||
|
||||
return str_replace('_', '-', (string) $view_name);
|
||||
}
|
||||
@ -219,7 +219,7 @@ class Field implements \JsonSerializable {
|
||||
*/
|
||||
public function __get($att) {
|
||||
|
||||
$allowed_callable = array(
|
||||
$allowed_callable = [
|
||||
'title',
|
||||
'desc',
|
||||
'content',
|
||||
@ -232,11 +232,11 @@ class Field implements \JsonSerializable {
|
||||
'value',
|
||||
'html_attr',
|
||||
'img',
|
||||
);
|
||||
];
|
||||
|
||||
$attr = isset($this->atts[ $att ]) ? $this->atts[ $att ] : false;
|
||||
$attr = $this->atts[ $att ] ?? false;
|
||||
|
||||
$allow_callable_prefix = is_string($attr) && strncmp($attr, 'wu_get_', strlen('wu_get_')) === 0 && is_callable($attr);
|
||||
$allow_callable_prefix = is_string($attr) && str_starts_with($attr, 'wu_get_') && 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))) {
|
||||
@ -278,17 +278,17 @@ class Field implements \JsonSerializable {
|
||||
*/
|
||||
protected function sanitization_rules() {
|
||||
|
||||
$rules = array(
|
||||
$rules = [
|
||||
'text' => 'sanitize_text_field',
|
||||
'header' => '__return_null',
|
||||
'number' => array($this, 'validate_number_field'),
|
||||
'wp_editor' => array($this, 'validate_textarea_field'),
|
||||
'textarea' => array($this, 'validate_textarea_field'),
|
||||
'number' => [$this, 'validate_number_field'],
|
||||
'wp_editor' => [$this, 'validate_textarea_field'],
|
||||
'textarea' => [$this, 'validate_textarea_field'],
|
||||
'checkbox' => 'wu_string_to_bool',
|
||||
'multi_checkbox' => false,
|
||||
'select2' => false,
|
||||
'multiselect' => false,
|
||||
);
|
||||
];
|
||||
|
||||
return apply_filters('wu_settings_fields_sanitization_rules', $rules);
|
||||
}
|
||||
@ -332,11 +332,11 @@ class Field implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function sanitize() {
|
||||
public function sanitize(): void {
|
||||
|
||||
$rules = $this->sanitization_rules();
|
||||
|
||||
$sanitize_method = isset($rules[ $this->type ]) ? $rules[ $this->type ] : $rules['text'];
|
||||
$sanitize_method = $rules[ $this->type ] ?? $rules['text'];
|
||||
|
||||
if ($sanitize_method) {
|
||||
$this->value = call_user_func($sanitize_method, $this->value);
|
||||
|
@ -27,7 +27,7 @@ class Form implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $atts = array();
|
||||
protected $atts = [];
|
||||
|
||||
/**
|
||||
* Holds the fields we want to display using this form.
|
||||
@ -35,7 +35,7 @@ class Form implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $fields = array();
|
||||
protected $fields = [];
|
||||
|
||||
/**
|
||||
* Set and the attributes passed via the constructor.
|
||||
@ -46,13 +46,13 @@ class Form implements \JsonSerializable {
|
||||
* @param array $fields List of arrays representing the form fields.
|
||||
* @param array $atts Form attributes.
|
||||
*/
|
||||
public function __construct($id, $fields, $atts = array()) {
|
||||
public function __construct($id, $fields, $atts = []) {
|
||||
|
||||
$this->atts = apply_filters(
|
||||
"wu_{$id}_form_atts",
|
||||
wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'id' => $id,
|
||||
'method' => 'post',
|
||||
'before' => '',
|
||||
@ -65,15 +65,15 @@ class Form implements \JsonSerializable {
|
||||
'field_wrapper_classes' => false,
|
||||
'field_classes' => false,
|
||||
'views' => 'settings/fields',
|
||||
'variables' => array(),
|
||||
'step' => (object) array(
|
||||
'variables' => [],
|
||||
'step' => (object) [
|
||||
'classes' => '',
|
||||
'element_id' => '',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'class' => '',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@ -90,12 +90,12 @@ class Form implements \JsonSerializable {
|
||||
*/
|
||||
public function __get($att) {
|
||||
|
||||
$allowed_callable = array(
|
||||
$allowed_callable = [
|
||||
'before',
|
||||
'after',
|
||||
);
|
||||
];
|
||||
|
||||
$attr = isset($this->atts[ $att ]) ? $this->atts[ $att ] : false;
|
||||
$attr = $this->atts[ $att ] ?? false;
|
||||
|
||||
if (in_array($att, $allowed_callable, true) && is_callable($attr)) {
|
||||
$attr = call_user_func($attr, $this);
|
||||
@ -134,7 +134,7 @@ class Form implements \JsonSerializable {
|
||||
* @param array $fields List of fields of the form.
|
||||
* @return void
|
||||
*/
|
||||
public function set_fields($fields) {
|
||||
public function set_fields($fields): void {
|
||||
|
||||
$id = $this->id;
|
||||
|
||||
@ -160,15 +160,15 @@ class Form implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
public function render(): void {
|
||||
|
||||
$variables = array_merge(
|
||||
$this->variables,
|
||||
array(
|
||||
[
|
||||
'form_slug' => $this->id,
|
||||
'form' => $this,
|
||||
'step' => $this->step,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
ob_start();
|
||||
@ -186,10 +186,10 @@ class Form implements \JsonSerializable {
|
||||
|
||||
wu_get_template(
|
||||
"{$this->views}/field-{$template_name}",
|
||||
array(
|
||||
[
|
||||
'field_slug' => $field_slug,
|
||||
'field' => $field,
|
||||
),
|
||||
],
|
||||
"{$this->views}/field-text"
|
||||
);
|
||||
}
|
||||
|
@ -121,29 +121,29 @@ class Invoices_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('Invoices', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['limit'] = array(
|
||||
$fields['limit'] = [
|
||||
'type' => 'int',
|
||||
'title' => __('Limit', 'wp-ultimo'),
|
||||
'value' => 10,
|
||||
'desc' => __('Limit the number of invoices to show.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -167,13 +167,13 @@ class Invoices_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Invoices',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,10 +192,10 @@ class Invoices_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'title' => __('Invoices', 'wp-ultimo'),
|
||||
'limit' => 0,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,7 +204,7 @@ class Invoices_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_enqueue_script('wu-ajax-list-table');
|
||||
}
|
||||
@ -215,7 +215,7 @@ class Invoices_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function dependencies() {
|
||||
public function dependencies(): void {
|
||||
|
||||
if ( ! function_exists('convert_to_screen')) {
|
||||
require_once ABSPATH . 'wp-admin/includes/template.php';
|
||||
@ -237,7 +237,7 @@ class Invoices_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->membership = WP_Ultimo()->currents->get_membership();
|
||||
|
||||
@ -254,7 +254,7 @@ class Invoices_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->membership = wu_mock_membership();
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ class Jumper {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action('wp_ultimo_load', array($this, 'add_settings'), 20);
|
||||
add_action('wp_ultimo_load', [$this, 'add_settings'], 20);
|
||||
|
||||
add_action('init', array($this, 'load_jumper'));
|
||||
add_action('init', [$this, 'load_jumper']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,14 +70,14 @@ class Jumper {
|
||||
* @param \WP_Ultimo\Admin_Pages\Base_Admin_Page $page The current page.
|
||||
* @return void
|
||||
*/
|
||||
public function add_jumper_trigger($page) {
|
||||
public function add_jumper_trigger($page): void {
|
||||
|
||||
wu_get_template(
|
||||
'ui/jumper-trigger',
|
||||
array(
|
||||
[
|
||||
'page' => $page,
|
||||
'jumper' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -87,26 +87,26 @@ class Jumper {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function load_jumper() {
|
||||
public function load_jumper(): void {
|
||||
|
||||
if ($this->is_jumper_enabled() && is_admin()) {
|
||||
add_action('wu_header_right', array($this, 'add_jumper_trigger'));
|
||||
add_action('wu_header_right', [$this, 'add_jumper_trigger']);
|
||||
|
||||
add_action('admin_init', array($this, 'rebuild_menu'));
|
||||
add_action('admin_init', [$this, 'rebuild_menu']);
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
|
||||
add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
|
||||
add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']);
|
||||
|
||||
add_action('admin_footer', array($this, 'output'));
|
||||
add_action('admin_footer', [$this, 'output']);
|
||||
|
||||
add_filter('update_footer', array($this, 'add_jumper_footer_message'), 200);
|
||||
add_filter('update_footer', [$this, 'add_jumper_footer_message'], 200);
|
||||
|
||||
add_action('wu_after_save_settings', array($this, 'clear_jump_cache_on_save'));
|
||||
add_action('wu_after_save_settings', [$this, 'clear_jump_cache_on_save']);
|
||||
|
||||
add_filter('wu_link_list', array($this, 'add_wp_ultimo_extra_links'));
|
||||
add_filter('wu_link_list', [$this, 'add_wp_ultimo_extra_links']);
|
||||
|
||||
add_filter('wu_link_list', array($this, 'add_user_custom_links'));
|
||||
add_filter('wu_link_list', [$this, 'add_user_custom_links']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ class Jumper {
|
||||
* @param array $settings Settings being saved.
|
||||
* @return void
|
||||
*/
|
||||
public function clear_jump_cache_on_save($settings) {
|
||||
public function clear_jump_cache_on_save($settings): void {
|
||||
|
||||
if (isset($settings['jumper_custom_links'])) {
|
||||
delete_site_transient($this->transient_key);
|
||||
@ -134,7 +134,7 @@ class Jumper {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function rebuild_menu() {
|
||||
public function rebuild_menu(): void {
|
||||
|
||||
if (isset($_GET[ $this->reset_slug ]) && current_user_can('manage_network')) {
|
||||
delete_site_transient($this->transient_key);
|
||||
@ -153,7 +153,7 @@ class Jumper {
|
||||
*/
|
||||
public function get_user_custom_links() {
|
||||
|
||||
$treated_lines = array();
|
||||
$treated_lines = [];
|
||||
|
||||
$saved_links = wu_get_setting('jumper_custom_links');
|
||||
|
||||
@ -202,7 +202,7 @@ class Jumper {
|
||||
public function add_wp_ultimo_extra_links($links) {
|
||||
|
||||
if (isset($links['WP Ultimo'])) {
|
||||
$settings_tabs = array(
|
||||
$settings_tabs = [
|
||||
'general' => __('General', 'wp-ultimo'),
|
||||
'network' => __('Network Settings', 'wp-ultimo'),
|
||||
'gateways' => __('Payment Gateways', 'wp-ultimo'),
|
||||
@ -212,7 +212,7 @@ class Jumper {
|
||||
'tools' => __('Tools', 'wp-ultimo'),
|
||||
'advanced' => __('Advanced', 'wp-ultimo'),
|
||||
'activation' => __('Activation & Support', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($settings_tabs as $tab => $tab_label) {
|
||||
$url = network_admin_url('admin.php?page=wp-ultimo-settings&wu-tab=' . $tab);
|
||||
@ -262,12 +262,12 @@ class Jumper {
|
||||
|
||||
$trigger_key = $this->get_defined_trigger_key();
|
||||
|
||||
$keys = array(
|
||||
'win' => array('ctrl', 'alt', $trigger_key),
|
||||
'osx' => array('command', 'option', $trigger_key),
|
||||
);
|
||||
$keys = [
|
||||
'win' => ['ctrl', 'alt', $trigger_key],
|
||||
'osx' => ['command', 'option', $trigger_key],
|
||||
];
|
||||
|
||||
return isset($keys[ $os ]) ? $keys[ $os ] : $keys['win'];
|
||||
return $keys[ $os ] ?? $keys['win'];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,22 +306,22 @@ class Jumper {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
public function enqueue_scripts(): void {
|
||||
|
||||
wp_register_script('wu-mousetrap', wu_get_asset('mousetrap.js', 'js/lib'), array('jquery'), wu_get_version(), true);
|
||||
wp_register_script('wu-mousetrap', wu_get_asset('mousetrap.js', 'js/lib'), ['jquery'], wu_get_version(), true);
|
||||
|
||||
wp_register_script('wu-jumper', wu_get_asset('jumper.js', 'js'), array('jquery', 'wu-selectize', 'wu-mousetrap', 'underscore'), wu_get_version(), true);
|
||||
wp_register_script('wu-jumper', wu_get_asset('jumper.js', 'js'), ['jquery', 'wu-selectize', 'wu-mousetrap', 'underscore'], wu_get_version(), true);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-jumper',
|
||||
'wu_jumper_vars',
|
||||
array(
|
||||
[
|
||||
'not_found_message' => __('Nothing found for', 'wp-ultimo'),
|
||||
'trigger_key' => $this->get_defined_trigger_key(),
|
||||
'network_base_url' => network_admin_url(),
|
||||
'ajaxurl' => wu_ajax_url(),
|
||||
'base_url' => get_admin_url(get_current_site()->blog_id),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-jumper');
|
||||
@ -335,9 +335,9 @@ class Jumper {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_styles() {
|
||||
public function enqueue_styles(): void {
|
||||
|
||||
wp_enqueue_style('wu-jumper', wu_get_asset('jumper.css', 'css'), array(), wu_get_version());
|
||||
wp_enqueue_style('wu-jumper', wu_get_asset('jumper.css', 'css'), [], wu_get_version());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -346,13 +346,13 @@ class Jumper {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
wu_get_template(
|
||||
'ui/jumper',
|
||||
array(
|
||||
[
|
||||
'menu_groups' => $this->get_link_list(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
/**
|
||||
@ -382,11 +382,11 @@ class Jumper {
|
||||
*/
|
||||
public function get_target_url($url) {
|
||||
|
||||
if (strpos($url, 'http') !== false) {
|
||||
if (str_contains($url, 'http')) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
if (strpos($url, '.php') !== false) {
|
||||
if (str_contains($url, '.php')) {
|
||||
return network_admin_url($url);
|
||||
}
|
||||
|
||||
@ -410,11 +410,11 @@ class Jumper {
|
||||
global $menu, $submenu;
|
||||
|
||||
// This variable is going to carry our options
|
||||
$choices = array();
|
||||
$choices = [];
|
||||
|
||||
// Prevent first run bug
|
||||
if ( ! is_array($menu) || ! is_array($submenu)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
// Loop all submenus so que can get our final
|
||||
@ -457,7 +457,7 @@ class Jumper {
|
||||
|
||||
$saved_menu = get_site_transient($this->transient_key);
|
||||
|
||||
return $saved_menu ? $saved_menu : array();
|
||||
return $saved_menu ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -480,67 +480,67 @@ class Jumper {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_settings() {
|
||||
public function add_settings(): void {
|
||||
|
||||
wu_register_settings_section(
|
||||
'tools',
|
||||
array(
|
||||
[
|
||||
'title' => __('Tools', 'wp-ultimo'),
|
||||
'desc' => __('Tools', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-tools',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'tools',
|
||||
'tools_header',
|
||||
array(
|
||||
[
|
||||
'title' => __('Jumper', 'wp-ultimo'),
|
||||
'desc' => __('Spotlight-like search bar that allows you to easily access everything on your network.', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'tools',
|
||||
'enable_jumper',
|
||||
array(
|
||||
[
|
||||
'title' => __('Enable Jumper', 'wp-ultimo'),
|
||||
'desc' => __('Turn this option on to make the Jumper available on your network.', 'wp-ultimo'),
|
||||
'type' => 'toggle',
|
||||
'default' => 1,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'tools',
|
||||
'jumper_key',
|
||||
array(
|
||||
[
|
||||
'title' => __('Trigger Key', 'wp-ultimo'),
|
||||
'desc' => __('Change the keyboard key used in conjunction with ctrl + alt (or cmd + option), to trigger the Jumper box.', 'wp-ultimo'),
|
||||
'type' => 'text',
|
||||
'default' => 'g',
|
||||
'require' => array(
|
||||
'require' => [
|
||||
'enable_jumper' => 1,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'tools',
|
||||
'jumper_custom_links',
|
||||
array(
|
||||
[
|
||||
'title' => __('Custom Links', 'wp-ultimo'),
|
||||
'desc' => __('Use this textarea to add custom links to the Jumper. Add one per line, with the format "Title : url".', 'wp-ultimo'),
|
||||
'placeholder' => __('Tile of Custom Link : http://link.com', 'wp-ultimo'),
|
||||
'type' => 'textarea',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 4,
|
||||
),
|
||||
'require' => array(
|
||||
],
|
||||
'require' => [
|
||||
'enable_jumper' => 1,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -120,23 +120,23 @@ class Limits_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('Site Limits', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['columns'] = array(
|
||||
$fields['columns'] = [
|
||||
'type' => 'number',
|
||||
'title' => __('Columns', 'wp-ultimo'),
|
||||
'desc' => __('How many columns to use.', 'wp-ultimo'),
|
||||
@ -144,7 +144,7 @@ class Limits_Element extends Base_Element {
|
||||
'value' => 1,
|
||||
'min' => 1,
|
||||
'max' => 10,
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -168,13 +168,13 @@ class Limits_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Account',
|
||||
'Limits',
|
||||
'Quotas',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,10 +193,10 @@ class Limits_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'columns' => 1,
|
||||
'title' => __('Site Limits', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,7 +205,7 @@ class Limits_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->site = WP_Ultimo()->currents->get_site();
|
||||
|
||||
@ -220,7 +220,7 @@ class Limits_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
}
|
||||
@ -241,9 +241,9 @@ class Limits_Element extends Base_Element {
|
||||
public function output($atts, $content = null) {
|
||||
|
||||
$post_types = get_post_types(
|
||||
array(
|
||||
[
|
||||
'public' => true,
|
||||
),
|
||||
],
|
||||
'objects'
|
||||
);
|
||||
|
||||
|
@ -61,10 +61,10 @@ class Login_Form_Element extends Base_Element {
|
||||
* @since 2.0.11
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
// Handle login redirection
|
||||
add_filter('login_redirect', array($this, 'handle_redirect'), -1, 3);
|
||||
add_filter('login_redirect', [$this, 'handle_redirect'], -1, 3);
|
||||
|
||||
parent::init();
|
||||
}
|
||||
@ -135,160 +135,160 @@ class Login_Form_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['display_title'] = array(
|
||||
$fields['display_title'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Title?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the title element.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('Login', 'wp-ultimo'),
|
||||
'desc' => '',
|
||||
'tooltip' => '',
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'display_title' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['redirect_type'] = array(
|
||||
$fields['redirect_type'] = [
|
||||
'type' => 'select',
|
||||
'title' => __('Redirect Type', 'wp-ultimo'),
|
||||
'desc' => __('The behavior after login', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'default' => 'default',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'default' => __('Wordpress Default', 'wp-ultimo'),
|
||||
'customer_site' => __('Send To Customer Site', 'wp-ultimo'),
|
||||
'main_site' => __('Send To Main Site', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['customer_redirect_path'] = array(
|
||||
$fields['customer_redirect_path'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Customer Redirect Path', 'wp-ultimo'),
|
||||
'value' => __('/wp-admin', 'wp-ultimo'),
|
||||
'desc' => __('e.g. /wp-admin', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'redirect_type' => 'customer_site',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['main_redirect_path'] = array(
|
||||
$fields['main_redirect_path'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Main Site Redirect Path', 'wp-ultimo'),
|
||||
'value' => __('/wp-admin', 'wp-ultimo'),
|
||||
'desc' => __('e.g. /wp-admin', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'redirect_type' => 'main_site',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['header_username'] = array(
|
||||
$fields['header_username'] = [
|
||||
'title' => __('Username Field', 'wp-ultimo'),
|
||||
'desc' => __('Username Field', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['label_username'] = array(
|
||||
$fields['label_username'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Username Field Label', 'wp-ultimo'),
|
||||
'value' => __('Username or Email Address', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['placeholder_username'] = array(
|
||||
$fields['placeholder_username'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Username Field Placeholder', 'wp-ultimo'),
|
||||
'desc' => __('e.g. Username Here', 'wp-ultimo'),
|
||||
'value' => '',
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['header_password'] = array(
|
||||
$fields['header_password'] = [
|
||||
'title' => __('Password Field', 'wp-ultimo'),
|
||||
'desc' => __('Password Field', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['label_password'] = array(
|
||||
$fields['label_password'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Password Field Label', 'wp-ultimo'),
|
||||
'value' => __('Password', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['placeholder_password'] = array(
|
||||
$fields['placeholder_password'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Password Field Placeholder', 'wp-ultimo'),
|
||||
'desc' => __('e.g. Your Password', 'wp-ultimo'),
|
||||
'value' => '',
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['header_remember'] = array(
|
||||
$fields['header_remember'] = [
|
||||
'title' => __('Remember Me', 'wp-ultimo'),
|
||||
'desc' => __('Remember Me', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['remember'] = array(
|
||||
$fields['remember'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Remember Toggle?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the remember me checkbox.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['label_remember'] = array(
|
||||
$fields['label_remember'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Remember Me Label', 'wp-ultimo'),
|
||||
'value' => __('Remember Me'),
|
||||
'desc' => '',
|
||||
'tooltip' => '',
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'remember' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['desc_remember'] = array(
|
||||
$fields['desc_remember'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Remember Me Description', 'wp-ultimo'),
|
||||
'value' => __('Keep me logged in for two weeks.', 'wp-ultimo'),
|
||||
'desc' => '',
|
||||
'tooltip' => '',
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'remember' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['header_submit'] = array(
|
||||
$fields['header_submit'] = [
|
||||
'title' => __('Submit Button', 'wp-ultimo'),
|
||||
'desc' => __('Submit Button', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['label_log_in'] = array(
|
||||
$fields['label_log_in'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Submit Button Label', 'wp-ultimo'),
|
||||
'value' => __('Log In', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -299,7 +299,7 @@ class Login_Form_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_enqueue_style('wu-admin');
|
||||
}
|
||||
@ -323,12 +323,12 @@ class Login_Form_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Login',
|
||||
'Reset Password',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,7 +350,7 @@ class Login_Form_Element extends Base_Element {
|
||||
// Default 'redirect' value takes the user back to the request URI.
|
||||
$redirect_to = wu_get_current_url();
|
||||
|
||||
return array(
|
||||
return [
|
||||
'display_title' => 1,
|
||||
'title' => __('Login', 'wp-ultimo'),
|
||||
|
||||
@ -379,7 +379,7 @@ class Login_Form_Element extends Base_Element {
|
||||
'remember' => true,
|
||||
'value_username' => '',
|
||||
'value_remember' => false, // Set 'value_remember' to true to default the "Remember me" checkbox to checked.
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,7 +388,7 @@ class Login_Form_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->logged = is_user_logged_in();
|
||||
|
||||
@ -400,9 +400,19 @@ class Login_Form_Element extends Base_Element {
|
||||
if (isset($_GET['key']) && isset($_GET['login'])) {
|
||||
$value = sprintf('%s:%s', wp_unslash($_GET['login']), wp_unslash($_GET['key']));
|
||||
|
||||
setcookie($rp_cookie, $value, 0, $rp_path, (string) COOKIE_DOMAIN, is_ssl(), true);
|
||||
setcookie(
|
||||
$rp_cookie,
|
||||
$value,
|
||||
[
|
||||
'expires' => 0,
|
||||
'path' => $rp_path,
|
||||
'domain' => (string) COOKIE_DOMAIN,
|
||||
'secure' => is_ssl(),
|
||||
'httponly' => true,
|
||||
]
|
||||
);
|
||||
|
||||
wp_safe_redirect(remove_query_arg(array('key', 'login')));
|
||||
wp_safe_redirect(remove_query_arg(['key', 'login']));
|
||||
|
||||
exit;
|
||||
}
|
||||
@ -518,7 +528,7 @@ class Login_Form_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->logged = false;
|
||||
}
|
||||
@ -560,12 +570,12 @@ class Login_Form_Element extends Base_Element {
|
||||
* login URL so the user can re-login with the new password.
|
||||
*/
|
||||
if ($this->is_reset_confirmation_page()) {
|
||||
$fields = array(
|
||||
'email-activation-instructions' => array(
|
||||
$fields = [
|
||||
'email-activation-instructions' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('Your password has been reset.') . ' <a href="' . esc_url(wp_login_url()) . '">' . __('Log in') . '</a>',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Check if are in the email confirmation instructions page.
|
||||
@ -573,16 +583,16 @@ class Login_Form_Element extends Base_Element {
|
||||
* If that's the case, we show the instructions.
|
||||
*/
|
||||
} elseif ($this->is_check_email_confirm()) {
|
||||
$fields = array(
|
||||
'email-activation-instructions' => array(
|
||||
$fields = [
|
||||
'email-activation-instructions' => [
|
||||
'type' => 'note',
|
||||
'desc' => sprintf(
|
||||
/* translators: %s: Link to the login page. */
|
||||
__('Check your email for the confirmation link, then visit the <a href="%s">login page</a>.'),
|
||||
wp_login_url()
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Check if we are in the set new password page.
|
||||
@ -594,7 +604,7 @@ class Login_Form_Element extends Base_Element {
|
||||
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
|
||||
|
||||
if (isset($_COOKIE[ $rp_cookie ]) && 0 < strpos((string) $_COOKIE[ $rp_cookie ], ':')) {
|
||||
list($rp_login, $rp_key) = explode(':', wp_unslash($_COOKIE[ $rp_cookie ]), 2);
|
||||
[$rp_login, $rp_key] = explode(':', wp_unslash($_COOKIE[ $rp_cookie ]), 2);
|
||||
|
||||
$user = check_password_reset_key($rp_key, $rp_login);
|
||||
|
||||
@ -605,58 +615,58 @@ class Login_Form_Element extends Base_Element {
|
||||
$user = false;
|
||||
}
|
||||
|
||||
$redirect_to = add_query_arg('password-reset', 'success', remove_query_arg(array('action', 'error')));
|
||||
$redirect_to = add_query_arg('password-reset', 'success', remove_query_arg(['action', 'error']));
|
||||
|
||||
$fields = array(
|
||||
'pass1' => array(
|
||||
$fields = [
|
||||
'pass1' => [
|
||||
'type' => 'password',
|
||||
'title' => __('New password'),
|
||||
'placeholder' => '',
|
||||
'value' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'size' => 24,
|
||||
'autocapitalize' => 'off',
|
||||
),
|
||||
),
|
||||
'pass2' => array(
|
||||
],
|
||||
],
|
||||
'pass2' => [
|
||||
'type' => 'password',
|
||||
'title' => __('Confirm new password'),
|
||||
'placeholder' => '',
|
||||
'value' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'size' => 24,
|
||||
'autocapitalize' => 'off',
|
||||
),
|
||||
),
|
||||
'lost-password-instructions' => array(
|
||||
],
|
||||
],
|
||||
'lost-password-instructions' => [
|
||||
'type' => 'note',
|
||||
'desc' => wp_get_password_hint(),
|
||||
'tooltip' => '',
|
||||
),
|
||||
'action' => array(
|
||||
],
|
||||
'action' => [
|
||||
'type' => 'hidden',
|
||||
'value' => 'resetpass',
|
||||
),
|
||||
'rp_key' => array(
|
||||
],
|
||||
'rp_key' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $rp_key,
|
||||
),
|
||||
'user_login' => array(
|
||||
],
|
||||
'user_login' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $rp_login,
|
||||
),
|
||||
'redirect_to' => array(
|
||||
],
|
||||
'redirect_to' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $redirect_to,
|
||||
),
|
||||
'wp-submit' => array(
|
||||
],
|
||||
'wp-submit' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Save Password'),
|
||||
'value' => __('Save Password'),
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-bg-none',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Checks if we are in the first reset password page, where the customer requests a reset.
|
||||
@ -671,70 +681,70 @@ class Login_Form_Element extends Base_Element {
|
||||
$user_login = wp_unslash($user_login);
|
||||
}
|
||||
|
||||
$redirect_to = add_query_arg('checkemail', 'confirm', remove_query_arg(array('action', 'error')));
|
||||
$redirect_to = add_query_arg('checkemail', 'confirm', remove_query_arg(['action', 'error']));
|
||||
|
||||
$fields = array(
|
||||
'lost-password-instructions' => array(
|
||||
$fields = [
|
||||
'lost-password-instructions' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('Please enter your username or email address. You will receive an email message with instructions on how to reset your password.'),
|
||||
'tooltip' => '',
|
||||
),
|
||||
'user_login' => array(
|
||||
],
|
||||
'user_login' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Username or Email Address'),
|
||||
'placeholder' => '',
|
||||
'value' => $user_login,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'size' => 20,
|
||||
'autocapitalize' => 'off',
|
||||
),
|
||||
),
|
||||
'action' => array(
|
||||
],
|
||||
],
|
||||
'action' => [
|
||||
'type' => 'hidden',
|
||||
'value' => 'lostpassword',
|
||||
),
|
||||
'redirect_to' => array(
|
||||
],
|
||||
'redirect_to' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $redirect_to,
|
||||
),
|
||||
'wp-submit' => array(
|
||||
],
|
||||
'wp-submit' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Get New Password'),
|
||||
'value' => __('Get New Password'),
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-bg-none',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$view = 'dashboard-widgets/login-form';
|
||||
|
||||
$fields = array(
|
||||
'log' => array(
|
||||
$fields = [
|
||||
'log' => [
|
||||
'type' => 'text',
|
||||
'title' => $atts['label_username'],
|
||||
'placeholder' => $atts['placeholder_username'],
|
||||
'tooltip' => '',
|
||||
),
|
||||
'pwd' => array(
|
||||
],
|
||||
'pwd' => [
|
||||
'type' => 'password',
|
||||
'title' => $atts['label_password'],
|
||||
'placeholder' => $atts['placeholder_password'],
|
||||
'tooltip' => '',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($atts['remember']) {
|
||||
$fields['rememberme'] = array(
|
||||
$fields['rememberme'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => $atts['label_remember'],
|
||||
'desc' => $atts['desc_remember'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$fields['redirect_to'] = array(
|
||||
$fields['redirect_to'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => $atts['redirect'],
|
||||
);
|
||||
];
|
||||
|
||||
if (isset($_GET['redirect_to'])) {
|
||||
$atts['redirect_type'] = 'query_redirect';
|
||||
@ -745,25 +755,25 @@ class Login_Form_Element extends Base_Element {
|
||||
$fields['redirect_to']['value'] = $atts['main_redirect_path'];
|
||||
}
|
||||
|
||||
$fields['wu_login_form_redirect_type'] = array(
|
||||
$fields['wu_login_form_redirect_type'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => $atts['redirect_type'],
|
||||
);
|
||||
];
|
||||
|
||||
$fields['wp-submit'] = array(
|
||||
$fields['wp-submit'] = [
|
||||
'type' => 'submit',
|
||||
'title' => $atts['label_log_in'],
|
||||
'value' => $atts['label_log_in'],
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-bg-none',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['lost-password'] = array(
|
||||
$fields['lost-password'] = [
|
||||
'type' => 'html',
|
||||
'content' => sprintf('<a class="wu-text-xs wu-block wu-text-center wu--mt-4" href="%s">%s</a>', esc_url(add_query_arg('action', 'lostpassword')), __('Lost your password?')),
|
||||
'classes' => '',
|
||||
'wrapper_classes' => 'wu-items-end wu-bg-none',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -775,20 +785,20 @@ class Login_Form_Element extends Base_Element {
|
||||
if (wu_request('error')) {
|
||||
$username = wu_request('username', '');
|
||||
|
||||
$error_message_field = array(
|
||||
'error_message' => array(
|
||||
$error_message_field = [
|
||||
'error_message' => [
|
||||
'type' => 'note',
|
||||
'desc' => Checkout_Pages::get_instance()->get_error_message(wu_request('error'), $username),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields = array_merge($error_message_field, $fields);
|
||||
}
|
||||
|
||||
$fields['wu_login_page_url'] = array(
|
||||
$fields['wu_login_page_url'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_get_current_url(),
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Instantiate the form for the order details.
|
||||
@ -798,16 +808,16 @@ class Login_Form_Element extends Base_Element {
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
$this->get_id(),
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'action' => esc_url(site_url('wp-login.php', 'login_post')),
|
||||
'wrap_in_form_tag' => true,
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-p-0 wu-m-0',
|
||||
'field_wrapper_classes' => 'wu-box-border wu-items-center wu-flex wu-justify-between wu-py-4 wu-m-0',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'class' => 'wu-w-full',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$atts['logged'] = $this->logged;
|
||||
|
@ -130,66 +130,66 @@ class My_Sites_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['site_manage_type'] = array(
|
||||
$fields['site_manage_type'] = [
|
||||
'type' => 'select',
|
||||
'title' => __('Site Manage Type', 'wp-ultimo'),
|
||||
'desc' => __('The page to manage a site.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'default' => 'default',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'default' => __('Same Page', 'wp-ultimo'),
|
||||
'wp_admin' => __('WP Admin', 'wp-ultimo'),
|
||||
'custom_page' => __('Custom Page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['site_show'] = array(
|
||||
$fields['site_show'] = [
|
||||
'type' => 'select',
|
||||
'title' => __('Which sites to show?', 'wp-ultimo'),
|
||||
'desc' => __('Select which sites should be listed for user.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'default' => 'all',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'all' => __('All', 'wp-ultimo'),
|
||||
'owned' => __('Owned', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$pages = get_pages(
|
||||
array(
|
||||
'exclude' => array(get_the_ID()),
|
||||
)
|
||||
[
|
||||
'exclude' => [get_the_ID()],
|
||||
]
|
||||
);
|
||||
|
||||
$pages = $pages ? $pages : array();
|
||||
$pages = $pages ?: [];
|
||||
|
||||
$pages_list = array(0 => __('Current Page', 'wp-ultimo'));
|
||||
$pages_list = [0 => __('Current Page', 'wp-ultimo')];
|
||||
|
||||
foreach ($pages as $page) {
|
||||
$pages_list[ $page->ID ] = $page->post_title;
|
||||
}
|
||||
|
||||
$fields['custom_manage_page'] = array(
|
||||
$fields['custom_manage_page'] = [
|
||||
'type' => 'select',
|
||||
'title' => __('Manage Redirect Page', 'wp-ultimo'),
|
||||
'value' => 0,
|
||||
'desc' => __('The page to redirect user after select a site.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'required' => array(
|
||||
'required' => [
|
||||
'site_manage_type' => 'custom_page',
|
||||
),
|
||||
],
|
||||
'options' => $pages_list,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['columns'] = array(
|
||||
$fields['columns'] = [
|
||||
'type' => 'number',
|
||||
'title' => __('Columns', 'wp-ultimo'),
|
||||
'desc' => __('How many columns to use.', 'wp-ultimo'),
|
||||
@ -197,15 +197,15 @@ class My_Sites_Element extends Base_Element {
|
||||
'value' => 4,
|
||||
'min' => 1,
|
||||
'max' => 5,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['display_images'] = array(
|
||||
$fields['display_images'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Site Screenshot?', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the site screenshots on the element.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -229,13 +229,13 @@ class My_Sites_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Site',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,13 +254,13 @@ class My_Sites_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'columns' => 4,
|
||||
'display_images' => 1,
|
||||
'site_manage_type' => 'default',
|
||||
'custom_manage_page' => 0,
|
||||
'site_show' => 'owned',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -269,7 +269,7 @@ class My_Sites_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_enqueue_style('wu-admin');
|
||||
}
|
||||
@ -280,7 +280,7 @@ class My_Sites_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -299,14 +299,14 @@ class My_Sites_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->customer = wu_mock_customer();
|
||||
|
||||
$this->sites = array(
|
||||
$this->sites = [
|
||||
wu_mock_site(1),
|
||||
wu_mock_site(2),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,14 +343,14 @@ class My_Sites_Element extends Base_Element {
|
||||
return $this->sites;
|
||||
}
|
||||
|
||||
$this->sites = apply_filters('wp_ultimo_pre_my_sites_sites', array(), $show);
|
||||
$this->sites = apply_filters('wp_ultimo_pre_my_sites_sites', [], $show);
|
||||
|
||||
if ( ! empty($this->sites)) {
|
||||
return $this->sites;
|
||||
}
|
||||
|
||||
if ( ! empty($this->customer)) {
|
||||
$pending_sites = \WP_Ultimo\Models\Site::get_all_by_type('pending', array('customer_id' => $this->customer->get_id()));
|
||||
$pending_sites = \WP_Ultimo\Models\Site::get_all_by_type('pending', ['customer_id' => $this->customer->get_id()]);
|
||||
|
||||
$customer_sites = array_reduce(
|
||||
$this->customer->get_sites(),
|
||||
@ -367,7 +367,7 @@ class My_Sites_Element extends Base_Element {
|
||||
$user_sites = array_reduce(
|
||||
$wp_user_sites,
|
||||
function ($user_sites, $wp_site) use ($customer_sites) {
|
||||
if ( ! array_key_exists($wp_site->userblog_id, $customer_sites ?? array()) && $wp_site->userblog_id !== get_main_site_id()) {
|
||||
if ( ! array_key_exists($wp_site->userblog_id, $customer_sites ?? []) && $wp_site->userblog_id !== get_main_site_id()) {
|
||||
$wu_site = wu_get_site($wp_site->userblog_id);
|
||||
$wu_site->set_membership_id(0);
|
||||
$user_sites[ $wp_site->userblog_id ] = $wu_site;
|
||||
@ -378,9 +378,9 @@ class My_Sites_Element extends Base_Element {
|
||||
}
|
||||
|
||||
$sites = array_merge(
|
||||
$pending_sites ?? array(),
|
||||
$customer_sites ?? array(),
|
||||
$user_sites ?? array(),
|
||||
$pending_sites ?? [],
|
||||
$customer_sites ?? [],
|
||||
$user_sites ?? [],
|
||||
);
|
||||
|
||||
$this->sites = apply_filters('wp_ultimo_after_my_sites_sites', $sites, $show);
|
||||
@ -413,9 +413,9 @@ class My_Sites_Element extends Base_Element {
|
||||
$site_hash = \WP_Ultimo\Helpers\Hash::encode($site_id, 'site');
|
||||
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
$url_param => $site_hash,
|
||||
),
|
||||
],
|
||||
$custom_page
|
||||
);
|
||||
}
|
||||
@ -441,9 +441,9 @@ class My_Sites_Element extends Base_Element {
|
||||
if ($membership) {
|
||||
if ($url) {
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'membership' => $membership->get_hash(),
|
||||
),
|
||||
],
|
||||
$url
|
||||
);
|
||||
}
|
||||
@ -453,9 +453,9 @@ class My_Sites_Element extends Base_Element {
|
||||
|
||||
if ( ! empty($sites)) {
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'page' => 'add-new-site',
|
||||
),
|
||||
],
|
||||
get_admin_url($sites[0]->get_id())
|
||||
);
|
||||
}
|
||||
|
@ -105,29 +105,29 @@ class Payment_Methods_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['password_strength'] = array(
|
||||
$fields['password_strength'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Password Strength Meter', 'wp-ultimo'),
|
||||
'desc' => __('Set this customer as a VIP.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['apply_styles'] = array(
|
||||
$fields['apply_styles'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Apply Styles', 'wp-ultimo'),
|
||||
'desc' => __('Set this customer as a VIP.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -151,13 +151,13 @@ class Payment_Methods_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Payment Methods',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,7 +176,7 @@ class Payment_Methods_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,24 +121,24 @@ class Simple_Text_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['simple_text'] = array(
|
||||
$fields['simple_text'] = [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Content', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. Text, HTML or shortcode.', 'wp-ultimo'),
|
||||
'desc' => __('You can insert plain text, HTML or a shortcode in this block.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 6,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -149,7 +149,7 @@ class Simple_Text_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_enqueue_style('wu-admin');
|
||||
}
|
||||
@ -173,14 +173,14 @@ class Simple_Text_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'text',
|
||||
'simple text',
|
||||
'shortcode',
|
||||
'textarea',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,9 +199,9 @@ class Simple_Text_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'simple_text' => __('Text, HTML or shortcode.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
add_wubox();
|
||||
}
|
||||
@ -141,60 +141,60 @@ class Site_Actions_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['show_change_password'] = array(
|
||||
$fields['show_change_password'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Show Change Password', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the password link.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['show_change_default_site'] = array(
|
||||
$fields['show_change_default_site'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Show Change Default Site', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the change default site link.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$fields['show_change_payment_method'] = array(
|
||||
$fields['show_change_payment_method'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Show Change Payment Method', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide the option to cancel the current payment method.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$pages = get_pages(
|
||||
array(
|
||||
'exclude' => array(get_the_ID()),
|
||||
)
|
||||
[
|
||||
'exclude' => [get_the_ID()],
|
||||
]
|
||||
);
|
||||
|
||||
$pages = $pages ? $pages : array();
|
||||
$pages = $pages ?: [];
|
||||
|
||||
$pages_list = array(0 => __('Default', 'wp-ultimo'));
|
||||
$pages_list = [0 => __('Default', 'wp-ultimo')];
|
||||
|
||||
foreach ($pages as $page) {
|
||||
$pages_list[ $page->ID ] = $page->post_title;
|
||||
}
|
||||
|
||||
$fields['redirect_after_delete'] = array(
|
||||
$fields['redirect_after_delete'] = [
|
||||
'type' => 'select',
|
||||
'title' => __('Redirect After Delete', 'wp-ultimo'),
|
||||
'value' => 0,
|
||||
'desc' => __('The page to redirect user after delete current site.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'options' => $pages_list,
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -218,13 +218,13 @@ class Site_Actions_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Actions',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,12 +243,12 @@ class Site_Actions_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'show_change_password' => 1,
|
||||
'show_change_default_site' => 1,
|
||||
'show_change_payment_method' => 1,
|
||||
'redirect_after_delete' => 0,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,7 +257,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->site = WP_Ultimo()->currents->get_site();
|
||||
|
||||
@ -280,7 +280,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
|
||||
@ -293,7 +293,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.21
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
@ -306,51 +306,51 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.21
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
|
||||
wu_register_form(
|
||||
'change_password',
|
||||
array(
|
||||
'render' => array($this, 'render_change_password'),
|
||||
'handler' => array($this, 'handle_change_password'),
|
||||
[
|
||||
'render' => [$this, 'render_change_password'],
|
||||
'handler' => [$this, 'handle_change_password'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'delete_site',
|
||||
array(
|
||||
'render' => array($this, 'render_delete_site'),
|
||||
'handler' => array($this, 'handle_delete_site'),
|
||||
[
|
||||
'render' => [$this, 'render_delete_site'],
|
||||
'handler' => [$this, 'handle_delete_site'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'change_default_site',
|
||||
array(
|
||||
'render' => array($this, 'render_change_default_site'),
|
||||
'handler' => array($this, 'handle_change_default_site'),
|
||||
[
|
||||
'render' => [$this, 'render_change_default_site'],
|
||||
'handler' => [$this, 'handle_change_default_site'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'cancel_payment_method',
|
||||
array(
|
||||
'render' => array($this, 'render_cancel_payment_method'),
|
||||
'handler' => array($this, 'handle_cancel_payment_method'),
|
||||
[
|
||||
'render' => [$this, 'render_cancel_payment_method'],
|
||||
'handler' => [$this, 'handle_cancel_payment_method'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_form(
|
||||
'cancel_membership',
|
||||
array(
|
||||
'render' => array($this, 'render_cancel_membership'),
|
||||
'handler' => array($this, 'handle_cancel_membership'),
|
||||
[
|
||||
'render' => [$this, 'render_cancel_membership'],
|
||||
'handler' => [$this, 'handle_cancel_membership'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -363,58 +363,58 @@ class Site_Actions_Element extends Base_Element {
|
||||
*/
|
||||
public function get_actions($atts) {
|
||||
|
||||
$actions = array();
|
||||
$actions = [];
|
||||
|
||||
$all_blogs = get_blogs_of_user(get_current_user_id());
|
||||
|
||||
$is_template_switching_enabled = wu_get_setting('allow_template_switching', true);
|
||||
|
||||
if ($is_template_switching_enabled && $this->site) {
|
||||
$actions['template_switching'] = array(
|
||||
$actions['template_switching'] = [
|
||||
'label' => __('Change Site Template', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
|
||||
'href' => add_query_arg(
|
||||
array(
|
||||
[
|
||||
'page' => 'wu-template-switching',
|
||||
),
|
||||
],
|
||||
get_admin_url($this->site->get_id())
|
||||
),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (count($all_blogs) > 1 && wu_get_isset($atts, 'show_change_default_site')) {
|
||||
$actions['default_site'] = array(
|
||||
$actions['default_site'] = [
|
||||
'label' => __('Change Default Site', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
|
||||
'classes' => 'wubox',
|
||||
'href' => wu_get_form_url('change_default_site'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (wu_get_isset($atts, 'show_change_password')) {
|
||||
$actions['change_password'] = array(
|
||||
$actions['change_password'] = [
|
||||
'label' => __('Change Password', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
|
||||
'classes' => 'wubox',
|
||||
'href' => wu_get_form_url('change_password'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$payment_gateway = $this->membership ? $this->membership->get_gateway() : false;
|
||||
|
||||
if (wu_get_isset($atts, 'show_change_payment_method') && $payment_gateway) {
|
||||
$actions['cancel_payment_method'] = array(
|
||||
$actions['cancel_payment_method'] = [
|
||||
'label' => __('Cancel Current Payment Method', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
|
||||
'classes' => 'wubox',
|
||||
'href' => wu_get_form_url(
|
||||
'cancel_payment_method',
|
||||
array(
|
||||
[
|
||||
'membership' => $this->membership->get_hash(),
|
||||
'redirect_url' => wu_get_current_url(),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return apply_filters('wu_element_get_site_actions', $actions, $atts, $this->site, $this->membership);
|
||||
@ -429,44 +429,44 @@ class Site_Actions_Element extends Base_Element {
|
||||
*/
|
||||
public function get_danger_zone_actions($atts) {
|
||||
|
||||
$actions = array();
|
||||
$actions = [];
|
||||
|
||||
if ($this->site) {
|
||||
$actions = array_merge(
|
||||
array(
|
||||
'delete_site' => array(
|
||||
[
|
||||
'delete_site' => [
|
||||
'label' => __('Delete Site', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
|
||||
'classes' => 'wubox wu-text-red-500',
|
||||
'href' => wu_get_form_url(
|
||||
'delete_site',
|
||||
array(
|
||||
[
|
||||
'site' => $this->site->get_hash(),
|
||||
'redirect_url' => ! $atts['redirect_after_delete'] ? false : get_page_link($atts['redirect_after_delete']),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
$actions
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->membership && $this->membership->is_recurring() && $this->membership->get_status() !== Membership_Status::CANCELLED) {
|
||||
$actions = array_merge(
|
||||
array(
|
||||
'cancel_membership' => array(
|
||||
[
|
||||
'cancel_membership' => [
|
||||
'label' => __('Cancel Membership', 'wp-ultimo'),
|
||||
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
|
||||
'classes' => 'wubox wu-text-red-500',
|
||||
'href' => wu_get_form_url(
|
||||
'cancel_membership',
|
||||
array(
|
||||
[
|
||||
'membership' => $this->membership->get_hash(),
|
||||
'redirect_url' => wu_get_current_url(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
$actions
|
||||
);
|
||||
}
|
||||
@ -480,7 +480,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.21
|
||||
* @return void
|
||||
*/
|
||||
public function render_delete_site() {
|
||||
public function render_delete_site(): void {
|
||||
|
||||
$site = wu_get_site_by_hash(wu_request('site'));
|
||||
|
||||
@ -497,21 +497,21 @@ class Site_Actions_Element extends Base_Element {
|
||||
}
|
||||
|
||||
if ( ! empty($error)) {
|
||||
$error_field = array(
|
||||
'error_message' => array(
|
||||
$error_field = [
|
||||
'error_message' => [
|
||||
'type' => 'note',
|
||||
'desc' => $error,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'change_password',
|
||||
$error_field,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -519,52 +519,52 @@ class Site_Actions_Element extends Base_Element {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'site' => array(
|
||||
$fields = [
|
||||
'site' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('site'),
|
||||
),
|
||||
'redirect_url' => array(
|
||||
],
|
||||
'redirect_url' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('redirect_url'),
|
||||
),
|
||||
'confirm' => array(
|
||||
],
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Site Deletion', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Delete Site', 'wp-ultimo'),
|
||||
'placeholder' => __('Delete Site', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'change_password',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'change_password',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -614,16 +614,16 @@ class Site_Actions_Element extends Base_Element {
|
||||
$redirect_url = wu_request('redirect_url');
|
||||
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'site_deleted' => true,
|
||||
),
|
||||
],
|
||||
wu_request('redirect_url') ?? user_admin_url()
|
||||
);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => $redirect_url,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -633,49 +633,49 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.21
|
||||
* @return void
|
||||
*/
|
||||
public function render_change_password() {
|
||||
public function render_change_password(): void {
|
||||
|
||||
$fields = array(
|
||||
'password' => array(
|
||||
$fields = [
|
||||
'password' => [
|
||||
'type' => 'password',
|
||||
'title' => __('Current Password', 'wp-ultimo'),
|
||||
'placeholder' => __('******', 'wp-ultimo'),
|
||||
),
|
||||
'new_password' => array(
|
||||
],
|
||||
'new_password' => [
|
||||
'type' => 'password',
|
||||
'title' => __('New Password', 'wp-ultimo'),
|
||||
'placeholder' => __('******', 'wp-ultimo'),
|
||||
'meter' => true,
|
||||
),
|
||||
'new_password_conf' => array(
|
||||
],
|
||||
'new_password_conf' => [
|
||||
'type' => 'password',
|
||||
'placeholder' => __('******', 'wp-ultimo'),
|
||||
'title' => __('Confirm New Password', 'wp-ultimo'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Reset Password', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
// 'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'change_password',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'change_password',
|
||||
'data-state' => wu_convert_to_state(),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -687,7 +687,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.21
|
||||
* @return void
|
||||
*/
|
||||
public function handle_change_password() {
|
||||
public function handle_change_password(): void {
|
||||
|
||||
$user = wp_get_current_user();
|
||||
|
||||
@ -728,9 +728,9 @@ class Site_Actions_Element extends Base_Element {
|
||||
do_action('wp_login', $user->user_login, $user); // PHPCS:ignore
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -740,11 +740,11 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.21
|
||||
* @return void
|
||||
*/
|
||||
public function render_change_default_site() {
|
||||
public function render_change_default_site(): void {
|
||||
|
||||
$all_blogs = get_blogs_of_user(get_current_user_id());
|
||||
|
||||
$option_blogs = array();
|
||||
$option_blogs = [];
|
||||
|
||||
foreach ($all_blogs as $key => $blog) {
|
||||
$option_blogs[ $blog->userblog_id ] = get_home_url($blog->userblog_id);
|
||||
@ -752,45 +752,45 @@ class Site_Actions_Element extends Base_Element {
|
||||
|
||||
$primary_blog = get_user_meta(get_current_user_id(), 'primary_blog', true);
|
||||
|
||||
$fields = array(
|
||||
'new_primary_site' => array(
|
||||
$fields = [
|
||||
'new_primary_site' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Primary Site', 'wp-ultimo'),
|
||||
'desc' => __('Change the primary site of your network.', 'wp-ultimo'),
|
||||
'options' => $option_blogs,
|
||||
'value' => $primary_blog,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'new_primary_site',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Change Default Site', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => 'new_primary_site === "' . $primary_blog . '"',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'change_default_site',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'change_default_site',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'new_primary_site' => $primary_blog,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -802,7 +802,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.0.21
|
||||
* @return void
|
||||
*/
|
||||
public function handle_change_default_site() {
|
||||
public function handle_change_default_site(): void {
|
||||
|
||||
$new_primary_site = wu_request('new_primary_site');
|
||||
|
||||
@ -810,9 +810,9 @@ class Site_Actions_Element extends Base_Element {
|
||||
update_user_meta(get_current_user_id(), 'primary_blog', $new_primary_site);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -827,7 +827,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.1.2
|
||||
* @return void
|
||||
*/
|
||||
public function render_cancel_payment_method() {
|
||||
public function render_cancel_payment_method(): void {
|
||||
|
||||
$membership = wu_get_membership_by_hash(wu_request('membership'));
|
||||
|
||||
@ -844,21 +844,21 @@ class Site_Actions_Element extends Base_Element {
|
||||
}
|
||||
|
||||
if ( ! empty($error)) {
|
||||
$error_field = array(
|
||||
'error_message' => array(
|
||||
$error_field = [
|
||||
'error_message' => [
|
||||
'type' => 'note',
|
||||
'desc' => $error,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'cancel_payment_method',
|
||||
$error_field,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -866,52 +866,52 @@ class Site_Actions_Element extends Base_Element {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'membership' => array(
|
||||
$fields = [
|
||||
'membership' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('membership'),
|
||||
),
|
||||
'redirect_url' => array(
|
||||
],
|
||||
'redirect_url' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('redirect_url'),
|
||||
),
|
||||
'confirm' => array(
|
||||
],
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Payment Method Cancellation', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Cancel Payment Method', 'wp-ultimo'),
|
||||
'placeholder' => __('Cancel Payment Method', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'cancel_payment_method',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'cancel_payment_method',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -923,7 +923,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.1.2
|
||||
* @return void
|
||||
*/
|
||||
public function handle_cancel_payment_method() {
|
||||
public function handle_cancel_payment_method(): void {
|
||||
|
||||
$membership = wu_get_membership_by_hash(wu_request('membership'));
|
||||
|
||||
@ -955,16 +955,16 @@ class Site_Actions_Element extends Base_Element {
|
||||
$redirect_url = wu_request('redirect_url');
|
||||
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'payment_gateway_cancelled' => true,
|
||||
),
|
||||
],
|
||||
$redirect_url ?? user_admin_url()
|
||||
);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => $redirect_url,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -974,7 +974,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.1.2
|
||||
* @return void
|
||||
*/
|
||||
public function render_cancel_membership() {
|
||||
public function render_cancel_membership(): void {
|
||||
|
||||
$membership = wu_get_membership_by_hash(wu_request('membership'));
|
||||
|
||||
@ -991,21 +991,21 @@ class Site_Actions_Element extends Base_Element {
|
||||
}
|
||||
|
||||
if ( ! empty($error)) {
|
||||
$error_field = array(
|
||||
'error_message' => array(
|
||||
$error_field = [
|
||||
'error_message' => [
|
||||
'type' => 'note',
|
||||
'desc' => $error,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'cancel_membership',
|
||||
$error_field,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -1013,24 +1013,24 @@ class Site_Actions_Element extends Base_Element {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'membership' => array(
|
||||
$fields = [
|
||||
'membership' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('membership'),
|
||||
),
|
||||
'redirect_url' => array(
|
||||
],
|
||||
'redirect_url' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('redirect_url'),
|
||||
),
|
||||
'cancellation_reason' => array(
|
||||
],
|
||||
'cancellation_reason' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Please tell us why you are cancelling.', 'wp-ultimo'),
|
||||
'desc' => __('We would love your feedback.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'cancellation_reason',
|
||||
),
|
||||
],
|
||||
'default' => '',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'' => __('Select a reason', 'wp-ultimo'),
|
||||
'unused' => __('I no longer need it', 'wp-ultimo'),
|
||||
'too_expensive' => __('It\'s too expensive', 'wp-ultimo'),
|
||||
@ -1039,23 +1039,23 @@ class Site_Actions_Element extends Base_Element {
|
||||
'customer_service' => __('Customer support is less than expected', 'wp-ultimo'),
|
||||
'too_complex' => __('Too complex', 'wp-ultimo'),
|
||||
'other' => __('Other', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
'cancellation_explanation' => array(
|
||||
],
|
||||
],
|
||||
'cancellation_explanation' => [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Please provide additional details.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'cancellation_reason === "other"',
|
||||
),
|
||||
),
|
||||
'confirm' => array(
|
||||
],
|
||||
],
|
||||
'confirm' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Type <code class="wu-text-red-600">CANCEL</code> to confirm this membership cancellation.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmation',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$next_charge = false;
|
||||
|
||||
@ -1064,42 +1064,42 @@ class Site_Actions_Element extends Base_Element {
|
||||
}
|
||||
|
||||
if ($next_charge && $next_charge > time()) {
|
||||
$fields['next_charge'] = array(
|
||||
$fields['next_charge'] = [
|
||||
'type' => 'note',
|
||||
// translators: %s: Next charge date.
|
||||
'desc' => sprintf(__('Your sites will stay working until %s.', 'wp-ultimo'), date_i18n(get_option('date_format'), $next_charge)),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$fields['submit_button'] = array(
|
||||
$fields['submit_button'] = [
|
||||
'type' => 'submit',
|
||||
'title' => __('Cancel Membership', 'wp-ultimo'),
|
||||
'placeholder' => __('Cancel Membership', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => 'confirmation !== "' . __('CANCEL', 'wp-ultimo') . '" || cancellation_reason === ""',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'cancel_membership',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'cancel_membership',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'confirmation' => '',
|
||||
'cancellation_reason' => '',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -1111,7 +1111,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
* @since 2.1.2
|
||||
* @return void
|
||||
*/
|
||||
public function handle_cancel_membership() {
|
||||
public function handle_cancel_membership(): void {
|
||||
|
||||
$membership = wu_get_membership_by_hash(wu_request('membership'));
|
||||
|
||||
@ -1133,7 +1133,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
return;
|
||||
}
|
||||
|
||||
$cancellation_options = array(
|
||||
$cancellation_options = [
|
||||
'unused' => __('I no longer need it', 'wp-ultimo'),
|
||||
'too_expensive' => __('It\'s too expensive', 'wp-ultimo'),
|
||||
'missing_features' => __('I need more features', 'wp-ultimo'),
|
||||
@ -1141,7 +1141,7 @@ class Site_Actions_Element extends Base_Element {
|
||||
'customer_service' => __('Customer support is less than expected', 'wp-ultimo'),
|
||||
'too_complex' => __('Too complex', 'wp-ultimo'),
|
||||
'other' => wu_request('cancellation_explanation'),
|
||||
);
|
||||
];
|
||||
|
||||
$reason = wu_get_isset($cancellation_options, wu_request('cancellation_reason'), '');
|
||||
|
||||
@ -1150,16 +1150,16 @@ class Site_Actions_Element extends Base_Element {
|
||||
$redirect_url = wu_request('redirect_url');
|
||||
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'payment_gateway_cancelled' => true,
|
||||
),
|
||||
],
|
||||
! empty($redirect_url) ? $redirect_url : user_admin_url()
|
||||
);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => $redirect_url,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
if (wu_get_setting('maintenance_mode')) {
|
||||
parent::init();
|
||||
@ -126,28 +126,28 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Label', 'wp-ultimo'),
|
||||
'value' => __('Toggle Maintenance Mode', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. Toggle Maintenance Mode', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['desc'] = array(
|
||||
$fields['desc'] = [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Description', 'wp-ultimo'),
|
||||
'value' => __('Put your site on maintenance mode. When activated, the front-end will only be accessible to logged users.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -171,12 +171,12 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Login',
|
||||
'Reset Password',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,10 +195,10 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'title' => __('Toggle Maintenance Mode', 'wp-ultimo'),
|
||||
'desc' => __('Put your site on maintenance mode. When activated, the front-end will only be accessible to logged users.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,7 +207,7 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->site = WP_Ultimo()->currents->get_site();
|
||||
|
||||
@ -224,7 +224,7 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
}
|
||||
@ -235,17 +235,17 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_register_script('wu-site-maintenance', wu_get_asset('site-maintenance.js', 'js'), array('jquery', 'wu-functions'), wu_get_version());
|
||||
wp_register_script('wu-site-maintenance', wu_get_asset('site-maintenance.js', 'js'), ['jquery', 'wu-functions'], wu_get_version());
|
||||
|
||||
wp_localize_script(
|
||||
'wu-site-maintenance',
|
||||
'wu_site_maintenance',
|
||||
array(
|
||||
[
|
||||
'nonce' => wp_create_nonce('wu_toggle_maintenance_mode'),
|
||||
'ajaxurl' => wu_ajax_url(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-site-maintenance');
|
||||
@ -266,18 +266,18 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
*/
|
||||
public function output($atts, $content = null) {
|
||||
|
||||
$fields = array(
|
||||
'maintenance_mode' => array(
|
||||
$fields = [
|
||||
'maintenance_mode' => [
|
||||
'type' => 'toggle',
|
||||
'title' => $atts['title'],
|
||||
'desc' => $atts['desc'],
|
||||
'value' => wu_string_to_bool($this->site->get_meta('wu_maintenance_mode')),
|
||||
),
|
||||
'site_hash' => array(
|
||||
],
|
||||
'site_hash' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $this->site->get_hash(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Instantiate the form for the order details.
|
||||
@ -287,12 +287,12 @@ class Site_Maintenance_Element extends Base_Element {
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'maintenance-mode',
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-widget-list wu-striped wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0 wu-list-none wu-p-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(),
|
||||
)
|
||||
'html_attr' => [],
|
||||
]
|
||||
);
|
||||
|
||||
$atts['form'] = $form;
|
||||
|
@ -42,9 +42,9 @@ class Template_Previewer {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wp_ultimo_load', array($this, 'hooks'));
|
||||
add_action('wp_ultimo_load', [$this, 'hooks']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ class Template_Previewer {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function hooks() {
|
||||
public function hooks(): void {
|
||||
|
||||
if ($this->is_preview()) {
|
||||
/*
|
||||
@ -65,19 +65,19 @@ class Template_Previewer {
|
||||
|
||||
add_filter('wu_is_toolbox_enabled', '__return_false');
|
||||
|
||||
add_filter('home_url', array($this, 'append_preview_parameter'), 9999, 4);
|
||||
add_filter('home_url', [$this, 'append_preview_parameter'], 9999, 4);
|
||||
|
||||
add_action('send_headers', array($this, 'send_cross_origin_headers'), 1000);
|
||||
add_action('send_headers', [$this, 'send_cross_origin_headers'], 1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->is_template_previewer()) {
|
||||
add_action('init', array($this, 'template_previewer'));
|
||||
add_action('init', [$this, 'template_previewer']);
|
||||
|
||||
add_action('wp_enqueue_scripts', array($this, 'register_scripts'));
|
||||
add_action('wp_enqueue_scripts', [$this, 'register_scripts']);
|
||||
|
||||
add_action('wp_print_styles', array($this, 'remove_unnecessary_styles'), 0);
|
||||
add_action('wp_print_styles', [$this, 'remove_unnecessary_styles'], 0);
|
||||
|
||||
/**
|
||||
* Runs when inside the template previewer context.
|
||||
@ -95,7 +95,7 @@ class Template_Previewer {
|
||||
* @since 2.0.9
|
||||
* @return void
|
||||
*/
|
||||
public function send_cross_origin_headers() {
|
||||
public function send_cross_origin_headers(): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -112,7 +112,7 @@ class Template_Previewer {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -122,31 +122,31 @@ class Template_Previewer {
|
||||
$button_bg_color = wu_color($settings['button_bg_color']);
|
||||
$button_bg_darker = wu_color($button_bg_color->darken(4));
|
||||
|
||||
wp_register_script('wu-template-previewer', wu_get_asset('template-previewer.js', 'js'), array(), wu_get_version());
|
||||
wp_register_script('wu-template-previewer', wu_get_asset('template-previewer.js', 'js'), [], wu_get_version());
|
||||
|
||||
wp_localize_script(
|
||||
'wu-template-previewer',
|
||||
'wu_template_previewer',
|
||||
array(
|
||||
[
|
||||
'domain' => str_replace('www.', '', (string) $current_site->domain),
|
||||
'current_template' => wu_request($this->get_preview_parameter(), false),
|
||||
'current_url' => wu_get_current_url(),
|
||||
'query_parameter' => $this->get_preview_parameter(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-template-previewer');
|
||||
|
||||
wp_enqueue_style('wu-template-previewer', wu_get_asset('template-previewer.css', 'css'), array(), wu_get_version());
|
||||
wp_enqueue_style('wu-template-previewer', wu_get_asset('template-previewer.css', 'css'), [], wu_get_version());
|
||||
|
||||
wp_add_inline_style(
|
||||
'wu-template-previewer',
|
||||
wu_get_template_contents(
|
||||
'dynamic-styles/template-previewer',
|
||||
array(
|
||||
[
|
||||
'bg_color' => $bg_color,
|
||||
'button_bg_color' => $button_bg_color,
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@ -159,15 +159,15 @@ class Template_Previewer {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function remove_unnecessary_styles() {
|
||||
public function remove_unnecessary_styles(): void {
|
||||
|
||||
global $wp_styles;
|
||||
|
||||
$wp_styles->queue = array(
|
||||
$wp_styles->queue = [
|
||||
'wu-admin',
|
||||
'wu-template-previewer',
|
||||
'dashicons',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,11 +184,11 @@ class Template_Previewer {
|
||||
*/
|
||||
public function append_preview_parameter($url, $path, $orig_scheme, $blog_id) {
|
||||
|
||||
$allowed_schemes = array(
|
||||
$allowed_schemes = [
|
||||
null,
|
||||
'http',
|
||||
'https',
|
||||
);
|
||||
];
|
||||
|
||||
if (in_array($orig_scheme, $allowed_schemes, true) === false) {
|
||||
return $url;
|
||||
@ -211,9 +211,9 @@ class Template_Previewer {
|
||||
*/
|
||||
public function get_preview_url($site_id) {
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
$this->get_preview_parameter() => $site_id,
|
||||
);
|
||||
];
|
||||
|
||||
if (wu_request('open')) {
|
||||
$args['open'] = 1;
|
||||
@ -228,7 +228,7 @@ class Template_Previewer {
|
||||
* @since 1.5.5
|
||||
* @return void
|
||||
*/
|
||||
public function template_previewer() {
|
||||
public function template_previewer(): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -243,18 +243,18 @@ class Template_Previewer {
|
||||
wp_die(__('This template is not available', 'wp-ultimo'));
|
||||
}
|
||||
|
||||
$categories = array();
|
||||
$categories = [];
|
||||
|
||||
$settings = $this->get_settings();
|
||||
|
||||
$render_parameters = array(
|
||||
$render_parameters = [
|
||||
'current_site' => $current_site,
|
||||
'categories' => $categories,
|
||||
'selected_template' => $selected_template,
|
||||
'tp' => $this,
|
||||
);
|
||||
];
|
||||
|
||||
$products_ids = isset($_COOKIE['wu_selected_products']) ? explode(',', (string) $_COOKIE['wu_selected_products']) : array();
|
||||
$products_ids = isset($_COOKIE['wu_selected_products']) ? explode(',', (string) $_COOKIE['wu_selected_products']) : [];
|
||||
|
||||
$products = array_map('wu_get_product', $products_ids);
|
||||
|
||||
@ -264,9 +264,9 @@ class Template_Previewer {
|
||||
if ( ! empty($products)) {
|
||||
$limits = new \WP_Ultimo\Objects\Limitations();
|
||||
|
||||
list($plan, $additional_products) = wu_segregate_products($products);
|
||||
[$plan, $additional_products] = wu_segregate_products($products);
|
||||
|
||||
$products = array_merge(array($plan), $additional_products);
|
||||
$products = array_merge([$plan], $additional_products);
|
||||
|
||||
foreach ($products as $product) {
|
||||
$limits = $limits->merge($product->get_limitations());
|
||||
@ -356,7 +356,7 @@ class Template_Previewer {
|
||||
$initial_pagenow = $GLOBALS['pagenow'] ?? '';
|
||||
$GLOBALS['pagenow'] = '';
|
||||
|
||||
$default_settings = array(
|
||||
$default_settings = [
|
||||
'bg_color' => '#f9f9f9',
|
||||
'button_bg_color' => '#00a1ff',
|
||||
'logo_url' => wu_get_network_logo(),
|
||||
@ -366,9 +366,9 @@ class Template_Previewer {
|
||||
'use_custom_logo' => false,
|
||||
'custom_logo' => false,
|
||||
'enabled' => true,
|
||||
);
|
||||
];
|
||||
|
||||
$saved_settings = wu_get_option(self::KEY, array());
|
||||
$saved_settings = wu_get_option(self::KEY, []);
|
||||
|
||||
$default_settings = array_merge($default_settings, $saved_settings);
|
||||
|
||||
|
@ -102,9 +102,9 @@ class Template_Switching_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wu_ajax_wu_switch_template', array($this, 'switch_template'));
|
||||
add_action('wu_ajax_wu_switch_template', [$this, 'switch_template']);
|
||||
|
||||
parent::init();
|
||||
}
|
||||
@ -116,16 +116,16 @@ class Template_Switching_Element extends Base_Element {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_register_script('wu-template-switching', wu_get_asset('template-switching.js', 'js'), array('jquery', 'wu-vue-apps', 'wu-selectizer', 'wp-hooks', 'wu-cookie-helpers'));
|
||||
wp_register_script('wu-template-switching', wu_get_asset('template-switching.js', 'js'), ['jquery', 'wu-vue-apps', 'wu-selectizer', 'wp-hooks', 'wu-cookie-helpers']);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-template-switching',
|
||||
'wu_template_switching_params',
|
||||
array(
|
||||
[
|
||||
'ajaxurl' => wu_ajax_url(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-template-switching');
|
||||
@ -139,39 +139,39 @@ class Template_Switching_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('Layout', 'wp-ultimo'),
|
||||
'desc' => __('Layout', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['template_selection_template'] = array(
|
||||
$fields['template_selection_template'] = [
|
||||
'type' => 'group',
|
||||
'desc' => Field_Templates_Manager::get_instance()->render_preview_block('template_selection'),
|
||||
'fields' => array(
|
||||
'template_selection_template' => array(
|
||||
'fields' => [
|
||||
'template_selection_template' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Template Selector Layout', 'wp-ultimo'),
|
||||
'placeholder' => __('Select your Layout', 'wp-ultimo'),
|
||||
'default' => 'clean',
|
||||
'options' => array($this, 'get_template_selection_templates'),
|
||||
'options' => [$this, 'get_template_selection_templates'],
|
||||
'wrapper_classes' => 'wu-flex-grow',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'template_selection_template',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$fields['_dev_note_develop_your_own_template_1'] = array(
|
||||
$fields['_dev_note_develop_your_own_template_1'] = [
|
||||
'type' => 'note',
|
||||
'order' => 99,
|
||||
'wrapper_classes' => 'sm:wu-p-0 sm:wu-block',
|
||||
'classes' => '',
|
||||
'desc' => sprintf('<div class="wu-p-4 wu-bg-blue-100 wu-text-grey-600">%s</div>', __('Want to add customized template selection templates?<br><a target="_blank" class="wu-no-underline" href="https://help.wpultimo.com/article/343-customize-your-checkout-flow-using-field-templates">See how you can do that here</a>.', 'wp-ultimo')),
|
||||
);
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -185,12 +185,12 @@ class Template_Switching_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Template',
|
||||
'Template Switching',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,16 +202,16 @@ class Template_Switching_Element extends Base_Element {
|
||||
public function defaults() {
|
||||
|
||||
$site_template_ids = wu_get_site_templates(
|
||||
array(
|
||||
[
|
||||
'fields' => 'ids',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return array(
|
||||
return [
|
||||
'slug' => 'template-switching',
|
||||
'template_selection_template' => 'clean',
|
||||
'template_selection_sites' => implode(',', $site_template_ids),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,7 +220,7 @@ class Template_Switching_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->site = wu_get_current_site();
|
||||
|
||||
@ -232,9 +232,9 @@ class Template_Switching_Element extends Base_Element {
|
||||
|
||||
$this->membership = $this->site->get_membership();
|
||||
|
||||
$this->products = array();
|
||||
$this->products = [];
|
||||
|
||||
$all_membership_products = array();
|
||||
$all_membership_products = [];
|
||||
|
||||
if ($this->membership) {
|
||||
$all_membership_products = $this->membership->get_all_products();
|
||||
@ -254,7 +254,7 @@ class Template_Switching_Element extends Base_Element {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->site = wu_mock_site();
|
||||
}
|
||||
@ -291,14 +291,14 @@ class Template_Switching_Element extends Base_Element {
|
||||
|
||||
if ($switch) {
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg(
|
||||
array(
|
||||
[
|
||||
'updated' => 1,
|
||||
),
|
||||
],
|
||||
$_SERVER['HTTP_REFERER']
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -326,7 +326,7 @@ class Template_Switching_Element extends Base_Element {
|
||||
$template_selection_field = $filter_template_limits->maybe_filter_template_selection_options($atts);
|
||||
|
||||
if ( ! isset($template_selection_field['sites'])) {
|
||||
$template_selection_field['sites'] = array();
|
||||
$template_selection_field['sites'] = [];
|
||||
}
|
||||
|
||||
$atts['template_selection_sites'] = implode(',', $template_selection_field['sites']);
|
||||
@ -339,11 +339,11 @@ class Template_Switching_Element extends Base_Element {
|
||||
|
||||
$categories = \WP_Ultimo\Models\Site::get_all_categories($sites);
|
||||
|
||||
$template_attributes = array(
|
||||
$template_attributes = [
|
||||
'sites' => $sites,
|
||||
'name' => '',
|
||||
'categories' => $categories,
|
||||
);
|
||||
];
|
||||
|
||||
$reducer_class = new \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Template_Selection();
|
||||
|
||||
@ -351,74 +351,74 @@ class Template_Switching_Element extends Base_Element {
|
||||
|
||||
$content = $template_class ? $template_class->render_container($template_attributes, $reducer_class) : __('Template does not exist.', 'wp-ultimo');
|
||||
|
||||
$checkout_fields['back_to_template_selection'] = array(
|
||||
$checkout_fields['back_to_template_selection'] = [
|
||||
'type' => 'note',
|
||||
'order' => 0,
|
||||
'desc' => sprintf('<a href="#" class="wu-no-underline wu-mt-1 wu-uppercase wu-text-2xs wu-font-semibold wu-text-gray-600" v-on:click.prevent="template_id = original_template_id; confirm_switch = false">%s</a>', __('← Back to Template Selection', 'wp-ultimo')),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-init:original_template_id' => $this->site->get_template_id(),
|
||||
'v-show' => 'template_id != original_template_id',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$checkout_fields['template_element'] = array(
|
||||
$checkout_fields['template_element'] = [
|
||||
'type' => 'note',
|
||||
'wrapper_classes' => 'wu-w-full',
|
||||
'classes' => 'wu-w-full',
|
||||
'desc' => $content,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'template_id == original_template_id',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$checkout_fields['confirm_switch'] = array(
|
||||
$checkout_fields['confirm_switch'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm template switch?', 'wp-ultimo'),
|
||||
'desc' => __('Switching your current template completely overwrites the content of your site with the contents of the newly chosen template. All customizations will be lost. This action cannot be undone.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'wrapper_classes' => '',
|
||||
'value' => 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirm_switch',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'template_id != 0 && template_id != original_template_id',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$checkout_fields['submit_switch'] = array(
|
||||
$checkout_fields['submit_switch'] = [
|
||||
'type' => 'link',
|
||||
'display_value' => __('Process Switch', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-text-right wu-bg-gray-100',
|
||||
'classes' => 'button button-primary',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
'v-show' => 'confirm_switch',
|
||||
'v-on:click.prevent' => 'ready = true',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$checkout_fields['template_id'] = array(
|
||||
$checkout_fields['template_id'] = [
|
||||
'type' => 'hidden',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'template_id',
|
||||
'v-init:template_id' => $this->site->get_template_id(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$section_slug = 'wu-template-switching-form';
|
||||
|
||||
$form = new Form(
|
||||
$section_slug,
|
||||
$checkout_fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-striped wu-widget-inset',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-py-5 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
ob_start();
|
||||
|
@ -84,7 +84,7 @@ class Thank_You_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
}
|
||||
@ -130,28 +130,28 @@ class Thank_You_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
$has_pending_site = $this->membership ? (bool) $this->membership->get_pending_site() : false;
|
||||
$is_publishing = $has_pending_site ? $this->membership->get_pending_site()->is_publishing() : false;
|
||||
|
||||
wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), array(), wu_get_version());
|
||||
wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), [], wu_get_version());
|
||||
|
||||
wp_localize_script(
|
||||
'wu-thank-you',
|
||||
'wu_thank_you',
|
||||
array(
|
||||
[
|
||||
'creating' => $is_publishing,
|
||||
'has_pending_site' => $has_pending_site,
|
||||
'next_queue' => wu_get_next_queue_run(),
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'resend_verification_email_nonce' => wp_create_nonce('wu_resend_verification_email_nonce'),
|
||||
'membership_hash' => $this->membership ? $this->membership->get_hash() : false,
|
||||
'i18n' => array(
|
||||
'i18n' => [
|
||||
'resending_verification_email' => __('Resending verification email...', 'wp-ultimo'),
|
||||
'email_sent' => __('Verification email sent!', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-thank-you');
|
||||
@ -207,62 +207,62 @@ class Thank_You_Element extends Base_Element {
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['header'] = array(
|
||||
$fields['header'] = [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title', 'wp-ultimo'),
|
||||
'value' => __('Thank You', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['thank_you_message'] = array(
|
||||
$fields['thank_you_message'] = [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Thank You Message', 'wp-ultimo'),
|
||||
'desc' => __('Shortcodes are supported.', 'wp-ultimo'),
|
||||
'value' => __('Thank you for your payment! Your transaction has been completed and a receipt for your purchase has been emailed to you.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 4,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['title_pending'] = array(
|
||||
$fields['title_pending'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Title (Pending)', 'wp-ultimo'),
|
||||
'value' => __('Thank You', 'wp-ultimo'),
|
||||
'desc' => __('Leave blank to hide the title completely. This title is used when the payment was not yet confirmed.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['thank_you_message_pending'] = array(
|
||||
$fields['thank_you_message_pending'] = [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Thank You Message (Pending)', 'wp-ultimo'),
|
||||
'desc' => __('This content is used when the payment was not yet confirmed. Shortcodes are supported.', 'wp-ultimo'),
|
||||
'value' => __('Thank you for your order! We are waiting on the payment processor to confirm your payment, which can take up to 5 minutes. We will notify you via email when your site is ready.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 4,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['no_sites_message'] = array(
|
||||
$fields['no_sites_message'] = [
|
||||
'type' => 'textarea',
|
||||
'title' => __('No Sites Message', 'wp-ultimo'),
|
||||
'desc' => __('A message to show if membership has no sites. Shortcodes are supported.', 'wp-ultimo'),
|
||||
'value' => __('No sites found', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 4,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -286,13 +286,13 @@ class Thank_You_Element extends Base_Element {
|
||||
*/
|
||||
public function keywords() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'WP Ultimo',
|
||||
'WP Multisite WaaS',
|
||||
'Thank You',
|
||||
'Form',
|
||||
'Cart',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -311,13 +311,13 @@ class Thank_You_Element extends Base_Element {
|
||||
*/
|
||||
public function defaults() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'title' => __('Thank You', 'wp-ultimo'),
|
||||
'thank_you_message' => __('Thank you for your payment! Your transaction has been completed and a receipt for your purchase has been emailed to you.', 'wp-ultimo'),
|
||||
'title_pending' => __('Thank You', 'wp-ultimo'),
|
||||
'thank_you_message_pending' => __('Thank you for your order! We are waiting on the payment processor to confirm your payment, which can take up to 5 minutes. We will notify you via email when your site is ready.', 'wp-ultimo'),
|
||||
'no_sites_message' => __('No sites found', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,7 +326,7 @@ class Thank_You_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
public function setup(): void {
|
||||
|
||||
$this->payment = wu_get_payment_by_hash(wu_request('payment'));
|
||||
|
||||
@ -346,9 +346,9 @@ class Thank_You_Element extends Base_Element {
|
||||
|
||||
$this->customer = $this->membership->get_customer();
|
||||
|
||||
add_filter('document_title_parts', array($this, 'replace_page_title'));
|
||||
add_filter('document_title_parts', [$this, 'replace_page_title']);
|
||||
|
||||
add_filter('the_title', array($this, 'maybe_replace_page_title'), 10, 2);
|
||||
add_filter('the_title', [$this, 'maybe_replace_page_title'], 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -357,7 +357,7 @@ class Thank_You_Element extends Base_Element {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_preview() {
|
||||
public function setup_preview(): void {
|
||||
|
||||
$this->payment = wu_mock_payment();
|
||||
|
||||
@ -395,7 +395,7 @@ class Thank_You_Element extends Base_Element {
|
||||
$conversion_snippets = $atts['checkout_form']->get_conversion_snippets();
|
||||
|
||||
if ( ! empty($conversion_snippets)) {
|
||||
$product_ids = array();
|
||||
$product_ids = [];
|
||||
|
||||
foreach ($this->payment->get_line_items() as $line_item) {
|
||||
if ($line_item->get_product_id()) {
|
||||
@ -405,7 +405,7 @@ class Thank_You_Element extends Base_Element {
|
||||
|
||||
$conversion_placeholders = apply_filters(
|
||||
'wu_conversion_placeholders',
|
||||
array(
|
||||
[
|
||||
'CUSTOMER_ID' => $this->customer->get_id(),
|
||||
'CUSTOMER_EMAIL' => $this->customer->get_email_address(),
|
||||
'MEMBERSHIP_DURATION' => $this->membership->get_recurring_description(),
|
||||
@ -415,7 +415,7 @@ class Thank_You_Element extends Base_Element {
|
||||
'ORDER_CURRENCY' => $this->payment->get_currency(),
|
||||
'ORDER_PRODUCTS' => array_values($product_ids),
|
||||
'ORDER_AMOUNT' => $this->payment->get_total(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($conversion_placeholders as $placeholder => $value) {
|
||||
|
@ -28,7 +28,7 @@ class Toolbox {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action('init', array($this, 'load_toolbox'));
|
||||
add_action('init', [$this, 'load_toolbox']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,14 +56,14 @@ class Toolbox {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function load_toolbox() {
|
||||
public function load_toolbox(): void {
|
||||
|
||||
if ($this->is_toolbox_enabled()) {
|
||||
add_action('wp_footer', array($this, 'output'));
|
||||
add_action('wp_footer', [$this, 'output']);
|
||||
|
||||
add_action('admin_footer', array($this, 'output'));
|
||||
add_action('admin_footer', [$this, 'output']);
|
||||
|
||||
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
|
||||
add_action('wp_enqueue_scripts', [$this, 'enqueue_styles']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ class Toolbox {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_styles() {
|
||||
public function enqueue_styles(): void {
|
||||
|
||||
wp_enqueue_style('wu-admin');
|
||||
}
|
||||
@ -84,18 +84,18 @@ class Toolbox {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
$current_site = wu_get_current_site();
|
||||
|
||||
wu_get_template(
|
||||
'ui/toolbox',
|
||||
array(
|
||||
[
|
||||
'toolbox' => $this,
|
||||
'current_site' => $current_site,
|
||||
'customer' => $current_site ? $current_site->get_customer() : false,
|
||||
'membership' => $current_site ? $current_site->get_membership() : false,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class Tours {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $tours = array();
|
||||
protected $tours = [];
|
||||
|
||||
/**
|
||||
* Element construct.
|
||||
@ -36,11 +36,11 @@ class Tours {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action('wp_ajax_wu_mark_tour_as_finished', array($this, 'mark_as_finished'));
|
||||
add_action('wp_ajax_wu_mark_tour_as_finished', [$this, 'mark_as_finished']);
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'register_scripts'));
|
||||
add_action('admin_enqueue_scripts', [$this, 'register_scripts']);
|
||||
|
||||
add_action('in_admin_footer', array($this, 'enqueue_scripts'));
|
||||
add_action('in_admin_footer', [$this, 'enqueue_scripts']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ class Tours {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function mark_as_finished() {
|
||||
public function mark_as_finished(): void {
|
||||
|
||||
check_ajax_referer('wu_tour_finished', 'nonce');
|
||||
|
||||
@ -70,11 +70,11 @@ class Tours {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
WP_Ultimo()->scripts->register_script('wu-shepherd', wu_get_asset('lib/shepherd.js', 'js'), array());
|
||||
WP_Ultimo()->scripts->register_script('wu-shepherd', wu_get_asset('lib/shepherd.js', 'js'), []);
|
||||
|
||||
WP_Ultimo()->scripts->register_script('wu-tours', wu_get_asset('tours.js', 'js'), array('wu-shepherd', 'underscore'));
|
||||
WP_Ultimo()->scripts->register_script('wu-tours', wu_get_asset('tours.js', 'js'), ['wu-shepherd', 'underscore']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +83,7 @@ class Tours {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
public function enqueue_scripts(): void {
|
||||
|
||||
if ($this->has_tours()) {
|
||||
wp_localize_script('wu-tours', 'wu_tours', $this->tours);
|
||||
@ -91,14 +91,14 @@ class Tours {
|
||||
wp_localize_script(
|
||||
'wu-tours',
|
||||
'wu_tours_vars',
|
||||
array(
|
||||
[
|
||||
'ajaxurl' => wu_ajax_url(),
|
||||
'nonce' => wp_create_nonce('wu_tour_finished'),
|
||||
'i18n' => array(
|
||||
'i18n' => [
|
||||
'next' => __('Next', 'wp-ultimo'),
|
||||
'finish' => __('Close', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-tours');
|
||||
@ -128,7 +128,7 @@ class Tours {
|
||||
* @param boolean $once Whether or not we will show this more than once.
|
||||
* @return void
|
||||
*/
|
||||
public function create_tour($id, $steps = array(), $once = true) {
|
||||
public function create_tour($id, $steps = [], $once = true): void {
|
||||
|
||||
if (did_action('in_admin_header')) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user