Converted array() to []

This commit is contained in:
dcooperdalrymple
2022-04-13 10:18:38 -05:00
parent b3ea11c7ce
commit 24efd02e0a
5 changed files with 101 additions and 101 deletions

View File

@@ -12,9 +12,9 @@ if (!defined('ABSPATH')) exit;
class Alert {
public static function load() {
add_action('init', array(__CLASS__, 'init'));
add_filter('manage_alert_posts_columns', array(__CLASS__, 'register_columns'));
add_action('manage_alert_posts_custom_column', array(__CLASS__, 'display_column'), 10, 2);
add_action('init', [__CLASS__, 'init']);
add_filter('manage_alert_posts_columns', [__CLASS__, 'register_columns']);
add_action('manage_alert_posts_custom_column', [__CLASS__, 'display_column'], 10, 2);
// OgreAlert Content Filters
add_filter('ogrealert/content', 'wptexturize');
@@ -27,8 +27,8 @@ class Alert {
}
static function init() {
$post_type_args = array(
'supports' => array('title', 'editor', 'revisions'),
$post_type_args = [
'supports' => ['title', 'editor', 'revisions'],
'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => false,
@@ -38,22 +38,22 @@ class Alert {
'show_in_admin_bar' => true,
'menu_position' => apply_filters('ogrealert/menu_position', 20),
'menu_icon' => 'dashicons-format-status',
);
];
if (class_exists('Ogre')) {
$post_type_args['labels'] = \Ogre::get_labels(__('Alerts', 'ogrealert'), __('Alert', 'ogrealert'));
} else {
$post_type_args['labels'] = array(
$post_type_args['labels'] = [
'name' => __('Alerts', 'ogrealert'),
'singular_name' => __('Alert', 'ogrealert'),
);
];
}
register_post_type('alert', apply_filters('ogrealert/post_type_args', $post_type_args));
}
static function register_columns($columns) {
$_columns = array();
$_columns = [];
foreach ($columns as $key => $label) {
if ($key == 'date') {
@@ -97,7 +97,7 @@ class Alert {
$ids = array_map('intval', $ids);
$remove_keys = array();
$remove_keys = [];
foreach ($ids as $key => $id) {
if (!self::valid($id)) $remove_keys[] = $key;
}
@@ -125,7 +125,7 @@ class Alert {
}
public static function get_active() {
$alerts = get_posts(apply_filters('ogrealert/get_active_args', array(
$alerts = get_posts(apply_filters('ogrealert/get_active_args', [
'posts_per_page' => -1,
'offset' => 0,
'orderby' => 'rand',
@@ -133,7 +133,7 @@ class Alert {
'post_type' => 'alert',
'post_stauts' => 'publish',
'fields' => 'ids',
)));
]));
$alerts = !is_wp_error($alerts) && !empty($alerts) ? $alerts : false;
self::validate_ids($alerts);
@@ -173,29 +173,29 @@ class AlertMetaBox {
public static function load() {
if (is_admin()) {
add_action('load-post.php', array(__ClASS__, 'init'));
add_action('load-post-new.php', array(__ClASS__, 'init'));
add_action('load-post.php', [__CLASS__, 'init']);
add_action('load-post-new.php', [__CLASS__, 'init']);
}
}
public static function init() {
add_action('add_meta_boxes_alert', array(__CLASS__, 'add'));
add_action('save_post', array(__CLASS__, 'save'), 10, 2);
add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
add_action('add_meta_boxes_alert', [__CLASS__, 'add']);
add_action('save_post', [__CLASS__, 'save'], 10, 2);
add_action('admin_enqueue_scripts', [__CLASS__, 'enqueue_scripts']);
}
static function enqueue_scripts() {
if (!wp_style_is('jquery-ui-datepicker', 'enqueued')) {
wp_enqueue_style('jquery-ui-datepicker');
}
wp_enqueue_script('ogrealert-post', \OgreAlert\Settings::get('dir') . 'assets/js/post.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'), \OgreAlert\Settings::get('version'), true);
wp_enqueue_script('ogrealert-post', \OgreAlert\Settings::get('dir') . 'assets/js/post.js', ['jquery', 'jquery-ui-core', 'jquery-ui-datepicker'], \OgreAlert\Settings::get('version'), true);
}
static function add() {
add_meta_box(
'ogrealert_post_settings',
__('Message Settings', 'ogrealert'),
array(__CLASS__, 'render'),
[__CLASS__, 'render'],
'alert',
'side',
'default'
@@ -206,35 +206,35 @@ class AlertMetaBox {
wp_nonce_field('post_settings', '_ogrealert_nonce');
echo '<p>';
self::field_select(array(
self::field_select([
'id' => 'ogrealert_post_settings_priority',
'name' => '_ogrealert_priority',
'label' => __('Priority', 'ogrealert'),
'options' => array(
'options' => [
'high' => __('High', 'ogrealert'),
'normal' => __('Normal', 'ogrealert'),
'low' => __('Low', 'ogrealert'),
),
],
'default' => 'normal',
'class' => 'widefat',
));
]);
echo '</p>';
echo '<p>';
self::field_date(array(
self::field_date([
'id' => 'ogrealert_post_settings_expiration',
'name' => '_ogrealert_expiration',
'label' => __('Expires On', 'ogrealer'),
'label' => __('Expires On', 'ogrealert'),
'class' => 'widefat',
));
]);
echo '</p>';
echo '<p>';
self::field_select(array(
self::field_select([
'id' => 'ogrealert_post_settings_duration',
'name' => '_ogrealert_duration',
'label' => __('Dismiss Duration', 'ogrealert'),
'options' => array(
'options' => [
'none' => __('None', 'ogrealert'),
'page' => __('Page', 'ogrealert'),
'minute' => __('Minute', 'ogrealert'),
@@ -243,11 +243,11 @@ class AlertMetaBox {
'week' => __('Week', 'ogrealert'),
'month' => __('Month', 'ogrealert'),
'year' => __('Year', 'ogrealert'),
),
],
'default' => \OgreAlert\Settings::get('message_dismiss_duration'),
'class' => 'widefat',
'description' => __('If "None" is selected, the notice will not be able to be dismissed.', 'ogrealert'),
));
]);
echo '</p>';
}
@@ -261,11 +261,11 @@ class AlertMetaBox {
// Check if not an autosave or revision
if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) return;
$keys = array(
$keys = [
'_ogrealert_priority',
'_ogrealert_expiration',
'_ogrealert_duration',
);
];
foreach ($keys as $key) {
if (isset($_POST[$key])) update_post_meta($post_id, $key, $_POST[$key]);
}
@@ -275,10 +275,10 @@ class AlertMetaBox {
if (!isset($args['id']) || empty($args['id'])) return;
if (isset($args['label']) && !empty($args['label'])) {
self::field_label(array(
self::field_label([
'title' => $args['label'],
'required' => isset($args['required']) && $args['required'] == true,
));
]);
}
$selected = '';
@@ -324,10 +324,10 @@ class AlertMetaBox {
if (!isset($args['id']) || empty($args['id'])) return;
if (isset($args['label']) && !empty($args['label'])) {
self::field_label(array(
self::field_label([
'title' => $args['label'],
'required' => isset($args['required']) && $args['required'] == true,
));
]);
}
$value = get_post_meta(get_the_ID(), $args['name'], true);