Converted array() to []
This commit is contained in:
@@ -40,7 +40,7 @@ class Settings {
|
||||
public static $message_low_background_color;
|
||||
|
||||
public static function init() {
|
||||
self::$defaults = array(
|
||||
self::$defaults = [
|
||||
'message_enabled' => '1',
|
||||
'message_position' => 'bottom',
|
||||
'message_container' => '1200',
|
||||
@@ -57,7 +57,7 @@ class Settings {
|
||||
|
||||
'message_low_text_color' => 'rgba(255, 255, 255, 1)',
|
||||
'message_low_background_color' => 'rgba(23, 162, 184, 1)',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public static function get($key) {
|
||||
@@ -97,7 +97,7 @@ class Settings {
|
||||
|
||||
default:
|
||||
$options = get_option('ogrealert_options');
|
||||
if (!is_array($options)) $options = array();
|
||||
if (!is_array($options)) $options = [];
|
||||
$options["ogrealert_settings_{$key}"] = $value;
|
||||
update_option('ogrealert_options', $options);
|
||||
break;
|
||||
@@ -122,7 +122,7 @@ class Settings {
|
||||
$regex = '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/';
|
||||
if (preg_match($regex, $hex) != 1) return false;
|
||||
|
||||
$dec = array('r' => 0, 'g' => 0, 'b' => 0);
|
||||
$dec = ['r' => 0, 'g' => 0, 'b' => 0];
|
||||
|
||||
if (strlen($hex) == strlen('#000')) {
|
||||
$dec['r'] = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
|
||||
@@ -169,28 +169,28 @@ class Settings {
|
||||
class SettingsPage {
|
||||
|
||||
public static function init() {
|
||||
add_action('admin_init', array(__CLASS__, 'register_settings'));
|
||||
add_action('admin_menu', array(__CLASS__, 'menu'));
|
||||
add_action('admin_init', [__CLASS__, 'register_settings']);
|
||||
add_action('admin_menu', [__CLASS__, 'menu']);
|
||||
}
|
||||
|
||||
static function menu() {
|
||||
if (!current_user_can(\OgreAlert\Settings::get('capability'))) return;
|
||||
|
||||
$page = add_submenu_page('edit.php?post_type=alert', __('OgreAlert Settings', 'ogrealert'), __('Settings', 'ogrealert'), \OgreAlert\Settings::get('capability'), 'ogrealert_settings', array(__CLASS__, 'page'));
|
||||
add_action('load-' . $page, array(__CLASS__, 'load_page'));
|
||||
$page = add_submenu_page('edit.php?post_type=alert', __('OgreAlert Settings', 'ogrealert'), __('Settings', 'ogrealert'), \OgreAlert\Settings::get('capability'), 'ogrealert_settings', [__CLASS__, 'page']);
|
||||
add_action('load-' . $page, [__CLASS__, 'load_page']);
|
||||
}
|
||||
|
||||
static function load_page() {
|
||||
if (!current_user_can(\OgreAlert\Settings::get('capability'))) return;
|
||||
|
||||
add_action('admin_enqueue_scripts', array(__CLASS__, 'admin_enqueue_scripts'));
|
||||
add_action('admin_enqueue_scripts', [__CLASS__, 'admin_enqueue_scripts']);
|
||||
}
|
||||
|
||||
static function admin_enqueue_scripts() {
|
||||
if (!wp_style_is('wp-color-picker', 'enqueued')) {
|
||||
wp_enqueue_style('wp-color-picker');
|
||||
}
|
||||
wp_enqueue_script('ogrealert-settings', \OgreAlert\Settings::get('dir') . 'assets/js/settings.js', array('jquery', 'wp-color-picker'), \OgreAlert\Settings::get('version'), true);
|
||||
wp_enqueue_script('ogrealert-settings', \OgreAlert\Settings::get('dir') . 'assets/js/settings.js', ['jquery', 'wp-color-picker'], \OgreAlert\Settings::get('version'), true);
|
||||
}
|
||||
|
||||
static function register_settings() {
|
||||
@@ -198,53 +198,53 @@ class SettingsPage {
|
||||
|
||||
// Message Settings
|
||||
|
||||
add_settings_section('ogrealert_section_general', __('General Settings', 'ogrealert'), array(__CLASS__, 'section'), 'ogrealert');
|
||||
add_settings_section('ogrealert_section_general', __('General Settings', 'ogrealert'), [__CLASS__, 'section'], 'ogrealert');
|
||||
|
||||
add_settings_field('ogrealert_message_enabled', __('Enable Alerts', 'ogrealert'), array(__CLASS__, 'field_checkbox'), 'ogrealert', 'ogrealert_section_general', array(
|
||||
add_settings_field('ogrealert_message_enabled', __('Enable Alerts', 'ogrealert'), [__CLASS__, 'field_checkbox'], 'ogrealert', 'ogrealert_section_general', [
|
||||
'id' => 'ogrealert_settings_message_enabled',
|
||||
'default' => \OgreAlert\Settings::get_default('message_enabled'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_position', __('Position', 'ogrealert'), array(__CLASS__, 'field_select'), 'ogrealert', 'ogrealert_section_general', array(
|
||||
add_settings_field('ogrealert_message_position', __('Position', 'ogrealert'), [__CLASS__, 'field_select'], 'ogrealert', 'ogrealert_section_general', [
|
||||
'id' => 'ogrealert_settings_message_position',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'top' => __('Fixed Top', 'ogrealert'),
|
||||
'bottom' => __('Fixed Bottom', 'ogrealert'),
|
||||
'footer' => __('After Footer', 'ogrealert'),
|
||||
'custom' => __('Custom', 'ogrealert'),
|
||||
),
|
||||
],
|
||||
'default' => \OgreAlert\Settings::get_default('message_position'),
|
||||
'description' => __('If you choose Custom, you must add "do_action(\'display_alerts\');" to a suitable location in your template files.', 'ogrealert'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_container', __('Container Width', 'ogrealert'), array(__CLASS__, 'field_text'), 'ogrealert', 'ogrealert_section_general', array(
|
||||
add_settings_field('ogrealert_message_container', __('Container Width', 'ogrealert'), [__CLASS__, 'field_text'], 'ogrealert', 'ogrealert_section_general', [
|
||||
'id' => 'ogrealert_settings_message_container',
|
||||
'description' => 'A positive integer in pixels.',
|
||||
'placeholder' => \OgreAlert\Settings::get_default('message_container'),
|
||||
'default' => \OgreAlert\Settings::get_default('message_container'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_transition_duration', __('Transition Duration', 'ogrealert'), array(__CLASS__, 'field_text'), 'ogrealert', 'ogrealert_section_general', array(
|
||||
add_settings_field('ogrealert_message_transition_duration', __('Transition Duration', 'ogrealert'), [__CLASS__, 'field_text'], 'ogrealert', 'ogrealert_section_general', [
|
||||
'id' => 'ogrealert_settings_message_transition_duration',
|
||||
'description' => 'A positive integer in milliseconds.',
|
||||
'placeholder' => \OgreAlert\Settings::get_default('message_transition_duration'),
|
||||
'default' => \OgreAlert\Settings::get_default('message_transition_duration'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_transition_animation', __('Transition Animation', 'ogrealert'), array(__CLASS__, 'field_select'), 'ogrealert', 'ogrealert_section_general', array(
|
||||
add_settings_field('ogrealert_message_transition_animation', __('Transition Animation', 'ogrealert'), [__CLASS__, 'field_select'], 'ogrealert', 'ogrealert_section_general', [
|
||||
'id' => 'ogrealert_settings_message_transition_animation',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'slide' => __('Slide', 'ogrealert'),
|
||||
'fade' => __('Fade', 'ogrealert'),
|
||||
'custom' => __('Custom', 'ogrealert'),
|
||||
),
|
||||
],
|
||||
'default' => \OgreAlert\Settings::get_default('message_transition_animation'),
|
||||
'description' => __('If you choose Custom, the animation must be handled with the "ogrealert-message-transition-custom" class in css.', 'ogrealert'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_dismiss_duration', __('Default Dismiss Duration', 'ogrealert'), array(__CLASS__, 'field_select'), 'ogrealert', 'ogrealert_section_general', array(
|
||||
add_settings_field('ogrealert_message_dismiss_duration', __('Default Dismiss Duration', 'ogrealert'), [__CLASS__, 'field_select'], 'ogrealert', 'ogrealert_section_general', [
|
||||
'id' => 'ogrealert_settings_message_dismiss_duration',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'none' => __('None', 'ogrealert'),
|
||||
'page' => __('Page', 'ogrealert'),
|
||||
'minute' => __('Minute', 'ogrealert'),
|
||||
@@ -253,52 +253,52 @@ class SettingsPage {
|
||||
'week' => __('Week', 'ogrealert'),
|
||||
'month' => __('Month', 'ogrealert'),
|
||||
'year' => __('Year', 'ogrealert'),
|
||||
),
|
||||
],
|
||||
'default' => \OgreAlert\Settings::get_default('message_dismiss_duration'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_index', __('Z-Index', 'ogrealert'), array(__CLASS__, 'field_text'), 'ogrealert', 'ogrealert_section_general', array(
|
||||
add_settings_field('ogrealert_message_index', __('Z-Index', 'ogrealert'), [__CLASS__, 'field_text'], 'ogrealert', 'ogrealert_section_general', [
|
||||
'id' => 'ogrealert_settings_message_index',
|
||||
'description' => 'Sets the z-index value of all OgreAlert messages. Useful for ensuring your messages appear above certain elements of your site.',
|
||||
'placeholder' => \OgreAlert\Settings::get_default('message_index'),
|
||||
'default' => \OgreAlert\Settings::get_default('message_index'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_section('ogrealert_section_high', __('High Priority', 'ogrealert'), array(__CLASS__, 'section'), 'ogrealert');
|
||||
add_settings_section('ogrealert_section_high', __('High Priority', 'ogrealert'), [__CLASS__, 'section'], 'ogrealert');
|
||||
|
||||
add_settings_field('ogrealert_message_high_text_color', __('Text Color', 'ogrealert'), array(__CLASS__, 'field_color'), 'ogrealert', 'ogrealert_section_high', array(
|
||||
add_settings_field('ogrealert_message_high_text_color', __('Text Color', 'ogrealert'), [__CLASS__, 'field_color'], 'ogrealert', 'ogrealert_section_high', [
|
||||
'id' => 'ogrealert_settings_message_high_text_color',
|
||||
'default' => \OgreAlert\Settings::get_default('message_high_text_color'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_high_background_color', __('Background Color', 'ogrealert'), array(__CLASS__, 'field_color'), 'ogrealert', 'ogrealert_section_high', array(
|
||||
add_settings_field('ogrealert_message_high_background_color', __('Background Color', 'ogrealert'), [__CLASS__, 'field_color'], 'ogrealert', 'ogrealert_section_high', [
|
||||
'id' => 'ogrealert_settings_message_high_background_color',
|
||||
'default' => \OgreAlert\Settings::get_default('message_high_background_color'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_section('ogrealert_section_normal', __('Normal Priority', 'ogrealert'), array(__CLASS__, 'section'), 'ogrealert');
|
||||
add_settings_section('ogrealert_section_normal', __('Normal Priority', 'ogrealert'), [__CLASS__, 'section'], 'ogrealert');
|
||||
|
||||
add_settings_field('ogrealert_message_normal_text_color', __('Text Color', 'ogrealert'), array(__CLASS__, 'field_color'), 'ogrealert', 'ogrealert_section_normal', array(
|
||||
add_settings_field('ogrealert_message_normal_text_color', __('Text Color', 'ogrealert'), [__CLASS__, 'field_color'], 'ogrealert', 'ogrealert_section_normal', [
|
||||
'id' => 'ogrealert_settings_message_normal_text_color',
|
||||
'default' => \OgreAlert\Settings::get_default('message_normal_text_color'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_normal_background_color', __('Background Color', 'ogrealert'), array(__CLASS__, 'field_color'), 'ogrealert', 'ogrealert_section_normal', array(
|
||||
add_settings_field('ogrealert_message_normal_background_color', __('Background Color', 'ogrealert'), [__CLASS__, 'field_color'], 'ogrealert', 'ogrealert_section_normal', [
|
||||
'id' => 'ogrealert_settings_message_normal_background_color',
|
||||
'default' => \OgreAlert\Settings::get_default('message_normal_background_color'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_section('ogrealert_section_low', __('Low Priority', 'ogrealert'), array(__CLASS__, 'section'), 'ogrealert');
|
||||
add_settings_section('ogrealert_section_low', __('Low Priority', 'ogrealert'), [__CLASS__, 'section'], 'ogrealert');
|
||||
|
||||
add_settings_field('ogrealert_message_low_text_color', __('Text Color', 'ogrealert'), array(__CLASS__, 'field_color'), 'ogrealert', 'ogrealert_section_low', array(
|
||||
add_settings_field('ogrealert_message_low_text_color', __('Text Color', 'ogrealert'), [__CLASS__, 'field_color'], 'ogrealert', 'ogrealert_section_low', [
|
||||
'id' => 'ogrealert_settings_message_low_text_color',
|
||||
'default' => \OgreAlert\Settings::get_default('message_low_text_color'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_field('ogrealert_message_low_background_color', __('Background Color', 'ogrealert'), array(__CLASS__, 'field_color'), 'ogrealert', 'ogrealert_section_low', array(
|
||||
add_settings_field('ogrealert_message_low_background_color', __('Background Color', 'ogrealert'), [__CLASS__, 'field_color'], 'ogrealert', 'ogrealert_section_low', [
|
||||
'id' => 'ogrealert_settings_message_low_background_color',
|
||||
'default' => \OgreAlert\Settings::get_default('message_low_background_color'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
static function page() {
|
||||
@@ -385,12 +385,12 @@ class SettingsPage {
|
||||
if (isset($args['default'])) $value = $args['default'];
|
||||
if (isset($options[$args['id']]) && !empty($options[$args['id']])) $value = $options[$args['id']];
|
||||
|
||||
$settings = array(
|
||||
$settings = [
|
||||
'tinymce' => true,
|
||||
'textarea_name' => 'ogrealert_options[' . $args['id'] . ']',
|
||||
'textarea_rows' => 15,
|
||||
'tabindex' => 1,
|
||||
);
|
||||
];
|
||||
wp_editor($value, $args['id'], $settings);
|
||||
|
||||
if (isset($args['description']) && !empty($args['description'])) {
|
||||
|
||||
Reference in New Issue
Block a user