Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -74,9 +74,9 @@ class About_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the title of the page.
|
||||
@ -117,7 +117,7 @@ class About_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
wu_get_template('about');
|
||||
}
|
||||
@ -128,7 +128,7 @@ class About_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
@ -140,7 +140,7 @@ class About_Admin_Page extends Base_Admin_Page {
|
||||
background: url("%s") right bottom no-repeat;
|
||||
background-size: 60%%;
|
||||
}',
|
||||
wu_get_asset('bg-setup.png', 'img')
|
||||
wu_get_asset('bg-setup.webp', 'img')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ abstract class Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @var array
|
||||
*/
|
||||
public $action_links = array();
|
||||
public $action_links = [];
|
||||
|
||||
/**
|
||||
* Holds the page title
|
||||
@ -159,9 +159,9 @@ abstract class Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Creates the page with the necessary hooks.
|
||||
@ -173,9 +173,9 @@ abstract class Base_Admin_Page {
|
||||
* Adds the page to all the necessary admin panels.
|
||||
*/
|
||||
foreach ($this->supported_panels as $panel => $capability) {
|
||||
add_action($panel, array($this, 'add_menu_page'));
|
||||
add_action($panel, [$this, 'add_menu_page']);
|
||||
|
||||
add_action($panel, array($this, 'fix_subdomain_name'), 100);
|
||||
add_action($panel, [$this, 'fix_subdomain_name'], 100);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -186,7 +186,7 @@ abstract class Base_Admin_Page {
|
||||
/*
|
||||
* Add forms
|
||||
*/
|
||||
add_action('plugins_loaded', array($this, 'register_forms'));
|
||||
add_action('plugins_loaded', [$this, 'register_forms']);
|
||||
|
||||
/**
|
||||
* Allow plugin developers to run additional things when pages are registered.
|
||||
@ -236,7 +236,7 @@ abstract class Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function fix_subdomain_name() {
|
||||
public function fix_subdomain_name(): void {
|
||||
|
||||
global $submenu;
|
||||
|
||||
@ -271,7 +271,7 @@ abstract class Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function install_hooks() {
|
||||
public function install_hooks(): void {
|
||||
|
||||
/**
|
||||
* Get the action links
|
||||
@ -309,9 +309,9 @@ abstract class Base_Admin_Page {
|
||||
/**
|
||||
* Fixes menu highlights when necessary.
|
||||
*/
|
||||
add_filter('parent_file', array($this, 'fix_menu_highlight'), 99);
|
||||
add_filter('parent_file', [$this, 'fix_menu_highlight'], 99);
|
||||
|
||||
add_filter('submenu_file', array($this, 'fix_menu_highlight'), 99);
|
||||
add_filter('submenu_file', [$this, 'fix_menu_highlight'], 99);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -335,7 +335,7 @@ abstract class Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
final public function display() {
|
||||
final public function display(): void {
|
||||
|
||||
/**
|
||||
* 'Hack-y' solution for the customer facing title problem... but good enough for now.
|
||||
@ -411,7 +411,7 @@ abstract class Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function add_menu_page() {
|
||||
public function add_menu_page(): void {
|
||||
|
||||
/**
|
||||
* Create the admin page or sub-page
|
||||
@ -441,7 +441,7 @@ abstract class Base_Admin_Page {
|
||||
$this->get_menu_label(),
|
||||
$this->get_capability(),
|
||||
$this->id,
|
||||
array($this, 'display'),
|
||||
[$this, 'display'],
|
||||
$this->menu_icon,
|
||||
$this->position
|
||||
);
|
||||
@ -465,7 +465,7 @@ abstract class Base_Admin_Page {
|
||||
$this->get_menu_label(),
|
||||
$this->get_capability(),
|
||||
$this->id,
|
||||
array($this, 'display')
|
||||
[$this, 'display']
|
||||
);
|
||||
}
|
||||
|
||||
@ -475,14 +475,14 @@ abstract class Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_branding() {
|
||||
public function add_branding(): void {
|
||||
|
||||
if (apply_filters('wp_ultimo_remove_branding', false) === false) {
|
||||
add_action('in_admin_header', array($this, 'brand_header'));
|
||||
add_action('in_admin_header', [$this, 'brand_header']);
|
||||
|
||||
add_action('wu_header_right', array($this, 'add_container_toggle'));
|
||||
add_action('wu_header_right', [$this, 'add_container_toggle']);
|
||||
|
||||
add_action('in_admin_footer', array($this, 'brand_footer'));
|
||||
add_action('in_admin_footer', [$this, 'brand_footer']);
|
||||
|
||||
add_filter('admin_footer_text', '__return_empty_string', 1000);
|
||||
|
||||
@ -496,13 +496,13 @@ abstract class Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_container_toggle() {
|
||||
public function add_container_toggle(): void {
|
||||
|
||||
wu_get_template(
|
||||
'ui/container-toggle',
|
||||
array(
|
||||
[
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -512,13 +512,13 @@ abstract class Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function brand_header() {
|
||||
public function brand_header(): void {
|
||||
|
||||
wu_get_template(
|
||||
'ui/branding/header',
|
||||
array(
|
||||
[
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -528,13 +528,13 @@ abstract class Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function brand_footer() {
|
||||
public function brand_footer(): void {
|
||||
|
||||
wu_get_template(
|
||||
'ui/branding/footer',
|
||||
array(
|
||||
[
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -544,7 +544,7 @@ abstract class Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_admin_body_classes() {
|
||||
public function add_admin_body_classes(): void {
|
||||
|
||||
add_action(
|
||||
'admin_body_class',
|
||||
@ -579,28 +579,28 @@ abstract class Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
final public function enqueue_default_hooks() {
|
||||
final public function enqueue_default_hooks(): void {
|
||||
|
||||
if ($this->page_hook) {
|
||||
add_action("load-$this->page_hook", array($this, 'install_hooks'));
|
||||
add_action("load-$this->page_hook", [$this, 'install_hooks']);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'page_loaded'));
|
||||
add_action("load-$this->page_hook", [$this, 'page_loaded']);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'hooks'));
|
||||
add_action("load-$this->page_hook", [$this, 'hooks']);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'register_scripts'), 10);
|
||||
add_action("load-$this->page_hook", [$this, 'register_scripts'], 10);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'screen_options'), 10);
|
||||
add_action("load-$this->page_hook", [$this, 'screen_options'], 10);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'register_widgets'), 20);
|
||||
add_action("load-$this->page_hook", [$this, 'register_widgets'], 20);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'add_admin_body_classes'), 20);
|
||||
add_action("load-$this->page_hook", [$this, 'add_admin_body_classes'], 20);
|
||||
|
||||
/*
|
||||
* Add the page to WP Multisite WaaS branding (aka top-bar and footer)
|
||||
*/
|
||||
if (is_network_admin()) {
|
||||
add_action("load-$this->page_hook", array($this, 'add_branding'));
|
||||
add_action("load-$this->page_hook", [$this, 'add_branding']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -622,11 +622,11 @@ abstract class Base_Admin_Page {
|
||||
public function get_title_links() {
|
||||
|
||||
if (wu_get_documentation_url($this->get_id(), false)) {
|
||||
$this->action_links[] = array(
|
||||
$this->action_links[] = [
|
||||
'url' => wu_get_documentation_url($this->get_id()),
|
||||
'label' => __('Documentation'),
|
||||
'icon' => 'wu-open-book',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -647,7 +647,7 @@ abstract class Base_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $original_parameters = array();
|
||||
protected $original_parameters = [];
|
||||
|
||||
/**
|
||||
* If this customer facing page has menu settings.
|
||||
@ -62,7 +62,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->change_parameters();
|
||||
|
||||
@ -70,17 +70,17 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
|
||||
$this->editing = wu_request('customize');
|
||||
|
||||
add_action('wu_enqueue_extra_hooks', array($this, 'additional_hooks'));
|
||||
add_action('wu_enqueue_extra_hooks', [$this, 'additional_hooks']);
|
||||
|
||||
add_action('updated_user_meta', array($this, 'save_settings'), 10, 4);
|
||||
add_action('updated_user_meta', [$this, 'save_settings'], 10, 4);
|
||||
|
||||
wu_register_form(
|
||||
"edit_admin_page_$this->id",
|
||||
array(
|
||||
'render' => array($this, 'render_edit_page'),
|
||||
'handler' => array($this, 'handle_edit_page'),
|
||||
[
|
||||
'render' => [$this, 'render_edit_page'],
|
||||
'handler' => [$this, 'handle_edit_page'],
|
||||
'capability' => 'exist',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->register_page_settings();
|
||||
@ -92,13 +92,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function change_parameters() {
|
||||
public function change_parameters(): void {
|
||||
|
||||
$this->original_parameters = array(
|
||||
$this->original_parameters = [
|
||||
'title' => $this->get_title(),
|
||||
'position' => $this->position,
|
||||
'menu_icon' => $this->menu_icon,
|
||||
);
|
||||
];
|
||||
|
||||
$new_parameters = $this->get_page_settings();
|
||||
|
||||
@ -114,71 +114,71 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_edit_page() {
|
||||
public function render_edit_page(): void {
|
||||
|
||||
$settings = $this->get_page_settings();
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$fields['title'] = array(
|
||||
$fields['title'] = [
|
||||
'type' => 'text',
|
||||
'title' => __('Page & Menu Title', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'title', ''),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->menu_settings) {
|
||||
$fields['position'] = array(
|
||||
$fields['position'] = [
|
||||
'type' => 'number',
|
||||
'title' => __('Menu', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'position', ''),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$fields['menu_icon'] = array(
|
||||
$fields['menu_icon'] = [
|
||||
'type' => 'dashicon',
|
||||
'title' => __('Menu Icon', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'menu_icon', ''),
|
||||
'tooltip' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$fields['save_line'] = array(
|
||||
$fields['save_line'] = [
|
||||
'type' => 'group',
|
||||
'classes' => 'wu-justify-between',
|
||||
'wrapper_classes' => 'wu-bg-gray-100',
|
||||
'fields' => array(
|
||||
'reset' => array(
|
||||
'fields' => [
|
||||
'reset' => [
|
||||
'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',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$fields = apply_filters("wu_customer_facing_page_{$this->id}_fields", $fields);
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'edit_page',
|
||||
$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}_page_customize",
|
||||
'data-state' => wu_convert_to_state(),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
echo '<div class="wu-styling">';
|
||||
@ -194,16 +194,16 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_edit_page() {
|
||||
public function handle_edit_page(): void {
|
||||
|
||||
$settings_to_save = wu_request('submit') !== 'restore' ? $_POST : array(); // don't worry, this gets cleaned later on.
|
||||
$settings_to_save = wu_request('submit') !== 'restore' ? $_POST : []; // don't worry, this gets cleaned later on.
|
||||
|
||||
$this->save_page_settings($settings_to_save);
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -239,14 +239,14 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_page_settings() {
|
||||
public function register_page_settings(): void {
|
||||
|
||||
wu_register_settings_field(
|
||||
'core',
|
||||
$this->get_page_unique_id() . '_settings',
|
||||
array(
|
||||
[
|
||||
'raw' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_page_settings() {
|
||||
|
||||
$atts = wu_get_setting($this->get_page_unique_id() . '_settings', array());
|
||||
$atts = wu_get_setting($this->get_page_unique_id() . '_settings', []);
|
||||
|
||||
return wp_parse_args($atts, $this->get_defaults());
|
||||
}
|
||||
@ -284,13 +284,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function additional_hooks() {
|
||||
public function additional_hooks(): void {
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'register_additional_scripts'));
|
||||
add_action("load-$this->page_hook", [$this, 'register_additional_scripts']);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'add_additional_body_classes'));
|
||||
add_action("load-$this->page_hook", [$this, 'add_additional_body_classes']);
|
||||
|
||||
add_action("load-$this->page_hook", array($this, 'additional_on_page_load'));
|
||||
add_action("load-$this->page_hook", [$this, 'additional_on_page_load']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,13 +299,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function additional_on_page_load() {
|
||||
public function additional_on_page_load(): void {
|
||||
|
||||
add_filter('wu_element_display_super_admin_notice', array($this, 'is_edit_mode'));
|
||||
add_filter('wu_element_display_super_admin_notice', [$this, 'is_edit_mode']);
|
||||
|
||||
add_action("get_user_option_meta-box-order_{$this->page_hook}", array($this, 'get_settings'), 10, 3);
|
||||
add_action("get_user_option_meta-box-order_{$this->page_hook}", [$this, 'get_settings'], 10, 3);
|
||||
|
||||
add_action("get_user_option_screen_layout_{$this->page_hook}", array($this, 'get_settings'), 10, 3);
|
||||
add_action("get_user_option_screen_layout_{$this->page_hook}", [$this, 'get_settings'], 10, 3);
|
||||
|
||||
/**
|
||||
* 'Hack-y' solution for the customer facing title problem... but good enough for now.
|
||||
@ -330,7 +330,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_additional_body_classes() {
|
||||
public function add_additional_body_classes(): void {
|
||||
|
||||
add_action(
|
||||
'admin_body_class',
|
||||
@ -349,7 +349,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_additional_scripts() {
|
||||
public function register_additional_scripts(): void {
|
||||
|
||||
\WP_Ultimo\Scripts::get_instance()->register_style('wu-admin-screen', wu_get_asset('admin-screen.css', 'css'));
|
||||
|
||||
@ -360,21 +360,21 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
}
|
||||
|
||||
if (current_user_can($this->edit_capability)) {
|
||||
\WP_Ultimo\Scripts::get_instance()->register_script('wu-admin-screen', wu_get_asset('admin-screen.js', 'js'), array('jquery', 'wu-fonticonpicker'));
|
||||
\WP_Ultimo\Scripts::get_instance()->register_script('wu-admin-screen', wu_get_asset('admin-screen.js', 'js'), ['jquery', 'wu-fonticonpicker']);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-admin-screen',
|
||||
'wu_admin_screen',
|
||||
array(
|
||||
[
|
||||
'page_customize_link' => wu_get_form_url("edit_admin_page_$this->id"),
|
||||
'customize_link' => add_query_arg('customize', 1),
|
||||
'close_link' => remove_query_arg('customize'),
|
||||
'i18n' => array(
|
||||
'i18n' => [
|
||||
'page_customize_label' => __('Customize Page', 'wp-ultimo'),
|
||||
'customize_label' => __('Customize Elements', 'wp-ultimo'),
|
||||
'close_label' => __('Exit Customize Mode', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-admin-screen');
|
||||
@ -411,13 +411,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
* @param mixed $_meta_value The original saved value.
|
||||
* @return void
|
||||
*/
|
||||
public function save_settings($meta_id, $user_id, $meta_key, $_meta_value) {
|
||||
public function save_settings($meta_id, $user_id, $meta_key, $_meta_value): void {
|
||||
|
||||
if (wu_request('action') !== 'meta-box-order') {
|
||||
return;
|
||||
}
|
||||
|
||||
$is_this_page = strpos((string) wu_request('page'), $this->id) !== false;
|
||||
$is_this_page = str_contains((string) wu_request('page'), $this->id);
|
||||
|
||||
if ( ! $is_this_page) {
|
||||
return;
|
||||
@ -460,7 +460,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page {
|
||||
$this->title . ' ' . $this->get_badge(),
|
||||
$this->get_capability(),
|
||||
$this->id,
|
||||
array($this, 'display'),
|
||||
[$this, 'display'],
|
||||
$this->menu_icon,
|
||||
$this->position
|
||||
);
|
||||
|
@ -76,9 +76,9 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_edit_broadcasts',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to register widgets, if they need them.
|
||||
@ -86,72 +86,72 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'events',
|
||||
array(
|
||||
[
|
||||
'title' => __('Events', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
|
||||
'query_filter' => array($this, 'events_query_filter'),
|
||||
)
|
||||
'query_filter' => [$this, 'events_query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'html_attr' => array(
|
||||
[
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'save_broadcast',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'type' => $this->get_object()->get_type(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'type' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'type' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Broadcast Type', 'wp-ultimo'),
|
||||
'placeholder' => __('Type', 'wp-ultimo'),
|
||||
'desc' => __('Broadcast type cannot be edited.', 'wp-ultimo'),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'broadcast_email' => __('Email', 'wp-ultimo'),
|
||||
'broadcast_notice' => __('Admin Notice', 'wp-ultimo'),
|
||||
),
|
||||
],
|
||||
'value' => $this->get_object()->get_type(),
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'disabled' => 'disabled',
|
||||
'name' => '',
|
||||
),
|
||||
),
|
||||
'notice_type' => array(
|
||||
],
|
||||
],
|
||||
'notice_type' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Broadcast Status', 'wp-ultimo'),
|
||||
'placeholder' => __('Status', 'wp-ultimo'),
|
||||
'desc' => __('This option determines the color of the admin notice.', 'wp-ultimo'),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'info' => __('Info (blue)', 'wp-ultimo'),
|
||||
'success' => __('Success (green)', 'wp-ultimo'),
|
||||
'warning' => __('Warning (yellow)', 'wp-ultimo'),
|
||||
'error' => __('Error (red)', 'wp-ultimo'),
|
||||
),
|
||||
],
|
||||
'value' => $this->get_object()->get_notice_type(),
|
||||
'tooltip' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => 'type === "broadcast_notice"',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box('wp-ultimo-broadcast-customer-targets', __('Customer Targets', 'wp-ultimo'), array($this, 'output_default_widget_customer_targets'), get_current_screen()->id, 'side');
|
||||
add_meta_box('wp-ultimo-broadcast-customer-targets', __('Customer Targets', 'wp-ultimo'), [$this, 'output_default_widget_customer_targets'], get_current_screen()->id, 'side');
|
||||
|
||||
add_meta_box('wp-ultimo-broadcast-product-targets', __('Product Targets', 'wp-ultimo'), array($this, 'output_default_widget_product_targets'), get_current_screen()->id, 'side');
|
||||
add_meta_box('wp-ultimo-broadcast-product-targets', __('Product Targets', 'wp-ultimo'), [$this, 'output_default_widget_product_targets'], get_current_screen()->id, 'side');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,13 +160,13 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_customer_targets() {
|
||||
public function output_default_widget_customer_targets(): void {
|
||||
|
||||
$object = $this->get_object();
|
||||
|
||||
$all_targets = $object->get_message_targets();
|
||||
|
||||
$targets = array();
|
||||
$targets = [];
|
||||
|
||||
$customer_targets = wu_get_isset($all_targets, 'customers', '');
|
||||
|
||||
@ -198,9 +198,9 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
case $targets_count === 1:
|
||||
$customer = wu_get_customer($targets[0]);
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'id' => $customer->get_id(),
|
||||
);
|
||||
];
|
||||
|
||||
$customer_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts);
|
||||
|
||||
@ -209,10 +209,10 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
32,
|
||||
'identicon',
|
||||
'',
|
||||
array(
|
||||
[
|
||||
'force_display' => true,
|
||||
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$display_name = $customer->get_display_name();
|
||||
@ -242,14 +242,14 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
32,
|
||||
'identicon',
|
||||
'',
|
||||
array(
|
||||
[
|
||||
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'id' => $customer->get_id(),
|
||||
);
|
||||
];
|
||||
|
||||
$customer_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts);
|
||||
|
||||
@ -257,13 +257,13 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
}
|
||||
|
||||
if ($targets_count < 7) {
|
||||
$modal_atts = array(
|
||||
$modal_atts = [
|
||||
'action' => 'wu_modal_targets_display',
|
||||
'object_id' => $object->get_id(),
|
||||
'width' => '400',
|
||||
'height' => '360',
|
||||
'target_type' => 'customers',
|
||||
);
|
||||
];
|
||||
|
||||
$html .= sprintf(
|
||||
'<div class="wu-inline-block wu--mr-4">
|
||||
@ -277,13 +277,13 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
} else {
|
||||
$count = $targets_count - 6;
|
||||
|
||||
$modal_atts = array(
|
||||
$modal_atts = [
|
||||
'action' => 'wu_modal_targets_display',
|
||||
'object_id' => $object->get_id(),
|
||||
'width' => '400',
|
||||
'height' => '360',
|
||||
'target_type' => 'customers',
|
||||
);
|
||||
];
|
||||
|
||||
$html .= sprintf(
|
||||
'<div class="wu-inline-block wu-ml-4">
|
||||
@ -310,25 +310,25 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_product_targets() {
|
||||
public function output_default_widget_product_targets(): void {
|
||||
|
||||
$object = $this->get_object();
|
||||
|
||||
$targets = wu_get_broadcast_targets($object->get_id(), 'products');
|
||||
|
||||
$product_targets = array();
|
||||
$product_targets = [];
|
||||
|
||||
if ($targets) {
|
||||
foreach ($targets as $key => $value) {
|
||||
$product = wu_get_product($value);
|
||||
|
||||
if ($product) {
|
||||
$modal_atts = array(
|
||||
$modal_atts = [
|
||||
'action' => 'wu_modal_product_targets_display',
|
||||
'product_id' => $product->get_id(),
|
||||
'width' => '400',
|
||||
'height' => '360',
|
||||
);
|
||||
];
|
||||
|
||||
$link = wu_get_form_url('view_broadcast_targets', $modal_atts);
|
||||
|
||||
@ -347,23 +347,23 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
// translators: %s is the number of customers.
|
||||
$description = sprintf(__('%s customer(s) targeted.', 'wp-ultimo'), $customer_count);
|
||||
|
||||
$product_targets[ $key ] = array(
|
||||
$product_targets[ $key ] = [
|
||||
'link' => $link,
|
||||
'avatar' => $image,
|
||||
'display_name' => $product->get_name(),
|
||||
'id' => $product->get_id(),
|
||||
'description' => $description,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'targets' => $product_targets,
|
||||
'loading_text' => __('Loading...', 'wp-ultimo'),
|
||||
'wrapper_class' => 'wu-bg-gray-100 wu--mt-3 wu--mb-6 wu--mx-3',
|
||||
'modal_class' => 'wubox',
|
||||
);
|
||||
];
|
||||
|
||||
wu_get_template('broadcast/widget-targets', $args);
|
||||
}
|
||||
@ -398,7 +398,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -409,7 +409,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Broadcast', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Broadcast', 'wp-ultimo'),
|
||||
'updated_message' => __('Broadcast updated with success!', 'wp-ultimo'),
|
||||
@ -419,7 +419,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Broadcast', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -432,10 +432,10 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'broadcast',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -495,10 +495,10 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function events_query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'broadcast',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_broadcasts',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register ajax forms that we use for send broadcasts.
|
||||
@ -62,28 +62,28 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add new broadcast notice.
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_broadcast_message',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_broadcast_modal'),
|
||||
'handler' => array($this, 'handle_add_new_broadcast_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_broadcast_modal'],
|
||||
'handler' => [$this, 'handle_add_new_broadcast_modal'],
|
||||
'capability' => 'wu_add_broadcasts',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
* Ajax to render the broadcast targets modal.
|
||||
*/
|
||||
add_action('wu_ajax_wu_modal_targets_display', array($this, 'display_targets_modal'));
|
||||
add_action('wu_ajax_wu_modal_targets_display', [$this, 'display_targets_modal']);
|
||||
|
||||
/**
|
||||
* Ajax to render the targets modal with customers from a specific membership.
|
||||
*/
|
||||
add_action('wu_ajax_wu_modal_product_targets_display', array($this, 'display_product_targets_modal'));
|
||||
add_action('wu_ajax_wu_modal_product_targets_display', [$this, 'display_product_targets_modal']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,7 +92,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
@ -105,7 +105,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function display_targets_modal() {
|
||||
public function display_targets_modal(): void {
|
||||
|
||||
$broadcast_id = wu_request('object_id');
|
||||
|
||||
@ -115,16 +115,16 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
$targets = wu_get_broadcast_targets($object->get_id(), $target_type);
|
||||
|
||||
$display_targets = array();
|
||||
$display_targets = [];
|
||||
|
||||
if ($targets) {
|
||||
if ($target_type === 'customers') {
|
||||
foreach ($targets as $key => $value) {
|
||||
$customer = wu_get_customer($value);
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'id' => $customer->get_id(),
|
||||
);
|
||||
];
|
||||
|
||||
$link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts);
|
||||
|
||||
@ -133,19 +133,19 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
48,
|
||||
'identicon',
|
||||
'',
|
||||
array(
|
||||
[
|
||||
'force_display' => true,
|
||||
'class' => 'wu-rounded-full',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$display_targets[ $key ] = array(
|
||||
$display_targets[ $key ] = [
|
||||
'link' => $link,
|
||||
'avatar' => $avatar,
|
||||
'display_name' => $customer->get_display_name(),
|
||||
'id' => $customer->get_id(),
|
||||
'description' => $customer->get_email_address(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,9 +153,9 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
foreach ($targets as $key => $value) {
|
||||
$product = wu_get_product($value);
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'id' => $product->get_id(),
|
||||
);
|
||||
];
|
||||
|
||||
$link = wu_network_admin_url('wp-ultimo-edit-product', $url_atts);
|
||||
|
||||
@ -178,22 +178,22 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
// translators: %s is the number of customers.
|
||||
$description = sprintf(__('%s customer(s) targeted.', 'wp-ultimo'), $customer_count);
|
||||
|
||||
$display_targets[ $key ] = array(
|
||||
$display_targets[ $key ] = [
|
||||
'link' => $link,
|
||||
'avatar' => $avatar,
|
||||
'display_name' => $product->get_name(),
|
||||
'id' => $product->get_id(),
|
||||
'description' => $description,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'targets' => $display_targets,
|
||||
'wrapper_class' => 'wu-bg-gray-100 wu--mt-3 wu--mb-6 wu-max-h-2',
|
||||
'modal_class' => '',
|
||||
);
|
||||
];
|
||||
|
||||
wu_get_template('broadcast/widget-targets', $args);
|
||||
|
||||
@ -206,21 +206,21 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function display_product_targets_modal() {
|
||||
public function display_product_targets_modal(): void {
|
||||
|
||||
$product_id = wu_request('product_id');
|
||||
|
||||
$customers = wu_get_membership_customers($product_id);
|
||||
|
||||
$display_targets = array();
|
||||
$display_targets = [];
|
||||
|
||||
if ($customers) {
|
||||
foreach ($customers as $key => $value) {
|
||||
$customer = wu_get_customer($value);
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'id' => $customer->get_id(),
|
||||
);
|
||||
];
|
||||
|
||||
$link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts);
|
||||
|
||||
@ -229,27 +229,27 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
48,
|
||||
'identicon',
|
||||
'',
|
||||
array(
|
||||
[
|
||||
'force_display' => true,
|
||||
'class' => 'wu-rounded-full',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$display_targets[ $key ] = array(
|
||||
$display_targets[ $key ] = [
|
||||
'link' => $link,
|
||||
'avatar' => $avatar,
|
||||
'display_name' => $customer->get_display_name(),
|
||||
'id' => $customer->get_id(),
|
||||
'description' => $customer->get_email_address(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'targets' => $display_targets,
|
||||
'wrapper_class' => 'wu-bg-gray-100 wu--mt-3 wu--mb-6 wu-max-h-2',
|
||||
'modal_class' => '',
|
||||
);
|
||||
];
|
||||
|
||||
wu_get_template('broadcast/widget-targets', $args);
|
||||
|
||||
@ -262,10 +262,10 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_new_broadcast_modal() {
|
||||
public function render_add_new_broadcast_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'type' => array(
|
||||
$fields = [
|
||||
'type' => [
|
||||
'type' => 'select-icon',
|
||||
'title' => __('Broadcast Type', 'wp-ultimo'),
|
||||
'desc' => __('Select the type of message you want to send.', 'wp-ultimo'),
|
||||
@ -273,171 +273,171 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
'tooltip' => '',
|
||||
'value' => '',
|
||||
'classes' => 'wu-w-1/2',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'type',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 1',
|
||||
),
|
||||
'options' => array(
|
||||
'broadcast_notice' => array(
|
||||
],
|
||||
'options' => [
|
||||
'broadcast_notice' => [
|
||||
'title' => __('Message', 'wp-ultimo'),
|
||||
'tooltip' => __('Display a message on your customers\' dashboard.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-before dashicons-excerpt-view',
|
||||
),
|
||||
'broadcast_email' => array(
|
||||
],
|
||||
'broadcast_email' => [
|
||||
'title' => __('Email', 'wp-ultimo'),
|
||||
'tooltip' => __('Send an email to your customers.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-before dashicons-email',
|
||||
),
|
||||
),
|
||||
),
|
||||
'step_note' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
'step_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => sprintf('<a href="#" class="wu-no-underline wu-mt-1 wu-uppercase wu-text-2xs wu-font-semibold wu-text-gray-600" v-show="step === 2" v-on:click.prevent="step = 1">%s</a>', __('← Back to Type Selection', 'wp-ultimo')),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 2',
|
||||
),
|
||||
),
|
||||
'target_customers' => array(
|
||||
],
|
||||
],
|
||||
'target_customers' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Target Customers', 'wp-ultimo'),
|
||||
'desc' => __('This broadcast will be sent to the user or users that are selected here. You can select more than one.', 'wp-ultimo'),
|
||||
'placeholder' => __('Search a customer...', 'wp-ultimo'),
|
||||
'min' => 1,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'target_customers',
|
||||
'data-model' => 'customer',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'display_name',
|
||||
'data-search-field' => 'display_name',
|
||||
'data-max-items' => 10000,
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 2',
|
||||
),
|
||||
),
|
||||
'target_products' => array(
|
||||
],
|
||||
],
|
||||
'target_products' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Target Product', 'wp-ultimo'),
|
||||
'desc' => __('This broadcast will be sent to the users that have this product. You can select more than one.', 'wp-ultimo'),
|
||||
'placeholder' => __('Search for a product..', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'target_products',
|
||||
'data-model' => 'product',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'name',
|
||||
'data-search-field' => 'name',
|
||||
'data-max-items' => 99,
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 2',
|
||||
),
|
||||
),
|
||||
'notice_type' => array(
|
||||
],
|
||||
],
|
||||
'notice_type' => [
|
||||
'title' => __('Message Type', 'wp-ultimo'),
|
||||
'desc' => __('The color of the notice is based on the type.', 'wp-ultimo'),
|
||||
'type' => 'select',
|
||||
'default' => 'success',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'success' => __('Success (green)', 'wp-ultimo'),
|
||||
'info' => __('Info (blue)', 'wp-ultimo'),
|
||||
'warning' => __('Warning (orange)', 'wp-ultimo'),
|
||||
'error' => __('Error (red)', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "step === 2 && require('type', 'broadcast_notice')",
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'step_note_2' => array(
|
||||
],
|
||||
],
|
||||
'step_note_2' => [
|
||||
'type' => 'note',
|
||||
'desc' => sprintf('<a href="#" class="wu-no-underline wu-mt-1 wu-uppercase wu-text-2xs wu-font-semibold wu-text-gray-600" v-show="step === 3" v-on:click.prevent="step = 2">%s</a>', __('← Back to Target Selection', 'wp-ultimo')),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 3',
|
||||
),
|
||||
),
|
||||
'subject' => array(
|
||||
],
|
||||
],
|
||||
'subject' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Message Subject', 'wp-ultimo'),
|
||||
'desc' => __('The title will appear above the main content in the notice or used as subject of the email.', 'wp-ultimo'),
|
||||
'placeholder' => __('Enter a title for your broadcast.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'subject',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 3',
|
||||
),
|
||||
),
|
||||
'content' => array(
|
||||
],
|
||||
],
|
||||
'content' => [
|
||||
'id' => 'content',
|
||||
'title' => __('Content', 'wp-ultimo'),
|
||||
'desc' => __('The main content of your broadcast.', 'wp-ultimo'),
|
||||
'type' => 'wp-editor',
|
||||
'settings' => array(
|
||||
'tinymce' => array('toolbar1' => 'bold,italic,strikethrough,link,unlink,undo,redo,pastetext'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
'settings' => [
|
||||
'tinymce' => ['toolbar1' => 'bold,italic,strikethrough,link,unlink,undo,redo,pastetext'],
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'content',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 3',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Next Step →', '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' => 'step === 1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => 'type === ""',
|
||||
'v-on:click.prevent' => 'step = 2',
|
||||
),
|
||||
),
|
||||
'submit_button_2' => array(
|
||||
],
|
||||
],
|
||||
'submit_button_2' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Next Step →', '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' => 'step === 2',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => 'target_customers === "" && target_products === ""', // phpcs:ignore
|
||||
'v-on:click.prevent' => 'step = 3',
|
||||
),
|
||||
),
|
||||
'submit_button_3' => array(
|
||||
],
|
||||
],
|
||||
'submit_button_3' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Send →', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => 'subject === ""',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'step === 3',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'add_new_broadcast',
|
||||
$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_broadcast',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'type' => 'broadcast_notice',
|
||||
'content' => '',
|
||||
'step' => 1,
|
||||
@ -445,10 +445,10 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
'target_customers' => '',
|
||||
'target_products' => '',
|
||||
'subject' => '',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -460,7 +460,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_add_new_broadcast_modal() {
|
||||
public function handle_add_new_broadcast_modal(): void {
|
||||
|
||||
$broadcast = Broadcast_Manager::get_instance();
|
||||
|
||||
@ -483,10 +483,10 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Broadcast removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Broadcast', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -530,19 +530,19 @@ class Broadcast_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add Broadcast', 'wp-ultimo'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_broadcast_message'),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-emails'),
|
||||
'label' => __('System Emails'),
|
||||
'icon' => 'wu-mail',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -52,9 +52,9 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_checkout_forms',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the list page tour.
|
||||
@ -62,31 +62,31 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
\WP_Ultimo\UI\Tours::get_instance()->create_tour(
|
||||
'checkout-form-list',
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
'id' => 'checkout-form-list',
|
||||
'title' => __('Checkout Forms', 'wp-ultimo'),
|
||||
'text' => array(
|
||||
'text' => [
|
||||
__('Checkout Forms are an easy and flexible way to experiment with different approaches when trying to convert new customers.', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => 'default-form',
|
||||
'title' => __('Experiment!', 'wp-ultimo'),
|
||||
'text' => array(
|
||||
'text' => [
|
||||
__('You can create as many checkout forms as you want, with different fields, products on offer, etc.', 'wp-ultimo'),
|
||||
__('Planning on running some sort of promotion? Why not create a custom landing page with a tailor-maid checkout form to go with? The possibilities are endless.', 'wp-ultimo'),
|
||||
),
|
||||
'attachTo' => array(
|
||||
],
|
||||
'attachTo' => [
|
||||
'element' => '#wp-ultimo-wrap > h1 > a:first-child',
|
||||
'on' => 'right',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -96,17 +96,17 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add new Checkout Form
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_checkout_form',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_checkout_form_modal'),
|
||||
'handler' => array($this, 'handle_add_new_checkout_form_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_checkout_form_modal'],
|
||||
'handler' => [$this, 'handle_add_new_checkout_form_modal'],
|
||||
'capability' => 'wu_edit_checkout_forms',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -116,10 +116,10 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_new_checkout_form_modal() {
|
||||
public function render_add_new_checkout_form_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'template' => array(
|
||||
$fields = [
|
||||
'template' => [
|
||||
'type' => 'select-icon',
|
||||
'title' => __('Checkout Form Template', 'wp-ultimo'),
|
||||
'desc' => __('Select a starting point for a new Checkout Form.', 'wp-ultimo'),
|
||||
@ -127,49 +127,49 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
'tooltip' => '',
|
||||
'value' => '',
|
||||
'classes' => 'wu-w-1/3',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'template',
|
||||
),
|
||||
'options' => array(
|
||||
'single-step' => array(
|
||||
],
|
||||
'options' => [
|
||||
'single-step' => [
|
||||
'title' => __('Single Step', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-before dashicons-list-view',
|
||||
),
|
||||
'multi-step' => array(
|
||||
],
|
||||
'multi-step' => [
|
||||
'title' => __('Multi-Step', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-before dashicons-excerpt-view',
|
||||
),
|
||||
'blank' => array(
|
||||
],
|
||||
'blank' => [
|
||||
'title' => __('Blank', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-before dashicons-admin-page',
|
||||
),
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Go to the Editor →', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'add_new_checkout_form',
|
||||
$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_checkout_form_field',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'template' => 'single-step',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -181,7 +181,7 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_add_new_checkout_form_modal() {
|
||||
public function handle_add_new_checkout_form_modal(): void {
|
||||
|
||||
$template = wu_request('template');
|
||||
|
||||
@ -201,14 +201,14 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
wp_send_json_error($status);
|
||||
} else {
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-checkout-form',
|
||||
array(
|
||||
[
|
||||
'id' => $checkout_form->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -221,10 +221,10 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Checkout Form removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Checkout Form', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,14 +268,14 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add Checkout Form'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_checkout_form'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,11 +46,11 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.1
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
add_action('plugins_loaded', array($this, 'export_customers'));
|
||||
add_action('plugins_loaded', [$this, 'export_customers']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +59,7 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.1
|
||||
* @return void
|
||||
*/
|
||||
public function export_customers() {
|
||||
public function export_customers(): void {
|
||||
|
||||
if (wu_request('wu_action') !== 'wu_export_customers') {
|
||||
return;
|
||||
@ -81,7 +81,7 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
$billing_address = array_map(fn($field) => $field['value'], $customer->get_billing_address()->get_fields());
|
||||
|
||||
return array_merge(
|
||||
array(
|
||||
[
|
||||
$customer->get_id(),
|
||||
$customer->get_user_id(),
|
||||
$customer->get_hash(),
|
||||
@ -93,12 +93,12 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
$customer->get_signup_form(),
|
||||
$membership_amount,
|
||||
implode('|', $memberships_ids),
|
||||
),
|
||||
],
|
||||
$billing_address,
|
||||
array(
|
||||
[
|
||||
$customer->get_last_login(),
|
||||
$customer->get_date_registered(),
|
||||
)
|
||||
]
|
||||
);
|
||||
},
|
||||
wu_get_customers()
|
||||
@ -107,7 +107,7 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
$billing_fields = array_keys(\WP_Ultimo\Objects\Billing_Address::fields());
|
||||
|
||||
$headers = array_merge(
|
||||
array(
|
||||
[
|
||||
'id',
|
||||
'user_id',
|
||||
'customer_hash',
|
||||
@ -119,17 +119,17 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
'signup_form',
|
||||
'membership_amount',
|
||||
'membership_ids',
|
||||
),
|
||||
],
|
||||
$billing_fields,
|
||||
array(
|
||||
[
|
||||
'last_login',
|
||||
'date_registered',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$file_name = sprintf('wp-ultimo-customers-(%s)', gmdate('Y-m-d', wu_get_current_time('timestamp')));
|
||||
|
||||
wu_generate_csv($file_name, array_merge(array($headers), $customer_data));
|
||||
wu_generate_csv($file_name, array_merge([$headers], $customer_data));
|
||||
|
||||
die;
|
||||
}
|
||||
@ -144,9 +144,9 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_customers',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register ajax forms that we use for payments.
|
||||
@ -154,17 +154,17 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add new Customer
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_customer',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_customer_modal'),
|
||||
'handler' => array($this, 'handle_add_new_customer_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_customer_modal'],
|
||||
'handler' => [$this, 'handle_add_new_customer_modal'],
|
||||
'capability' => 'wu_invite_customers',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -174,100 +174,100 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_new_customer_modal() {
|
||||
public function render_add_new_customer_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'type' => array(
|
||||
$fields = [
|
||||
'type' => [
|
||||
'type' => 'tab-select',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'type',
|
||||
),
|
||||
'options' => array(
|
||||
],
|
||||
'options' => [
|
||||
'existing' => __('Existing User', 'wp-ultimo'),
|
||||
'new' => __('Invite New', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
'user_id' => array(
|
||||
],
|
||||
],
|
||||
'user_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Existing User', 'wp-ultimo'),
|
||||
'placeholder' => __('Search WordPress user...', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'min' => 1,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'existing')",
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'data-model' => 'user',
|
||||
'data-value-field' => 'ID',
|
||||
'data-label-field' => 'display_name',
|
||||
'data-search-field' => 'display_name',
|
||||
'data-max-items' => 1,
|
||||
),
|
||||
),
|
||||
'username' => array(
|
||||
],
|
||||
],
|
||||
'username' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Username', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. johnsmith', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'new')",
|
||||
),
|
||||
),
|
||||
'email_address' => array(
|
||||
],
|
||||
],
|
||||
'email_address' => [
|
||||
'type' => 'email',
|
||||
'title' => __('Email Address', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. customer@wpultimo.dev', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'new')",
|
||||
),
|
||||
),
|
||||
'set_password' => array(
|
||||
],
|
||||
],
|
||||
'set_password' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Set Password', 'wp-ultimo'),
|
||||
'desc' => __('If not set, the user will be asked to set a password after accepting the invite.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'new')",
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'set_password',
|
||||
),
|
||||
),
|
||||
'password' => array(
|
||||
],
|
||||
],
|
||||
'password' => [
|
||||
'type' => 'password',
|
||||
'title' => __('Password', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. p@$$w0rd', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'new') && require('set_password', true)",
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Create Customer', '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(
|
||||
'add_new_customer',
|
||||
$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_customer',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'set_password' => false,
|
||||
'type' => 'existing',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -279,19 +279,19 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_add_new_customer_modal() {
|
||||
public function handle_add_new_customer_modal(): void {
|
||||
|
||||
if (wu_request('type', 'existing') === 'new') {
|
||||
$customer_data = array(
|
||||
$customer_data = [
|
||||
'email' => wu_request('email_address'),
|
||||
'username' => wu_request('username'),
|
||||
'password' => wu_request('password', false),
|
||||
'meta' => array(),
|
||||
);
|
||||
'meta' => [],
|
||||
];
|
||||
} else {
|
||||
$customer_data = array(
|
||||
$customer_data = [
|
||||
'user_id' => wu_request('user_id', 0),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -304,14 +304,14 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-customer',
|
||||
array(
|
||||
[
|
||||
'id' => $customer->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -331,10 +331,10 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Customer removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Customer', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -378,24 +378,24 @@ class Customer_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add Customer', 'wp-ultimo'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_customer'),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'label' => __('Export as CSV', 'wp-ultimo'),
|
||||
'icon' => 'wu-export',
|
||||
'url' => add_query_arg(
|
||||
array(
|
||||
[
|
||||
'wu_action' => 'wu_export_customers',
|
||||
'nonce' => wp_create_nonce('wu_export_customers'),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
/**
|
||||
* Process save, if necessary
|
||||
@ -59,7 +59,7 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
add_action("wu_edit_{$screen->id}_after_normal", array($this, 'display_preview_window'));
|
||||
add_action("wu_edit_{$screen->id}_after_normal", [$this, 'display_preview_window']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,14 +68,14 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function display_preview_window() {
|
||||
public function display_preview_window(): void {
|
||||
|
||||
wu_get_template(
|
||||
'base/edit/editor-customizer',
|
||||
array(
|
||||
[
|
||||
'preview_iframe_url' => $this->get_preview_url(),
|
||||
'preview_height' => $this->preview_height,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -85,11 +85,11 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
wp_enqueue_script('wu-customizer', wu_get_asset('customizer.js', 'js'), array('jquery', 'wu-vue', 'wu-block-ui'));
|
||||
wp_enqueue_script('wu-customizer', wu_get_asset('customizer.js', 'js'), ['jquery', 'wu-vue', 'wu-block-ui']);
|
||||
|
||||
wp_enqueue_style('wp-color-picker');
|
||||
|
||||
|
@ -60,9 +60,9 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_dashboard',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The tab being displayed.
|
||||
@ -94,7 +94,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
@ -113,11 +113,11 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function hooks() {
|
||||
public function hooks(): void {
|
||||
|
||||
add_action('wu_dash_after_full_metaboxes', array($this, 'render_filter'));
|
||||
add_action('wu_dash_after_full_metaboxes', [$this, 'render_filter']);
|
||||
|
||||
add_action('wu_dashboard_general_widgets', array($this, 'register_general_tab_widgets'), 10, 2);
|
||||
add_action('wu_dashboard_general_widgets', [$this, 'register_general_tab_widgets'], 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,32 +128,32 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @param WP_Ultimo\Admin_Pages\Base_Admin_Page $page The page object.
|
||||
* @return void
|
||||
*/
|
||||
public function render_filter($page) {
|
||||
public function render_filter($page): void {
|
||||
|
||||
if (apply_filters('wu_dashboard_display_filter', true) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($page->id === 'wp-ultimo') {
|
||||
$preset_options = array(
|
||||
'last_7_days' => array(
|
||||
$preset_options = [
|
||||
'last_7_days' => [
|
||||
'label' => __('Last 7 days', 'wp-ultimo'),
|
||||
'start_date' => date_i18n('Y-m-d', strtotime('-7 days')),
|
||||
'end_date' => date_i18n('Y-m-d'),
|
||||
),
|
||||
'last_30_days' => array(
|
||||
],
|
||||
'last_30_days' => [
|
||||
'label' => __('Last 30 days', 'wp-ultimo'),
|
||||
'start_date' => date_i18n('Y-m-d', strtotime('-30 days')),
|
||||
'end_date' => date_i18n('Y-m-d'),
|
||||
),
|
||||
'year_to_date' => array(
|
||||
],
|
||||
'year_to_date' => [
|
||||
'label' => __('Year to date', 'wp-ultimo'),
|
||||
'start_date' => date_i18n('Y-m-d', strtotime('first day of january this year')),
|
||||
'end_date' => date_i18n('Y-m-d'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'preset_options' => $preset_options,
|
||||
'filters_el_id' => 'dashboard-filters',
|
||||
'search_label' => '',
|
||||
@ -162,7 +162,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
'table' => $this,
|
||||
'active_tab' => $this->tab,
|
||||
'views' => $this->get_views(),
|
||||
);
|
||||
];
|
||||
|
||||
wu_get_template('dashboard-statistics/filter', $args);
|
||||
}
|
||||
@ -176,14 +176,14 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_views() {
|
||||
|
||||
$dashboard_filters = array(
|
||||
'general' => array(
|
||||
$dashboard_filters = [
|
||||
'general' => [
|
||||
'field' => 'type',
|
||||
'url' => add_query_arg('tab', 'general'),
|
||||
'label' => __('General', 'wp-ultimo'),
|
||||
'count' => 0,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return apply_filters('wu_dashboard_filter_bar', $dashboard_filters);
|
||||
}
|
||||
@ -194,7 +194,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
@ -227,49 +227,49 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
if (wu_request('tab', 'general') === 'general') {
|
||||
\WP_Ultimo\UI\Tours::get_instance()->create_tour(
|
||||
'wp-ultimo-dashboard',
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
'id' => 'your-dashboard',
|
||||
'title' => __('Our dashboard', 'wp-ultimo'),
|
||||
'text' => array(
|
||||
'text' => [
|
||||
__('This is the <strong>WP Multisite WaaS Dashboard</strong>, where you will find most of the important information you will need regarding your business\' performance.', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => 'documentation',
|
||||
'title' => __('Learning more', 'wp-ultimo'),
|
||||
'text' => array(
|
||||
'text' => [
|
||||
__('Most of the WP Multisite WaaS admin pages will contain a link like this one at the top. These will link directly to the relevant knowledge base page on the WP Multisite WaaS site.', 'wp-ultimo'),
|
||||
),
|
||||
'attachTo' => array(
|
||||
],
|
||||
'attachTo' => [
|
||||
'element' => '#wp-ultimo-wrap > h1 > a:last-child',
|
||||
'on' => 'left',
|
||||
),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => 'mrr-growth',
|
||||
'title' => __('It\'s all about growth!', 'wp-ultimo'),
|
||||
'text' => array(
|
||||
'text' => [
|
||||
__('This graph allows you to follow how your monthly recurring revenue is growing this year.', 'wp-ultimo'),
|
||||
),
|
||||
'attachTo' => array(
|
||||
],
|
||||
'attachTo' => [
|
||||
'element' => '#wp-ultimo-mrr-growth',
|
||||
'on' => 'bottom',
|
||||
),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => 'tailor-made',
|
||||
'title' => __('Date-range support', 'wp-ultimo'),
|
||||
'text' => array(
|
||||
'text' => [
|
||||
__('Checking statistics and comparing data for different periods is key in maintaining a good grasp on your business.', 'wp-ultimo'),
|
||||
__('You can use the date-range selectors to have access to just the data you need and nothing more.', 'wp-ultimo'),
|
||||
),
|
||||
'attachTo' => array(
|
||||
],
|
||||
'attachTo' => [
|
||||
'element' => '#dashboard-filters',
|
||||
'on' => 'bottom',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -283,21 +283,21 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @param \WP_Screen $screen The screen object.
|
||||
* @return void
|
||||
*/
|
||||
public function register_general_tab_widgets($tab, $screen) {
|
||||
public function register_general_tab_widgets($tab, $screen): void {
|
||||
|
||||
if (current_user_can('wu_read_financial')) {
|
||||
add_meta_box('wp-ultimo-mrr-growth', __('Monthly Recurring Revenue Growth', 'wp-ultimo'), array($this, 'output_widget_mrr_growth'), $screen->id, 'full', 'high');
|
||||
add_meta_box('wp-ultimo-mrr-growth', __('Monthly Recurring Revenue Growth', 'wp-ultimo'), [$this, 'output_widget_mrr_growth'], $screen->id, 'full', 'high');
|
||||
|
||||
add_meta_box('wp-ultimo-revenue', __('Revenue', 'wp-ultimo'), array($this, 'output_widget_revenues'), $screen->id, 'normal', 'high');
|
||||
add_meta_box('wp-ultimo-revenue', __('Revenue', 'wp-ultimo'), [$this, 'output_widget_revenues'], $screen->id, 'normal', 'high');
|
||||
}
|
||||
|
||||
add_meta_box('wp-ultimo-countries', __('Signups by Countries', 'wp-ultimo'), array($this, 'output_widget_countries'), $screen->id, 'side', 'high');
|
||||
add_meta_box('wp-ultimo-countries', __('Signups by Countries', 'wp-ultimo'), [$this, 'output_widget_countries'], $screen->id, 'side', 'high');
|
||||
|
||||
add_meta_box('wp-ultimo-signups', __('Signups by Form', 'wp-ultimo'), array($this, 'output_widget_forms'), $screen->id, 'side', 'high');
|
||||
add_meta_box('wp-ultimo-signups', __('Signups by Form', 'wp-ultimo'), [$this, 'output_widget_forms'], $screen->id, 'side', 'high');
|
||||
|
||||
add_meta_box('wp-ultimo-most-visited-sites', __('Most Visited Sites', 'wp-ultimo'), array($this, 'output_widget_most_visited_sites'), $screen->id, 'side', 'low');
|
||||
add_meta_box('wp-ultimo-most-visited-sites', __('Most Visited Sites', 'wp-ultimo'), [$this, 'output_widget_most_visited_sites'], $screen->id, 'side', 'low');
|
||||
|
||||
add_meta_box('wp-ultimo-new-accounts', __('New Memberships', 'wp-ultimo'), array($this, 'output_widget_new_accounts'), $screen->id, 'normal', 'low');
|
||||
add_meta_box('wp-ultimo-new-accounts', __('New Memberships', 'wp-ultimo'), [$this, 'output_widget_new_accounts'], $screen->id, 'normal', 'low');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,7 +306,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @return void
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function output_widget_mrr_growth() {
|
||||
public function output_widget_mrr_growth(): void {
|
||||
|
||||
wu_get_template('dashboard-statistics/widget-mrr-growth');
|
||||
}
|
||||
@ -317,14 +317,14 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @return void
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function output_widget_countries() {
|
||||
public function output_widget_countries(): void {
|
||||
|
||||
wu_get_template(
|
||||
'dashboard-statistics/widget-countries',
|
||||
array(
|
||||
[
|
||||
'countries' => wu_get_countries_of_customers(10, $this->start_date, $this->end_date),
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -334,14 +334,14 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @return void
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function output_widget_forms() {
|
||||
public function output_widget_forms(): void {
|
||||
|
||||
wu_get_template(
|
||||
'dashboard-statistics/widget-forms',
|
||||
array(
|
||||
[
|
||||
'forms' => wu_calculate_signups_by_form($this->start_date, $this->end_date),
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -351,9 +351,9 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @return void
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function output_widget_most_visited_sites() {
|
||||
public function output_widget_most_visited_sites(): void {
|
||||
|
||||
$sites = array();
|
||||
$sites = [];
|
||||
|
||||
$site_results = \WP_Ultimo\Objects\Visits::get_sites_by_visit_count($this->start_date, $this->end_date, 10);
|
||||
|
||||
@ -364,18 +364,18 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sites[] = (object) array(
|
||||
$sites[] = (object) [
|
||||
'site' => $site,
|
||||
'count' => $site_result->count,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
wu_get_template(
|
||||
'dashboard-statistics/widget-most-visited-sites',
|
||||
array(
|
||||
[
|
||||
'sites' => $sites,
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -388,16 +388,16 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $metabox With the metabox arguments passed when registered.
|
||||
* @return void.
|
||||
*/
|
||||
public function output_widget_revenues($unknown = null, $metabox = null) {
|
||||
public function output_widget_revenues($unknown = null, $metabox = null): void {
|
||||
|
||||
wu_get_template(
|
||||
'dashboard-statistics/widget-revenue',
|
||||
array(
|
||||
[
|
||||
'mrr' => wu_calculate_mrr(),
|
||||
'gross_revenue' => wu_calculate_revenue($this->start_date, $this->end_date),
|
||||
'refunds' => wu_calculate_refunds($this->start_date, $this->end_date),
|
||||
'product_stats' => wu_calculate_financial_data_by_product($this->start_date, $this->end_date),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -410,25 +410,25 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $metabox With the metabox arguments passed when registered.
|
||||
* @return void.
|
||||
*/
|
||||
public function output_widget_new_accounts($unknown = null, $metabox = array()) {
|
||||
public function output_widget_new_accounts($unknown = null, $metabox = []): void {
|
||||
|
||||
$new_accounts = wu_get_memberships(
|
||||
array(
|
||||
'fields' => array('plan_id'),
|
||||
'date_query' => array(
|
||||
[
|
||||
'fields' => ['plan_id'],
|
||||
'date_query' => [
|
||||
'column' => 'date_created',
|
||||
'after' => $this->start_date . ' 00:00:00',
|
||||
'before' => $this->end_date . ' 23:59:59',
|
||||
'inclusive' => true,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$products = wu_get_products(
|
||||
array(
|
||||
[
|
||||
'type' => 'plan',
|
||||
'fields' => array('id', 'name', 'count'),
|
||||
)
|
||||
'fields' => ['id', 'name', 'count'],
|
||||
]
|
||||
);
|
||||
|
||||
$products_ids = array_column($products, 'id');
|
||||
@ -448,10 +448,10 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
/**
|
||||
* Add edge case for no plan.
|
||||
*/
|
||||
$products['none'] = (object) array(
|
||||
$products['none'] = (object) [
|
||||
'name' => __('No Product', 'wp-ultimo'),
|
||||
'count' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($new_accounts as $new_account) {
|
||||
if (isset($products[ $new_account->plan_id ])) {
|
||||
@ -463,10 +463,10 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
|
||||
wu_get_template(
|
||||
'dashboard-statistics/widget-new-accounts',
|
||||
array(
|
||||
[
|
||||
'new_accounts' => count($new_accounts),
|
||||
'products' => $products,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -476,9 +476,9 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
$month_list = array();
|
||||
$month_list = [];
|
||||
|
||||
$current_year = date_i18n('Y');
|
||||
|
||||
@ -487,42 +487,42 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
}
|
||||
|
||||
$statistics = new Dashboard_Statistics(
|
||||
array(
|
||||
[
|
||||
'start_date' => $this->start_date,
|
||||
'end_date' => $this->end_date,
|
||||
'types' => array(
|
||||
'types' => [
|
||||
'mrr_growth' => 'mrr_growth',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$data = $statistics->statistics_data();
|
||||
|
||||
wp_register_script('wu-apex-charts', wu_get_asset('apexcharts.js', 'js/lib'), array(), wu_get_version(), true);
|
||||
wp_register_script('wu-apex-charts', wu_get_asset('apexcharts.js', 'js/lib'), [], wu_get_version(), true);
|
||||
|
||||
wp_register_script('wu-vue-apex-charts', wu_get_asset('vue-apexcharts.js', 'js/lib'), array(), wu_get_version(), true);
|
||||
wp_register_script('wu-vue-apex-charts', wu_get_asset('vue-apexcharts.js', 'js/lib'), [], wu_get_version(), true);
|
||||
|
||||
wp_register_script('wu-dashboard-stats', wu_get_asset('dashboard-statistics.js', 'js'), array('jquery', 'wu-functions', 'wu-ajax-list-table', 'moment', 'wu-block-ui', 'dashboard', 'wu-apex-charts', 'wu-vue-apex-charts'), wu_get_version(), true);
|
||||
wp_register_script('wu-dashboard-stats', wu_get_asset('dashboard-statistics.js', 'js'), ['jquery', 'wu-functions', 'wu-ajax-list-table', 'moment', 'wu-block-ui', 'dashboard', 'wu-apex-charts', 'wu-vue-apex-charts'], wu_get_version(), true);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-dashboard-stats',
|
||||
'wu_dashboard_statistics_vars',
|
||||
array(
|
||||
[
|
||||
'mrr_array' => $data['mrr_growth'],
|
||||
'start_date' => date_i18n('Y-m-d', strtotime((string) wu_request('start_date', '-1 month'))),
|
||||
'end_date' => date_i18n('Y-m-d', strtotime((string) wu_request('end_date', 'tomorrow'))),
|
||||
'today' => date_i18n('Y-m-d', strtotime('tomorrow')),
|
||||
'month_list' => $month_list,
|
||||
'i18n' => array(
|
||||
'i18n' => [
|
||||
'new_mrr' => __('New MRR', 'wp-ultimo'),
|
||||
'cancellations' => __('Cancellations', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-dashboard-stats');
|
||||
|
||||
wp_enqueue_style('wu-apex-charts', wu_get_asset('apexcharts.css', 'css'), array(), wu_get_version());
|
||||
wp_enqueue_style('wu-apex-charts', wu_get_asset('apexcharts.css', 'css'), [], wu_get_version());
|
||||
|
||||
wp_enqueue_style('wu-flags');
|
||||
}
|
||||
@ -566,17 +566,17 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/dash',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'has_full_position' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -588,16 +588,16 @@ class Dashboard_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $args Data array to convert to CSV.
|
||||
* @return void
|
||||
*/
|
||||
public function render_csv_button($args) {
|
||||
public function render_csv_button($args): void {
|
||||
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
[
|
||||
'slug' => 'csv',
|
||||
'headers' => array(),
|
||||
'data' => array(),
|
||||
'headers' => [],
|
||||
'data' => [],
|
||||
'action' => apply_filters('wu_export_data_table_action', 'wu_generate_csv'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$slug = $args['slug'];
|
||||
|
@ -77,9 +77,9 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_edit_discount_codes',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to register widgets, if they need them.
|
||||
@ -87,150 +87,150 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
$this->add_fields_widget(
|
||||
'description',
|
||||
array(
|
||||
[
|
||||
'title' => __('Description', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'fields' => array(
|
||||
'description' => array(
|
||||
'fields' => [
|
||||
'description' => [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Description', 'wp-ultimo'),
|
||||
'placeholder' => __('Tell your customers what this product is about.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_description(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$tz_note = sprintf('The site timezone is <code>%s</code>. The current time is <code>%s</code>', date_i18n('e'), date_i18n('r'));
|
||||
|
||||
$options = array(
|
||||
'general' => array(
|
||||
$options = [
|
||||
'general' => [
|
||||
'title' => __('Limit Uses', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-lock',
|
||||
'desc' => __('Rules and limitations to the applicability of this discount code.', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'uses' => array(
|
||||
'fields' => [
|
||||
'uses' => [
|
||||
'title' => __('Uses', 'wp-ultimo'),
|
||||
'type' => 'text-display',
|
||||
// translators: %d is the number of times the coupon was used.
|
||||
'display_value' => sprintf(__('This discount code was used %d times.', 'wp-ultimo'), $this->get_object()->get_uses()),
|
||||
'tooltip' => __('The number of times that this discount code was used so far.', 'wp-ultimo'),
|
||||
),
|
||||
'max_uses' => array(
|
||||
],
|
||||
'max_uses' => [
|
||||
'title' => __('Max Uses', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to set a limit on how many times this discount code can be used. Leave blank or 0 for unlimited uses.', 'wp-ultimo'),
|
||||
'type' => 'number',
|
||||
'min' => 0,
|
||||
'placeholder' => 0,
|
||||
'value' => $this->get_object()->has_max_uses() ? $this->get_object()->get_max_uses() : __('Unlimited', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
),
|
||||
'time' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
'time' => [
|
||||
'title' => __('Start & Expiration Dates', 'wp-ultimo'),
|
||||
'desc' => __('Define a start and end date for this discount code. Useful when running campaigns for a pre-determined period.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-calendar',
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'enable_date_start' => $this->get_object()->get_date_start(),
|
||||
'enable_date_expiration' => $this->get_object()->get_date_expiration(),
|
||||
),
|
||||
'fields' => array(
|
||||
'enable_date_start' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'enable_date_start' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Enable Start Date', 'wp-ultimo'),
|
||||
'desc' => __('Allows you to set a start date for this coupon code.', 'wp-ultimo'),
|
||||
'value' => 1,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'enable_date_start',
|
||||
),
|
||||
),
|
||||
'date_start' => array(
|
||||
],
|
||||
],
|
||||
'date_start' => [
|
||||
'title' => __('Start Date', 'wp-ultimo'),
|
||||
'desc' => __('The discount code will only be good to be used after this date.', 'wp-ultimo') . ' ' . $tz_note,
|
||||
'type' => 'text',
|
||||
'date' => true,
|
||||
'value' => $this->edit ? $this->get_object()->get_date_start() : __('No date', 'wp-ultimo'),
|
||||
'placeholder' => 'E.g. 2020-04-04 12:00:00',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
'v-show' => 'enable_date_start',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-bind:name' => 'enable_date_start ? "date_start" : ""',
|
||||
'wu-datepicker' => 'true',
|
||||
'data-format' => 'Y-m-d H:i:S',
|
||||
'data-allow-time' => 'true',
|
||||
),
|
||||
),
|
||||
'enable_date_expiration' => array(
|
||||
],
|
||||
],
|
||||
'enable_date_expiration' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Enable Expiration Date', 'wp-ultimo'),
|
||||
'desc' => __('Allows you to set an expiration date for this coupon code.', 'wp-ultimo'),
|
||||
'value' => 1,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'enable_date_expiration',
|
||||
),
|
||||
),
|
||||
'date_expiration' => array(
|
||||
],
|
||||
],
|
||||
'date_expiration' => [
|
||||
'title' => __('Expiration Date', 'wp-ultimo'),
|
||||
'desc' => __('The discount code will expire after this date.', 'wp-ultimo') . ' ' . $tz_note,
|
||||
'type' => 'text',
|
||||
'date' => true,
|
||||
'value' => $this->edit ? $this->get_object()->get_date_expiration() : __('Never Expires', 'wp-ultimo'),
|
||||
'placeholder' => 'E.g. 2020-04-04 12:00:00',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
'v-show' => 'enable_date_expiration',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-bind:name' => 'enable_date_expiration ? "date_expiration" : ""',
|
||||
'wu-datepicker' => 'true',
|
||||
'data-format' => 'Y-m-d H:i:S',
|
||||
'data-allow-time' => 'true',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'products' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'products' => [
|
||||
'title' => __('Limit Products', 'wp-ultimo'),
|
||||
'desc' => __('Determine if you want this discount code to apply to all discountable products or not.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-price-tag',
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'limit_products' => $this->get_object()->get_limit_products(),
|
||||
),
|
||||
],
|
||||
'fields' => array_merge(
|
||||
array(
|
||||
'limit_products' => array(
|
||||
[
|
||||
'limit_products' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Select Products', 'wp-ultimo'),
|
||||
'desc' => __('Manually select to which products this discount code should be applicable.', 'wp-ultimo'),
|
||||
'value' => 1,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'limit_products',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
$this->get_product_field_list()
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->add_tabs_widget(
|
||||
'options',
|
||||
array(
|
||||
[
|
||||
'title' => __('Advanced Options', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'sections' => apply_filters('wu_discount_code_options_sections', $options, $this->get_object()),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -240,151 +240,151 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'events',
|
||||
array(
|
||||
[
|
||||
'title' => __('Events', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
|
||||
'query_filter' => array($this, 'query_filter'),
|
||||
)
|
||||
'query_filter' => [$this, 'query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'html_attr' => array(
|
||||
[
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'save_discount_code',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'apply_to_setup_fee' => $this->get_object()->get_setup_fee_value() > 0,
|
||||
'code' => $this->get_object()->get_code(),
|
||||
'type' => $this->get_object()->get_type(),
|
||||
'value' => $this->get_object()->get_value(),
|
||||
'setup_fee_type' => $this->get_object()->get_setup_fee_type(),
|
||||
'setup_fee_value' => $this->get_object()->get_setup_fee_value(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'code' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'code' => [
|
||||
'title' => __('Coupon Code', 'wp-ultimo'),
|
||||
'type' => 'text',
|
||||
'placeholder' => __('E.g. XMAS10OFF', 'wp-ultimo'),
|
||||
'desc' => __('The actual code your customers will enter during checkout.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_code(),
|
||||
'tooltip' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-on:input' => 'code = $event.target.value.toUpperCase().replace(/[^A-Z0-9-_]+/g, "")',
|
||||
'v-bind:value' => 'code',
|
||||
),
|
||||
),
|
||||
'value_group' => array(
|
||||
],
|
||||
],
|
||||
'value_group' => [
|
||||
'type' => 'group',
|
||||
'title' => __('Discount', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'fields' => array(
|
||||
'type' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'type' => [
|
||||
'type' => 'select',
|
||||
'value' => $this->get_object()->get_type(),
|
||||
'placeholder' => '',
|
||||
'wrapper_classes' => 'wu-w-2/3',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'percentage' => __('Percentage (%)', 'wp-ultimo'),
|
||||
// translators: %s is the currency symbol. e.g. $
|
||||
'absolute' => sprintf(__('Absolute (%s)', 'wp-ultimo'), wu_get_currency_symbol()),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'type',
|
||||
),
|
||||
),
|
||||
'value' => array(
|
||||
],
|
||||
],
|
||||
'value' => [
|
||||
'type' => 'number',
|
||||
'value' => $this->get_object()->get_value(),
|
||||
'placeholder' => '',
|
||||
'wrapper_classes' => 'wu-ml-2 wu-w-1/3',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'min' => 0,
|
||||
'v-bind:max' => "type === 'percentage' ? 100 : 999999999",
|
||||
'step' => 'any',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'apply_to_renewals' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'apply_to_renewals' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Apply to Renewals', 'wp-ultimo'),
|
||||
'desc' => __('By default, discounts are only applied to the first payment.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->should_apply_to_renewals(),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
'apply_to_setup_fee' => array(
|
||||
],
|
||||
],
|
||||
'apply_to_setup_fee' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Setup Fee Discount', 'wp-ultimo'),
|
||||
'desc' => __('Also set a discount for setup fee?', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_setup_fee_value() > 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'apply_to_setup_fee',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
'setup_fee_value_group' => array(
|
||||
],
|
||||
],
|
||||
'setup_fee_value_group' => [
|
||||
'type' => 'group',
|
||||
'title' => __('Setup Fee Discount', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'apply_to_setup_fee',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'fields' => array(
|
||||
'setup_fee_type' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'setup_fee_type' => [
|
||||
'type' => 'select',
|
||||
'value' => $this->get_object()->get_setup_fee_type(),
|
||||
'placeholder' => '',
|
||||
'wrapper_classes' => 'wu-w-2/3',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'percentage' => __('Percentage (%)', 'wp-ultimo'),
|
||||
// translators: %s is the currency symbol. e.g $
|
||||
'absolute' => sprintf(__('Absolute (%s)', 'wp-ultimo'), wu_get_currency_symbol()),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'setup_fee_type',
|
||||
),
|
||||
),
|
||||
'setup_fee_value' => array(
|
||||
],
|
||||
],
|
||||
'setup_fee_value' => [
|
||||
'type' => 'number',
|
||||
'value' => $this->get_object()->get_setup_fee_value(),
|
||||
'placeholder' => '',
|
||||
'wrapper_classes' => 'wu-ml-2 wu-w-1/3',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'min' => 0,
|
||||
'v-bind:max' => "setup_fee_type === 'percentage' ? 100 : 999999999",
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'active',
|
||||
array(
|
||||
[
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'active' => array(
|
||||
'fields' => [
|
||||
'active' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to manually enable or disable this discount code for new sign-ups.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_active(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -396,48 +396,48 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
protected function get_product_field_list() {
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
foreach (wu_get_products() as $product) {
|
||||
$product_id = $product->get_id();
|
||||
|
||||
$fields[ "allowed_products_{$product_id}" ] = array(
|
||||
$fields[ "allowed_products_{$product_id}" ] = [
|
||||
'type' => 'toggle',
|
||||
'title' => $product->get_name(),
|
||||
'desc' => __('Make applicable to this product.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'wrapper_classes' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
':name' => "'allowed_products[]'",
|
||||
':checked' => json_encode(!$this->get_object()->get_limit_products() || in_array($product_id, $this->get_object()->get_allowed_products())), // phpcs:ignore
|
||||
':value' => $product_id,
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
'v-show' => 'limit_products',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// TODO: this is a hack-y fix. Needs to be re-implemented.
|
||||
$fields['allowed_products_none'] = array(
|
||||
$fields['allowed_products_none'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => '__none',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
':name' => "'allowed_products[]'",
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($fields)) {
|
||||
$fields['allowed_products_no_products'] = array(
|
||||
$fields['allowed_products_no_products'] = [
|
||||
'type' => 'note',
|
||||
'title' => '',
|
||||
'desc' => __('You do not have any products at this moment.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
'v-show' => 'limit_products',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return $fields;
|
||||
@ -449,11 +449,11 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_legacy_options() {
|
||||
public function handle_legacy_options(): void {
|
||||
|
||||
global $wp_filter;
|
||||
|
||||
$tabs = array(__('Legacy Add-ons', 'wp-ultimo'));
|
||||
$tabs = [__('Legacy Add-ons', 'wp-ultimo')];
|
||||
|
||||
if ( ! isset($wp_filter['wp_ultimo_coupon_advanced_options'])) {
|
||||
return;
|
||||
@ -463,40 +463,40 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$priorities = $wp_filter['wp_ultimo_coupon_advanced_options']->callbacks;
|
||||
|
||||
$fields = array(
|
||||
'heading' => array(
|
||||
$fields = [
|
||||
'heading' => [
|
||||
'type' => 'header',
|
||||
'title' => __('Legacy Options', 'wp-ultimo'),
|
||||
// translators: %s is the comma-separated list of legacy add-ons.
|
||||
'desc' => sprintf(__('Options for %s, and others.', 'wp-ultimo'), implode(', ', $tabs)),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($priorities as $priority => $callbacks) {
|
||||
foreach ($callbacks as $id => $callable) {
|
||||
$fields[ $id ] = array(
|
||||
$fields[ $id ] = [
|
||||
'type' => 'html',
|
||||
'classes' => 'wu--mt-2',
|
||||
'content' => function () use ($callable) {
|
||||
|
||||
call_user_func($callable['function'], $this->get_object());
|
||||
},
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->add_fields_widget(
|
||||
'legacy-options',
|
||||
array(
|
||||
[
|
||||
'title' => __('Legacy Options', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'fields' => $fields,
|
||||
'classes' => 'wu-legacy-options-panel',
|
||||
'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' => [
|
||||
'style' => 'margin-top: -5px;',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -506,16 +506,16 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Delete Discount code - Confirmation modal
|
||||
*/
|
||||
|
||||
add_filter(
|
||||
'wu_data_json_success_delete_discount_code_modal',
|
||||
fn($data_json) => array(
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-discount-codes', array('deleted' => 1)),
|
||||
)
|
||||
fn($data_json) => [
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-discount-codes', ['deleted' => 1]),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -529,10 +529,10 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'discount_code',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -567,7 +567,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -578,7 +578,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Discount Code', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Discount Code', 'wp-ultimo'),
|
||||
'updated_message' => __('Discount Code updated successfully!', 'wp-ultimo'),
|
||||
@ -588,7 +588,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Discount Code', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -639,7 +639,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
/*
|
||||
* Set the recurring value to zero if the toggle is disabled.
|
||||
*/
|
||||
|
@ -50,9 +50,9 @@ class Discount_Code_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_discount_codes',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to register widgets, if they need them.
|
||||
@ -70,10 +70,10 @@ class Discount_Code_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Discount Code removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Discount Code', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,13 +117,13 @@ class Discount_Code_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-edit-discount-code'),
|
||||
'label' => __('Add Discount Code'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,9 +76,9 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_edit_domains',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register ajax forms.
|
||||
@ -86,13 +86,13 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Adds the hooks to handle deletion.
|
||||
*/
|
||||
add_filter('wu_form_fields_delete_domain_modal', array($this, 'domain_extra_delete_fields'), 10, 2);
|
||||
add_filter('wu_form_fields_delete_domain_modal', [$this, 'domain_extra_delete_fields'], 10, 2);
|
||||
|
||||
add_action('wu_after_delete_domain_modal', array($this, 'domain_after_delete_actions'));
|
||||
add_action('wu_after_delete_domain_modal', [$this, 'domain_after_delete_actions']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,47 +116,47 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
$has_other_domains = is_countable($other_domains) ? count($other_domains) - 1 : false;
|
||||
}
|
||||
|
||||
$custom_fields = array(
|
||||
'set_domain_as_primary' => array(
|
||||
$custom_fields = [
|
||||
'set_domain_as_primary' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Set another domain as primary', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'domain',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'domain',
|
||||
'data-search-field' => 'domain',
|
||||
'data-max-items' => 1,
|
||||
'data-exclude' => json_encode(array($domain->get_id())),
|
||||
'data-exclude' => json_encode([$domain->get_id()]),
|
||||
'data-include' => json_encode($domain->get_blog_id()),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => $is_primary_domain && $has_other_domains ? 'true' : 'false',
|
||||
),
|
||||
),
|
||||
'confirm' => array(
|
||||
],
|
||||
],
|
||||
'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',
|
||||
),
|
||||
),
|
||||
'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',
|
||||
),
|
||||
),
|
||||
'id' => array(
|
||||
],
|
||||
],
|
||||
'id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $domain->get_id(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return array_merge($custom_fields, $fields);
|
||||
}
|
||||
@ -169,7 +169,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @param object $domain The domain object.
|
||||
* @return void
|
||||
*/
|
||||
public function domain_after_delete_actions($domain) {
|
||||
public function domain_after_delete_actions($domain): void {
|
||||
|
||||
$new_primary_domain_name = wu_request('set_domain_as_primary');
|
||||
|
||||
@ -188,180 +188,180 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
$this->add_fields_widget(
|
||||
'domain-url',
|
||||
array(
|
||||
[
|
||||
'title' => __('Domain URL', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'after' => array($this, 'render_dns_widget'),
|
||||
'fields' => array(
|
||||
'domain' => array(
|
||||
'after' => [$this, 'render_dns_widget'],
|
||||
'fields' => [
|
||||
'domain' => [
|
||||
'type' => 'text-display',
|
||||
'title' => __('Domain', 'wp-ultimo'),
|
||||
'tooltip' => __('Editing an existing domain is not possible. If you want to make changes to this domain, first delete it, and then re-add the right domain.', 'wp-ultimo'),
|
||||
'display_value' => '<span class="wu-text-sm wu-uppercase wu-font-mono">' . $this->get_object()->get_domain() . '</span> <a target="_blank" class="wu-no-underline" href="' . esc_url($this->get_object()->get_url()) . '"><span class="dashicons-wu-link1 "></span></a>',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_tabs_widget(
|
||||
'options',
|
||||
array(
|
||||
[
|
||||
'title' => __('Domain Options', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'sections' => array(
|
||||
'general' => array(
|
||||
'sections' => [
|
||||
'general' => [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General options for the domain.', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-globe',
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'primary_domain' => $this->get_object()->is_primary_domain(),
|
||||
),
|
||||
'fields' => array(
|
||||
'primary_domain' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'primary_domain' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Is Primary Domain?', 'wp-ultimo'),
|
||||
'desc' => __('Set as the primary domain.', 'wp-ultimo'),
|
||||
'tooltip' => __('Setting this as the primary domain will remove any other domain mapping marked as the primary domain for this site.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_primary_domain(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'primary_domain',
|
||||
),
|
||||
),
|
||||
'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)",
|
||||
),
|
||||
),
|
||||
'secure' => array(
|
||||
],
|
||||
],
|
||||
'secure' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Is Secure?', 'wp-ultimo'),
|
||||
'desc' => __('Force the load using HTTPS.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_secure(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'sites',
|
||||
array(
|
||||
[
|
||||
'title' => __('Linked Site', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Memberships_Site_List_Table(),
|
||||
'query_filter' => array($this, 'sites_query_filter'),
|
||||
)
|
||||
'query_filter' => [$this, 'sites_query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box('wp-ultimo-domain-log', __('Domain Test Log', 'wp-ultimo'), array($this, 'render_log_widget'), get_current_screen()->id, 'normal', null);
|
||||
add_meta_box('wp-ultimo-domain-log', __('Domain Test Log', 'wp-ultimo'), [$this, 'render_log_widget'], get_current_screen()->id, 'normal', null);
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'events',
|
||||
array(
|
||||
[
|
||||
'title' => __('Events', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
|
||||
'query_filter' => array($this, 'query_filter'),
|
||||
)
|
||||
'query_filter' => [$this, 'query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'html_attr' => array(
|
||||
[
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'save',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'stage' => $this->get_object()->get_stage(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'stage' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'stage' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Stage', 'wp-ultimo'),
|
||||
'placeholder' => __('Select Stage', 'wp-ultimo'),
|
||||
'desc' => __('The stage in the checking lifecycle of this domain.', 'wp-ultimo'),
|
||||
'options' => Domain_Stage::to_array(),
|
||||
'value' => $this->get_object()->get_stage(),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'@change' => 'window.wu_basic.stage = $event.target.value',
|
||||
'v-model' => 'stage',
|
||||
),
|
||||
),
|
||||
'blog_id' => array(
|
||||
],
|
||||
],
|
||||
'blog_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Site', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Site...', 'wp-ultimo'),
|
||||
'desc' => __('The target site of this domain.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_blog_id(),
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'site',
|
||||
'data-value-field' => 'blog_id',
|
||||
'data-label-field' => 'title',
|
||||
'data-search-field' => 'title',
|
||||
'data-max-items' => 1,
|
||||
'data-selected' => $this->get_object()->get_site() ? json_encode($this->get_object()->get_site()->to_search_results()) : '',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$check_for_active_string = sprintf('%s.includes(stage)', json_encode(\WP_Ultimo\Models\Domain::INACTIVE_STAGES));
|
||||
|
||||
$this->add_fields_widget(
|
||||
'basic',
|
||||
array(
|
||||
[
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'basic',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'stage' => $this->get_object()->get_stage(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'active' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'active' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to manually enable or disable this domain.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_active(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
'v-bind:disabled' => $check_for_active_string,
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-bind:class' => "$check_for_active_string ? 'wu-cursor-not-allowed wu-opacity-75' : ''",
|
||||
),
|
||||
],
|
||||
|
||||
),
|
||||
'note' => array(
|
||||
],
|
||||
'note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('This domain has a domain stage that forces it to be inactive. Change the status to Ready or Ready (without SSL) to be able to control the active status directly.', 'wp-ultimo'),
|
||||
'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => $check_for_active_string,
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -371,13 +371,13 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_dns_widget() {
|
||||
public function render_dns_widget(): void {
|
||||
|
||||
wu_get_template(
|
||||
'domain/dns-table',
|
||||
array(
|
||||
[
|
||||
'domain' => $this->get_object(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -387,14 +387,14 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_log_widget() {
|
||||
public function render_log_widget(): void {
|
||||
|
||||
wu_get_template(
|
||||
'domain/log',
|
||||
array(
|
||||
[
|
||||
'domain' => $this->get_object(),
|
||||
'log_path' => \WP_Ultimo\Logger::get_logs_folder(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -428,7 +428,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -439,7 +439,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Domain', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Domain', 'wp-ultimo'),
|
||||
'updated_message' => __('Domain updated with success!', 'wp-ultimo'),
|
||||
@ -449,7 +449,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Domain', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -462,10 +462,10 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'domain',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -527,7 +527,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
if ( ! wu_request('primary_domain')) {
|
||||
$_POST['primary_domain'] = false;
|
||||
@ -541,7 +541,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
$_POST['secure'] = false;
|
||||
}
|
||||
|
||||
wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $this->get_object()->get_id()), 'domain');
|
||||
wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $this->get_object()->get_id()], 'domain');
|
||||
|
||||
parent::handle_save();
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_domains',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register ajax forms that we use for payments.
|
||||
@ -63,17 +63,17 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add new Domain
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_domain',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_domain_modal'),
|
||||
'handler' => array($this, 'handle_add_new_domain_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_domain_modal'],
|
||||
'handler' => [$this, 'handle_add_new_domain_modal'],
|
||||
'capability' => 'wu_edit_domains',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -83,127 +83,127 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_new_domain_modal() {
|
||||
public function render_add_new_domain_modal(): void {
|
||||
|
||||
$addon_url = wu_network_admin_url(
|
||||
'wp-ultimo-addons',
|
||||
array(
|
||||
[
|
||||
's' => 'Domain Seller',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
// translators: %s is the URL to the add-on.
|
||||
$note_desc = sprintf(__('To activate this feature you need to install the <a href="%s" target="_blank" class="wu-no-underline">WP Multisite WaaS: Domain Seller</a> add-on.', 'wp-ultimo'), $addon_url);
|
||||
|
||||
$fields = array(
|
||||
'type' => array(
|
||||
$fields = [
|
||||
'type' => [
|
||||
'type' => 'tab-select',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'add' => __('Add Existing Domain', 'wp-ultimo'),
|
||||
'register' => __('Register New', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'type',
|
||||
),
|
||||
),
|
||||
'domain' => array(
|
||||
],
|
||||
],
|
||||
'domain' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Domain', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. mydomain.com', 'wp-ultimo'),
|
||||
'desc' => __('Be sure the domain has the right DNS setup in place before adding it.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'add')",
|
||||
),
|
||||
),
|
||||
'blog_id' => array(
|
||||
],
|
||||
],
|
||||
'blog_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Apply to Site', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Sites...', 'wp-ultimo'),
|
||||
'desc' => __('The target site of the domain being added.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'site',
|
||||
'data-value-field' => 'blog_id',
|
||||
'data-label-field' => 'title',
|
||||
'data-search-field' => 'title',
|
||||
'data-max-items' => 1,
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'add')",
|
||||
),
|
||||
),
|
||||
'stage' => array(
|
||||
],
|
||||
],
|
||||
'stage' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Stage', 'wp-ultimo'),
|
||||
'placeholder' => __('Select Stage', 'wp-ultimo'),
|
||||
'desc' => __('The stage in the domain check lifecycle. Leave "Checking DNS" to have the domain go through WP Multisite WaaS\'s automated tests.', 'wp-ultimo'),
|
||||
'options' => Domain_Stage::to_array(),
|
||||
'value' => Domain_Stage::CHECKING_DNS,
|
||||
),
|
||||
'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',
|
||||
),
|
||||
),
|
||||
'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-show' => "require('primary_domain', true)",
|
||||
),
|
||||
),
|
||||
'submit_button_new' => array(
|
||||
],
|
||||
],
|
||||
'submit_button_new' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Add Existing 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' => "require('type', 'add')",
|
||||
),
|
||||
),
|
||||
'addon_note' => array(
|
||||
],
|
||||
],
|
||||
'addon_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => $note_desc,
|
||||
'classes' => 'wu-p-2 wu-bg-blue-100 wu-text-gray-600 wu-rounded wu-w-full',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "require('type', 'register')",
|
||||
),
|
||||
),
|
||||
'submit_button_register' => array(
|
||||
],
|
||||
],
|
||||
'submit_button_register' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Register and Add Domain (soon)', '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' => "require('type', 'register')",
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'disabled' => 'disabled',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$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(
|
||||
[
|
||||
'type' => 'add',
|
||||
'primary_domain' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -215,7 +215,7 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_add_new_domain_modal() {
|
||||
public function handle_add_new_domain_modal(): void {
|
||||
|
||||
/**
|
||||
* Fires before handle the add new domain modal request.
|
||||
@ -229,12 +229,12 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
* Tries to create the domain
|
||||
*/
|
||||
$domain = wu_create_domain(
|
||||
array(
|
||||
[
|
||||
'domain' => wu_request('domain'),
|
||||
'stage' => wu_request('stage'),
|
||||
'blog_id' => (int) wu_request('blog_id'),
|
||||
'primary_domain' => (bool) wu_request('primary_domain'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (is_wp_error($domain)) {
|
||||
@ -243,31 +243,31 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
if (wu_request('primary_domain')) {
|
||||
$old_primary_domains = wu_get_domains(
|
||||
array(
|
||||
[
|
||||
'primary_domain' => true,
|
||||
'blog_id' => wu_request('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('wu_async_remove_old_primary_domains', array($old_primary_domains));
|
||||
do_action('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');
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-domain',
|
||||
array(
|
||||
[
|
||||
'id' => $domain->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -280,10 +280,10 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Domains removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Domains', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,14 +327,14 @@ class Domain_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add Domain'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_domain'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +75,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
/**
|
||||
* Setups the object
|
||||
@ -106,11 +106,11 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function hooks() {
|
||||
public function hooks(): void {
|
||||
|
||||
parent::hooks();
|
||||
|
||||
add_filter('removable_query_args', array($this, 'removable_query_args'));
|
||||
add_filter('removable_query_args', [$this, 'removable_query_args']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,17 +143,17 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
// translators: %s is the date, using the site format options
|
||||
$message = sprintf(__('This item is locked from editions.<br />This is probably due to a background action being performed (like a transfer between different accounts, for example). You can manually unlock it, but be careful. The lock should be released automatically in %s seconds.', 'wp-ultimo'), wu_get_next_queue_run() + 10);
|
||||
|
||||
$actions = array(
|
||||
'preview' => array(
|
||||
$actions = [
|
||||
'preview' => [
|
||||
'title' => __('Unlock', 'wp-ultimo'),
|
||||
'url' => add_query_arg(
|
||||
array(
|
||||
[
|
||||
'remove-lock' => 1,
|
||||
'unlock_wpultimo_nonce' => wp_create_nonce(sprintf('unlocking_%s', $this->object_id)),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
WP_Ultimo()->notices->add($message, 'warning', 'network-admin', false, $actions);
|
||||
}
|
||||
@ -165,7 +165,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function remove_lock() {
|
||||
public function remove_lock(): void {
|
||||
|
||||
$unlock_tag = "unlocking_{$this->object_id}";
|
||||
|
||||
@ -186,10 +186,10 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
|
||||
wp_redirect(
|
||||
remove_query_arg(
|
||||
array(
|
||||
[
|
||||
'remove-lock',
|
||||
'unlock_wpultimo_nonce',
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@ -203,7 +203,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
final public function process_save() {
|
||||
final public function process_save(): void {
|
||||
|
||||
$saving_tag = "saving_{$this->object_id}";
|
||||
|
||||
@ -234,7 +234,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
final public function process_delete() {
|
||||
final public function process_delete(): void {
|
||||
|
||||
$deleting_tag = "deleting_{$this->object_id}";
|
||||
|
||||
@ -263,7 +263,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
$default_labels = array(
|
||||
$default_labels = [
|
||||
'edit_label' => __('Edit Object', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add New Object', 'wp-ultimo'),
|
||||
'updated_message' => __('Object updated with success!', 'wp-ultimo'),
|
||||
@ -273,7 +273,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
|
||||
return apply_filters('wu_edit_admin_page_labels', $default_labels);
|
||||
}
|
||||
@ -284,7 +284,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
@ -315,20 +315,20 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
$this->add_info_widget(
|
||||
'info',
|
||||
array(
|
||||
[
|
||||
'title' => __('Timestamps', 'wp-ultimo'),
|
||||
'position' => 'side-bottom',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->edit) {
|
||||
$this->add_delete_widget('delete', array());
|
||||
$this->add_delete_widget('delete', []);
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Array containing the attributes to be passed to the widget.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_info_widget($id, $atts = array()) {
|
||||
protected function add_info_widget($id, $atts = []) {
|
||||
|
||||
$created_key = 'date_created';
|
||||
|
||||
@ -349,38 +349,38 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
$created_key = 'date_registered';
|
||||
}
|
||||
|
||||
$created_value = call_user_func(array($this->get_object(), "get_$created_key"));
|
||||
$created_value = call_user_func([$this->get_object(), "get_$created_key"]);
|
||||
|
||||
$atts['fields'][ $created_key ] = array(
|
||||
$atts['fields'][ $created_key ] = [
|
||||
'title' => __('Created at', 'wp-ultimo'),
|
||||
'type' => 'text-display',
|
||||
'date' => true,
|
||||
'display_value' => $this->edit ? $created_value : false,
|
||||
'value' => $created_value,
|
||||
'placeholder' => '2020-04-04 12:00:00',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'wu-datepicker' => 'true',
|
||||
'data-format' => 'Y-m-d H:i:S',
|
||||
'data-allow-time' => 'true',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$show_modified = wu_get_isset($atts, 'modified', true);
|
||||
|
||||
if ($this->edit && $show_modified === true) {
|
||||
$atts['fields']['date_modified'] = array(
|
||||
$atts['fields']['date_modified'] = [
|
||||
'title' => __('Last Modified at', 'wp-ultimo'),
|
||||
'type' => 'text-display',
|
||||
'date' => true,
|
||||
'display_value' => $this->edit ? $this->get_object()->get_date_modified() : __('No date', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_date_modified(),
|
||||
'placeholder' => '2020-04-04 12:00:00',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'wu-datepicker' => 'true',
|
||||
'data-format' => 'Y-m-d H:i:S',
|
||||
'data-allow-time' => 'true',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$this->add_fields_widget($id, $atts);
|
||||
@ -395,11 +395,11 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Array containing the attributes to be passed to the widget.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_list_table_widget($id, $atts = array()) {
|
||||
protected function add_list_table_widget($id, $atts = []) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'widget_id' => $id,
|
||||
'before' => '',
|
||||
'after' => '',
|
||||
@ -412,7 +412,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
'edit' => true,
|
||||
'table' => false,
|
||||
'query_filter' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$atts['table']->set_context('widget');
|
||||
@ -460,22 +460,22 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Array of attributes to pass to the form.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_fields_widget($id, $atts = array()) {
|
||||
protected function add_fields_widget($id, $atts = []) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'widget_id' => $id,
|
||||
'before' => '',
|
||||
'after' => '',
|
||||
'title' => __('Fields', 'wp-ultimo'),
|
||||
'position' => 'side',
|
||||
'screen' => get_current_screen(),
|
||||
'fields' => array(),
|
||||
'html_attr' => array(),
|
||||
'fields' => [],
|
||||
'html_attr' => [],
|
||||
'classes' => '',
|
||||
'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',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box(
|
||||
@ -484,13 +484,13 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
function () use ($atts) {
|
||||
|
||||
if (wu_get_isset($atts['html_attr'], 'data-wu-app')) {
|
||||
$atts['fields']['loading'] = array(
|
||||
$atts['fields']['loading'] = [
|
||||
'type' => 'note',
|
||||
'desc' => sprintf('<div class="wu-block wu-text-center wu-blinking-animation wu-text-gray-600 wu-my-1 wu-text-2xs wu-uppercase wu-font-semibold">%s</div>', __('Loading...', 'wp-ultimo')),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => 0,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,14 +501,14 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
$atts['widget_id'],
|
||||
$atts['fields'],
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3 ' . $atts['classes'],
|
||||
'field_wrapper_classes' => $atts['field_wrapper_classes'],
|
||||
'html_attr' => $atts['html_attr'],
|
||||
'before' => $atts['before'],
|
||||
'after' => $atts['after'],
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -529,30 +529,30 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Array of attributes to pass to the form.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_tabs_widget($id, $atts = array()) {
|
||||
protected function add_tabs_widget($id, $atts = []) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'widget_id' => $id,
|
||||
'before' => '',
|
||||
'after' => '',
|
||||
'title' => __('Tabs', 'wp-ultimo'),
|
||||
'position' => 'advanced',
|
||||
'screen' => get_current_screen(),
|
||||
'sections' => array(),
|
||||
'html_attr' => array(),
|
||||
)
|
||||
'sections' => [],
|
||||
'html_attr' => [],
|
||||
]
|
||||
);
|
||||
|
||||
$current_section = wu_request($id, current(array_keys($atts['sections'])));
|
||||
|
||||
$atts['html_attr']['data-wu-app'] = $id;
|
||||
|
||||
$atts['html_attr']['data-state'] = array(
|
||||
$atts['html_attr']['data-state'] = [
|
||||
'section' => $current_section,
|
||||
'display_all' => false,
|
||||
);
|
||||
];
|
||||
|
||||
add_meta_box(
|
||||
"wp-ultimo-{$id}-widget",
|
||||
@ -562,16 +562,16 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
foreach ($atts['sections'] as $section_id => &$section) {
|
||||
$section = wp_parse_args(
|
||||
$section,
|
||||
array(
|
||||
[
|
||||
'form' => '',
|
||||
'before' => '',
|
||||
'after' => '',
|
||||
'v-show' => '1',
|
||||
'fields' => array(),
|
||||
'html_attr' => array(),
|
||||
'state' => array(),
|
||||
'fields' => [],
|
||||
'html_attr' => [],
|
||||
'state' => [],
|
||||
'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',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -579,25 +579,25 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
$atts['html_attr']['data-state'] = array_merge($atts['html_attr']['data-state'], $section['state']);
|
||||
|
||||
$section['html_attr'] = array(
|
||||
$section['html_attr'] = [
|
||||
'v-cloak' => 1,
|
||||
'v-show' => "(section == '{$section_id}' || display_all) && " . $section['v-show'],
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Adds a header field
|
||||
*/
|
||||
$section['fields'] = array_merge(
|
||||
array(
|
||||
$section_id => array(
|
||||
[
|
||||
$section_id => [
|
||||
'title' => $section['title'],
|
||||
'desc' => $section['desc'],
|
||||
'type' => 'header',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'display_all',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
$section['fields']
|
||||
);
|
||||
|
||||
@ -609,25 +609,25 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
$section['form'] = new \WP_Ultimo\UI\Form(
|
||||
$section_id,
|
||||
$section['fields'],
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-widget-list wu-striped wu-m-0 wu-border-solid wu-border-gray-300 wu-border-0 wu-border-b',
|
||||
'field_wrapper_classes' => $section['field_wrapper_classes'],
|
||||
'html_attr' => $section['html_attr'],
|
||||
'before' => $section['before'],
|
||||
'after' => $section['after'],
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
wu_get_template(
|
||||
'base/edit/widget-tabs',
|
||||
array(
|
||||
[
|
||||
'sections' => $atts['sections'],
|
||||
'html_attr' => $atts['html_attr'],
|
||||
'before' => $atts['before'],
|
||||
'after' => $atts['after'],
|
||||
)
|
||||
]
|
||||
);
|
||||
},
|
||||
$atts['screen']->id,
|
||||
@ -645,11 +645,11 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Widget parameters.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_widget($id, $atts = array()) {
|
||||
protected function add_widget($id, $atts = []) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'widget_id' => $id,
|
||||
'before' => '',
|
||||
'after' => '',
|
||||
@ -657,7 +657,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
'screen' => get_current_screen(),
|
||||
'position' => 'side',
|
||||
'display' => '__return_empty_string',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box("wp-ultimo-{$id}-widget", $atts['title'], $atts['display'], $atts['screen']->id, $atts['position'], 'default');
|
||||
@ -672,7 +672,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Array containing the attributes to be passed to the widget.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_save_widget($id, $atts = array()) {
|
||||
protected function add_save_widget($id, $atts = []) {
|
||||
|
||||
$labels = $this->get_labels();
|
||||
|
||||
@ -681,15 +681,15 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
/**
|
||||
* Adds Submit Button
|
||||
*/
|
||||
$atts['fields']['submit_save'] = array(
|
||||
$atts['fields']['submit_save'] = [
|
||||
'type' => 'submit',
|
||||
'title' => $labels['save_button_label'],
|
||||
'placeholder' => $labels['save_button_label'],
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'html_attr' => array(),
|
||||
'wrapper_html_attr' => array(),
|
||||
);
|
||||
'html_attr' => [],
|
||||
'wrapper_html_attr' => [],
|
||||
];
|
||||
|
||||
if (isset($atts['html_attr']['data-wu-app'])) {
|
||||
$atts['fields']['submit_save']['wrapper_html_attr']['v-cloak'] = 1;
|
||||
@ -713,28 +713,28 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Array containing the attributes to be passed to the widget.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_delete_widget($id, $atts = array()) {
|
||||
protected function add_delete_widget($id, $atts = []) {
|
||||
|
||||
$labels = $this->get_labels();
|
||||
|
||||
$atts_default = array(
|
||||
$atts_default = [
|
||||
'title' => __('Delete', 'wp-ultimo'),
|
||||
'position' => 'side-bottom',
|
||||
);
|
||||
];
|
||||
$atts = array_merge($atts_default, $atts);
|
||||
|
||||
/**
|
||||
* Adds Note
|
||||
*/
|
||||
$atts['fields']['note'] = array(
|
||||
$atts['fields']['note'] = [
|
||||
'type' => 'note',
|
||||
'desc' => $labels['delete_description'],
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Adds Submit Button
|
||||
*/
|
||||
$default_delete_field_settings = array(
|
||||
$default_delete_field_settings = [
|
||||
'type' => 'link',
|
||||
'title' => '',
|
||||
'display_value' => $labels['delete_button_label'] ?? '',
|
||||
@ -742,19 +742,19 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
'value' => 'delete',
|
||||
'classes' => 'button wubox wu-w-full wu-text-center',
|
||||
'wrapper_classes' => 'wu-bg-gray-100',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'title' => $labels['delete_button_label'],
|
||||
'href' => wu_get_form_url(
|
||||
'delete_modal',
|
||||
array(
|
||||
[
|
||||
'id' => $this->get_object()->get_id(),
|
||||
'model' => $this->get_object()->model,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$custom_delete_field_settings = wu_get_isset($atts['fields'], 'delete', array());
|
||||
$custom_delete_field_settings = wu_get_isset($atts['fields'], 'delete', []);
|
||||
|
||||
$atts['fields']['delete'] = array_merge($default_delete_field_settings, $custom_delete_field_settings);
|
||||
|
||||
@ -767,18 +767,18 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/edit',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'labels' => $this->get_labels(),
|
||||
'object' => $this->get_object(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -846,9 +846,9 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$array_params = array(
|
||||
$array_params = [
|
||||
'updated' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->edit === false) {
|
||||
$array_params['id'] = $object->get_id();
|
||||
@ -870,7 +870,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_delete() {
|
||||
public function handle_delete(): void {
|
||||
|
||||
$object = $this->get_object();
|
||||
|
||||
|
@ -78,9 +78,9 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_edit_emails',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Initializes the class
|
||||
@ -88,14 +88,14 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
/**
|
||||
* Runs the parent init functions
|
||||
*/
|
||||
parent::init();
|
||||
|
||||
add_action('wu_page_edit_redirect_handlers', array($this, 'handle_page_redirect'), 10);
|
||||
add_action('wu_page_edit_redirect_handlers', [$this, 'handle_page_redirect'], 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,11 +104,11 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
wp_enqueue_script('wu-email-edit-page', wu_get_asset('email-edit-page.js', 'js'), array('jquery', 'clipboard'));
|
||||
wp_enqueue_script('wu-email-edit-page', wu_get_asset('email-edit-page.js', 'js'), ['jquery', 'clipboard']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +117,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
@ -138,224 +138,224 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'html_attr' => array(
|
||||
[
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'email_edit_save',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'slug' => $this->edit ? $object->get_slug() : '',
|
||||
'target' => $this->edit ? $object->get_target() : 'admin',
|
||||
'schedule' => $this->edit ? $object->has_schedule() : false,
|
||||
'schedule_type' => $this->edit ? $object->get_schedule_type() : 'days',
|
||||
'days' => $this->edit ? $object->get_send_days() : 1,
|
||||
'hours' => $this->edit ? $object->get_send_hours() : '12:00',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'slug' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'slug' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Slug', 'wp-ultimo'),
|
||||
'desc' => __('An unique identifier for this system email.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_slug() : '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'required' => 'required',
|
||||
'v-on:input' => 'slug = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")',
|
||||
'v-bind:value' => 'slug',
|
||||
),
|
||||
),
|
||||
'event' => array(
|
||||
],
|
||||
],
|
||||
'event' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Event', 'wp-ultimo'),
|
||||
'desc' => __('The event that will trigger the sending of this email.', 'wp-ultimo'),
|
||||
'placeholder' => __('Event', 'wp-ultimo'),
|
||||
'options' => 'wu_get_event_types_as_options',
|
||||
'value' => $this->edit ? $object->get_event() : 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'name' => '',
|
||||
),
|
||||
),
|
||||
'target' => array(
|
||||
],
|
||||
],
|
||||
'target' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Target', 'wp-ultimo'),
|
||||
'desc' => __('To whom this email should be sent.', 'wp-ultimo'),
|
||||
'placeholder' => __('Network Administrators', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_target() : 'admin',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'admin' => __('Network Administrators', 'wp-ultimo'),
|
||||
'customer' => __('Customer', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'target',
|
||||
),
|
||||
),
|
||||
'send_copy_to_admin' => array(
|
||||
],
|
||||
],
|
||||
'send_copy_to_admin' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Send Copy to Admins?', 'wp-ultimo'),
|
||||
'desc' => __('Checking this options will add the network admins as bcc every time this email is sent to a customer.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_send_copy_to_admin() : false,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'target == "customer"',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'schedule' => array(
|
||||
],
|
||||
],
|
||||
'schedule' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Schedule?', 'wp-ultimo'),
|
||||
'desc' => __('You can define when the email is sent after the event triggers.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $this->get_object()->has_schedule() : 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'schedule',
|
||||
),
|
||||
),
|
||||
'send_date' => array(
|
||||
],
|
||||
],
|
||||
'send_date' => [
|
||||
'type' => 'group',
|
||||
'title' => __('Scheduling Options', 'wp-ultimo'),
|
||||
'tooltip' => __('When this email will be sent after the event?', 'wp-ultimo'),
|
||||
'desc' => $desc,
|
||||
'desc_id' => 'send_date_desc',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'schedule',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'fields' => array(
|
||||
'schedule_type' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'schedule_type' => [
|
||||
'type' => 'select',
|
||||
'default' => 'days',
|
||||
'wrapper_classes' => 'wu-w-2/3',
|
||||
'value' => $this->edit ? $object->get_schedule_type() : 'days',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'hours' => __('Delay for hours', 'wp-ultimo'),
|
||||
'days' => __('Delay for days', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'schedule_type',
|
||||
),
|
||||
),
|
||||
'send_days' => array(
|
||||
],
|
||||
],
|
||||
'send_days' => [
|
||||
'type' => 'number',
|
||||
'value' => $this->edit && $object->get_send_days() ? $object->get_send_days() : 1,
|
||||
'placeholder' => 1,
|
||||
'min' => 0,
|
||||
'wrapper_classes' => 'wu-ml-2 wu-w-1/3',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "schedule_type == 'days'",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'days',
|
||||
),
|
||||
),
|
||||
'send_hours' => array(
|
||||
],
|
||||
],
|
||||
'send_hours' => [
|
||||
'type' => 'text',
|
||||
'date' => true,
|
||||
'placeholder' => $this->edit ? $object->get_send_hours() : '12:00',
|
||||
'value' => $this->edit ? $object->get_send_hours() : '',
|
||||
'wrapper_classes' => 'wu-ml-2 wu-w-1/3',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-no-calendar' => 'true',
|
||||
'wu-datepicker' => 'true',
|
||||
'data-format' => 'H:i',
|
||||
'data-allow-time' => 'true',
|
||||
'v-model' => 'hours',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "schedule_type == 'hours'",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box('wp-ultimo-placeholders', __('Placeholders', 'wp-ultimo'), array($this, 'output_default_widget_placeholders'), get_current_screen()->id, 'normal', null, array());
|
||||
add_meta_box('wp-ultimo-placeholders', __('Placeholders', 'wp-ultimo'), [$this, 'output_default_widget_placeholders'], get_current_screen()->id, 'normal', null, []);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'active',
|
||||
array(
|
||||
[
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'active' => array(
|
||||
'fields' => [
|
||||
'active' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to manually enable or disable this email.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_active(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_tabs_widget(
|
||||
'email_edit_options',
|
||||
array(
|
||||
[
|
||||
'title' => __('Advanced Options', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'sections' => array(
|
||||
'general' => array(
|
||||
'sections' => [
|
||||
'general' => [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-lock',
|
||||
'desc' => __('Rules and limitations to the applicability of this discount code.', 'wp-ultimo'),
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'sender' => $this->edit ? $object->get_custom_sender() : 0,
|
||||
),
|
||||
'fields' => array(
|
||||
'style' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'style' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Email Style', 'wp-ultimo'),
|
||||
'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-ultimo'),
|
||||
'placeholder' => __('Style', 'wp-ultimo'),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'default' => __('Use Default', 'wp-ultimo'),
|
||||
'html' => __('HTML Emails', 'wp-ultimo'),
|
||||
'plain' => __('Plain Emails', 'wp-ultimo'),
|
||||
),
|
||||
],
|
||||
'value' => $this->edit ? $object->get_style() : 'html',
|
||||
),
|
||||
),
|
||||
),
|
||||
'sender' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
'sender' => [
|
||||
'title' => __('Custom Sender', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-mail',
|
||||
'desc' => __('You can define an email and a name that will only be used when this email is sent.', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'custom_sender' => array(
|
||||
'fields' => [
|
||||
'custom_sender' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Use a custom sender?', 'wp-ultimo'),
|
||||
'desc' => __('You can define an email and a name that will only be used when this email is sent.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_custom_sender() : 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'sender',
|
||||
),
|
||||
),
|
||||
'custom_sender_name' => array(
|
||||
],
|
||||
],
|
||||
'custom_sender_name' => [
|
||||
'type' => 'text',
|
||||
'title' => __('From "Name"', 'wp-ultimo'),
|
||||
'desc' => __('Override the global from name for this particular email.', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-full',
|
||||
'value' => $this->edit ? $object->get_custom_sender_name() : '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'sender',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'custom_sender_email' => array(
|
||||
],
|
||||
],
|
||||
'custom_sender_email' => [
|
||||
'type' => 'email',
|
||||
'title' => __('From "Email"', 'wp-ultimo'),
|
||||
'desc' => __('Override the global from email for this particular email.', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-full',
|
||||
'value' => $this->edit ? $object->get_custom_sender_email() : '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'sender',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -368,14 +368,14 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @param array $data Arguments passed by add_meta_box.
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_placeholders($unused, $data) {
|
||||
public function output_default_widget_placeholders($unused, $data): void {
|
||||
|
||||
wu_get_template(
|
||||
'email/widget-placeholders',
|
||||
array(
|
||||
[
|
||||
'title' => __('Event Payload', 'wp-ultimo'),
|
||||
'loading_text' => __('Loading Payload', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -409,27 +409,27 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'id' => $this->get_object()->get_id(),
|
||||
'model' => 'email',
|
||||
'page' => 'edit',
|
||||
);
|
||||
];
|
||||
|
||||
$send_test_link = wu_get_form_url('send_new_test', $url_atts);
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-emails'),
|
||||
'label' => __('Go Back', 'wp-ultimo'),
|
||||
'icon' => 'wu-reply',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'url' => $send_test_link,
|
||||
'label' => __('Send Test Email', 'wp-ultimo'),
|
||||
'icon' => 'wu-mail',
|
||||
'classes' => 'wubox',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -440,7 +440,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Email', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Email', 'wp-ultimo'),
|
||||
'updated_message' => __('Email updated with success!', 'wp-ultimo'),
|
||||
@ -450,7 +450,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Email', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -463,10 +463,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'system_email',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -477,7 +477,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
$_POST['schedule'] = wu_request('schedule');
|
||||
|
||||
@ -491,10 +491,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
/**
|
||||
* Handles the redirect notice from sent new test modal.
|
||||
*
|
||||
* @param WP_Ultimo\Admin_Pages\Base_Admin_Page $page The page object.
|
||||
* @param Base_Admin_Page $page The page object.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_page_redirect($page) {
|
||||
public function handle_page_redirect($page): void {
|
||||
|
||||
if ($page->get_id() === 'wp-ultimo-edit-email') {
|
||||
if (wu_request('test_notice')) {
|
||||
@ -567,10 +567,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function events_query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'email',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
|
@ -66,9 +66,9 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_emails',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Initializes the class
|
||||
@ -76,14 +76,14 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
/**
|
||||
* Runs the parent init functions
|
||||
*/
|
||||
parent::init();
|
||||
|
||||
add_action('wu_page_list_redirect_handlers', array($this, 'handle_page_redirect'), 10);
|
||||
add_action('wu_page_list_redirect_handlers', [$this, 'handle_page_redirect'], 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,17 +133,17 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Send a email test
|
||||
*/
|
||||
wu_register_form(
|
||||
'send_new_test',
|
||||
array(
|
||||
'render' => array($this, 'render_send_new_test_modal'),
|
||||
'handler' => array($this, 'handle_send_new_test_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_send_new_test_modal'],
|
||||
'handler' => [$this, 'handle_send_new_test_modal'],
|
||||
'capability' => 'wu_add_broadcast',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -151,11 +151,11 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
wu_register_form(
|
||||
'reset_import',
|
||||
array(
|
||||
'render' => array($this, 'render_reset_import_modal'),
|
||||
'handler' => array($this, 'handle_reset_import_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_reset_import_modal'],
|
||||
'handler' => [$this, 'handle_reset_import_modal'],
|
||||
'capability' => 'wu_add_broadcasts',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -163,11 +163,11 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
wu_register_form(
|
||||
'reset_confirmation',
|
||||
array(
|
||||
'render' => array($this, 'render_reset_confirmation_modal'),
|
||||
'handler' => array($this, 'handle_reset_confirmation_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_reset_confirmation_modal'],
|
||||
'handler' => [$this, 'handle_reset_confirmation_modal'],
|
||||
'capability' => 'wu_add_broadcasts',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -177,47 +177,47 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_send_new_test_modal() {
|
||||
public function render_send_new_test_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'send_to' => array(
|
||||
$fields = [
|
||||
'send_to' => [
|
||||
'type' => 'email',
|
||||
'title' => __('Send To', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. network@email.com', 'wp-ultimo'),
|
||||
'desc' => __('The test email will be sent to the above email address.', 'wp-ultimo'),
|
||||
'value' => get_network_option(null, 'admin_email'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'required' => 'required',
|
||||
),
|
||||
),
|
||||
'email_id' => array(
|
||||
],
|
||||
],
|
||||
'email_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('id'),
|
||||
),
|
||||
'page' => array(
|
||||
],
|
||||
'page' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('page'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Send Test Email', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-text-right',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'send_new_test',
|
||||
$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' => 'send_new_test',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -227,7 +227,7 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
* Handles the modal to send tests with system emails.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
public function handle_send_new_test_modal() {
|
||||
|
||||
@ -238,20 +238,20 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
if ( ! $email_id || ! $send_to) {
|
||||
$error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo'));
|
||||
|
||||
return wp_send_json_error($error);
|
||||
wp_send_json_error($error);
|
||||
}
|
||||
|
||||
$from = array(
|
||||
$from = [
|
||||
'name' => wu_get_setting('from_name'),
|
||||
'email' => wu_get_setting('from_email'),
|
||||
);
|
||||
];
|
||||
|
||||
$to = array(
|
||||
array(
|
||||
$to = [
|
||||
[
|
||||
'name' => wu_get_setting('from_name'),
|
||||
'email' => $send_to,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$email = wu_get_email($email_id);
|
||||
|
||||
@ -259,54 +259,54 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
$event_type = wu_get_event_type($event_slug);
|
||||
|
||||
$payload = array();
|
||||
$payload = [];
|
||||
|
||||
if ($event_type) {
|
||||
$payload = wu_maybe_lazy_load_payload($event_type['payload']);
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'style' => $email->get_style(),
|
||||
'content' => $email->get_content(),
|
||||
'subject' => get_network_option(null, 'site_name') . ' - ' . $email->get_title(),
|
||||
'payload' => $payload,
|
||||
);
|
||||
];
|
||||
|
||||
$send_mail = wu_send_mail($from, $to, $args);
|
||||
|
||||
if ( ! $send_mail) {
|
||||
$error = new \WP_Error('error', __('Something wrong happened with your test.', 'wp-ultimo'));
|
||||
|
||||
return wp_send_json_error($error);
|
||||
wp_send_json_error($error);
|
||||
}
|
||||
|
||||
$page = wu_request('page', 'list');
|
||||
|
||||
if ($page === 'edit') {
|
||||
if ('edit' === $page) {
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-email',
|
||||
array(
|
||||
[
|
||||
'id' => $email_id,
|
||||
'test_notice' => __('Test sent successfully', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-emails',
|
||||
array(
|
||||
[
|
||||
'notice' => __('Test sent successfully', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -317,36 +317,36 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_reset_import_modal() {
|
||||
public function render_reset_import_modal(): void {
|
||||
|
||||
$default_system_emails = wu_get_default_system_emails();
|
||||
|
||||
$created_emails = wu_get_all_system_emails();
|
||||
|
||||
$fields = array(
|
||||
'reset_emails' => array(
|
||||
$fields = [
|
||||
'reset_emails' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Reset System Emails ', 'wp-ultimo'),
|
||||
'desc' => __('Restore the system emails to their original content.'),
|
||||
'desc' => __('Restore the system emails to their original content.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'reset_emails',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$fields['reset_note'] = array(
|
||||
$fields['reset_note'] = [
|
||||
'type' => 'note',
|
||||
'title' => '',
|
||||
'desc' => __('No emails to reset.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 0,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'reset_emails',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($created_emails as $system_email_key => $system_email_value) {
|
||||
$system_email_slug = $system_email_value->get_slug();
|
||||
@ -358,18 +358,18 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
$field_title = '<div><strong class="wu-inline-block wu-pr-1">' . $system_email_value->get_title() . '</strong></div>';
|
||||
|
||||
$fields[ $field_name ] = array(
|
||||
$fields[ $field_name ] = [
|
||||
'type' => 'toggle',
|
||||
'title' => $field_title,
|
||||
'desc' => $system_email_value->get_event() . ' <span class="wu-bg-gray-200 wu-text-gray-700 wu-py-1 wu-px-2 wu-rounded-sm wu-text-xs wu-font-mono">' . $system_email_target . '</span>',
|
||||
'tooltip' => '',
|
||||
'value' => 0,
|
||||
'wrapper_classes' => 'wu-bg-gray-100',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'reset_emails',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if (isset($fields['reset_note'])) {
|
||||
unset($fields['reset_note']);
|
||||
@ -377,28 +377,28 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
}
|
||||
|
||||
$fields['import_emails'] = array(
|
||||
$fields['import_emails'] = [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Import System Emails', 'wp-ultimo'),
|
||||
'desc' => __('Add new system emails based on WP Multisite WaaS presets.'),
|
||||
'desc' => __('Add new system emails based on WP Multisite WaaS presets.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'import_emails',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields['import_note'] = array(
|
||||
$fields['import_note'] = [
|
||||
'type' => 'note',
|
||||
'title' => '',
|
||||
'desc' => __('All emails are already present.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'value' => 0,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'import_emails',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($default_system_emails as $default_email_key => $default_email_value) {
|
||||
$maybe_is_created = wu_get_email_by('slug', $default_email_key);
|
||||
@ -408,18 +408,18 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
$field_title = '<div><strong class="wu-inline-block wu-pr-1">' . $default_email_value['title'] . '</strong> </div>';
|
||||
|
||||
$fields[ $field_name ] = array(
|
||||
$fields[ $field_name ] = [
|
||||
'type' => 'toggle',
|
||||
'title' => $field_title,
|
||||
'desc' => $default_email_value['event'] . ' <span class="wu-bg-gray-200 wu-text-gray-700 wu-py-1 wu-px-2 wu-rounded-sm wu-text-xs wu-font-mono">' . $default_email_value['target'] . '</span>',
|
||||
'tooltip' => '',
|
||||
'value' => 0,
|
||||
'wrapper_classes' => 'wu-bg-gray-100',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'import_emails',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if (isset($fields['import_note'])) {
|
||||
unset($fields['import_note']);
|
||||
@ -427,31 +427,31 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
}
|
||||
|
||||
$fields['submit_button'] = array(
|
||||
$fields['submit_button'] = [
|
||||
'type' => 'submit',
|
||||
'title' => __('Reset and/or Import', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-text-right',
|
||||
);
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'reset_import',
|
||||
$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' => 'reset_import',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
'data-state' => wp_json_encode(
|
||||
[
|
||||
'reset_emails' => false,
|
||||
'import_emails' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -464,7 +464,7 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle_reset_import_modal() {
|
||||
public function handle_reset_import_modal(): void {
|
||||
|
||||
$reset = wu_request('reset_emails');
|
||||
|
||||
@ -501,19 +501,19 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-emails'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the redirect notice from sent new test modal.
|
||||
*
|
||||
* @param WP_Ultimo\Admin_Pages\Base_Admin_Page $page The page object.
|
||||
* @param Base_Admin_Page $page The page object.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_page_redirect($page) {
|
||||
public function handle_page_redirect($page): void {
|
||||
|
||||
if ($page->get_id() === 'wp-ultimo-emails') {
|
||||
if (wu_request('notice')) {
|
||||
@ -528,7 +528,6 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -539,42 +538,42 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_reset_confirmation_modal() {
|
||||
public function render_reset_confirmation_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'single_reset' => array(
|
||||
$fields = [
|
||||
'single_reset' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Reset', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'default' => 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'required' => 'required',
|
||||
),
|
||||
),
|
||||
'email_id' => array(
|
||||
],
|
||||
],
|
||||
'email_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('id'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Reset Email', 'wp-ultimo'),
|
||||
'value' => 'reset',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-text-right',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'reset_confirmation',
|
||||
$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' => 'reset_confirmation',
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -585,7 +584,7 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
public function handle_reset_confirmation_modal() {
|
||||
|
||||
@ -596,7 +595,7 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
if ( ! $single_reset || ! $email_id) {
|
||||
$error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo'));
|
||||
|
||||
return wp_send_json_error($error);
|
||||
wp_send_json_error($error);
|
||||
}
|
||||
|
||||
$email = wu_get_email($email_id);
|
||||
@ -615,18 +614,18 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
if ( ! $new_email) {
|
||||
$error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo'));
|
||||
|
||||
return wp_send_json_error($error);
|
||||
wp_send_json_error($error);
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-email',
|
||||
array(
|
||||
[
|
||||
'id' => $new_email->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -641,24 +640,24 @@ class Email_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
$email_template_default = get_network_option(null, 'wu_default_email_template');
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-edit-email'),
|
||||
'label' => __('Add System Email'),
|
||||
'label' => __('Add System Email', 'wp-ultimo'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-customize-email-template&id=' . $email_template_default),
|
||||
'label' => __('Email Template'),
|
||||
'label' => __('Email Template', 'wp-ultimo'),
|
||||
'icon' => 'wu-mail',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'url' => wu_get_form_url('reset_import'),
|
||||
'classes' => 'wubox',
|
||||
'label' => __('Reset or Import'),
|
||||
'label' => __('Reset or Import', 'wp-ultimo'),
|
||||
'icon' => 'wu-cycle',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,9 +66,9 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_customize_email_template',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Overrides the init method to add additional hooks.
|
||||
@ -76,11 +76,11 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
add_action('wp_ajax_wu-email-template-preview', array($this, 'email_template_preview'));
|
||||
add_action('wp_ajax_wu-email-template-preview', [$this, 'email_template_preview']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +101,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function email_template_preview() {
|
||||
public function email_template_preview(): void {
|
||||
|
||||
$object = $this;
|
||||
|
||||
@ -151,14 +151,14 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
|
||||
wu_get_template(
|
||||
'broadcast/emails/base',
|
||||
array(
|
||||
[
|
||||
'site_name' => get_network_option(null, 'site_name'),
|
||||
'site_url' => get_site_url(),
|
||||
'logo_url' => wu_get_network_logo(),
|
||||
'content' => $content,
|
||||
'subject' => __('Sample Subject', 'wp-ultimo'),
|
||||
'is_editor' => true,
|
||||
'template_settings' => array(
|
||||
'template_settings' => [
|
||||
'use_custom_logo' => wu_string_to_bool(wu_request('use_custom_logo', $first_request ? $object->get_setting('use_custom_logo', false) : false)),
|
||||
'custom_logo' => wu_request('custom_logo', $object->get_setting('custom_logo', false)),
|
||||
'background_color' => wu_request('background_color', $object->get_setting('background_color', '#f9f9f9')),
|
||||
@ -174,8 +174,8 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
'footer_color' => wu_request('footer_color', $object->get_setting('footer_color', '#000000')),
|
||||
'footer_align' => wu_request('footer_align', $object->get_setting('footer_align', 'center')),
|
||||
'display_company_address' => wu_string_to_bool(wu_request('display_company_address', $first_request ? $object->get_setting('display_company_address', true) : false)),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
die;
|
||||
@ -192,10 +192,10 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
$url = get_admin_url(wu_get_main_site_id(), 'admin-ajax.php');
|
||||
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'action' => 'wu-email-template-preview',
|
||||
'customizer' => 1,
|
||||
),
|
||||
],
|
||||
$url
|
||||
);
|
||||
}
|
||||
@ -206,22 +206,22 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'html_attr' => array(
|
||||
[
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'save',
|
||||
'data-state' => wu_convert_to_state(),
|
||||
),
|
||||
'fields' => array(
|
||||
'note' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('System emails and broadcasts will be sent using this template.', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$settings = $this->get_attributes();
|
||||
@ -232,273 +232,273 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
|
||||
$custom_logo_url = $custom_logo_args ? $custom_logo_args[0] : '';
|
||||
|
||||
$fields = array(
|
||||
'tab' => array(
|
||||
$fields = [
|
||||
'tab' => [
|
||||
'type' => 'tab-select',
|
||||
'wrapper_classes' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'tab',
|
||||
),
|
||||
'options' => array(
|
||||
],
|
||||
'options' => [
|
||||
'header' => __('Header', 'wp-ultimo'),
|
||||
'content' => __('Content', 'wp-ultimo'),
|
||||
'footer' => __('Footer', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
'use_custom_logo' => array(
|
||||
],
|
||||
],
|
||||
'use_custom_logo' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Use Custom Logo', 'wp-ultimo'),
|
||||
'desc' => __('You can set a different logo to be used on the system emails.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "header")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'use_custom_logo',
|
||||
),
|
||||
),
|
||||
'custom_logo' => array(
|
||||
],
|
||||
],
|
||||
'custom_logo' => [
|
||||
'type' => 'image',
|
||||
'stacked' => true,
|
||||
'title' => __('Custom Logo', 'wp-ultimo'),
|
||||
'desc' => __('The custom logo is used in the email header, if HTML emails are used.', 'wp-ultimo'),
|
||||
'value' => $custom_logo,
|
||||
'img' => $custom_logo_url,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "header") && require("use_custom_logo", true)',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
// 'v-model' => 'custom_logo',
|
||||
),
|
||||
),
|
||||
'background_color' => array(
|
||||
],
|
||||
],
|
||||
'background_color' => [
|
||||
'type' => 'color-picker',
|
||||
'title' => __('Background Color', 'wp-ultimo'),
|
||||
'tooltip' => __('The cover background color of the email.', 'wp-ultimo'),
|
||||
'value' => '#00a1ff',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "header")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'background_color',
|
||||
),
|
||||
),
|
||||
'title_color' => array(
|
||||
],
|
||||
],
|
||||
'title_color' => [
|
||||
'type' => 'color-picker',
|
||||
'title' => __('Title Color', 'wp-ultimo'),
|
||||
'value' => '#00a1ff',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "header")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'title_color',
|
||||
),
|
||||
),
|
||||
'title_size' => array(
|
||||
],
|
||||
],
|
||||
'title_size' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Title Size', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'title_size'),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'h1' => __('h1', 'wp-ultimo'),
|
||||
'h2' => __('h2', 'wp-ultimo'),
|
||||
'h3' => __('h3', 'wp-ultimo'),
|
||||
'h4' => __('h4', 'wp-ultimo'),
|
||||
'h5' => __('h5', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "header")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'title_size',
|
||||
),
|
||||
),
|
||||
'title_align' => array(
|
||||
],
|
||||
],
|
||||
'title_align' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Title Align', 'wp-ultimo'),
|
||||
'tooltip' => __('Aligment of the font in the title.', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'title_align', ''),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'left' => __('Left', 'wp-ultimo'),
|
||||
'center' => __('Center', 'wp-ultimo'),
|
||||
'right' => __('Right', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "header")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'title_align',
|
||||
),
|
||||
),
|
||||
'title_font' => array(
|
||||
],
|
||||
],
|
||||
'title_font' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Title Font-Family', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'title_font', ''),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif' => __('Helvetica', 'wp-ultimo'),
|
||||
'Arial, Helvetica, sans-serif' => __('Arial', 'wp-ultimo'),
|
||||
'Times New Roman, Times, serif' => __('Times New Roman', 'wp-ultimo'),
|
||||
'Lucida Console, Courier, monospace' => __('Lucida', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "header")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'title_font',
|
||||
),
|
||||
),
|
||||
'content_color' => array(
|
||||
],
|
||||
],
|
||||
'content_color' => [
|
||||
'type' => 'color-picker',
|
||||
'title' => __('Content Color', 'wp-ultimo'),
|
||||
'value' => '#000000',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "content")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'content_color',
|
||||
),
|
||||
),
|
||||
'content_align' => array(
|
||||
],
|
||||
],
|
||||
'content_align' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Content Alignment', 'wp-ultimo'),
|
||||
'tooltip' => __('Alignment of the font in the main email content.', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'content_align', ''),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'left' => __('Left', 'wp-ultimo'),
|
||||
'center' => __('Center', 'wp-ultimo'),
|
||||
'right' => __('Right', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "content")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'content_align',
|
||||
),
|
||||
),
|
||||
'content_font' => array(
|
||||
],
|
||||
],
|
||||
'content_font' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Content Font-Family', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'content_font', ''),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif' => __('Helvetica', 'wp-ultimo'),
|
||||
'Arial, Helvetica, sans-serif' => __('Arial', 'wp-ultimo'),
|
||||
'Times New Roman, Times, serif' => __('Times New Roman', 'wp-ultimo'),
|
||||
'Lucida Console, Courier, monospace' => __('Lucida', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "content")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'content_font',
|
||||
),
|
||||
),
|
||||
'display_company_address' => array(
|
||||
],
|
||||
],
|
||||
'display_company_address' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Display Company Address', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show/hide your company address.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "footer")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'display_company_address',
|
||||
),
|
||||
),
|
||||
'footer_text' => array(
|
||||
],
|
||||
],
|
||||
'footer_text' => [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Footer Content', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. Extra info in the email footer.', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'footer_text', ''),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "footer")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'footer_text',
|
||||
),
|
||||
),
|
||||
'footer_font' => array(
|
||||
],
|
||||
],
|
||||
'footer_font' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Footer Font-Family', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'footer_font', ''),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif' => __('Helvetica', 'wp-ultimo'),
|
||||
'Arial, Helvetica, sans-serif' => __('Arial', 'wp-ultimo'),
|
||||
'Times New Roman, Times, serif' => __('Times New Roman', 'wp-ultimo'),
|
||||
'Lucida Console, Courier, monospace' => __('Lucida', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "footer")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'footer_font',
|
||||
),
|
||||
),
|
||||
'footer_color' => array(
|
||||
],
|
||||
],
|
||||
'footer_color' => [
|
||||
'type' => 'color-picker',
|
||||
'title' => __('Footer Color', 'wp-ultimo'),
|
||||
'value' => '#000000',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "footer")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'footer_color',
|
||||
),
|
||||
),
|
||||
'footer_align' => array(
|
||||
],
|
||||
],
|
||||
'footer_align' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Footer Alignment', 'wp-ultimo'),
|
||||
'tooltip' => __('Alignment of the font in the main email footer.', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'footer_align', ''),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'left' => __('Left', 'wp-ultimo'),
|
||||
'center' => __('Center', 'wp-ultimo'),
|
||||
'right' => __('Right', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "footer")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'footer_align',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$state = array_merge(
|
||||
$settings,
|
||||
array(
|
||||
[
|
||||
'tab' => 'header',
|
||||
'refresh' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'customizer',
|
||||
array(
|
||||
[
|
||||
'title' => __('Customizer', 'wp-ultimo'),
|
||||
'position' => 'side',
|
||||
'fields' => $fields,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'style' => 'margin-top: -6px;',
|
||||
'data-wu-app' => 'email_template_customizer',
|
||||
'data-wu-customizer-panel' => true,
|
||||
'data-state' => json_encode($state),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -532,7 +532,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -543,7 +543,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'customize_label' => __('Customize Email Template', 'wp-ultimo'),
|
||||
'add_new_label' => __('Customize Email Template', 'wp-ultimo'),
|
||||
'edit_label' => __('Edit Email Template', 'wp-ultimo'),
|
||||
@ -554,7 +554,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Email Template', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -563,7 +563,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
$_POST['footer_text'] = stripslashes((string) $_POST['footer_text']);
|
||||
|
||||
@ -590,9 +590,9 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public function get_attributes() {
|
||||
|
||||
$saved_atts = $this->get_settings();
|
||||
$saved_atts = static::get_settings();
|
||||
|
||||
$attributes = wp_parse_args($saved_atts, $this->get_default_settings());
|
||||
$attributes = wp_parse_args($saved_atts, static::get_default_settings());
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
@ -605,7 +605,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public static function get_default_settings() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'use_custom_logo' => false,
|
||||
'custom_logo' => false,
|
||||
'display_company_address' => true,
|
||||
@ -621,7 +621,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
'footer_text' => '',
|
||||
'footer_color' => '#000000',
|
||||
'footer_align' => 'center',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -633,7 +633,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public static function get_settings() {
|
||||
|
||||
return wu_get_option('email_template', array());
|
||||
return wu_get_option('email_template', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -648,7 +648,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
public function get_setting($setting, $default = false) {
|
||||
|
||||
if ($setting) {
|
||||
$return = wu_get_option('email_template', array());
|
||||
$return = wu_get_option('email_template', []);
|
||||
|
||||
if ($return && isset($return[ $setting ])) {
|
||||
$return = $return[ $setting ];
|
||||
|
@ -52,9 +52,9 @@ class Event_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_events',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Instantiate the necessary hooks.
|
||||
@ -62,9 +62,9 @@ class Event_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('init', array($this, 'set_badge_count'));
|
||||
add_action('init', [$this, 'set_badge_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,11 +73,11 @@ class Event_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
parent::page_loaded();
|
||||
|
||||
add_action('in_admin_header', array($this, 'count_seen_events'));
|
||||
add_action('in_admin_header', [$this, 'count_seen_events']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +86,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function set_badge_count() {
|
||||
public function set_badge_count(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -119,19 +119,19 @@ class Event_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function count_seen_events() {
|
||||
public function count_seen_events(): void {
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
delete_site_transient("wu_{$user_id}_unseen_events_count");
|
||||
|
||||
$last_event = wu_get_events(
|
||||
array(
|
||||
[
|
||||
'orderby' => 'id',
|
||||
'fields' => 'ids',
|
||||
'order' => 'DESC',
|
||||
'number' => 1,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! empty($last_event)) {
|
||||
@ -159,10 +159,10 @@ class Event_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Event removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Event', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,13 +206,13 @@ class Event_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-view-logs'),
|
||||
'label' => __('View Logs'),
|
||||
'icon' => 'dashicons dashicons-editor-ol',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,9 +76,9 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_events',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to register scripts and styles that can be loaded on the output function, for example.
|
||||
@ -86,11 +86,11 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
\WP_Ultimo\Scripts::get_instance()->register_script('wu-event-view', wu_get_asset('event-view-page.js', 'js'), array('jquery'));
|
||||
\WP_Ultimo\Scripts::get_instance()->register_script('wu-event-view', wu_get_asset('event-view-page.js', 'js'), ['jquery']);
|
||||
|
||||
wp_enqueue_script('wu-event-view');
|
||||
|
||||
@ -105,16 +105,16 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Delete Event - Confirmation modal
|
||||
*/
|
||||
|
||||
add_filter(
|
||||
'wu_data_json_success_delete_event_modal',
|
||||
fn($data_json) => array(
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-events', array('deleted' => 1)),
|
||||
)
|
||||
fn($data_json) => [
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-events', ['deleted' => 1]),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -124,23 +124,23 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
add_meta_box('wp-ultimo-message', __('Event Message', 'wp-ultimo'), array($this, 'output_default_widget_message'), get_current_screen()->id, 'normal', 'default');
|
||||
add_meta_box('wp-ultimo-message', __('Event Message', 'wp-ultimo'), [$this, 'output_default_widget_message'], get_current_screen()->id, 'normal', 'default');
|
||||
|
||||
add_meta_box('wp-ultimo-initiator', __('Event', 'wp-ultimo'), array($this, 'output_default_widget_initiator'), get_current_screen()->id, 'side', 'default');
|
||||
add_meta_box('wp-ultimo-initiator', __('Event', 'wp-ultimo'), [$this, 'output_default_widget_initiator'], get_current_screen()->id, 'side', 'default');
|
||||
|
||||
add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), array($this, 'output_default_widget_payload'), get_current_screen()->id, 'normal', 'default');
|
||||
add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), [$this, 'output_default_widget_payload'], get_current_screen()->id, 'normal', 'default');
|
||||
|
||||
$this->add_info_widget(
|
||||
'info',
|
||||
array(
|
||||
[
|
||||
'title' => __('Timestamps', 'wp-ultimo'),
|
||||
'position' => 'side',
|
||||
'modified' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -150,16 +150,16 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_message() {
|
||||
public function output_default_widget_message(): void {
|
||||
|
||||
wu_get_template(
|
||||
'events/widget-message',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'labels' => $this->get_labels(),
|
||||
'object' => $this->get_object(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -169,17 +169,17 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_payload() {
|
||||
public function output_default_widget_payload(): void {
|
||||
|
||||
$object = $this->get_object();
|
||||
|
||||
wu_get_template(
|
||||
'events/widget-payload',
|
||||
array(
|
||||
[
|
||||
'title' => __('Event Payload', 'wp-ultimo'),
|
||||
'loading_text' => __('Loading Payload', 'wp-ultimo'),
|
||||
'payload' => json_encode($object->get_payload(), JSON_PRETTY_PRINT),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -189,13 +189,13 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_initiator() {
|
||||
public function output_default_widget_initiator(): void {
|
||||
|
||||
$object = $this->get_object();
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'object' => $object,
|
||||
);
|
||||
];
|
||||
|
||||
wu_get_template('events/widget-initiator', $args);
|
||||
}
|
||||
@ -230,7 +230,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,7 +241,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Event', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Event', 'wp-ultimo'),
|
||||
'updated_message' => __('Event updated with success!', 'wp-ultimo'),
|
||||
@ -251,7 +251,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Event', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,9 +66,9 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Current integration being setup.
|
||||
@ -84,7 +84,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
if (isset($_GET['integration'])) {
|
||||
$domain_manager = \WP_Ultimo\Managers\Domain_Manager::get_instance();
|
||||
@ -131,30 +131,30 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
*/
|
||||
public function get_sections() {
|
||||
|
||||
$sections = array(
|
||||
'activation' => array(
|
||||
$sections = [
|
||||
'activation' => [
|
||||
'title' => __('Activation', 'wp-ultimo'),
|
||||
'view' => array($this, 'section_activation'),
|
||||
'handler' => array($this, 'handle_activation'),
|
||||
),
|
||||
'instructions' => array(
|
||||
'view' => [$this, 'section_activation'],
|
||||
'handler' => [$this, 'handle_activation'],
|
||||
],
|
||||
'instructions' => [
|
||||
'title' => __('Instructions', 'wp-ultimo'),
|
||||
'view' => array($this, 'section_instructions'),
|
||||
),
|
||||
'config' => array(
|
||||
'view' => [$this, 'section_instructions'],
|
||||
],
|
||||
'config' => [
|
||||
'title' => __('Configuration', 'wp-ultimo'),
|
||||
'view' => array($this, 'section_configuration'),
|
||||
'handler' => array($this, 'handle_configuration'),
|
||||
),
|
||||
'testing' => array(
|
||||
'view' => [$this, 'section_configuration'],
|
||||
'handler' => [$this, 'handle_configuration'],
|
||||
],
|
||||
'testing' => [
|
||||
'title' => __('Testing Integration', 'wp-ultimo'),
|
||||
'view' => array($this, 'section_test'),
|
||||
),
|
||||
'done' => array(
|
||||
'view' => [$this, 'section_test'],
|
||||
],
|
||||
'done' => [
|
||||
'title' => __('Ready!', 'wp-ultimo'),
|
||||
'view' => array($this, 'section_ready'),
|
||||
),
|
||||
);
|
||||
'view' => [$this, 'section_ready'],
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Some host providers require no instructions.
|
||||
@ -179,19 +179,19 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function section_activation() {
|
||||
public function section_activation(): void {
|
||||
|
||||
$explainer_lines = $this->integration->get_explainer_lines();
|
||||
|
||||
wu_get_template(
|
||||
'wizards/host-integrations/activation',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'integration' => $this->integration,
|
||||
'will' => $explainer_lines['will'],
|
||||
'will_not' => $explainer_lines['will_not'],
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -201,9 +201,9 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function section_instructions() {
|
||||
public function section_instructions(): void {
|
||||
|
||||
call_user_func(array($this->integration, 'get_instructions'));
|
||||
call_user_func([$this->integration, 'get_instructions']);
|
||||
|
||||
$this->render_submit_box();
|
||||
}
|
||||
@ -214,7 +214,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function section_configuration() {
|
||||
public function section_configuration(): void {
|
||||
|
||||
$fields = $this->integration->get_fields();
|
||||
|
||||
@ -225,23 +225,23 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
$this->get_current_section(),
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-px-6 wu-py-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',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (wu_request('manual')) {
|
||||
wu_get_template(
|
||||
'wizards/host-integrations/configuration-results',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'integration' => $this->integration,
|
||||
'form' => $form,
|
||||
'post' => $_GET['post'],
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return;
|
||||
@ -249,12 +249,12 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
|
||||
wu_get_template(
|
||||
'wizards/host-integrations/configuration',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'integration' => $this->integration,
|
||||
'form' => $form,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -264,15 +264,15 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function section_ready() {
|
||||
public function section_ready(): void {
|
||||
|
||||
wu_get_template(
|
||||
'wizards/host-integrations/ready',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'integration' => $this->integration,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_activation() {
|
||||
public function handle_activation(): void {
|
||||
|
||||
$is_enabled = $this->integration->is_enabled();
|
||||
|
||||
@ -305,15 +305,15 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_configuration() {
|
||||
public function handle_configuration(): void {
|
||||
|
||||
if (wu_request('submit') == '0') { // phpcs:ignore
|
||||
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'manual' => '1',
|
||||
'post' => $_POST,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_redirect($redirect_url);
|
||||
@ -344,17 +344,17 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function section_test() {
|
||||
public function section_test(): void {
|
||||
|
||||
wp_enqueue_script('wu-vue');
|
||||
|
||||
wu_get_template(
|
||||
'wizards/host-integrations/test',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'integration' => $this->integration,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_customize_invoice_template',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Overrides the original init to add the required ajax endpoints.
|
||||
@ -78,11 +78,11 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
add_action('wp_ajax_wu-preview-invoice', array($this, 'generate_invoice_preview'));
|
||||
add_action('wp_ajax_wu-preview-invoice', [$this, 'generate_invoice_preview']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,7 +91,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function generate_invoice_preview() {
|
||||
public function generate_invoice_preview(): void {
|
||||
|
||||
if ( ! current_user_can('wu_manage_invoice')) {
|
||||
return;
|
||||
@ -119,11 +119,11 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
$url = get_admin_url(wu_get_main_site_id(), 'admin-ajax.php');
|
||||
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'action' => 'wu-preview-invoice',
|
||||
'customizer' => 1,
|
||||
'invoice-customize' => 1,
|
||||
),
|
||||
],
|
||||
$url
|
||||
);
|
||||
}
|
||||
@ -134,20 +134,20 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$settings = Invoice::get_settings();
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'fields' => array(
|
||||
'note' => array(
|
||||
[
|
||||
'fields' => [
|
||||
'note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('Changes to this template will be applied to all PDF invoices generated after the change. <br><br>Existing PDF Invoices will not be affected unless explicitly re-generated', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$custom_logo = wu_get_isset($settings, 'custom_logo');
|
||||
@ -156,139 +156,139 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
|
||||
$custom_logo_url = $custom_logo_args ? $custom_logo_args[0] : '';
|
||||
|
||||
$fields = array(
|
||||
'tab' => array(
|
||||
$fields = [
|
||||
'tab' => [
|
||||
'type' => 'tab-select',
|
||||
'wrapper_classes' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'tab',
|
||||
),
|
||||
'options' => array(
|
||||
],
|
||||
'options' => [
|
||||
'general' => __('General', 'wp-ultimo'),
|
||||
'colors' => __('Colors', 'wp-ultimo'),
|
||||
'images' => __('Images', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'paid_tag_text' => array(
|
||||
'paid_tag_text' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Paid Tag', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. Paid.', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'paid_tag_text', __('Paid', 'wp-ultimo')),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "general")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'paid_tag_text',
|
||||
),
|
||||
),
|
||||
'font' => array(
|
||||
],
|
||||
],
|
||||
'font' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Font-Family', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'font', ''),
|
||||
'options' => array(
|
||||
'DejaVuSansCondensed' => __('Sans-Serif', 'wp-ultimo'),
|
||||
'FreeSerif' => __('Serif', 'wp-ultimo'),
|
||||
'FreeMono' => __('Mono', 'wp-ultimo'),
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
'options' => [
|
||||
'DejaVuSansCondensed' => __('Sans-Serif', 'wp-ultimo'),
|
||||
'DejaVuSerifCondensed' => __('Serif', 'wp-ultimo'),
|
||||
'FreeMono' => __('Mono', 'wp-ultimo'),
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "general")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'font',
|
||||
),
|
||||
),
|
||||
'footer_message' => array(
|
||||
],
|
||||
],
|
||||
'footer_message' => [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Footer Content', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g. Extra Info about the Invoice.', 'wp-ultimo'),
|
||||
'value' => wu_get_isset($settings, 'footer_message', ''),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "general")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'footer_message',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'primary_color' => array(
|
||||
'primary_color' => [
|
||||
'type' => 'color-picker',
|
||||
'title' => __('Primary Color', 'wp-ultimo'),
|
||||
'value' => '#00a1ff',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "colors")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'primary_color',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'use_custom_logo' => array(
|
||||
'use_custom_logo' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Use Custom Logo', 'wp-ultimo'),
|
||||
'desc' => __('You can set a different logo to be used on the invoice.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "images")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'use_custom_logo',
|
||||
),
|
||||
),
|
||||
'custom_logo' => array(
|
||||
],
|
||||
],
|
||||
'custom_logo' => [
|
||||
'type' => 'image',
|
||||
'title' => __('Custom Logo', 'wp-ultimo'),
|
||||
'desc' => __('This will be added to the top of the generated PDF.', 'wp-ultimo'),
|
||||
'value' => '',
|
||||
'img' => $custom_logo_url,
|
||||
'stacked' => true,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "images") && require("use_custom_logo", true)',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'custom_logo',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$settings = array(
|
||||
$settings = [
|
||||
'footer_message' => wu_get_isset($settings, 'footer_message', ''),
|
||||
'paid_tag_text' => wu_get_isset($settings, 'paid_tag_text', __('Paid', 'wp-ultimo')),
|
||||
'primary_color' => wu_get_isset($settings, 'primary_color', '00a1ff'),
|
||||
'use_custom_logo' => wu_get_isset($settings, 'use_custom_logo'),
|
||||
'custom_logo' => wu_get_isset($settings, 'custom_logo'),
|
||||
'font' => wu_get_isset($settings, 'font', 'DejaVuSansCondensed'),
|
||||
);
|
||||
];
|
||||
|
||||
$state = array_merge(
|
||||
$settings,
|
||||
array(
|
||||
[
|
||||
'tab' => 'general',
|
||||
'refresh' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'customizer',
|
||||
array(
|
||||
[
|
||||
'title' => __('Customizer', 'wp-ultimo'),
|
||||
'position' => 'side',
|
||||
'fields' => $fields,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'style' => 'margin-top: -6px;',
|
||||
'data-wu-app' => 'invoice_customizer',
|
||||
'data-wu-customizer-panel' => true,
|
||||
'data-state' => json_encode($state),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,7 +333,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'customize_label' => __('Customize Invoice Template', 'wp-ultimo'),
|
||||
'add_new_label' => __('Customize Invoice Template', 'wp-ultimo'),
|
||||
'edit_label' => __('Edit Invoice Template', 'wp-ultimo'),
|
||||
@ -342,7 +342,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
'title_description' => __('This name is used for internal reference only.', 'wp-ultimo'),
|
||||
'save_button_label' => __('Save Invoice Template', 'wp-ultimo'),
|
||||
'save_description' => __('Save Invoice Template', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -351,7 +351,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
Invoice::save_settings($_POST);
|
||||
|
||||
|
@ -66,9 +66,9 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_jobs',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Overrides the init method to add additional hooks.
|
||||
@ -76,11 +76,11 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
|
||||
add_filter('action_scheduler_admin_view_class', array($this, 'hide_as_admin_page'), 9999, 1);
|
||||
add_filter('action_scheduler_admin_view_class', [$this, 'hide_as_admin_page'], 9999, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,7 +97,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
|
||||
return $admin_view_class;
|
||||
}
|
||||
|
||||
return '\WP_Ultimo\Compat\AS_Admin_View';
|
||||
return \WP_Ultimo\Compat\AS_Admin_View::class;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +141,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.10
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
\ActionScheduler_AdminView::instance()->process_admin_ui();
|
||||
}
|
||||
@ -152,7 +152,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
\ActionScheduler_AdminView::instance()->render_admin_ui();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @var array
|
||||
*/
|
||||
protected $labels = array();
|
||||
protected $labels = [];
|
||||
|
||||
/**
|
||||
* Holds the WP_List_Table instance to be used on the list
|
||||
@ -56,7 +56,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
/**
|
||||
* Loads the list table
|
||||
@ -90,14 +90,14 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
/**
|
||||
* Runs the parent init functions
|
||||
*/
|
||||
parent::init();
|
||||
|
||||
add_filter('set-screen-option', array($this, 'save_screen_option'), 8, 3);
|
||||
add_filter('set-screen-option', [$this, 'save_screen_option'], 8, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,7 +106,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function process_single_action() {
|
||||
public function process_single_action(): void {
|
||||
|
||||
if ($this->table) {
|
||||
$this->table->process_single_action();
|
||||
@ -121,10 +121,10 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Object removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Object', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
@ -152,18 +152,18 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
/**
|
||||
* Renders the base list page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/list',
|
||||
array(
|
||||
[
|
||||
'page' => $this,
|
||||
'table' => $this->get_table(),
|
||||
'classes' => $this->table->get_filters() ? 'wu-advanced-filters' : 'wu-no-advanced-filters',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -184,14 +184,14 @@ abstract class List_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function screen_options() {
|
||||
public function screen_options(): void {
|
||||
|
||||
if ($this->table) {
|
||||
$args = array(
|
||||
$args = [
|
||||
'default' => 20,
|
||||
'label' => $this->table->get_per_page_option_label(),
|
||||
'option' => $this->table->get_per_page_option_name(),
|
||||
);
|
||||
];
|
||||
|
||||
add_screen_option('per_page', $args);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -53,9 +53,9 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_memberships',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register ajax forms to handle adding new memberships.
|
||||
@ -63,17 +63,17 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add new Membership
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_membership',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_membership_modal'),
|
||||
'handler' => array($this, 'handle_add_new_membership_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_membership_modal'],
|
||||
'handler' => [$this, 'handle_add_new_membership_modal'],
|
||||
'capability' => 'wu_edit_memberships',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -83,37 +83,37 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_new_membership_modal() {
|
||||
public function render_add_new_membership_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'customer_id' => array(
|
||||
$fields = [
|
||||
'customer_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Customer', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Customer...', 'wp-ultimo'),
|
||||
'desc' => __('The customer to attach this membership to.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'customer',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'display_name',
|
||||
'data-search-field' => 'display_name',
|
||||
'data-max-items' => 1,
|
||||
),
|
||||
),
|
||||
'product_ids' => array(
|
||||
],
|
||||
],
|
||||
'product_ids' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Products', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Products...', 'wp-ultimo'),
|
||||
'desc' => __('You can add multiples products to this membership.', 'wp-ultimo'),
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'product',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'name',
|
||||
'data-search-field' => 'name',
|
||||
'data-max-items' => 99,
|
||||
),
|
||||
),
|
||||
'status' => array(
|
||||
],
|
||||
],
|
||||
'status' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Status', 'wp-ultimo'),
|
||||
'placeholder' => __('Status', 'wp-ultimo'),
|
||||
@ -121,59 +121,59 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
'tooltip' => '',
|
||||
'value' => Membership_Status::PENDING,
|
||||
'options' => Membership_Status::to_array(),
|
||||
),
|
||||
'lifetime' => array(
|
||||
],
|
||||
'lifetime' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Lifetime', 'wp-ultimo'),
|
||||
'desc' => __('Activate this toggle to mark the newly created membership as lifetime.', 'wp-ultimo'),
|
||||
'value' => 1,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'lifetime',
|
||||
),
|
||||
),
|
||||
'date_expiration' => array(
|
||||
],
|
||||
],
|
||||
'date_expiration' => [
|
||||
'title' => __('Expiration Date', 'wp-ultimo'),
|
||||
'desc' => __('Set the expiration date of the membership to be created.', 'wp-ultimo'),
|
||||
'type' => 'text',
|
||||
'date' => true,
|
||||
'value' => gmdate('Y-m-d', strtotime('+1 month')),
|
||||
'placeholder' => '2020-04-04',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'wu-datepicker' => 'true',
|
||||
'data-format' => 'Y-m-d',
|
||||
'data-allow-time' => 'false',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => '!lifetime',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Create Membership', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'add_new_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' => 'add_new_membership',
|
||||
'data-on-load' => 'wu_initialize_datepickers',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'lifetime' => 1,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -185,7 +185,7 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_add_new_membership_modal() {
|
||||
public function handle_add_new_membership_modal(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -214,10 +214,10 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
|
||||
$cart = new \WP_Ultimo\Checkout\Cart(
|
||||
array(
|
||||
[
|
||||
'products' => $products,
|
||||
'country' => $customer->get_country(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$data = $cart->to_membership_data();
|
||||
@ -243,14 +243,14 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-membership',
|
||||
array(
|
||||
[
|
||||
'id' => $membership->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -262,10 +262,10 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Membership removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Membership', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,14 +309,14 @@ class Membership_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add Membership'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_membership'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,9 +66,9 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.24
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Overrides original construct method.
|
||||
@ -93,7 +93,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
|
||||
*/
|
||||
public function get_logo() {
|
||||
|
||||
return wu_get_asset('logo.png', 'img');
|
||||
return wu_get_asset('logo.webp', 'img');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,13 +126,13 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
|
||||
*/
|
||||
public function get_sections() {
|
||||
|
||||
return array(
|
||||
'alert' => array(
|
||||
return [
|
||||
'alert' => [
|
||||
'title' => __('Alert!', 'wp-ultimo'),
|
||||
'view' => array($this, 'section_alert'),
|
||||
'handler' => array($this, 'handle_proceed'),
|
||||
),
|
||||
);
|
||||
'view' => [$this, 'section_alert'],
|
||||
'handler' => [$this, 'handle_proceed'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,14 +141,14 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.24
|
||||
* @return void
|
||||
*/
|
||||
public function section_alert() {
|
||||
public function section_alert(): void {
|
||||
|
||||
wu_get_template(
|
||||
'wizards/setup/alert',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.24
|
||||
* @return void
|
||||
*/
|
||||
public function handle_proceed() {
|
||||
public function handle_proceed(): void {
|
||||
|
||||
delete_network_option(null, 'wu_setup_finished');
|
||||
delete_network_option(null, 'wu_is_migration_done');
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -52,9 +52,9 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_payments',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register ajax forms that we use for payments.
|
||||
@ -62,17 +62,17 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Edit/Add Line Item
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_payment',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_payment_modal'),
|
||||
'handler' => array($this, 'handle_add_new_payment_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_payment_modal'],
|
||||
'handler' => [$this, 'handle_add_new_payment_modal'],
|
||||
'capability' => 'wu_edit_payments',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -82,25 +82,25 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_new_payment_modal() {
|
||||
public function render_add_new_payment_modal(): void {
|
||||
|
||||
$fields = array(
|
||||
'products' => array(
|
||||
$fields = [
|
||||
'products' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Products', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Products...', 'wp-ultimo'),
|
||||
'desc' => __('Each product will be added as a line item.', 'wp-ultimo'),
|
||||
'value' => '',
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'product',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'name',
|
||||
'data-search-field' => 'name',
|
||||
'data-max-items' => 10,
|
||||
),
|
||||
),
|
||||
'status' => array(
|
||||
],
|
||||
],
|
||||
'status' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Status', 'wp-ultimo'),
|
||||
'placeholder' => __('Status', 'wp-ultimo'),
|
||||
@ -108,54 +108,54 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
'value' => Payment_Status::COMPLETED,
|
||||
'options' => Payment_Status::to_array(),
|
||||
'tooltip' => '',
|
||||
),
|
||||
'membership_id' => array(
|
||||
],
|
||||
'membership_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Membership', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Membership...', 'wp-ultimo'),
|
||||
'desc' => __('The membership associated with this payment.', 'wp-ultimo'),
|
||||
'value' => '',
|
||||
'tooltip' => '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'membership',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'reference_code',
|
||||
'data-max-items' => 1,
|
||||
'data-selected' => '',
|
||||
),
|
||||
),
|
||||
'add_setup_fees' => array(
|
||||
],
|
||||
],
|
||||
'add_setup_fees' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Include Setup Fees', 'wp-ultimo'),
|
||||
'desc' => __('Checking this box will include setup fees attached to the selected products as well.', 'wp-ultimo'),
|
||||
'value' => 1,
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Add Payment', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'wu-w-full button button-primary',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'add_payment',
|
||||
$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_payment',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'taxable' => 0,
|
||||
'type' => 'product',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -178,19 +178,19 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
|
||||
$cart = new \WP_Ultimo\Checkout\Cart(
|
||||
array(
|
||||
[
|
||||
'products' => explode(',', (string) wu_request('products')),
|
||||
'cart_type' => wu_request('add_setup_fees') ? 'new' : 'renewal',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$payment_data = array_merge(
|
||||
$cart->to_payment_data(),
|
||||
array(
|
||||
[
|
||||
'status' => wu_request('status'),
|
||||
'membership_id' => $membership->get_id(),
|
||||
'customer_id' => $membership->get_customer_id(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$payment = wu_create_payment($payment_data);
|
||||
@ -200,14 +200,14 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-payment',
|
||||
array(
|
||||
[
|
||||
'id' => $payment->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -227,10 +227,10 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Payment removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Payment', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,14 +274,14 @@ class Payment_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add Payment', 'wp-ultimo'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_payment'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,9 +58,9 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the title of the page.
|
||||
@ -101,24 +101,24 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
do_action('wu_load_edit_placeholders_list_page');
|
||||
|
||||
$columns = apply_filters(
|
||||
'wu_edit_placeholders_columns',
|
||||
array(
|
||||
[
|
||||
'placeholder' => __('Placeholder', 'wp-ultimo'),
|
||||
'content' => __('Content', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_get_template(
|
||||
'sites/edit-placeholders',
|
||||
array(
|
||||
[
|
||||
'columns' => $columns,
|
||||
'types' => array(),
|
||||
)
|
||||
'types' => [],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -128,20 +128,20 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
wp_register_script('wu-edit-placeholders', wu_get_asset('edit-placeholders.js', 'js'), array('wu-admin', 'wu-vue', 'underscore'), wu_get_version(), false);
|
||||
wp_register_script('wu-edit-placeholders', wu_get_asset('edit-placeholders.js', 'js'), ['wu-admin', 'wu-vue', 'underscore'], wu_get_version(), false);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-edit-placeholders',
|
||||
'wu_placeholdersl10n',
|
||||
array(
|
||||
[
|
||||
'name' => __('Tax', 'wp-ultimo'),
|
||||
'confirm_message' => __('Are you sure you want to delete this rows?', 'wp-ultimo'),
|
||||
'confirm_delete_tax_category_message' => __('Are you sure you want to delete this tax category?', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-edit-placeholders');
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -50,9 +50,9 @@ class Product_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_products',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to register widgets, if they need them.
|
||||
@ -70,10 +70,10 @@ class Product_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Product removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Product', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,13 +117,13 @@ class Product_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-edit-product'),
|
||||
'label' => __('Add Product'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,9 +62,9 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_settings',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Should we hide admin notices on this page?
|
||||
@ -104,7 +104,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_enqueue_editor();
|
||||
|
||||
@ -130,56 +130,56 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
wu_register_settings_side_panel(
|
||||
'login-and-registration',
|
||||
array(
|
||||
[
|
||||
'title' => __('Checkout Forms', 'wp-ultimo'),
|
||||
'render' => array($this, 'render_checkout_forms_side_panel'),
|
||||
)
|
||||
'render' => [$this, 'render_checkout_forms_side_panel'],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_side_panel(
|
||||
'sites',
|
||||
array(
|
||||
[
|
||||
'title' => __('Template Previewer', 'wp-ultimo'),
|
||||
'render' => array($this, 'render_site_template_side_panel'),
|
||||
)
|
||||
'render' => [$this, 'render_site_template_side_panel'],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_side_panel(
|
||||
'sites',
|
||||
array(
|
||||
[
|
||||
'title' => __('Placeholder Editor', 'wp-ultimo'),
|
||||
'render' => array($this, 'render_site_placeholders_side_panel'),
|
||||
)
|
||||
'render' => [$this, 'render_site_placeholders_side_panel'],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_side_panel(
|
||||
'payment-gateways',
|
||||
array(
|
||||
[
|
||||
'title' => __('Invoices', 'wp-ultimo'),
|
||||
'render' => array($this, 'render_invoice_side_panel'),
|
||||
)
|
||||
'render' => [$this, 'render_invoice_side_panel'],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_side_panel(
|
||||
'emails',
|
||||
array(
|
||||
[
|
||||
'title' => __('System Emails', 'wp-ultimo'),
|
||||
'render' => array($this, 'render_system_emails_side_panel'),
|
||||
)
|
||||
'render' => [$this, 'render_system_emails_side_panel'],
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_side_panel(
|
||||
'emails',
|
||||
array(
|
||||
[
|
||||
'title' => __('Email Template', 'wp-ultimo'),
|
||||
'render' => array($this, 'render_email_template_side_panel'),
|
||||
)
|
||||
'render' => [$this, 'render_email_template_side_panel'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_checkout_forms_side_panel() {
|
||||
public function render_checkout_forms_side_panel(): void {
|
||||
?>
|
||||
|
||||
<div class="wu-widget-inset">
|
||||
@ -201,7 +201,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
</span>
|
||||
|
||||
<div class="wu-py-2">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Checkout Forms', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/checkout-forms.png'); ?>">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Checkout Forms', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/checkout-forms.webp'); ?>">
|
||||
</div>
|
||||
|
||||
<p class="wu-text-gray-600 wu-p-0 wu-m-0">
|
||||
@ -231,7 +231,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_site_template_side_panel() {
|
||||
public function render_site_template_side_panel(): void {
|
||||
|
||||
?>
|
||||
|
||||
@ -244,7 +244,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
</span>
|
||||
|
||||
<div class="wu-py-2">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize the Template Previewer', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/site-template.png'); ?>">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize the Template Previewer', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/site-template.webp'); ?>">
|
||||
</div>
|
||||
|
||||
<p class="wu-text-gray-600 wu-p-0 wu-m-0">
|
||||
@ -274,7 +274,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_site_placeholders_side_panel() {
|
||||
public function render_site_placeholders_side_panel(): void {
|
||||
|
||||
?>
|
||||
|
||||
@ -287,7 +287,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
</span>
|
||||
|
||||
<div class="wu-py-2">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize the Template Placeholders', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/template-placeholders.png'); ?>">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize the Template Placeholders', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/template-placeholders.webp'); ?>">
|
||||
</div>
|
||||
|
||||
<p class="wu-text-gray-600 wu-p-0 wu-m-0">
|
||||
@ -317,7 +317,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_invoice_side_panel() {
|
||||
public function render_invoice_side_panel(): void {
|
||||
|
||||
?>
|
||||
|
||||
@ -330,7 +330,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
</span>
|
||||
|
||||
<div class="wu-py-2">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize the Invoice Template', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/invoice-template.png'); ?>">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize the Invoice Template', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/invoice-template.webp'); ?>">
|
||||
</div>
|
||||
|
||||
<p class="wu-text-gray-600 wu-p-0 wu-m-0">
|
||||
@ -360,7 +360,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_system_emails_side_panel() {
|
||||
public function render_system_emails_side_panel(): void {
|
||||
|
||||
?>
|
||||
|
||||
@ -373,7 +373,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
</span>
|
||||
|
||||
<div class="wu-py-2">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize System Emails', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/system-emails.png'); ?>">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize System Emails', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/system-emails.webp'); ?>">
|
||||
</div>
|
||||
|
||||
<p class="wu-text-gray-600 wu-p-0 wu-m-0">
|
||||
@ -403,7 +403,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_email_template_side_panel() {
|
||||
public function render_email_template_side_panel(): void {
|
||||
|
||||
?>
|
||||
|
||||
@ -416,7 +416,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
</span>
|
||||
|
||||
<div class="wu-py-2">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize Email Template', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/email-template.png'); ?>">
|
||||
<img class="wu-w-full" alt="<?php esc_attr_e('Customize Email Template', 'wp-ultimo'); ?>" src="<?php echo wu_get_asset('sidebar/email-template.webp'); ?>">
|
||||
</div>
|
||||
|
||||
<p class="wu-text-gray-600 wu-p-0 wu-m-0">
|
||||
@ -470,7 +470,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Enqueue the base Dashboard Scripts
|
||||
*/
|
||||
@ -486,14 +486,14 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
|
||||
wu_get_template(
|
||||
'base/settings',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'classes' => '',
|
||||
'sections' => $this->get_sections(),
|
||||
'current_section' => $this->get_current_section(),
|
||||
'clickable_navigation' => $this->clickable_navigation,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -514,14 +514,14 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function default_handler() {
|
||||
public function default_handler(): void {
|
||||
|
||||
if ( ! current_user_can('wu_edit_settings')) {
|
||||
wp_die(__('You do not have the permissions required to change settings.', 'wp-ultimo'));
|
||||
}
|
||||
|
||||
if ( ! isset($_POST['active_gateways']) && wu_request('tab') === 'payment-gateways') {
|
||||
$_POST['active_gateways'] = array();
|
||||
$_POST['active_gateways'] = [];
|
||||
}
|
||||
|
||||
WP_Ultimo()->settings->save_settings($_POST);
|
||||
@ -537,7 +537,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function default_view() {
|
||||
public function default_view(): void {
|
||||
|
||||
$sections = $this->get_sections();
|
||||
|
||||
@ -552,15 +552,15 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
/*
|
||||
* Get Field to save
|
||||
*/
|
||||
$fields['save'] = array(
|
||||
$fields['save'] = [
|
||||
'type' => 'submit',
|
||||
'title' => __('Save Settings', 'wp-ultimo'),
|
||||
'classes' => 'button button-primary button-large wu-ml-auto wu-w-full md:wu-w-auto',
|
||||
'wrapper_classes' => 'wu-sticky wu-bottom-0 wu-save-button wu-mr-px wu-w-full md:wu-w-auto',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-on:click' => 'send("window", "wu_block_ui", "#wpcontent")',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ( ! current_user_can('wu_edit_settings')) {
|
||||
$fields['save']['html_attr']['disabled'] = 'disabled';
|
||||
@ -569,17 +569,17 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
|
||||
$form = new Form(
|
||||
$section_slug,
|
||||
$fields,
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu--mt-5 wu--mx-in wu--mb-in',
|
||||
'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',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'style' => '',
|
||||
'data-on-load' => 'remove_block_ui',
|
||||
'data-wu-app' => str_replace('-', '_', $section_slug),
|
||||
'data-state' => json_encode(wu_array_map_keys('wu_replace_dashes', Settings::get_instance()->get_all(true))),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
|
@ -71,9 +71,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Is this an old install migrating.
|
||||
@ -119,29 +119,29 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
|
||||
$this->menu_icon = 'dashicons-wu-wp-ultimo';
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'register_scripts'));
|
||||
add_action('admin_enqueue_scripts', [$this, 'register_scripts']);
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
add_action('admin_action_download_migration_logs', array($this, 'download_migration_logs'));
|
||||
add_action('admin_action_download_migration_logs', [$this, 'download_migration_logs']);
|
||||
|
||||
/*
|
||||
* Serve the installers
|
||||
*/
|
||||
add_action('wp_ajax_wu_setup_install', array($this, 'setup_install'));
|
||||
add_action('wp_ajax_wu_setup_install', [$this, 'setup_install']);
|
||||
|
||||
/*
|
||||
* Load installers
|
||||
*/
|
||||
add_action('wu_handle_ajax_installers', array(Core_Installer::get_instance(), 'handle'), 10, 3);
|
||||
add_action('wu_handle_ajax_installers', array(Default_Content_Installer::get_instance(), 'handle'), 10, 3);
|
||||
add_action('wu_handle_ajax_installers', array(Migrator::get_instance(), 'handle'), 10, 3);
|
||||
add_action('wu_handle_ajax_installers', [Core_Installer::get_instance(), 'handle'], 10, 3);
|
||||
add_action('wu_handle_ajax_installers', [Default_Content_Installer::get_instance(), 'handle'], 10, 3);
|
||||
add_action('wu_handle_ajax_installers', [Migrator::get_instance(), 'handle'], 10, 3);
|
||||
|
||||
/*
|
||||
* Redirect on activation
|
||||
*/
|
||||
add_action('wu_activation', array($this, 'redirect_to_wizard'));
|
||||
add_action('wu_activation', [$this, 'redirect_to_wizard']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,7 +150,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.7
|
||||
* @return void
|
||||
*/
|
||||
public function download_migration_logs() {
|
||||
public function download_migration_logs(): void {
|
||||
|
||||
check_admin_referer('download_migration_logs', 'nonce');
|
||||
|
||||
@ -177,7 +177,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
parent::page_loaded();
|
||||
|
||||
@ -205,7 +205,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function set_settings() {
|
||||
public function set_settings(): void {
|
||||
|
||||
WP_Ultimo()->settings->default_sections();
|
||||
}
|
||||
@ -216,7 +216,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function redirect_to_wizard() {
|
||||
public function redirect_to_wizard(): void {
|
||||
|
||||
if ( ! \WP_Ultimo\Requirements::run_setup() && wu_request('page') !== 'wp-ultimo-setup') {
|
||||
wp_redirect(wu_network_admin_url('wp-ultimo-setup'));
|
||||
@ -231,7 +231,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function setup_install() {
|
||||
public function setup_install(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -279,7 +279,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
*/
|
||||
public function get_logo() {
|
||||
|
||||
return wu_get_asset('logo.png', 'img');
|
||||
return wu_get_asset('logo.webp', 'img');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -312,45 +312,45 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
*/
|
||||
public function get_sections() {
|
||||
|
||||
$sections = array(
|
||||
'welcome' => array(
|
||||
$sections = [
|
||||
'welcome' => [
|
||||
'title' => __('Welcome', 'wp-ultimo'),
|
||||
'description' => implode(
|
||||
'<br><br>',
|
||||
array(
|
||||
[
|
||||
__('...and thanks for choosing WP Multisite WaaS!', 'wp-ultimo'),
|
||||
__('This quick setup wizard will make sure your server is correctly setup, help you configure your new network, and migrate data from previous WP Multisite WaaS versions if necessary.', 'wp-ultimo'),
|
||||
__('You will also have the option of importing default content. It should take 10 minutes or less!', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
),
|
||||
'next_label' => __('Get Started →', 'wp-ultimo'),
|
||||
'back' => false,
|
||||
),
|
||||
'checks' => array(
|
||||
],
|
||||
'checks' => [
|
||||
'title' => __('Pre-install Checks', 'wp-ultimo'),
|
||||
'description' => __('Now it is time to see if this machine has what it takes to run WP Multisite WaaS well!', 'wp-ultimo'),
|
||||
'next_label' => \WP_Ultimo\Requirements::met() ? __('Go to the Next Step →', 'wp-ultimo') : __('Check Again', 'wp-ultimo'),
|
||||
'handler' => array($this, 'handle_checks'),
|
||||
'handler' => [$this, 'handle_checks'],
|
||||
'back' => false,
|
||||
'fields' => array(
|
||||
'requirements' => array(
|
||||
'fields' => [
|
||||
'requirements' => [
|
||||
'type' => 'note',
|
||||
'desc' => array($this, 'renders_requirements_table'),
|
||||
),
|
||||
),
|
||||
),
|
||||
'installation' => array(
|
||||
'desc' => [$this, 'renders_requirements_table'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'installation' => [
|
||||
'title' => __('Installation', 'wp-ultimo'),
|
||||
'description' => __('Now, let\'s update your database and install the Sunrise.php file, which are necessary for the correct functioning of WP Multisite WaaS.', 'wp-ultimo'),
|
||||
'next_label' => Core_Installer::get_instance()->all_done() ? __('Go to the Next Step →', 'wp-ultimo') : __('Install', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'terms' => array(
|
||||
'fields' => [
|
||||
'terms' => [
|
||||
'type' => 'note',
|
||||
'desc' => fn() => $this->render_installation_steps(Core_Installer::get_instance()->get_steps(), false),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* In case of migrations, add different sections.
|
||||
@ -374,19 +374,19 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
$description = __('It seems that you were running WP Multisite WaaS 1.X on this network. This migrator will convert the data from the old version to the new one.', 'wp-ultimo') . '<br><br>' . __('First, let\'s run a test migration to see if we can spot any potential errors.', 'wp-ultimo');
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'migration' => array(
|
||||
$fields = [
|
||||
'migration' => [
|
||||
'type' => 'note',
|
||||
'desc' => fn() => $this->render_installation_steps(Migrator::get_instance()->get_steps(), false),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if ($errors) {
|
||||
$subject = 'Errors on migrating my network';
|
||||
|
||||
$user = wp_get_current_user();
|
||||
|
||||
$message_lines = array(
|
||||
$message_lines = [
|
||||
'Hi there,',
|
||||
sprintf('My name is %s.', $user->display_name),
|
||||
'I tried to migrate my network from version 1 to version 2, but was not able to do it successfully...',
|
||||
@ -394,7 +394,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
sprintf('```%s%s%s```', PHP_EOL, implode(PHP_EOL, $errors), PHP_EOL),
|
||||
sprintf('```%s%s%s```', PHP_EOL, $back_traces ? implode(PHP_EOL, $back_traces) : 'No backtraces found.', PHP_EOL),
|
||||
'Kind regards.',
|
||||
);
|
||||
];
|
||||
|
||||
$message = implode(PHP_EOL . PHP_EOL, $message_lines);
|
||||
|
||||
@ -410,10 +410,10 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
'<br><a href="%2$s" class="wu-no-underline wu-text-red-500 wu-font-bold"><span class="dashicons-wu-download wu-mr-2"></span>%1$s</a>',
|
||||
__('Download migration error log', 'wp-ultimo'),
|
||||
add_query_arg(
|
||||
array(
|
||||
[
|
||||
'action' => 'download_migration_logs',
|
||||
'nonce' => wp_create_nonce('download_migration_logs'),
|
||||
),
|
||||
],
|
||||
network_admin_url('admin.php')
|
||||
)
|
||||
);
|
||||
@ -422,11 +422,11 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
'<br><a href="%2$s" class="wu-no-underline wu-text-red-500 wu-font-bold"><span class="dashicons-wu-back-in-time wu-mr-2"></span>%1$s</a>',
|
||||
__('Rollback to version 1.10.13', 'wp-ultimo'),
|
||||
add_query_arg(
|
||||
array(
|
||||
[
|
||||
'page' => 'wp-ultimo-rollback',
|
||||
'version' => '1.10.13',
|
||||
'type' => 'select-version',
|
||||
),
|
||||
],
|
||||
network_admin_url('admin.php')
|
||||
)
|
||||
);
|
||||
@ -434,57 +434,57 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
$error_list .= implode('<br>', $errors);
|
||||
|
||||
$fields = array_merge(
|
||||
array(
|
||||
'errors' => array(
|
||||
[
|
||||
'errors' => [
|
||||
'type' => 'note',
|
||||
'classes' => 'wu-flex-grow',
|
||||
'desc' => function () use ($error_list) {
|
||||
|
||||
/** Reset errors */
|
||||
Migrator::get_instance()->session->set('errors', array());
|
||||
Migrator::get_instance()->session->set('errors', []);
|
||||
|
||||
return sprintf('<div class="wu-mt-0 wu-p-4 wu-bg-red-100 wu-border wu-border-solid wu-border-red-200 wu-rounded-sm wu-text-red-500">%s</div>', $error_list);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
$fields
|
||||
);
|
||||
}
|
||||
|
||||
$sections['migration'] = array(
|
||||
$sections['migration'] = [
|
||||
'title' => __('Migration', 'wp-ultimo'),
|
||||
'description' => $description,
|
||||
'next_label' => $next_label,
|
||||
'skip' => false,
|
||||
'next' => $next,
|
||||
'handler' => array($this, 'handle_migration'),
|
||||
'handler' => [$this, 'handle_migration'],
|
||||
'fields' => $fields,
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$sections['your-company'] = array(
|
||||
$sections['your-company'] = [
|
||||
'title' => __('Your Company', 'wp-ultimo'),
|
||||
'description' => __('Before we move on, let\'s configure the basic settings of your network, shall we?', 'wp-ultimo'),
|
||||
'handler' => array($this, 'handle_save_settings'),
|
||||
'fields' => array($this, 'get_general_settings'),
|
||||
);
|
||||
'handler' => [$this, 'handle_save_settings'],
|
||||
'fields' => [$this, 'get_general_settings'],
|
||||
];
|
||||
|
||||
$sections['defaults'] = array(
|
||||
$sections['defaults'] = [
|
||||
'title' => __('Default Content', 'wp-ultimo'),
|
||||
'description' => __('Starting from scratch can be scarry, specially when first starting out. In this step, you can create default content to have a starting point for your network. Everything can be customized later.', 'wp-ultimo'),
|
||||
'next_label' => Default_Content_Installer::get_instance()->all_done() ? __('Go to the Next Step →', 'wp-ultimo') : __('Install', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'terms' => array(
|
||||
'fields' => [
|
||||
'terms' => [
|
||||
'type' => 'note',
|
||||
'desc' => fn() => $this->render_installation_steps(Default_Content_Installer::get_instance()->get_steps()),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$sections['done'] = array(
|
||||
$sections['done'] = [
|
||||
'title' => __('Ready!', 'wp-ultimo'),
|
||||
'view' => array($this, 'section_ready'),
|
||||
);
|
||||
'view' => [$this, 'section_ready'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow developers to add additional setup wizard steps.
|
||||
@ -514,23 +514,23 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
/*
|
||||
* Unset a couple of undesired settings
|
||||
*/
|
||||
$fields_to_unset = array(
|
||||
$fields_to_unset = [
|
||||
'error_reporting_header',
|
||||
'enable_error_reporting',
|
||||
'advanced_header',
|
||||
'uninstall_wipe_tables',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($fields_to_unset as $field_to_unset) {
|
||||
unset($general_fields[ $field_to_unset ]);
|
||||
}
|
||||
|
||||
// Adds a fake first field to bypass some styling issues with the top-border
|
||||
$fake_field = array(
|
||||
array(
|
||||
$fake_field = [
|
||||
[
|
||||
'type' => 'hidden',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$fields = array_merge($fake_field, $general_fields);
|
||||
|
||||
@ -549,9 +549,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
*/
|
||||
$payment_fields = \WP_Ultimo\Settings::get_instance()->get_section('payment-gateways')['fields'];
|
||||
|
||||
$fields_to_unset = array(
|
||||
$fields_to_unset = [
|
||||
'main_header',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($fields_to_unset as $field_to_unset) {
|
||||
unset($payment_fields[ $field_to_unset ]);
|
||||
@ -578,21 +578,21 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
wp_localize_script(
|
||||
'wu-setup-wizard',
|
||||
'wu_setup_settings',
|
||||
array(
|
||||
[
|
||||
'dry_run' => wu_request('dry-run', true),
|
||||
'generic_error_message' => __('A server error happened while processing this item.', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-setup-wizard');
|
||||
|
||||
return wu_get_template_contents(
|
||||
'wizards/setup/installation_steps',
|
||||
array(
|
||||
[
|
||||
'page' => $this,
|
||||
'steps' => $steps,
|
||||
'checks' => $checks,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -617,8 +617,8 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
|
||||
global $wp_version;
|
||||
|
||||
$requirements = array(
|
||||
'php' => array(
|
||||
$requirements = [
|
||||
'php' => [
|
||||
'name' => __('PHP', 'wp-ultimo'),
|
||||
'help' => wu_get_documentation_url('wp-ultimo-requirements'),
|
||||
'required_version' => \WP_Ultimo\Requirements::$php_version,
|
||||
@ -626,8 +626,8 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
'installed_version' => phpversion(),
|
||||
'pass_requirements' => version_compare(phpversion(), \WP_Ultimo\Requirements::$php_version, '>='),
|
||||
'pass_recommendation' => version_compare(phpversion(), \WP_Ultimo\Requirements::$php_recommended_version, '>='),
|
||||
),
|
||||
'wordpress' => array(
|
||||
],
|
||||
'wordpress' => [
|
||||
'name' => __('WordPress', 'wp-ultimo'),
|
||||
'help' => wu_get_documentation_url('wp-ultimo-requirements'),
|
||||
'required_version' => \WP_Ultimo\Requirements::$wp_version,
|
||||
@ -635,36 +635,36 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
'installed_version' => $wp_version,
|
||||
'pass_requirements' => version_compare(phpversion(), \WP_Ultimo\Requirements::$wp_version, '>='),
|
||||
'pass_recommendation' => version_compare(phpversion(), \WP_Ultimo\Requirements::$wp_recommended_version, '>='),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$plugin_requirements = array(
|
||||
'multisite' => array(
|
||||
$plugin_requirements = [
|
||||
'multisite' => [
|
||||
'name' => __('WordPress Multisite', 'wp-ultimo'),
|
||||
'help' => wu_get_documentation_url('wp-ultimo-requirements'),
|
||||
'condition' => __('Installed & Activated', 'wp-ultimo'),
|
||||
'pass_requirements' => is_multisite(),
|
||||
),
|
||||
'wp-ultimo' => array(
|
||||
],
|
||||
'wp-ultimo' => [
|
||||
'name' => __('WP Multisite WaaS', 'wp-ultimo'),
|
||||
'help' => wu_get_documentation_url('wp-ultimo-requirements'),
|
||||
'condition' => apply_filters('wp_ultimo_skip_network_active_check', false) ? __('Bypassed via filter', 'wp-ultimo') : __('Network Activated', 'wp-ultimo'),
|
||||
'pass_requirements' => \WP_Ultimo\Requirements::is_network_active(),
|
||||
),
|
||||
'wp-cron' => array(
|
||||
],
|
||||
'wp-cron' => [
|
||||
'name' => __('WordPress Cron', 'wp-ultimo'),
|
||||
'help' => wu_get_documentation_url('wp-ultimo-requirements'),
|
||||
'condition' => __('Activated', 'wp-ultimo'),
|
||||
'pass_requirements' => \WP_Ultimo\Requirements::check_wp_cron(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return wu_get_template_contents(
|
||||
'wizards/setup/requirements_table',
|
||||
array(
|
||||
[
|
||||
'requirements' => $requirements,
|
||||
'plugin_requirements' => $plugin_requirements,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function section_ready() {
|
||||
public function section_ready(): void {
|
||||
|
||||
update_network_option(null, 'wu_setup_finished', true);
|
||||
|
||||
@ -689,18 +689,18 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
|
||||
wu_enqueue_async_action(
|
||||
'wu_async_take_screenshot',
|
||||
array(
|
||||
[
|
||||
'site_id' => wu_get_main_site_id(),
|
||||
),
|
||||
],
|
||||
'site'
|
||||
);
|
||||
|
||||
wu_get_template(
|
||||
'wizards/setup/ready',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -710,7 +710,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_checks() {
|
||||
public function handle_checks(): void {
|
||||
|
||||
if (\WP_Ultimo\Requirements::met() === false) {
|
||||
wp_redirect(add_query_arg());
|
||||
@ -729,7 +729,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save_settings() {
|
||||
public function handle_save_settings(): void {
|
||||
|
||||
$this->set_settings();
|
||||
|
||||
@ -758,7 +758,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_migration() {
|
||||
public function handle_migration(): void {
|
||||
|
||||
$dry_run = wu_request('dry-run', true);
|
||||
|
||||
@ -783,7 +783,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_configuration() {
|
||||
public function handle_configuration(): void {
|
||||
|
||||
if ($_POST['submit'] === '1') {
|
||||
$this->integration->setup_constants($_POST);
|
||||
@ -803,17 +803,17 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function section_test() {
|
||||
public function section_test(): void {
|
||||
|
||||
wp_enqueue_script('wu-vue');
|
||||
|
||||
wu_get_template(
|
||||
'wizards/host-integrations/test',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'integration' => $this->integration,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -823,12 +823,12 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
if (WP_Ultimo()->is_loaded() === false) {
|
||||
wp_enqueue_style('wu-styling', wu_get_asset('framework.css', 'css'), false, wu_get_version());
|
||||
|
||||
wp_enqueue_style('wu-admin', wu_get_asset('admin.css', 'css'), array('wu-styling'), wu_get_version());
|
||||
wp_enqueue_style('wu-admin', wu_get_asset('admin.css', 'css'), ['wu-styling'], wu_get_version());
|
||||
|
||||
/*
|
||||
* Adds tipTip
|
||||
@ -838,9 +838,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
/*
|
||||
* Adds jQueryBlockUI
|
||||
*/
|
||||
wp_enqueue_script('wu-block-ui', wu_get_asset('lib/jquery.blockUI.js', 'js'), array('jquery'));
|
||||
wp_enqueue_script('wu-block-ui', wu_get_asset('lib/jquery.blockUI.js', 'js'), ['jquery']);
|
||||
|
||||
wp_register_script('wu-fields', wu_get_asset('fields.js', 'js'), array('jquery'));
|
||||
wp_register_script('wu-fields', wu_get_asset('fields.js', 'js'), ['jquery']);
|
||||
|
||||
/*
|
||||
* Localize components
|
||||
@ -848,22 +848,22 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
wp_localize_script(
|
||||
'wu-fields',
|
||||
'wu_fields',
|
||||
array(
|
||||
'l10n' => array(
|
||||
[
|
||||
'l10n' => [
|
||||
'image_picker_title' => __('Select an Image.', 'wp-ultimo'),
|
||||
'image_picker_button_text' => __('Use this image', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_register_script('wu-functions', wu_get_asset('functions.js', 'js'), array('jquery'));
|
||||
wp_register_script('wu-functions', wu_get_asset('functions.js', 'js'), ['jquery']);
|
||||
|
||||
wp_register_script('wubox', wu_get_asset('wubox.js', 'js'), array('wu-functions'));
|
||||
wp_register_script('wubox', wu_get_asset('wubox.js', 'js'), ['wu-functions']);
|
||||
|
||||
wp_localize_script(
|
||||
'wubox',
|
||||
'wuboxL10n',
|
||||
array(
|
||||
[
|
||||
'next' => __('Next >'),
|
||||
'prev' => __('< Prev'),
|
||||
'image' => __('Image'),
|
||||
@ -871,17 +871,17 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
'close' => __('Close'),
|
||||
'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
|
||||
'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_add_inline_script('wu-setup-wizard-polyfill', 'document.addEventListener("DOMContentLoaded", () => wu_initialize_imagepicker());', 'after');
|
||||
}
|
||||
|
||||
wp_enqueue_script('wu-setup-wizard-polyfill', wu_get_asset('setup-wizard-polyfill.js', 'js'), array('jquery', 'wu-fields', 'wu-functions', 'wubox'), wu_get_version());
|
||||
wp_enqueue_script('wu-setup-wizard-polyfill', wu_get_asset('setup-wizard-polyfill.js', 'js'), ['jquery', 'wu-fields', 'wu-functions', 'wubox'], wu_get_version());
|
||||
|
||||
wp_enqueue_media();
|
||||
|
||||
wp_register_script('wu-setup-wizard', wu_get_asset('setup-wizard.js', 'js'), array('jquery'), wu_get_version());
|
||||
wp_register_script('wu-setup-wizard', wu_get_asset('setup-wizard.js', 'js'), ['jquery'], wu_get_version());
|
||||
|
||||
wp_add_inline_style(
|
||||
'wu-admin',
|
||||
@ -891,7 +891,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
|
||||
background: url("%s") right bottom no-repeat;
|
||||
background-size: 90%%;
|
||||
}',
|
||||
wu_get_asset('bg-setup.png', 'img')
|
||||
wu_get_asset('bg-setup.webp', 'img')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ class Shortcodes_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to add further initializations.
|
||||
@ -78,7 +78,7 @@ class Shortcodes_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
parent::init();
|
||||
}
|
||||
@ -122,16 +122,16 @@ class Shortcodes_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
wu_get_template(
|
||||
'shortcodes/shortcodes',
|
||||
array(
|
||||
[
|
||||
'screen' => $screen,
|
||||
'data' => $this->get_data(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ class Shortcodes_Admin_Page extends Base_Admin_Page {
|
||||
|
||||
$elements = Base_Element::get_public_elements();
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$defaults = $element->defaults();
|
||||
@ -162,7 +162,7 @@ class Shortcodes_Admin_Page extends Base_Admin_Page {
|
||||
$params[ $key ]['options'] = '0 | 1';
|
||||
break;
|
||||
case 'select':
|
||||
$params[ $key ]['options'] = implode(' | ', array_keys(wu_get_isset($value, 'options', array())));
|
||||
$params[ $key ]['options'] = implode(' | ', array_keys(wu_get_isset($value, 'options', [])));
|
||||
break;
|
||||
case 'int':
|
||||
$params[ $key ]['options'] = __('integer', 'wp-ultimo');
|
||||
@ -184,17 +184,17 @@ class Shortcodes_Admin_Page extends Base_Admin_Page {
|
||||
|
||||
$id = $element->get_id();
|
||||
|
||||
if (strncmp((string) $id, 'wp-ultimo/', strlen('wp-ultimo/')) === 0) {
|
||||
if (str_starts_with((string) $id, 'wp-ultimo/')) {
|
||||
$id = substr((string) $element->get_id(), strlen('wp-ultimo/'));
|
||||
}
|
||||
|
||||
$data[] = array(
|
||||
$data[] = [
|
||||
'generator_form_url' => wu_get_form_url("shortcode_{$id}"),
|
||||
'title' => $element->get_title(),
|
||||
'shortcode' => $element->get_shortcode_id(),
|
||||
'description' => $element->get_description(),
|
||||
'params' => $params,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -77,9 +77,9 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_edit_sites',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers the necessary scripts and styles for this admin page.
|
||||
@ -87,11 +87,11 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
WP_Ultimo()->scripts->register_script('wu-screenshot-scraper', wu_get_asset('screenshot-scraper.js', 'js'), array('jquery'));
|
||||
WP_Ultimo()->scripts->register_script('wu-screenshot-scraper', wu_get_asset('screenshot-scraper.js', 'js'), ['jquery']);
|
||||
|
||||
wp_enqueue_script('wu-screenshot-scraper');
|
||||
|
||||
@ -106,17 +106,17 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Transfer site - Confirmation modal
|
||||
*/
|
||||
wu_register_form(
|
||||
'transfer_site',
|
||||
array(
|
||||
'render' => array($this, 'render_transfer_site_modal'),
|
||||
'handler' => array($this, 'handle_transfer_site_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_transfer_site_modal'],
|
||||
'handler' => [$this, 'handle_transfer_site_modal'],
|
||||
'capability' => 'wu_transfer_sites',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -125,12 +125,12 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
add_filter(
|
||||
'wu_data_json_success_delete_site_modal',
|
||||
fn($data_json) => array(
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-sites', array('deleted' => 1)),
|
||||
)
|
||||
fn($data_json) => [
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-sites', ['deleted' => 1]),
|
||||
]
|
||||
);
|
||||
|
||||
add_filter("wu_page_{$this->id}_load", array($this, 'add_new_site_template_warning_message'));
|
||||
add_filter("wu_page_{$this->id}_load", [$this, 'add_new_site_template_warning_message']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,7 +139,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_new_site_template_warning_message() {
|
||||
public function add_new_site_template_warning_message(): void {
|
||||
|
||||
if (wu_request('wu-new-model')) {
|
||||
if ( ! $this->get_object() || $this->get_object()->get_type() !== Site_Type::SITE_TEMPLATE) {
|
||||
@ -148,28 +148,28 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
\WP_Ultimo\UI\Tours::get_instance()->create_tour(
|
||||
'new_site_template_warning',
|
||||
array(
|
||||
array(
|
||||
[
|
||||
[
|
||||
'id' => 'new-site-template-warning',
|
||||
'title' => __('On adding a new Site Template...', 'wp-ultimo'),
|
||||
'text' => array(
|
||||
'text' => [
|
||||
__("You just successfully added a new site template to your WP Multisite WaaS network and that's awesome!", 'wp-ultimo'),
|
||||
__('Keep in mind that newly created site templates do not appear automatically in your checkout forms.', 'wp-ultimo'),
|
||||
__('To make a site template available on registration, you will need to manually add it to the template selection field of your checkout forms.', 'wp-ultimo'),
|
||||
),
|
||||
'buttons' => array(
|
||||
array(
|
||||
],
|
||||
'buttons' => [
|
||||
[
|
||||
'classes' => 'button wu-text-xs sm:wu-normal-case wu-float-left',
|
||||
'text' => __('Go to Checkout Forms', 'wp-ultimo'),
|
||||
'url' => wu_network_admin_url('wp-ultimo-checkout-forms'),
|
||||
),
|
||||
),
|
||||
'attachTo' => array(
|
||||
],
|
||||
],
|
||||
'attachTo' => [
|
||||
'element' => '#message.updated',
|
||||
'on' => 'top',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -180,7 +180,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
function render_transfer_site_modal() {
|
||||
function render_transfer_site_modal(): void {
|
||||
|
||||
$site = wu_get_site(wu_request('id'));
|
||||
|
||||
@ -188,52 +188,52 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'confirm' => array(
|
||||
$fields = [
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Transfer', 'wp-ultimo'),
|
||||
'desc' => __('This will start the transfer of assets from one membership to another.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Start Transfer', 'wp-ultimo'),
|
||||
'placeholder' => __('Start Transfer', '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',
|
||||
),
|
||||
),
|
||||
'id' => array(
|
||||
],
|
||||
],
|
||||
'id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $site->get_id(),
|
||||
),
|
||||
'target_membership_id' => array(
|
||||
],
|
||||
'target_membership_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => wu_request('target_membership_id'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'total-actions',
|
||||
$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' => 'transfer_site',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -245,7 +245,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_transfer_site_modal() {
|
||||
public function handle_transfer_site_modal(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -274,15 +274,15 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-site',
|
||||
array(
|
||||
[
|
||||
'id' => $site->get_id(),
|
||||
'updated' => 1,
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
@ -304,73 +304,73 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$this->add_fields_widget(
|
||||
'at_a_glance',
|
||||
array(
|
||||
[
|
||||
'title' => __('At a Glance', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'classes' => 'wu-overflow-hidden wu-m-0 wu--mt-1 wu--mx-3 wu--mb-3',
|
||||
'field_wrapper_classes' => 'wu-w-1/4 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'style' => 'margin-top: -6px;',
|
||||
),
|
||||
'fields' => array(
|
||||
'type' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'type' => [
|
||||
'type' => 'text-display',
|
||||
'title' => __('Site Type', 'wp-ultimo'),
|
||||
'display_value' => $tag,
|
||||
'tooltip' => '',
|
||||
),
|
||||
'id' => array(
|
||||
],
|
||||
'id' => [
|
||||
'type' => 'text-display',
|
||||
'copy' => true,
|
||||
'title' => __('Site ID', 'wp-ultimo'),
|
||||
'display_value' => $this->get_object()->get_id(),
|
||||
'tooltip' => '',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'description',
|
||||
array(
|
||||
[
|
||||
'title' => __('Description', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'fields' => array(
|
||||
'description' => array(
|
||||
'fields' => [
|
||||
'description' => [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Site Description', 'wp-ultimo'),
|
||||
'placeholder' => __('Tell your customers what this site is about.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_option_blogdescription(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'rows' => 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_tabs_widget(
|
||||
'options',
|
||||
array(
|
||||
[
|
||||
'title' => __('Site Options', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'sections' => $this->get_site_option_sections(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'domains',
|
||||
array(
|
||||
[
|
||||
'title' => __('Mapped Domains', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Sites_Domain_List_Table(),
|
||||
'query_filter' => array($this, 'domain_query_filter'),
|
||||
)
|
||||
'query_filter' => [$this, 'domain_query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->get_object()->get_type() === 'customer_owned') {
|
||||
$this->add_list_table_widget(
|
||||
'membership',
|
||||
array(
|
||||
[
|
||||
'title' => __('Linked Membership', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Customers_Membership_List_Table(),
|
||||
'query_filter' => function ($query) {
|
||||
@ -379,12 +379,12 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return $query;
|
||||
},
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'customer',
|
||||
array(
|
||||
[
|
||||
'title' => __('Linked Customer', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Site_Customer_List_Table(),
|
||||
'query_filter' => function ($query) {
|
||||
@ -393,17 +393,17 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return $query;
|
||||
},
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'events',
|
||||
array(
|
||||
[
|
||||
'title' => __('Events', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
|
||||
'query_filter' => array($this, 'query_filter'),
|
||||
)
|
||||
'query_filter' => [$this, 'query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
$membership_selected = $this->get_object()->get_membership() ? $this->get_object()->get_membership()->to_search_results() : '';
|
||||
@ -411,180 +411,180 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$this->add_fields_widget(
|
||||
'save',
|
||||
array(
|
||||
'html_attr' => array(
|
||||
[
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'site_type',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'type' => $this->get_object()->get_type(),
|
||||
'original_membership_id' => $this->get_object()->get_membership_id(),
|
||||
'membership_id' => $this->get_object()->get_membership_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
],
|
||||
'fields' => [
|
||||
// Fields for price
|
||||
'type_main' => array(
|
||||
'type_main' => [
|
||||
'type' => 'text-display',
|
||||
'title' => __('Site Type', 'wp-ultimo'),
|
||||
'display_value' => __('Main Site', 'wp-ultimo'),
|
||||
'tooltip' => __('You can\'t change the main site type.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
'v-show' => 'type === "main"',
|
||||
),
|
||||
),
|
||||
'type' => array(
|
||||
],
|
||||
],
|
||||
'type' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Site Type', 'wp-ultimo'),
|
||||
'placeholder' => __('Select Site Type', 'wp-ultimo'),
|
||||
'desc' => __('Different site types have different options and settings.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_type(),
|
||||
'tooltip' => '',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'default' => __('Regular WordPress', 'wp-ultimo'),
|
||||
'site_template' => __('Site Template', 'wp-ultimo'),
|
||||
'customer_owned' => __('Customer-owned', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'type',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
'v-show' => 'type !== "main"',
|
||||
),
|
||||
),
|
||||
'categories' => array(
|
||||
],
|
||||
],
|
||||
'categories' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Template Categories', 'wp-ultimo'),
|
||||
'placeholder' => __('e.g.: Landing Page, Health...', 'wp-ultimo'),
|
||||
'desc' => __('Customers will be able to filter by categories during signup.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_categories(),
|
||||
'options' => Site::get_all_categories(),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-selectize-categories' => 1,
|
||||
'multiple' => 1,
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "type === 'site_template'",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
'membership_id' => array(
|
||||
],
|
||||
],
|
||||
'membership_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Associated Membership', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Membership...', 'wp-ultimo'),
|
||||
'desc' => __('The membership that owns this site.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_membership_id(),
|
||||
'tooltip' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "type === 'customer_owned'",
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'data-model' => 'membership',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'reference_code',
|
||||
'data-search-field' => 'reference_code',
|
||||
'data-max-items' => 1,
|
||||
'data-selected' => json_encode($membership_selected),
|
||||
),
|
||||
),
|
||||
'transfer_note' => array(
|
||||
],
|
||||
],
|
||||
'transfer_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('Changing the membership will transfer the site and all its assets to the new membership.', 'wp-ultimo'),
|
||||
'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => '(original_membership_id != membership_id) && membership_id',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
'submit_save' => array(
|
||||
],
|
||||
],
|
||||
'submit_save' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Save Site', 'wp-ultimo'),
|
||||
'placeholder' => __('Save Site', 'wp-ultimo'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'original_membership_id == membership_id || !membership_id',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'transfer' => array(
|
||||
],
|
||||
],
|
||||
'transfer' => [
|
||||
'type' => 'link',
|
||||
'display_value' => __('Transfer Site', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-bg-gray-200',
|
||||
'classes' => 'button wubox wu-w-full wu-text-center',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'original_membership_id != membership_id && membership_id',
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-bind:href' => "'" . wu_get_form_url(
|
||||
'transfer_site',
|
||||
array(
|
||||
[
|
||||
'id' => $this->get_object()->get_id(),
|
||||
'target_membership_id' => '',
|
||||
)
|
||||
]
|
||||
) . "=' + membership_id",
|
||||
'title' => __('Transfer Site', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'active',
|
||||
array(
|
||||
[
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'active' => array(
|
||||
'fields' => [
|
||||
'active' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to manually enable or disable this site.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_active(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'image',
|
||||
array(
|
||||
[
|
||||
'title' => __('Site Image', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'featured_image_id' => array(
|
||||
'fields' => [
|
||||
'featured_image_id' => [
|
||||
'type' => 'image',
|
||||
'stacked' => true,
|
||||
'title' => __('Site Image', 'wp-ultimo'),
|
||||
'desc' => __('This image is used on lists of sites and other places. It can be automatically generated by the screenshot scraper.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_featured_image_id(),
|
||||
'img' => $this->get_object()->get_featured_image(),
|
||||
),
|
||||
'scraper_note' => array(
|
||||
],
|
||||
'scraper_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('You need to save the site for the change to take effect.', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-hidden wu-scraper-note',
|
||||
),
|
||||
'scraper_error' => array(
|
||||
],
|
||||
'scraper_error' => [
|
||||
'type' => 'note',
|
||||
'desc' => '<span class="wu-scraper-error-message wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-block"></span>',
|
||||
'wrapper_classes' => 'wu-hidden wu-scraper-error',
|
||||
),
|
||||
'scraper_message' => array(
|
||||
],
|
||||
'scraper_message' => [
|
||||
'type' => 'note',
|
||||
'desc' => sprintf('<span class="wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-block">%s</span>', __('We detected that this network might be running locally. If that\'s the case, WP Multisite WaaS will not be able to take a screenshot of the site. A site needs to be publicly available to the outside world in order for this feature to work.', 'wp-ultimo')),
|
||||
'wrapper_classes' => \WP_Ultimo\Domain_Mapping\Helper::is_development_mode() ? '' : 'wu-hidden',
|
||||
),
|
||||
'scraper' => array(
|
||||
],
|
||||
'scraper' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Take Screenshot', 'wp-ultimo'),
|
||||
'title' => __('Take Screenshot', 'wp-ultimo'),
|
||||
'classes' => 'button wu-w-full',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -600,7 +600,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
protected function get_site_option_sections() {
|
||||
|
||||
$sections = array();
|
||||
$sections = [];
|
||||
|
||||
$sections = apply_filters('wu_site_options_sections', $sections, $this->get_object());
|
||||
|
||||
@ -637,23 +637,23 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'url' => network_admin_url('site-settings.php?id=' . $this->get_object()->get_id()),
|
||||
'label' => __('Go to the Default Edit Screen', 'wp-ultimo'),
|
||||
'icon' => 'wu-cog',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'url' => get_site_url($this->get_object()->get_id()),
|
||||
'label' => __('Visit Site', 'wp-ultimo'),
|
||||
'icon' => 'wu-link',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'url' => get_admin_url($this->get_object()->get_id()),
|
||||
'label' => __('Dashboard', 'wp-ultimo'),
|
||||
'icon' => 'dashboard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -664,7 +664,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Site', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Site', 'wp-ultimo'),
|
||||
'updated_message' => __('Site updated with success!', 'wp-ultimo'),
|
||||
@ -674,7 +674,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Site', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -687,9 +687,9 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function domain_query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'blog_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -704,10 +704,10 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'site',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -756,7 +756,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function handle_save() {
|
||||
|
||||
$_POST['categories'] = wu_get_isset($_POST, 'categories', array());
|
||||
$_POST['categories'] = wu_get_isset($_POST, 'categories', []);
|
||||
|
||||
if ($_POST['type'] !== Site_Type::CUSTOMER_OWNED) {
|
||||
$_POST['membership_id'] = false;
|
||||
|
@ -50,9 +50,9 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_sites',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Register ajax forms that we use for sites.
|
||||
@ -60,17 +60,17 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Edit/Add New Site
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_site',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_site_modal'),
|
||||
'handler' => array($this, 'handle_add_new_site_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_site_modal'],
|
||||
'handler' => [$this, 'handle_add_new_site_modal'],
|
||||
'capability' => 'wu_add_sites',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -78,14 +78,14 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
wu_register_form(
|
||||
'publish_pending_site',
|
||||
array(
|
||||
'render' => array($this, 'render_publish_pending_site_modal'),
|
||||
'handler' => array($this, 'handle_publish_pending_site_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_publish_pending_site_modal'],
|
||||
'handler' => [$this, 'handle_publish_pending_site_modal'],
|
||||
'capability' => 'wu_publish_sites',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
add_action('wu_handle_bulk_action_form_site_screenshot', array($this, 'handle_bulk_screenshots'), 10, 3);
|
||||
add_action('wu_handle_bulk_action_form_site_screenshot', [$this, 'handle_bulk_screenshots'], 10, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,16 +98,16 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
* @param array $ids The ids list.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_bulk_screenshots($action, $model, $ids) {
|
||||
public function handle_bulk_screenshots($action, $model, $ids): void {
|
||||
|
||||
$item_ids = array_filter($ids);
|
||||
|
||||
foreach ($item_ids as $item_id) {
|
||||
wu_enqueue_async_action(
|
||||
'wu_async_take_screenshot',
|
||||
array(
|
||||
[
|
||||
'site_id' => $item_id,
|
||||
),
|
||||
],
|
||||
'site'
|
||||
);
|
||||
}
|
||||
@ -119,7 +119,7 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_publish_pending_site_modal() {
|
||||
public function render_publish_pending_site_modal(): void {
|
||||
|
||||
$membership = wu_get_membership(wu_request('membership_id'));
|
||||
|
||||
@ -127,52 +127,52 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'confirm' => array(
|
||||
$fields = [
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Publication', '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' => __('Publish', 'wp-ultimo'),
|
||||
'placeholder' => __('Publish', 'wp-ultimo'),
|
||||
'value' => 'publish',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => '!confirmed',
|
||||
),
|
||||
),
|
||||
'wu-when' => array(
|
||||
],
|
||||
],
|
||||
'wu-when' => [
|
||||
'type' => 'hidden',
|
||||
'value' => base64_encode('init'),
|
||||
),
|
||||
'membership_id' => array(
|
||||
],
|
||||
'membership_id' => [
|
||||
'type' => 'hidden',
|
||||
'value' => $membership->get_id(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'total-actions',
|
||||
$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' => 'true',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'confirmed' => false,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -184,7 +184,7 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_publish_pending_site_modal() {
|
||||
public function handle_publish_pending_site_modal(): void {
|
||||
|
||||
$membership = wu_get_membership(wu_request('membership_id'));
|
||||
|
||||
@ -216,14 +216,14 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
$redirect = current_user_can('wu_edit_sites') ? 'wp-ultimo-edit-site' : 'wp-ultimo-sites';
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
$redirect,
|
||||
array(
|
||||
[
|
||||
'id' => $pending_site->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -248,17 +248,17 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
$path = $d->path;
|
||||
}
|
||||
|
||||
$atts = array(
|
||||
$atts = [
|
||||
'domain' => $domain,
|
||||
'path' => $path,
|
||||
'title' => wu_request('title'),
|
||||
'type' => wu_request('type'),
|
||||
'template_id' => wu_request('template_site', 0),
|
||||
'membership_id' => wu_request('membership_id', false),
|
||||
'duplication_arguments' => array(
|
||||
'duplication_arguments' => [
|
||||
'copy_media' => wu_request('copy_media'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$site = wu_create_site($atts);
|
||||
|
||||
@ -275,16 +275,16 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
$redirect = current_user_can('wu_edit_sites') ? 'wp-ultimo-edit-site' : 'wp-ultimo-sites';
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
$redirect,
|
||||
array(
|
||||
[
|
||||
'id' => $site->get_id(),
|
||||
'wu-new-model' => 1,
|
||||
'updated' => 1,
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_add_new_site_modal() {
|
||||
public function render_add_new_site_modal(): void {
|
||||
|
||||
global $current_site;
|
||||
|
||||
@ -323,11 +323,11 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
$save_label = $duplicate_id ? __('Duplicate Site', 'wp-ultimo') : __('Add new Site', 'wp-ultimo');
|
||||
|
||||
$options = array(
|
||||
$options = [
|
||||
'sub-domain' => __('Subdomain', 'wp-ultimo'),
|
||||
'sub-directory' => __('Subdirectory', 'wp-ultimo'),
|
||||
'domain' => __('Domain', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* Only keep the tab that correspond to the install type.
|
||||
@ -338,137 +338,137 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
unset($options['sub-domain']);
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'tab' => array(
|
||||
$fields = [
|
||||
'tab' => [
|
||||
'type' => 'tab-select',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'tab',
|
||||
),
|
||||
],
|
||||
'options' => $options,
|
||||
),
|
||||
'title' => array(
|
||||
],
|
||||
'title' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Site Title', 'wp-ultimo'),
|
||||
'placeholder' => __('New Network Site', 'wp-ultimo'),
|
||||
'value' => $title,
|
||||
),
|
||||
'domain_group' => array(
|
||||
],
|
||||
'domain_group' => [
|
||||
'type' => 'group',
|
||||
// translators: the %s is the site preview url.
|
||||
'desc' => sprintf(__('The site URL will be: %s', 'wp-ultimo'), '<span class="wu-font-mono">{{ tab === "domain" ? domain : ( tab === "sub-directory" ? scheme + base_url + domain : scheme + domain + "." + base_url ) }}</span>'),
|
||||
'fields' => array(
|
||||
'domain' => array(
|
||||
'fields' => [
|
||||
'domain' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Site Domain/Path', 'wp-ultimo'),
|
||||
'tooltip' => __('Enter the complete domain for the site', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-w-full',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:placeholder' => 'tab === "domain" ? "mysite.com" : "mysite"',
|
||||
'v-on:input' => 'domain = tab === "domain" ? $event.target.value.toLowerCase().replace(/[^a-z0-9-.-]+/g, "") : $event.target.value.toLowerCase().replace(/[^a-z0-9-]+/g, "")',
|
||||
'v-bind:value' => 'domain',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'type' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'type' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Site Type', 'wp-ultimo'),
|
||||
'value' => $type,
|
||||
'placeholder' => '',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'default' => __('Regular WP Site', 'wp-ultimo'),
|
||||
'site_template' => __('Site Template', 'wp-ultimo'),
|
||||
'customer_owned' => __('Customer-Owned', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'type',
|
||||
),
|
||||
),
|
||||
'membership_id' => array(
|
||||
],
|
||||
],
|
||||
'membership_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Associated Membership', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Membership...', 'wp-ultimo'),
|
||||
'value' => '',
|
||||
'tooltip' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "type === 'customer_owned'",
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'data-model' => 'membership',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'reference_code',
|
||||
'data-search-field' => 'reference_code',
|
||||
'data-max-items' => 1,
|
||||
),
|
||||
),
|
||||
'copy' => array(
|
||||
],
|
||||
],
|
||||
'copy' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Copy Site', 'wp-ultimo'),
|
||||
'desc' => __('Select an existing site to use as a starting point.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'copy',
|
||||
),
|
||||
),
|
||||
'template_site' => array(
|
||||
],
|
||||
],
|
||||
'template_site' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Template Site', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Sites...', 'wp-ultimo'),
|
||||
'desc' => __('The site selected will be copied and used as a starting point.', 'wp-ultimo'),
|
||||
'value' => $template_id,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-model' => 'site',
|
||||
'data-selected' => $site ? json_encode($site->to_search_results()) : '',
|
||||
'data-value-field' => 'blog_id',
|
||||
'data-label-field' => 'title',
|
||||
'data-search-field' => 'title',
|
||||
'data-max-items' => 1,
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'copy',
|
||||
),
|
||||
),
|
||||
'copy_media' => array(
|
||||
],
|
||||
],
|
||||
'copy_media' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Copy Media on Duplication', 'wp-ultimo'),
|
||||
'desc' => __('Copy media files from the template site on duplication. Disabling this can lead to broken images on the new site.', 'wp-ultimo'),
|
||||
'value' => true,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'copy',
|
||||
),
|
||||
),
|
||||
'wu-when' => array(
|
||||
],
|
||||
],
|
||||
'wu-when' => [
|
||||
'type' => 'hidden',
|
||||
'value' => base64_encode('init'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => $save_label,
|
||||
'placeholder' => $save_label,
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-text-right',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-bind:disabled' => 'install_type !== tab && tab !== "domain"',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$d = wu_get_site_domain_and_path('replace');
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'add_new_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' => 'add_new_site',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'tab' => is_subdomain_install() ? 'sub-domain' : 'sub-directory',
|
||||
'install_type' => is_subdomain_install() ? 'sub-domain' : 'sub-directory',
|
||||
'membership' => $membership_id,
|
||||
@ -477,10 +477,10 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
'base_url' => str_replace('replace.', '', (string) $d->domain) . '/',
|
||||
'scheme' => is_ssl() ? 'https://' : 'http://',
|
||||
'domain' => $path,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -502,10 +502,10 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Site removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Site', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -549,14 +549,14 @@ class Site_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add Site'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_site'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,9 +68,9 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to add further initializations.
|
||||
@ -78,9 +78,9 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wp_ajax_wu_generate_text_file_system_info', array($this, 'generate_text_file_system_info'));
|
||||
add_action('wp_ajax_wu_generate_text_file_system_info', [$this, 'generate_text_file_system_info']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +89,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_enqueue_script('dashboard');
|
||||
|
||||
@ -102,7 +102,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
@ -129,16 +129,16 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $data Data.
|
||||
* @return void
|
||||
*/
|
||||
public function output_table_system_info($data) {
|
||||
public function output_table_system_info($data): void {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
wu_get_template(
|
||||
'system-info/system-info-table',
|
||||
array(
|
||||
[
|
||||
'data' => $data,
|
||||
'screen' => $screen,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -181,16 +181,16 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
wu_get_template(
|
||||
'system-info/system-info',
|
||||
array(
|
||||
[
|
||||
'data' => $this->get_data(),
|
||||
'screen' => $screen,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -224,9 +224,9 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
$all_options_bytes = round(mb_strlen($all_options_serialized, '8bit') / 1024, 2);
|
||||
$all_options_transients = $this->get_transients_in_options($all_options);
|
||||
|
||||
$array_active_plugins = array();
|
||||
$array_active_plugins = [];
|
||||
|
||||
$array_constants_options = array(
|
||||
$array_constants_options = [
|
||||
'SAVEQUERIES',
|
||||
'WP_DEBUG',
|
||||
'WP_DEBUG_DISPLAY',
|
||||
@ -235,16 +235,16 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
'SCRIPT_DEBUG',
|
||||
'WP_ENV',
|
||||
'NOBLOGREDIRECT',
|
||||
);
|
||||
];
|
||||
|
||||
$array_constants = array();
|
||||
$array_constants = [];
|
||||
|
||||
foreach ($array_constants_options as $constant) {
|
||||
$array_constants[] = array(
|
||||
$array_constants[] = [
|
||||
'tooltip' => '',
|
||||
'title' => $constant,
|
||||
'value' => defined($constant) ? (is_bool(constant($constant)) ? __('Enabled', 'wp-ultimo') : constant($constant)) : __('Disabled', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($plugins as $plugin_path => $plugin) {
|
||||
@ -255,15 +255,15 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
$plugin_uri = ' (' . $plugin['PluginURI'] . ')';
|
||||
}
|
||||
|
||||
$array_active_plugins[] = array(
|
||||
$array_active_plugins[] = [
|
||||
'tooltip' => '',
|
||||
'title' => $plugin['Name'],
|
||||
'value' => $plugin['Version'] . $plugin_uri,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$array_active_plugins_main_site = array();
|
||||
$array_active_plugins_main_site = [];
|
||||
|
||||
foreach ($plugins as $plugin_path => $plugin) {
|
||||
if (in_array($plugin_path, $active_plugins_main_site, true)) {
|
||||
@ -273,263 +273,263 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
$plugin_uri = ' (' . $plugin['PluginURI'] . ')';
|
||||
}
|
||||
|
||||
$array_active_plugins_main_site[] = array(
|
||||
$array_active_plugins_main_site[] = [
|
||||
'tooltip' => '',
|
||||
'title' => $plugin['Name'],
|
||||
'value' => $plugin['Version'] . $plugin_uri,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$wpultimo_settings = array();
|
||||
$wpultimo_settings = [];
|
||||
|
||||
foreach ($this->get_all_wp_ultimo_settings() as $setting => $value) {
|
||||
if (is_array($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$wpultimo_settings[ $setting ] = array(
|
||||
$wpultimo_settings[ $setting ] = [
|
||||
'tooltip' => '',
|
||||
'title' => $setting,
|
||||
'value' => $value,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$array_wu_tables = array();
|
||||
$array_wu_tables = [];
|
||||
|
||||
foreach ($wpdb->ms_global_tables as $key => $value) {
|
||||
if (strncmp((string) $value, 'wu_', strlen('wu_')) === 0 && ! array_key_exists($value, $array_wu_tables)) {
|
||||
$array_wu_tables[ $value ] = array(
|
||||
if (str_starts_with((string) $value, 'wu_') && ! array_key_exists($value, $array_wu_tables)) {
|
||||
$array_wu_tables[ $value ] = [
|
||||
'tooltip' => '',
|
||||
'title' => $value,
|
||||
'value' => get_network_option(null, "wpdb_{$value}_version"),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters(
|
||||
'wu_system_info_data',
|
||||
array(
|
||||
'WordPress and System Settings' => array(
|
||||
'wp-ultimo-version' => array(
|
||||
[
|
||||
'WordPress and System Settings' => [
|
||||
'wp-ultimo-version' => [
|
||||
'tooltip' => 'WP Multisite WaaS current version installed locally',
|
||||
'title' => 'WP Multisite WaaS Version',
|
||||
'value' => wu_get_version(),
|
||||
),
|
||||
'wordpress-version' => array(
|
||||
],
|
||||
'wordpress-version' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WordPress Version',
|
||||
'value' => get_bloginfo('version'),
|
||||
),
|
||||
'php-version' => array(
|
||||
],
|
||||
'php-version' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Version',
|
||||
'value' => PHP_VERSION,
|
||||
),
|
||||
'mysql-version' => array(
|
||||
],
|
||||
'mysql-version' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'MySQL Version ',
|
||||
'value' => $wpdb->db_version(),
|
||||
),
|
||||
'web-server' => array(
|
||||
],
|
||||
'web-server' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Web Server',
|
||||
'value' => $_SERVER['SERVER_SOFTWARE'],
|
||||
),
|
||||
'wordpress-url' => array(
|
||||
],
|
||||
'wordpress-url' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WordPress URL',
|
||||
'value' => get_bloginfo('wpurl'),
|
||||
),
|
||||
'home-url' => array(
|
||||
],
|
||||
'home-url' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Home URL',
|
||||
'value' => get_bloginfo('url'),
|
||||
),
|
||||
'content-directory' => array(
|
||||
],
|
||||
'content-directory' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Content Directory',
|
||||
'value' => WP_CONTENT_DIR,
|
||||
),
|
||||
'content-url' => array(
|
||||
],
|
||||
'content-url' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Content URL',
|
||||
'value' => WP_CONTENT_URL,
|
||||
),
|
||||
'plugins-directory' => array(
|
||||
],
|
||||
'plugins-directory' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Plugins Directory',
|
||||
'value' => WP_PLUGIN_DIR,
|
||||
),
|
||||
'pluguins-url' => array(
|
||||
],
|
||||
'pluguins-url' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Plugins URL',
|
||||
'value' => WP_PLUGIN_URL,
|
||||
),
|
||||
'uploads-directory' => array(
|
||||
],
|
||||
'uploads-directory' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Uploads Directory',
|
||||
'value' => (defined('UPLOADS') ? UPLOADS : WP_CONTENT_DIR . '/uploads'),
|
||||
),
|
||||
'pluguins-url' => array(
|
||||
],
|
||||
'pluguins-url' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Cookie Domain',
|
||||
'value' => defined('COOKIE_DOMAIN') ? COOKIE_DOMAIN ? COOKIE_DOMAIN : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'multisite-active' => array(
|
||||
'value' => defined('COOKIE_DOMAIN') ? COOKIE_DOMAIN ?: __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
],
|
||||
'multisite-active' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Multi-Site Active',
|
||||
'value' => is_multisite() ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'),
|
||||
),
|
||||
'php-current-time-gmt' => array(
|
||||
],
|
||||
'php-current-time-gmt' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Current Time - GMT',
|
||||
'value' => wu_get_current_time('mysql', true),
|
||||
),
|
||||
'timezone' => array(
|
||||
],
|
||||
'timezone' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Timezone',
|
||||
'value' => wp_timezone_string(),
|
||||
),
|
||||
'php-current-time' => array(
|
||||
],
|
||||
'php-current-time' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Current Time - with Timezone',
|
||||
'value' => wu_get_current_time(),
|
||||
),
|
||||
'database-current-time' => array(
|
||||
],
|
||||
'database-current-time' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Database Current Time',
|
||||
'value' => gmdate('Y-m-d H:i:s', strtotime((string) $wpdb->get_row('SELECT NOW() as time;')->time)),
|
||||
),
|
||||
'php-curl-support' => array(
|
||||
],
|
||||
'php-curl-support' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP cURL Support',
|
||||
'value' => function_exists('curl_init') ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'),
|
||||
),
|
||||
'php-gd-time' => array(
|
||||
],
|
||||
'php-gd-time' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP GD Support',
|
||||
'value' => function_exists('gd_info') ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'),
|
||||
),
|
||||
'php-memory-limit' => array(
|
||||
],
|
||||
'php-memory-limit' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Memory Limit',
|
||||
'value' => $memory_limit . 'M',
|
||||
),
|
||||
'php-memory-usage' => array(
|
||||
],
|
||||
'php-memory-usage' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Memory Usage',
|
||||
'value' => $memory_usage . 'M (' . round($memory_usage / $memory_limit * $pad_spaces, 0) . '%)',
|
||||
),
|
||||
'php-post-max-size' => array(
|
||||
],
|
||||
'php-post-max-size' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Post Max Size',
|
||||
'value' => ini_get('post_max_size'),
|
||||
),
|
||||
'php-upload-max-size' => array(
|
||||
],
|
||||
'php-upload-max-size' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Upload Max Size',
|
||||
'value' => ini_get('upload_max_filesize'),
|
||||
),
|
||||
'php-max-execution-time' => array(
|
||||
],
|
||||
'php-max-execution-time' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Max Execution Time',
|
||||
'value' => $max_execution_time,
|
||||
),
|
||||
'php-allow-url-fopen' => array(
|
||||
],
|
||||
'php-allow-url-fopen' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Allow URL Fopen',
|
||||
'value' => ini_get('allow_url_fopen'),
|
||||
),
|
||||
'php-max-file-uploads' => array(
|
||||
],
|
||||
'php-max-file-uploads' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'PHP Max File Uploads',
|
||||
'value' => ini_get('max_file_uploads'),
|
||||
),
|
||||
'wp-options-count' => array(
|
||||
],
|
||||
'wp-options-count' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Count',
|
||||
'value' => count($all_options),
|
||||
),
|
||||
'wp-options-size' => array(
|
||||
],
|
||||
'wp-options-size' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Size',
|
||||
'value' => $all_options_bytes . 'kb',
|
||||
),
|
||||
'wp-options-transients' => array(
|
||||
],
|
||||
'wp-options-transients' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Transients',
|
||||
'value' => count($all_options_transients),
|
||||
),
|
||||
'wp-debug' => array(
|
||||
],
|
||||
'wp-debug' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Transients',
|
||||
'value' => defined('WP_DEBUG') ? WP_DEBUG ? __('Enabled', 'wp-ultimo') : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'script-debug' => array(
|
||||
],
|
||||
'script-debug' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Transients',
|
||||
'value' => defined('SCRIPT_DEBUG') ? SCRIPT_DEBUG ? __('Enabled', 'wp-ultimo') : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'save-queries' => array(
|
||||
],
|
||||
'save-queries' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Transients',
|
||||
'value' => defined('SAVEQUERIES') ? SAVEQUERIES ? __('Enabled', 'wp-ultimo') : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'autosave-interval' => array(
|
||||
],
|
||||
'autosave-interval' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Transients',
|
||||
'value' => defined('AUTOSAVE_INTERVAL') ? AUTOSAVE_INTERVAL ? AUTOSAVE_INTERVAL : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'wp_post_revisions' => array(
|
||||
'value' => defined('AUTOSAVE_INTERVAL') ? AUTOSAVE_INTERVAL ?: __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
],
|
||||
'wp_post_revisions' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP Options Transients',
|
||||
'value' => defined('WP_POST_REVISIONS') ? WP_POST_REVISIONS ? WP_POST_REVISIONS : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'disable_wp_cron' => array(
|
||||
'value' => defined('WP_POST_REVISIONS') ? WP_POST_REVISIONS ?: __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'),
|
||||
],
|
||||
'disable_wp_cron' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'DISABLE_WP_CRON',
|
||||
'value' => defined('DISABLE_WP_CRON') ? DISABLE_WP_CRON ? DISABLE_WP_CRON : __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'),
|
||||
),
|
||||
'wp_lang' => array(
|
||||
'value' => defined('DISABLE_WP_CRON') ? DISABLE_WP_CRON ?: __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'),
|
||||
],
|
||||
'wp_lang' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WPLANG',
|
||||
'value' => defined('WPLANG') ? WPLANG ? WPLANG : __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'),
|
||||
),
|
||||
'wp_memory_limit' => array(
|
||||
'value' => defined('WPLANG') ? WPLANG ?: __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'),
|
||||
],
|
||||
'wp_memory_limit' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP_MEMORY_LIMIT',
|
||||
'value' => (defined('WP_MEMORY_LIMIT') && WP_MEMORY_LIMIT) ? WP_MEMORY_LIMIT : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'wp_max_memory_limit' => array(
|
||||
],
|
||||
'wp_max_memory_limit' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'WP_MAX_MEMORY_LIMIT',
|
||||
'value' => (defined('WP_MAX_MEMORY_LIMIT') && WP_MAX_MEMORY_LIMIT) ? WP_MAX_MEMORY_LIMIT : __('Not set', 'wp-ultimo'),
|
||||
),
|
||||
'operating-system' => array(
|
||||
],
|
||||
'operating-system' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Operating System',
|
||||
'value' => $browser['platform'],
|
||||
),
|
||||
'browser' => array(
|
||||
],
|
||||
'browser' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Browser',
|
||||
'value' => $browser['name'] . ' ' . $browser['version'],
|
||||
),
|
||||
'user-agent' => array(
|
||||
],
|
||||
'user-agent' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'User Agent',
|
||||
'value' => $browser['user_agent'],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'Active Theme' => array(
|
||||
'active-theme' => array(
|
||||
'Active Theme' => [
|
||||
'active-theme' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Active Theme',
|
||||
'value' => $theme->get('Name') . ' - ' . $theme->get('Version') . '(' . $theme->get('ThemeURI') . ')',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'Active Plugins' => $array_active_plugins,
|
||||
'Active Plugins on Main Site' => $array_active_plugins_main_site,
|
||||
@ -537,17 +537,17 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
'WP Multisite WaaS Database Status' => $array_wu_tables,
|
||||
|
||||
'WP Multisite WaaS Core Settings' => array_merge(
|
||||
array(
|
||||
'logs-directory' => array(
|
||||
[
|
||||
'logs-directory' => [
|
||||
'tooltip' => '',
|
||||
'title' => 'Logs Directory',
|
||||
'value' => is_writable(Logger::get_logs_folder()) ? __('Writable', 'wp-ultimo') : __('Not Writable', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
$wpultimo_settings
|
||||
),
|
||||
'Defined Constants' => $array_constants,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -557,7 +557,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function generate_text_file_system_info() {
|
||||
public function generate_text_file_system_info(): void {
|
||||
|
||||
$file_name = sprintf("$this->id-%s.txt", gmdate('Y-m-d'));
|
||||
$txt = fopen($file_name, 'w') or die('Unable to open file!');
|
||||
@ -629,7 +629,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
}
|
||||
|
||||
// Finally get the correct version number
|
||||
$known = array('Version', $browser_name_short, 'other');
|
||||
$known = ['Version', $browser_name_short, 'other'];
|
||||
$pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
|
||||
|
||||
if ( ! preg_match_all($pattern, (string) $user_agent, $matches)) {
|
||||
@ -657,13 +657,13 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
$version = '?';
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'user_agent' => $user_agent,
|
||||
'name' => $browser_name,
|
||||
'version' => $version,
|
||||
'platform' => $platform,
|
||||
'pattern' => $pattern,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -683,7 +683,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_active_plugins() {
|
||||
|
||||
return (array) get_site_option('active_sitewide_plugins', array());
|
||||
return (array) get_site_option('active_sitewide_plugins', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -693,7 +693,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_active_plugins_on_main_site() {
|
||||
|
||||
return (array) get_option('active_plugins', array());
|
||||
return (array) get_option('active_plugins', []);
|
||||
}
|
||||
/**
|
||||
* Get memory usage
|
||||
@ -722,7 +722,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_all_wp_ultimo_settings() {
|
||||
|
||||
$exclude = array(
|
||||
$exclude = [
|
||||
'email',
|
||||
'logo',
|
||||
'color',
|
||||
@ -734,11 +734,11 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
'license_key',
|
||||
'api-',
|
||||
'manual_payment_instructions',
|
||||
);
|
||||
];
|
||||
|
||||
$include = array('enable');
|
||||
$include = ['enable'];
|
||||
|
||||
$return_settings = array();
|
||||
$return_settings = [];
|
||||
|
||||
$settings = new \WP_Ultimo\Settings();
|
||||
|
||||
@ -769,7 +769,7 @@ class System_Info_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_transients_in_options($options) {
|
||||
|
||||
$transients = array();
|
||||
$transients = [];
|
||||
|
||||
foreach ($options as $name => $value) {
|
||||
if (stristr($name, 'transient')) {
|
||||
|
@ -60,9 +60,9 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the title of the page.
|
||||
@ -103,29 +103,29 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
do_action('wu_load_tax_rates_list_page');
|
||||
|
||||
$columns = apply_filters(
|
||||
'wu_tax_rates_columns',
|
||||
array(
|
||||
[
|
||||
'title' => __('Label', 'wp-ultimo'),
|
||||
'country' => __('Country', 'wp-ultimo'),
|
||||
'state' => __('State / Province', 'wp-ultimo'),
|
||||
'city' => __('City', 'wp-ultimo'),
|
||||
'tax_rate' => __('Tax Rate (%)', 'wp-ultimo'),
|
||||
'move' => '',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_get_template(
|
||||
'taxes/list',
|
||||
array(
|
||||
[
|
||||
'columns' => $columns,
|
||||
'screen' => get_current_screen(),
|
||||
'types' => Tax::get_instance()->get_tax_rate_types(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -135,25 +135,25 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
wp_register_script('wu-tax-rates', wu_get_asset('tax-rates.js', 'js'), array('wu-admin', 'wu-vue', 'underscore', 'wu-selectizer'), wu_get_version(), false);
|
||||
wp_register_script('wu-tax-rates', wu_get_asset('tax-rates.js', 'js'), ['wu-admin', 'wu-vue', 'underscore', 'wu-selectizer'], wu_get_version(), false);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-tax-rates',
|
||||
'wu_tax_ratesl10n',
|
||||
array(
|
||||
[
|
||||
'name' => __('Tax', 'wp-ultimo'),
|
||||
'confirm_message' => __('Are you sure you want to delete this rows?', 'wp-ultimo'),
|
||||
'confirm_delete_tax_category_message' => __('Are you sure you want to delete this tax category?', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-vue-sortable', '//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js', array(), wu_get_version());
|
||||
wp_enqueue_script('wu-vue-sortable', '//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js', [], wu_get_version());
|
||||
|
||||
wp_enqueue_script('wu-vue-draggable', '//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js', array(), wu_get_version());
|
||||
wp_enqueue_script('wu-vue-draggable', '//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js', [], wu_get_version());
|
||||
|
||||
wp_enqueue_script('wu-tax-rates');
|
||||
}
|
||||
@ -168,22 +168,22 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page {
|
||||
* @param array $atts Array of attributes to pass to the form.
|
||||
* @return void
|
||||
*/
|
||||
protected function add_fields_widget($id, $atts = array()) {
|
||||
protected function add_fields_widget($id, $atts = []) {
|
||||
|
||||
$atts = wp_parse_args(
|
||||
$atts,
|
||||
array(
|
||||
[
|
||||
'widget_id' => $id,
|
||||
'before' => '',
|
||||
'after' => '',
|
||||
'title' => __('Fields', 'wp-ultimo'),
|
||||
'position' => 'side',
|
||||
'screen' => get_current_screen(),
|
||||
'fields' => array(),
|
||||
'html_attr' => array(),
|
||||
'fields' => [],
|
||||
'html_attr' => [],
|
||||
'classes' => '',
|
||||
'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',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box(
|
||||
@ -192,13 +192,13 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page {
|
||||
function () use ($atts) {
|
||||
|
||||
if (wu_get_isset($atts['html_attr'], 'data-wu-app')) {
|
||||
$atts['fields']['loading'] = array(
|
||||
$atts['fields']['loading'] = [
|
||||
'type' => 'note',
|
||||
'desc' => sprintf('<div class="wu-block wu-text-center wu-blinking-animation wu-text-gray-600 wu-my-1 wu-text-2xs wu-uppercase wu-font-semibold">%s</div>', __('Loading...', 'wp-ultimo')),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => 0,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,14 +209,14 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page {
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
$atts['widget_id'],
|
||||
$atts['fields'],
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3 ' . $atts['classes'],
|
||||
'field_wrapper_classes' => $atts['field_wrapper_classes'],
|
||||
'html_attr' => $atts['html_attr'],
|
||||
'before' => $atts['before'],
|
||||
'after' => $atts['after'],
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
|
@ -60,9 +60,9 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_customize_invoice_template',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the preview URL. This is then added to the iframe.
|
||||
@ -75,10 +75,10 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
$url = get_site_url(null);
|
||||
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'customizer' => 1,
|
||||
Template_Previewer::get_instance()->get_preview_parameter() => 1,
|
||||
),
|
||||
],
|
||||
$url
|
||||
);
|
||||
}
|
||||
@ -89,27 +89,27 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'fields' => array(
|
||||
'preview_url_parameter' => array(
|
||||
[
|
||||
'fields' => [
|
||||
'preview_url_parameter' => [
|
||||
'type' => 'text',
|
||||
'title' => __('URL Parameter', 'wp-ultimo'),
|
||||
'desc' => __('This is the URL parameter WP Multisite WaaS will use to generate the template preview URLs.', 'wp-ultimo'),
|
||||
'value' => Template_Previewer::get_instance()->get_setting('preview_url_parameter', 'template-preview'),
|
||||
),
|
||||
'enabled' => array(
|
||||
],
|
||||
'enabled' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'desc' => __('If your site templates are not loading, you can disable the top-bar using this setting.', 'wp-ultimo'),
|
||||
'value' => Template_Previewer::get_instance()->get_setting('enabled', true),
|
||||
'html_attr' => array(),
|
||||
),
|
||||
),
|
||||
)
|
||||
'html_attr' => [],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$custom_logo_id = Template_Previewer::get_instance()->get_setting('custom_logo');
|
||||
@ -118,124 +118,124 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
|
||||
$custom_logo = $custom_logo ? $custom_logo[0] : false;
|
||||
|
||||
$fields = array(
|
||||
'tab' => array(
|
||||
$fields = [
|
||||
'tab' => [
|
||||
'type' => 'tab-select',
|
||||
'wrapper_classes' => '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'tab',
|
||||
),
|
||||
'options' => array(
|
||||
],
|
||||
'options' => [
|
||||
'general' => __('General', 'wp-ultimo'),
|
||||
'colors' => __('Colors', 'wp-ultimo'),
|
||||
'images' => __('Images', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'display_responsive_controls' => array(
|
||||
'display_responsive_controls' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Show Responsive Controls', 'wp-ultimo'),
|
||||
'desc' => __('Toggle to show or hide the responsive controls.', 'wp-ultimo'),
|
||||
'value' => true,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "general")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'display_responsive_controls',
|
||||
),
|
||||
),
|
||||
'button_text' => array(
|
||||
],
|
||||
],
|
||||
'button_text' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Button Text', 'wp-ultimo'),
|
||||
'value' => __('Use this Template', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "general")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model.lazy' => 'button_text',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'bg_color' => array(
|
||||
'bg_color' => [
|
||||
'type' => 'color-picker',
|
||||
'title' => __('Background Color', 'wp-ultimo'),
|
||||
'desc' => __('Choose the background color for the top-bar.', 'wp-ultimo'),
|
||||
'value' => '#f9f9f9',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "colors")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'bg_color',
|
||||
),
|
||||
),
|
||||
'button_bg_color' => array(
|
||||
],
|
||||
],
|
||||
'button_bg_color' => [
|
||||
'type' => 'color-picker',
|
||||
'title' => __('Button BG Color', 'wp-ultimo'),
|
||||
'desc' => __('Pick the background color for the button.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "colors")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'button_bg_color',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'use_custom_logo' => array(
|
||||
'use_custom_logo' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Use Custom Logo', 'wp-ultimo'),
|
||||
'desc' => __('You can set a different logo to be used on the top-bar.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "images")',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'use_custom_logo',
|
||||
),
|
||||
),
|
||||
'custom_logo' => array(
|
||||
],
|
||||
],
|
||||
'custom_logo' => [
|
||||
'type' => 'image',
|
||||
'stacked' => true,
|
||||
'title' => __('Custom Logo', 'wp-ultimo'),
|
||||
'desc' => __('The logo is displayed on the preview page top-bar.', 'wp-ultimo'),
|
||||
'value' => $custom_logo_id,
|
||||
'img' => $custom_logo,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'require("tab", "images") && require("use_custom_logo", true)',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$settings = Template_Previewer::get_instance()->get_settings();
|
||||
|
||||
$state = array_merge(
|
||||
$settings,
|
||||
array(
|
||||
[
|
||||
'tab' => 'general',
|
||||
'refresh' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'customizer',
|
||||
array(
|
||||
[
|
||||
'title' => __('Customizer', 'wp-ultimo'),
|
||||
'position' => 'side',
|
||||
'fields' => $fields,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'style' => 'margin-top: -6px;',
|
||||
'data-wu-app' => 'site_template_customizer',
|
||||
'data-wu-customizer-panel' => true,
|
||||
'data-state' => json_encode($state),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -280,7 +280,7 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'customize_label' => __('Customize Template Previewer', 'wp-ultimo'),
|
||||
'add_new_label' => __('Customize Template Previewer', 'wp-ultimo'),
|
||||
'edit_label' => __('Edit Template Previewer', 'wp-ultimo'),
|
||||
@ -289,7 +289,7 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
'title_description' => __('This name is used for internal reference only.', 'wp-ultimo'),
|
||||
'save_button_label' => __('Save Changes', 'wp-ultimo'),
|
||||
'save_description' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,13 +298,13 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
$settings = Template_Previewer::get_instance()->save_settings($_POST);
|
||||
|
||||
$array_params = array(
|
||||
$array_params = [
|
||||
'updated' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$url = add_query_arg($array_params);
|
||||
|
||||
|
@ -32,7 +32,7 @@ class Top_Admin_Nav_Menu {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action('admin_bar_menu', array($this, 'add_top_bar_menus'), 50);
|
||||
add_action('admin_bar_menu', [$this, 'add_top_bar_menus'], 50);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,7 +42,7 @@ class Top_Admin_Nav_Menu {
|
||||
* @param \WP_Admin_Bar $wp_admin_bar The admin bar identifier.
|
||||
* @return void
|
||||
*/
|
||||
public function add_top_bar_menus($wp_admin_bar) {
|
||||
public function add_top_bar_menus($wp_admin_bar): void {
|
||||
|
||||
// Only for super admins
|
||||
if ( ! current_user_can('manage_network')) {
|
||||
@ -50,111 +50,111 @@ class Top_Admin_Nav_Menu {
|
||||
}
|
||||
|
||||
// Add Parent element
|
||||
$parent = array(
|
||||
$parent = [
|
||||
'id' => 'wp-ultimo',
|
||||
'title' => __('Multisite Waas', 'wp-ultimo'),
|
||||
'href' => current_user_can('wu_read_dashboard') ? network_admin_url('admin.php?page=wp-ultimo') : '#',
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the dashboard', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Site
|
||||
$sites = array(
|
||||
$sites = [
|
||||
'id' => 'wp-ultimo-sites',
|
||||
'parent' => 'wp-ultimo',
|
||||
'title' => __('Manage Sites', 'wp-ultimo'),
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-sites'),
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the sites page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Memberships
|
||||
$memberships = array(
|
||||
$memberships = [
|
||||
'id' => 'wp-ultimo-memberships',
|
||||
'parent' => 'wp-ultimo',
|
||||
'title' => __('Manage Memberships', 'wp-ultimo'),
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-memberships'),
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the memberships page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Customers
|
||||
$customers = array(
|
||||
$customers = [
|
||||
'id' => 'wp-ultimo-customers',
|
||||
'parent' => 'wp-ultimo',
|
||||
'title' => __('Customers', 'wp-ultimo'),
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-customers'),
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the customers page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Products
|
||||
$products = array(
|
||||
$products = [
|
||||
'id' => 'wp-ultimo-products',
|
||||
'parent' => 'wp-ultimo',
|
||||
'title' => __('Products', 'wp-ultimo'),
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-products'),
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the products page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Payments
|
||||
$payments = array(
|
||||
$payments = [
|
||||
'id' => 'wp-ultimo-payments',
|
||||
'parent' => 'wp-ultimo',
|
||||
'title' => __('Payments', 'wp-ultimo'),
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-payments'),
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the payments page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Discount Codes
|
||||
$discount_codes = array(
|
||||
$discount_codes = [
|
||||
'id' => 'wp-ultimo-discount-codes',
|
||||
'parent' => 'wp-ultimo',
|
||||
'title' => __('Discount Codes', 'wp-ultimo'),
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-discount-codes'),
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the discount codes page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$container = array(
|
||||
$container = [
|
||||
'id' => 'wp-ultimo-settings-group',
|
||||
'parent' => 'wp-ultimo',
|
||||
'group' => true,
|
||||
'title' => __('Settings Container', 'wp-ultimo'),
|
||||
'href' => '#',
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu ab-sub-secondary',
|
||||
'title' => __('Go to the settings page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Settings
|
||||
$settings = array(
|
||||
$settings = [
|
||||
'id' => 'wp-ultimo-settings',
|
||||
'parent' => 'wp-ultimo-settings-group',
|
||||
'title' => __('Settings', 'wp-ultimo'),
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-settings'),
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu ab-sub-secondary',
|
||||
'title' => __('Go to the settings page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Add items to the top bar.
|
||||
@ -208,16 +208,16 @@ class Top_Admin_Nav_Menu {
|
||||
$parent = 'wp-ultimo-settings-addons';
|
||||
}
|
||||
|
||||
$settings_tab = array(
|
||||
$settings_tab = [
|
||||
'id' => 'wp-ultimo-settings-' . $tab,
|
||||
'parent' => $parent,
|
||||
'title' => $tab_info['title'],
|
||||
'href' => network_admin_url('admin.php?page=wp-ultimo-settings&tab=') . $tab,
|
||||
'meta' => array(
|
||||
'meta' => [
|
||||
'class' => 'wp-ultimo-top-menu',
|
||||
'title' => __('Go to the settings page', 'wp-ultimo'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$wp_admin_bar->add_node($settings_tab);
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'manage_network',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to add further initializations.
|
||||
@ -78,9 +78,9 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wp_ajax_wu_handle_view_logs', array($this, 'handle_view_logs'));
|
||||
add_action('wp_ajax_wu_handle_view_logs', [$this, 'handle_view_logs']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,20 +89,20 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
\WP_Ultimo\Scripts::get_instance()->register_script('wu-view-log', wu_get_asset('view-logs.js', 'js'), array('jquery'));
|
||||
\WP_Ultimo\Scripts::get_instance()->register_script('wu-view-log', wu_get_asset('view-logs.js', 'js'), ['jquery']);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-view-log',
|
||||
'wu_view_logs',
|
||||
array(
|
||||
'i18n' => array(
|
||||
[
|
||||
'i18n' => [
|
||||
'copied' => __('Copied!', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-view-log');
|
||||
@ -144,9 +144,9 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
$logs_list = list_files(
|
||||
Logger::get_logs_folder(),
|
||||
2,
|
||||
array(
|
||||
[
|
||||
'index.html',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$logs_list = array_combine(array_values($logs_list), array_map(fn($file) => str_replace(Logger::get_logs_folder(), '', (string) $file), $logs_list));
|
||||
@ -176,12 +176,12 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$contents = $file && file_exists($file) ? file_get_contents($file) : $default_content;
|
||||
|
||||
$response = array(
|
||||
$response = [
|
||||
'file' => $file,
|
||||
'file_name' => $file_name,
|
||||
'contents' => $contents,
|
||||
'logs_list' => $logs_list,
|
||||
);
|
||||
];
|
||||
|
||||
if (wp_doing_ajax()) {
|
||||
wp_send_json_success($response);
|
||||
@ -196,50 +196,50 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$info = $this->handle_view_logs();
|
||||
|
||||
add_meta_box('wp-ultimo-log-contents', __('Log Contents', 'wp-ultimo'), array($this, 'output_default_widget_payload'), get_current_screen()->id, 'normal', null, $info);
|
||||
add_meta_box('wp-ultimo-log-contents', __('Log Contents', 'wp-ultimo'), [$this, 'output_default_widget_payload'], get_current_screen()->id, 'normal', null, $info);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'file-selector',
|
||||
array(
|
||||
[
|
||||
'title' => __('Log Files', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'log_file' => array(
|
||||
'fields' => [
|
||||
'log_file' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Select Log File', 'wp-ultimo'),
|
||||
'placeholder' => __('Select Log File', 'wp-ultimo'),
|
||||
'value' => wu_request('file'),
|
||||
'tooltip' => '',
|
||||
'options' => $info['logs_list'],
|
||||
),
|
||||
'download' => array(
|
||||
],
|
||||
'download' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Download Log', 'wp-ultimo'),
|
||||
'value' => 'download',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'info',
|
||||
array(
|
||||
[
|
||||
'title' => __('Timestamps', 'wp-ultimo'),
|
||||
'position' => 'side',
|
||||
'fields' => array(
|
||||
'date_modified' => array(
|
||||
'fields' => [
|
||||
'date_modified' => [
|
||||
'title' => __('Last Modified at', 'wp-ultimo'),
|
||||
'type' => 'text-edit',
|
||||
'date' => true,
|
||||
'value' => date_i18n('Y-m-d H:i:s', filemtime($info['file'])),
|
||||
'display_value' => date_i18n('Y-m-d H:i:s', filemtime($info['file'])),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -252,15 +252,15 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
* @param array $data Arguments passed by add_meta_box.
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_payload($unused, $data) {
|
||||
public function output_default_widget_payload($unused, $data): void {
|
||||
|
||||
wu_get_template(
|
||||
'events/widget-payload',
|
||||
array(
|
||||
[
|
||||
'title' => __('Event Payload', 'wp-ultimo'),
|
||||
'loading_text' => __('Loading Payload', 'wp-ultimo'),
|
||||
'payload' => $data['args']['contents'],
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -272,14 +272,14 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('View Log', 'wp-ultimo'),
|
||||
'add_new_label' => __('View Log', 'wp-ultimo'),
|
||||
'title_placeholder' => __('Enter Customer', 'wp-ultimo'),
|
||||
'title_description' => __('Viewing file: ', 'wp-ultimo'),
|
||||
'delete_button_label' => __('Delete Log File', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,7 +290,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_object() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,7 +299,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
/**
|
||||
* Get the action links
|
||||
@ -318,7 +318,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
$action = wu_request('submit_button', 'none');
|
||||
|
||||
|
@ -76,9 +76,9 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_edit_webhooks',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers the necessary scripts and styles for this admin page.
|
||||
@ -86,22 +86,22 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), array('jquery', 'wu-sweet-alert'));
|
||||
wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), ['jquery', 'wu-sweet-alert']);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-webhook-page',
|
||||
'wu_webhook_page',
|
||||
array(
|
||||
'i18n' => array(
|
||||
[
|
||||
'i18n' => [
|
||||
'error_title' => __('Webhook Test', 'wp-ultimo'),
|
||||
'error_message' => __('An error occurred when sending the test webhook, please try again.', 'wp-ultimo'),
|
||||
'copied' => __('Copied!', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-webhook-page');
|
||||
@ -113,15 +113,15 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Delete Webhook - Confirmation modal
|
||||
*/
|
||||
add_filter(
|
||||
'wu_data_json_success_delete_webhook_modal',
|
||||
fn($data_json) => array(
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-webhooks', array('deleted' => 1)),
|
||||
)
|
||||
fn($data_json) => [
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-webhooks', ['deleted' => 1]),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -131,55 +131,55 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
$this->add_fields_widget(
|
||||
'domain-url',
|
||||
array(
|
||||
[
|
||||
'title' => __('Webhook URL', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'fields' => array(
|
||||
'webhook_url' => array(
|
||||
'fields' => [
|
||||
'webhook_url' => [
|
||||
'type' => 'url',
|
||||
'title' => __('Webhook URL', 'wp-ultimo'),
|
||||
'desc' => __('The URL where we will send the payload when the event triggers.', 'wp-ultimo'),
|
||||
'placeholder' => __('https://example.com', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->get_webhook_url(),
|
||||
),
|
||||
'actions' => array(
|
||||
],
|
||||
'actions' => [
|
||||
'type' => 'actions',
|
||||
'tooltip' => __('The event .', 'wp-ultimo'),
|
||||
'actions' => array(
|
||||
'send_test_event' => array(
|
||||
'actions' => [
|
||||
'send_test_event' => [
|
||||
'title' => __('Send Test Event', 'wp-ultimo'),
|
||||
'action' => 'wu_send_test_event',
|
||||
'object_id' => $this->get_object()->get_id(),
|
||||
'loading_text' => 'Sending Test...',
|
||||
),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
],
|
||||
'html_attr' => [
|
||||
'data-page' => 'edit',
|
||||
),
|
||||
],
|
||||
'wrapper_classes' => 'wu-items-left wu-justify-start',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), array($this, 'output_default_widget_payload'), get_current_screen()->id, 'normal');
|
||||
add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), [$this, 'output_default_widget_payload'], get_current_screen()->id, 'normal');
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'events',
|
||||
array(
|
||||
[
|
||||
'title' => __('Events', 'wp-ultimo'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
|
||||
'query_filter' => array($this, 'query_filter'),
|
||||
)
|
||||
'query_filter' => [$this, 'query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
$event_list = array();
|
||||
$event_list = [];
|
||||
|
||||
foreach (wu_get_event_types() as $key => $value) {
|
||||
$event_list[ $key ] = $value['name'];
|
||||
@ -187,42 +187,42 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'fields' => array(
|
||||
'event' => array(
|
||||
[
|
||||
'fields' => [
|
||||
'event' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Event', 'wp-ultimo'),
|
||||
'desc' => __('The event that triggers this webhook.', 'wp-ultimo'),
|
||||
'placeholder' => __('Select Event', 'wp-ultimo'),
|
||||
'options' => $event_list,
|
||||
'value' => $this->get_object()->get_event(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'active',
|
||||
array(
|
||||
[
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'active' => array(
|
||||
'fields' => [
|
||||
'active' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'tooltip' => __('Deactivate will end the event trigger for this webhook.', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to manually enable or disable this webhook.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_active(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'options',
|
||||
array(
|
||||
[
|
||||
'title' => __('Options', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'integration' => array(
|
||||
'fields' => [
|
||||
'integration' => [
|
||||
'edit' => true,
|
||||
'title' => __('Integration', 'wp-ultimo'),
|
||||
'type' => 'text-edit',
|
||||
@ -230,8 +230,8 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'value' => $this->get_object()->get_integration(),
|
||||
'display_value' => ucwords((string) $this->get_object()->get_integration()),
|
||||
'tooltip' => __('Name of the service responsible for creating this webhook. If you are manually creating this webhook, use the value "manual".', 'wp-ultimo'),
|
||||
),
|
||||
'event_count' => array(
|
||||
],
|
||||
'event_count' => [
|
||||
'title' => __('Run Count', 'wp-ultimo'),
|
||||
'type' => 'text-edit',
|
||||
'min' => 0,
|
||||
@ -241,9 +241,9 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
// translators: %d is the number of times that this webhook was triggered.
|
||||
'display_value' => sprintf(__('This webhook was triggered %d time(s).', 'wp-ultimo'), $this->get_object()->get_event_count()),
|
||||
'tooltip' => __('The number of times that this webhook was triggered so far. It includes test runs.', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_payload() {
|
||||
public function output_default_widget_payload(): void {
|
||||
|
||||
$object_event_slug = $this->get_object()->get_event();
|
||||
|
||||
@ -263,11 +263,11 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
wu_get_template(
|
||||
'events/widget-payload',
|
||||
array(
|
||||
[
|
||||
'title' => __('Event Payload', 'wp-ultimo'),
|
||||
'loading_text' => __('Loading Payload', 'wp-ultimo'),
|
||||
'payload' => $payload,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -281,10 +281,10 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'webhook',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -319,7 +319,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +330,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Webhook', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Webhook', 'wp-ultimo'),
|
||||
'updated_message' => __('Webhook updated successfully!', 'wp-ultimo'),
|
||||
@ -340,7 +340,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Webhook', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -383,7 +383,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
$object = $this->get_object();
|
||||
|
||||
@ -396,9 +396,9 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return;
|
||||
} else {
|
||||
$array_params = array(
|
||||
$array_params = [
|
||||
'updated' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->edit === false) {
|
||||
$array_params['id'] = $object->get_id();
|
||||
|
@ -50,9 +50,9 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_read_webhooks',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers the necessary scripts and styles for this admin page.
|
||||
@ -60,22 +60,22 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), array('jquery', 'wu-sweet-alert'));
|
||||
wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), ['jquery', 'wu-sweet-alert']);
|
||||
|
||||
wp_localize_script(
|
||||
'wu-webhook-page',
|
||||
'wu_webhook_page',
|
||||
array(
|
||||
'i18n' => array(
|
||||
[
|
||||
'i18n' => [
|
||||
'error_title' => __('Webhook Test', 'wp-ultimo'),
|
||||
'error_message' => __('An error occurred when sending the test webhook, please try again.', 'wp-ultimo'),
|
||||
'copied' => __('Copied!', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-webhook-page');
|
||||
@ -87,17 +87,17 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_forms() {
|
||||
public function register_forms(): void {
|
||||
/*
|
||||
* Add new webhook.
|
||||
*/
|
||||
wu_register_form(
|
||||
'add_new_webhook_modal',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_webhook_modal'),
|
||||
'handler' => array($this, 'handle_add_new_webhook_modal'),
|
||||
[
|
||||
'render' => [$this, 'render_add_new_webhook_modal'],
|
||||
'handler' => [$this, 'handle_add_new_webhook_modal'],
|
||||
'capability' => 'wu_edit_webhooks',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -107,63 +107,63 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
function render_add_new_webhook_modal() {
|
||||
function render_add_new_webhook_modal(): void {
|
||||
|
||||
$events = wu_get_event_types();
|
||||
|
||||
$event_options = array();
|
||||
$event_options = [];
|
||||
|
||||
foreach ($events as $slug => $event) {
|
||||
$event_options[ $slug ] = $event['name'];
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'name' => array(
|
||||
$fields = [
|
||||
'name' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Webhook Name', 'wp-ultimo'),
|
||||
'desc' => __('A name to easily identify your webhook.', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. Zapier Integration', 'wp-ultimo'),
|
||||
),
|
||||
'event' => array(
|
||||
],
|
||||
'event' => [
|
||||
'title' => __('Event', 'wp-ultimo'),
|
||||
'type' => 'select',
|
||||
'desc' => __('The event that will trigger the webhook.', 'wp-ultimo'),
|
||||
'options' => $event_options,
|
||||
),
|
||||
'webhook_url' => array(
|
||||
],
|
||||
'webhook_url' => [
|
||||
'type' => 'url',
|
||||
'title' => __('Webhook Url', 'wp-ultimo'),
|
||||
'desc' => __('The url of your webhook.', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. https://example.com/', 'wp-ultimo'),
|
||||
),
|
||||
'submit_button' => array(
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Add New Webhook', '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(
|
||||
'edit_line_item',
|
||||
$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_line_item',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
[
|
||||
'event' => '',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$form->render();
|
||||
@ -175,7 +175,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_add_new_webhook_modal() {
|
||||
public function handle_add_new_webhook_modal(): void {
|
||||
|
||||
$status = wu_create_webhook($_POST);
|
||||
|
||||
@ -183,14 +183,14 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
wp_send_json_error($status);
|
||||
} else {
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-webhook',
|
||||
array(
|
||||
[
|
||||
'id' => $status->get_id(),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -211,10 +211,10 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'deleted_message' => __('Webhook removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Webhook', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,14 +258,14 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'label' => __('Add New Webhook', 'wp-ultimo'),
|
||||
'icon' => 'wu-circle-with-plus',
|
||||
'classes' => 'wubox',
|
||||
'url' => wu_get_form_url('add_new_webhook_modal'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
/*
|
||||
* Load sections to memory.
|
||||
*/
|
||||
@ -99,14 +99,14 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
final public function process_save() {
|
||||
final public function process_save(): void {
|
||||
|
||||
$saving_tag = sprintf('saving_%s', $this->get_current_section());
|
||||
|
||||
if (isset($_REQUEST[ $saving_tag ])) {
|
||||
check_admin_referer($saving_tag, '_wpultimo_nonce');
|
||||
|
||||
$handler = isset($this->current_section['handler']) ? $this->current_section['handler'] : array($this, 'default_handler');
|
||||
$handler = $this->current_section['handler'] ?? [$this, 'default_handler'];
|
||||
|
||||
/*
|
||||
* Calls the saving function
|
||||
@ -123,7 +123,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Object', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add New Object', 'wp-ultimo'),
|
||||
'updated_message' => __('Object updated with success!', 'wp-ultimo'),
|
||||
@ -131,7 +131,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
'title_description' => '',
|
||||
'save_button_label' => __('Save', 'wp-ultimo'),
|
||||
'save_description' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +144,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
@ -152,7 +152,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
return;
|
||||
}
|
||||
|
||||
add_meta_box('wp-ultimo-wizard-body', wu_get_isset($this->current_section, 'title', __('Section', 'wp-ultimo')), array($this, 'output_default_widget_body'), $screen->id, 'normal', null);
|
||||
add_meta_box('wp-ultimo-wizard-body', wu_get_isset($this->current_section, 'title', __('Section', 'wp-ultimo')), [$this, 'output_default_widget_body'], $screen->id, 'normal', null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,11 +161,11 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_body() {
|
||||
public function output_default_widget_body(): void {
|
||||
|
||||
echo '<div class="wu-p-4">';
|
||||
|
||||
$view = isset($this->current_section['view']) ? $this->current_section['view'] : array($this, 'default_view');
|
||||
$view = $this->current_section['view'] ?? [$this, 'default_view'];
|
||||
|
||||
/*
|
||||
* Calls the view function.
|
||||
@ -192,13 +192,13 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/wizard',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'logo' => $this->get_logo(),
|
||||
@ -208,7 +208,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
'classes' => 'wu-w-full wu-mx-auto sm:wu-w-11/12 xl:wu-w-8/12 wu-mt-8 sm:wu-max-w-screen-lg',
|
||||
'clickable_navigation' => $this->clickable_navigation,
|
||||
'form_id' => $this->form_id,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function default_handler() {
|
||||
public function default_handler(): void {
|
||||
|
||||
wp_redirect($this->get_next_section_link());
|
||||
|
||||
@ -310,22 +310,22 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function default_view() {
|
||||
public function default_view(): void {
|
||||
|
||||
$section = wp_parse_args(
|
||||
$this->current_section,
|
||||
array(
|
||||
[
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
'content' => '',
|
||||
'fields' => array(),
|
||||
'fields' => [],
|
||||
'next_label' => __('Continue →', 'wp-ultimo'),
|
||||
'back_label' => __('← Go Back', 'wp-ultimo'),
|
||||
'skip_label' => __('Skip this Step', 'wp-ultimo'),
|
||||
'back' => false,
|
||||
'skip' => false,
|
||||
'next' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -339,11 +339,11 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
$this->get_current_section(),
|
||||
$section['fields'],
|
||||
array(
|
||||
[
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-widget-list wu-striped wu-m-0 wu-mt-2 wu--mb-6 wu--mx-6',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-px-6 wu-py-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',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
ob_start();
|
||||
@ -357,9 +357,9 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
'wizards/setup/default',
|
||||
array_merge(
|
||||
$section,
|
||||
array(
|
||||
[
|
||||
'page' => $this,
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -370,15 +370,15 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_submit_box() {
|
||||
public function render_submit_box(): void {
|
||||
|
||||
wu_get_template(
|
||||
'base/wizard/submit-box',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'labels' => $this->get_labels(),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,10 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'admin_menu' => 'exist',
|
||||
'user_admin_menu' => 'exist',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The current site instance.
|
||||
@ -113,7 +113,7 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
$this->current_site = wu_get_current_site();
|
||||
|
||||
@ -166,7 +166,7 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
\WP_Ultimo\UI\Current_Membership_Element::get_instance()->as_metabox(get_current_screen()->id);
|
||||
|
||||
@ -186,7 +186,7 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
|
||||
\WP_Ultimo\UI\Simple_Text_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes');
|
||||
|
||||
\WP_Ultimo\UI\Current_Site_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes', array('show_admin_link' => false));
|
||||
\WP_Ultimo\UI\Current_Site_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes', ['show_admin_link' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,17 +228,17 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/dash',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'has_full_position' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -84,10 +84,10 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'admin_menu' => 'exist',
|
||||
'user_admin_menu' => 'exist',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The current customer instance.
|
||||
@ -137,7 +137,7 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
$this->customer = wu_get_current_customer();
|
||||
}
|
||||
@ -157,7 +157,7 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function force_screen_options() {
|
||||
public function force_screen_options(): void {
|
||||
|
||||
if (get_current_screen()->id !== 'toplevel_page_sites') {
|
||||
return;
|
||||
@ -166,10 +166,10 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
// Forces Screen options so we can add our links.
|
||||
add_screen_option(
|
||||
'wu_fix',
|
||||
array(
|
||||
[
|
||||
'option' => 'test',
|
||||
'value' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -187,17 +187,17 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
\WP_Ultimo\UI\Simple_Text_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes');
|
||||
|
||||
\WP_Ultimo\UI\Checkout_Element::get_instance()->as_inline_content(
|
||||
get_current_screen()->id,
|
||||
'wu_dash_before_metaboxes',
|
||||
array(
|
||||
[
|
||||
'slug' => 'wu-add-new-site',
|
||||
'membership_limitations' => array('sites'),
|
||||
)
|
||||
'membership_limitations' => ['sites'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -240,17 +240,17 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/dash',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'has_full_position' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -66,10 +66,10 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'user_admin_menu' => 'read',
|
||||
'admin_menu' => 'read',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Should we hide admin notices on this page?
|
||||
@ -115,7 +115,7 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
do_action('wu_checkout_scripts', null, null);
|
||||
}
|
||||
@ -126,7 +126,7 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
do_action('wu_setup_checkout', null);
|
||||
|
||||
@ -141,12 +141,12 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad
|
||||
*/
|
||||
public function get_sections() {
|
||||
|
||||
$sections = array(
|
||||
'plan' => array(
|
||||
$sections = [
|
||||
'plan' => [
|
||||
'title' => __('Change Membership', 'wp-ultimo'),
|
||||
'view' => array($this, 'display_checkout_form'),
|
||||
),
|
||||
);
|
||||
'view' => [$this, 'display_checkout_form'],
|
||||
],
|
||||
];
|
||||
|
||||
return $sections;
|
||||
}
|
||||
@ -157,17 +157,17 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/centered',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'content' => do_shortcode('[wu_checkout slug="wu-checkout"]'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
\WP_Ultimo\UI\Current_Membership_Element::get_instance()->as_metabox(get_current_screen()->id);
|
||||
|
||||
|
@ -68,10 +68,10 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'admin_menu' => 'exist',
|
||||
'user_admin_menu' => 'exist',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The current customer instance.
|
||||
@ -113,11 +113,11 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
if ($this->current_site->get_type() === 'customer_owned') {
|
||||
parent::__construct();
|
||||
|
||||
add_action('admin_menu', array($this, 'unset_default_my_sites_menu'));
|
||||
add_action('admin_menu', [$this, 'unset_default_my_sites_menu']);
|
||||
|
||||
add_action('admin_bar_menu', array($this, 'change_my_sites_link'), 90);
|
||||
add_action('admin_bar_menu', [$this, 'change_my_sites_link'], 90);
|
||||
|
||||
add_action('current_screen', array($this, 'force_screen_options'));
|
||||
add_action('current_screen', [$this, 'force_screen_options']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
$this->customer = wu_get_current_customer();
|
||||
}
|
||||
@ -147,7 +147,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function unset_default_my_sites_menu() {
|
||||
public function unset_default_my_sites_menu(): void {
|
||||
|
||||
global $submenu;
|
||||
|
||||
@ -162,7 +162,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @param object $wp_admin_bar The admin bar object.
|
||||
* @return void
|
||||
*/
|
||||
public function change_my_sites_link($wp_admin_bar) {
|
||||
public function change_my_sites_link($wp_admin_bar): void {
|
||||
|
||||
$my_sites = $wp_admin_bar->get_node('my-sites');
|
||||
|
||||
@ -170,9 +170,9 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
'page' => 'sites',
|
||||
);
|
||||
];
|
||||
|
||||
$my_sites->href = add_query_arg($args, admin_url('admin.php'));
|
||||
|
||||
@ -185,7 +185,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function force_screen_options() {
|
||||
public function force_screen_options(): void {
|
||||
|
||||
if (get_current_screen()->id !== 'toplevel_page_sites') {
|
||||
return;
|
||||
@ -194,10 +194,10 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
// Forces Screen options so we can add our links.
|
||||
add_screen_option(
|
||||
'wu_fix',
|
||||
array(
|
||||
[
|
||||
'option' => 'test',
|
||||
'value' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
\WP_Ultimo\UI\Login_Form_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes');
|
||||
|
||||
@ -263,17 +263,17 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/dash',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'has_full_position' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -66,10 +66,10 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'user_admin_menu' => 'read',
|
||||
'admin_menu' => 'read',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Should we hide admin notices on this page?
|
||||
@ -123,7 +123,7 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
do_action('wu_template_switching_admin_page_scripts', null, null);
|
||||
}
|
||||
@ -134,7 +134,7 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function page_loaded() {
|
||||
public function page_loaded(): void {
|
||||
|
||||
do_action('wu_template_switching_admin_page', null);
|
||||
|
||||
@ -147,20 +147,20 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
/*
|
||||
* Renders the base edit page layout, with the columns and everything else =)
|
||||
*/
|
||||
wu_get_template(
|
||||
'base/centered',
|
||||
array(
|
||||
[
|
||||
'screen' => get_current_screen(),
|
||||
'page' => $this,
|
||||
'content' => '',
|
||||
'labels' => array(
|
||||
'labels' => [
|
||||
'updated_message' => __('Template switched successfully!', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
\WP_Ultimo\UI\Template_Switching_Element::get_instance()->as_metabox(get_current_screen()->id);
|
||||
}
|
||||
|
@ -69,9 +69,9 @@ class Debug_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'capability_here',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow child classes to register widgets, if they need them.
|
||||
@ -79,12 +79,12 @@ class Debug_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
add_meta_box(
|
||||
'wp-ultimo-debug-pages',
|
||||
__('All Registered Pages', 'wp-ultimo'),
|
||||
array($this, 'render_debug_pages'),
|
||||
[$this, 'render_debug_pages'],
|
||||
get_current_screen()->id,
|
||||
'normal',
|
||||
null
|
||||
@ -97,7 +97,7 @@ class Debug_Admin_Page extends Base_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_debug_pages() {
|
||||
public function render_debug_pages(): void {
|
||||
|
||||
$pages = Debug::get_instance()->get_pages();
|
||||
|
||||
@ -157,15 +157,15 @@ class Debug_Admin_Page extends Base_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
public function output(): void {
|
||||
|
||||
wu_get_template(
|
||||
'base/dash',
|
||||
array(
|
||||
[
|
||||
'page' => $this,
|
||||
'screen' => get_current_screen(),
|
||||
'has_full_position' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user