Converted array() to []
This commit is contained in:
@@ -12,9 +12,9 @@ if (!defined('ABSPATH')) exit;
|
|||||||
class Alert {
|
class Alert {
|
||||||
|
|
||||||
public static function load() {
|
public static function load() {
|
||||||
add_action('init', array(__CLASS__, 'init'));
|
add_action('init', [__CLASS__, 'init']);
|
||||||
add_filter('manage_alert_posts_columns', array(__CLASS__, 'register_columns'));
|
add_filter('manage_alert_posts_columns', [__CLASS__, 'register_columns']);
|
||||||
add_action('manage_alert_posts_custom_column', array(__CLASS__, 'display_column'), 10, 2);
|
add_action('manage_alert_posts_custom_column', [__CLASS__, 'display_column'], 10, 2);
|
||||||
|
|
||||||
// OgreAlert Content Filters
|
// OgreAlert Content Filters
|
||||||
add_filter('ogrealert/content', 'wptexturize');
|
add_filter('ogrealert/content', 'wptexturize');
|
||||||
@@ -27,8 +27,8 @@ class Alert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function init() {
|
static function init() {
|
||||||
$post_type_args = array(
|
$post_type_args = [
|
||||||
'supports' => array('title', 'editor', 'revisions'),
|
'supports' => ['title', 'editor', 'revisions'],
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'exclude_from_search' => true,
|
'exclude_from_search' => true,
|
||||||
'publicly_queryable' => false,
|
'publicly_queryable' => false,
|
||||||
@@ -38,22 +38,22 @@ class Alert {
|
|||||||
'show_in_admin_bar' => true,
|
'show_in_admin_bar' => true,
|
||||||
'menu_position' => apply_filters('ogrealert/menu_position', 20),
|
'menu_position' => apply_filters('ogrealert/menu_position', 20),
|
||||||
'menu_icon' => 'dashicons-format-status',
|
'menu_icon' => 'dashicons-format-status',
|
||||||
);
|
];
|
||||||
|
|
||||||
if (class_exists('Ogre')) {
|
if (class_exists('Ogre')) {
|
||||||
$post_type_args['labels'] = \Ogre::get_labels(__('Alerts', 'ogrealert'), __('Alert', 'ogrealert'));
|
$post_type_args['labels'] = \Ogre::get_labels(__('Alerts', 'ogrealert'), __('Alert', 'ogrealert'));
|
||||||
} else {
|
} else {
|
||||||
$post_type_args['labels'] = array(
|
$post_type_args['labels'] = [
|
||||||
'name' => __('Alerts', 'ogrealert'),
|
'name' => __('Alerts', 'ogrealert'),
|
||||||
'singular_name' => __('Alert', 'ogrealert'),
|
'singular_name' => __('Alert', 'ogrealert'),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
register_post_type('alert', apply_filters('ogrealert/post_type_args', $post_type_args));
|
register_post_type('alert', apply_filters('ogrealert/post_type_args', $post_type_args));
|
||||||
}
|
}
|
||||||
|
|
||||||
static function register_columns($columns) {
|
static function register_columns($columns) {
|
||||||
$_columns = array();
|
$_columns = [];
|
||||||
|
|
||||||
foreach ($columns as $key => $label) {
|
foreach ($columns as $key => $label) {
|
||||||
if ($key == 'date') {
|
if ($key == 'date') {
|
||||||
@@ -97,7 +97,7 @@ class Alert {
|
|||||||
|
|
||||||
$ids = array_map('intval', $ids);
|
$ids = array_map('intval', $ids);
|
||||||
|
|
||||||
$remove_keys = array();
|
$remove_keys = [];
|
||||||
foreach ($ids as $key => $id) {
|
foreach ($ids as $key => $id) {
|
||||||
if (!self::valid($id)) $remove_keys[] = $key;
|
if (!self::valid($id)) $remove_keys[] = $key;
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ class Alert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function get_active() {
|
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,
|
'posts_per_page' => -1,
|
||||||
'offset' => 0,
|
'offset' => 0,
|
||||||
'orderby' => 'rand',
|
'orderby' => 'rand',
|
||||||
@@ -133,7 +133,7 @@ class Alert {
|
|||||||
'post_type' => 'alert',
|
'post_type' => 'alert',
|
||||||
'post_stauts' => 'publish',
|
'post_stauts' => 'publish',
|
||||||
'fields' => 'ids',
|
'fields' => 'ids',
|
||||||
)));
|
]));
|
||||||
$alerts = !is_wp_error($alerts) && !empty($alerts) ? $alerts : false;
|
$alerts = !is_wp_error($alerts) && !empty($alerts) ? $alerts : false;
|
||||||
|
|
||||||
self::validate_ids($alerts);
|
self::validate_ids($alerts);
|
||||||
@@ -173,29 +173,29 @@ class AlertMetaBox {
|
|||||||
|
|
||||||
public static function load() {
|
public static function load() {
|
||||||
if (is_admin()) {
|
if (is_admin()) {
|
||||||
add_action('load-post.php', array(__ClASS__, 'init'));
|
add_action('load-post.php', [__CLASS__, 'init']);
|
||||||
add_action('load-post-new.php', array(__ClASS__, 'init'));
|
add_action('load-post-new.php', [__CLASS__, 'init']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function init() {
|
public static function init() {
|
||||||
add_action('add_meta_boxes_alert', array(__CLASS__, 'add'));
|
add_action('add_meta_boxes_alert', [__CLASS__, 'add']);
|
||||||
add_action('save_post', array(__CLASS__, 'save'), 10, 2);
|
add_action('save_post', [__CLASS__, 'save'], 10, 2);
|
||||||
add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
|
add_action('admin_enqueue_scripts', [__CLASS__, 'enqueue_scripts']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function enqueue_scripts() {
|
static function enqueue_scripts() {
|
||||||
if (!wp_style_is('jquery-ui-datepicker', 'enqueued')) {
|
if (!wp_style_is('jquery-ui-datepicker', 'enqueued')) {
|
||||||
wp_enqueue_style('jquery-ui-datepicker');
|
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() {
|
static function add() {
|
||||||
add_meta_box(
|
add_meta_box(
|
||||||
'ogrealert_post_settings',
|
'ogrealert_post_settings',
|
||||||
__('Message Settings', 'ogrealert'),
|
__('Message Settings', 'ogrealert'),
|
||||||
array(__CLASS__, 'render'),
|
[__CLASS__, 'render'],
|
||||||
'alert',
|
'alert',
|
||||||
'side',
|
'side',
|
||||||
'default'
|
'default'
|
||||||
@@ -206,35 +206,35 @@ class AlertMetaBox {
|
|||||||
wp_nonce_field('post_settings', '_ogrealert_nonce');
|
wp_nonce_field('post_settings', '_ogrealert_nonce');
|
||||||
|
|
||||||
echo '<p>';
|
echo '<p>';
|
||||||
self::field_select(array(
|
self::field_select([
|
||||||
'id' => 'ogrealert_post_settings_priority',
|
'id' => 'ogrealert_post_settings_priority',
|
||||||
'name' => '_ogrealert_priority',
|
'name' => '_ogrealert_priority',
|
||||||
'label' => __('Priority', 'ogrealert'),
|
'label' => __('Priority', 'ogrealert'),
|
||||||
'options' => array(
|
'options' => [
|
||||||
'high' => __('High', 'ogrealert'),
|
'high' => __('High', 'ogrealert'),
|
||||||
'normal' => __('Normal', 'ogrealert'),
|
'normal' => __('Normal', 'ogrealert'),
|
||||||
'low' => __('Low', 'ogrealert'),
|
'low' => __('Low', 'ogrealert'),
|
||||||
),
|
],
|
||||||
'default' => 'normal',
|
'default' => 'normal',
|
||||||
'class' => 'widefat',
|
'class' => 'widefat',
|
||||||
));
|
]);
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
|
|
||||||
echo '<p>';
|
echo '<p>';
|
||||||
self::field_date(array(
|
self::field_date([
|
||||||
'id' => 'ogrealert_post_settings_expiration',
|
'id' => 'ogrealert_post_settings_expiration',
|
||||||
'name' => '_ogrealert_expiration',
|
'name' => '_ogrealert_expiration',
|
||||||
'label' => __('Expires On', 'ogrealer'),
|
'label' => __('Expires On', 'ogrealert'),
|
||||||
'class' => 'widefat',
|
'class' => 'widefat',
|
||||||
));
|
]);
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
|
|
||||||
echo '<p>';
|
echo '<p>';
|
||||||
self::field_select(array(
|
self::field_select([
|
||||||
'id' => 'ogrealert_post_settings_duration',
|
'id' => 'ogrealert_post_settings_duration',
|
||||||
'name' => '_ogrealert_duration',
|
'name' => '_ogrealert_duration',
|
||||||
'label' => __('Dismiss Duration', 'ogrealert'),
|
'label' => __('Dismiss Duration', 'ogrealert'),
|
||||||
'options' => array(
|
'options' => [
|
||||||
'none' => __('None', 'ogrealert'),
|
'none' => __('None', 'ogrealert'),
|
||||||
'page' => __('Page', 'ogrealert'),
|
'page' => __('Page', 'ogrealert'),
|
||||||
'minute' => __('Minute', 'ogrealert'),
|
'minute' => __('Minute', 'ogrealert'),
|
||||||
@@ -243,11 +243,11 @@ class AlertMetaBox {
|
|||||||
'week' => __('Week', 'ogrealert'),
|
'week' => __('Week', 'ogrealert'),
|
||||||
'month' => __('Month', 'ogrealert'),
|
'month' => __('Month', 'ogrealert'),
|
||||||
'year' => __('Year', 'ogrealert'),
|
'year' => __('Year', 'ogrealert'),
|
||||||
),
|
],
|
||||||
'default' => \OgreAlert\Settings::get('message_dismiss_duration'),
|
'default' => \OgreAlert\Settings::get('message_dismiss_duration'),
|
||||||
'class' => 'widefat',
|
'class' => 'widefat',
|
||||||
'description' => __('If "None" is selected, the notice will not be able to be dismissed.', 'ogrealert'),
|
'description' => __('If "None" is selected, the notice will not be able to be dismissed.', 'ogrealert'),
|
||||||
));
|
]);
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,11 +261,11 @@ class AlertMetaBox {
|
|||||||
// Check if not an autosave or revision
|
// Check if not an autosave or revision
|
||||||
if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) return;
|
if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) return;
|
||||||
|
|
||||||
$keys = array(
|
$keys = [
|
||||||
'_ogrealert_priority',
|
'_ogrealert_priority',
|
||||||
'_ogrealert_expiration',
|
'_ogrealert_expiration',
|
||||||
'_ogrealert_duration',
|
'_ogrealert_duration',
|
||||||
);
|
];
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if (isset($_POST[$key])) update_post_meta($post_id, $key, $_POST[$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['id']) || empty($args['id'])) return;
|
||||||
|
|
||||||
if (isset($args['label']) && !empty($args['label'])) {
|
if (isset($args['label']) && !empty($args['label'])) {
|
||||||
self::field_label(array(
|
self::field_label([
|
||||||
'title' => $args['label'],
|
'title' => $args['label'],
|
||||||
'required' => isset($args['required']) && $args['required'] == true,
|
'required' => isset($args['required']) && $args['required'] == true,
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$selected = '';
|
$selected = '';
|
||||||
@@ -324,10 +324,10 @@ class AlertMetaBox {
|
|||||||
if (!isset($args['id']) || empty($args['id'])) return;
|
if (!isset($args['id']) || empty($args['id'])) return;
|
||||||
|
|
||||||
if (isset($args['label']) && !empty($args['label'])) {
|
if (isset($args['label']) && !empty($args['label'])) {
|
||||||
self::field_label(array(
|
self::field_label([
|
||||||
'title' => $args['label'],
|
'title' => $args['label'],
|
||||||
'required' => isset($args['required']) && $args['required'] == true,
|
'required' => isset($args['required']) && $args['required'] == true,
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = get_post_meta(get_the_ID(), $args['name'], true);
|
$value = get_post_meta(get_the_ID(), $args['name'], true);
|
||||||
|
|||||||
@@ -14,23 +14,23 @@ class Display {
|
|||||||
public static function load() {
|
public static function load() {
|
||||||
if (is_admin()) return;
|
if (is_admin()) return;
|
||||||
|
|
||||||
add_action('wp', array(__CLASS__, 'init'));
|
add_action('wp', [__CLASS__, 'init']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function init() {
|
static function init() {
|
||||||
if (!\OgreAlert\Alert::has_active()) return;
|
if (!\OgreAlert\Alert::has_active()) return;
|
||||||
|
|
||||||
add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
|
add_action('wp_enqueue_scripts', [__CLASS__, 'enqueue_scripts']);
|
||||||
|
|
||||||
$position = \OgreAlert\Settings::get('message_position');
|
$position = \OgreAlert\Settings::get('message_position');
|
||||||
switch ($position) {
|
switch ($position) {
|
||||||
case 'top':
|
case 'top':
|
||||||
case 'bottom':
|
case 'bottom':
|
||||||
case 'footer':
|
case 'footer':
|
||||||
add_action('wp_footer', array(__CLASS__, 'display_alerts'));
|
add_action('wp_footer', [__CLASS__, 'display_alerts']);
|
||||||
break;
|
break;
|
||||||
case 'custom':
|
case 'custom':
|
||||||
add_action('display_alerts', array(__CLASS__, 'display_alerts'));
|
add_action('display_alerts', [__CLASS__, 'display_alerts']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,14 +38,14 @@ class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function enqueue_scripts() {
|
static function enqueue_scripts() {
|
||||||
wp_enqueue_style('ogrealert', \OgreAlert\Settings::get('dir') . 'assets/sass/style.css', array(), \OgreAlert\Settings::get('version'), 'all');
|
wp_enqueue_style('ogrealert', \OgreAlert\Settings::get('dir') . 'assets/sass/style.css', [], \OgreAlert\Settings::get('version'), 'all');
|
||||||
wp_enqueue_script('ogrealert', \OgreAlert\Settings::get('dir') . 'assets/js/frontend.js', array('jquery'), \OgreAlert\Settings::get('version'), true);
|
wp_enqueue_script('ogrealert', \OgreAlert\Settings::get('dir') . 'assets/js/frontend.js', ['jquery'], \OgreAlert\Settings::get('version'), true);
|
||||||
wp_localize_script('ogrealert', 'ogrealert', array(
|
wp_localize_script('ogrealert', 'ogrealert', [
|
||||||
'text_color' => \OgreAlert\Settings::get('message_text_color'),
|
'text_color' => \OgreAlert\Settings::get('message_text_color'),
|
||||||
'background_color' => \OgreAlert\Settings::get('message_background_color'),
|
'background_color' => \OgreAlert\Settings::get('message_background_color'),
|
||||||
'transition_duration' => intval(\OgreAlert\Settings::get('message_transition_duration')),
|
'transition_duration' => intval(\OgreAlert\Settings::get('message_transition_duration')),
|
||||||
'transition_animation' => \OgreAlert\Settings::get('message_transition_animation'),
|
'transition_animation' => \OgreAlert\Settings::get('message_transition_animation'),
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function display_alerts() {
|
static function display_alerts() {
|
||||||
@@ -53,7 +53,7 @@ class Display {
|
|||||||
|
|
||||||
self::load_template('loop-start');
|
self::load_template('loop-start');
|
||||||
foreach (\OgreAlert\Alert::get_active() as $id) {
|
foreach (\OgreAlert\Alert::get_active() as $id) {
|
||||||
self::load_template('alert', \OgreAlert\Priority::get($id), true, array('id' => $id));
|
self::load_template('alert', \OgreAlert\Priority::get($id), true, ['id' => $id]);
|
||||||
}
|
}
|
||||||
self::load_template('loop-end');
|
self::load_template('loop-end');
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ class Display {
|
|||||||
return $classes;
|
return $classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function load_template($filename, $filepart = '', $echo = true, $vars = array()) {
|
private static function load_template($filename, $filepart = '', $echo = true, $vars = []) {
|
||||||
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '-' . $filepart . '.php';
|
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '-' . $filepart . '.php';
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '.php';
|
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '.php';
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ if (!defined('ABSPATH')) exit;
|
|||||||
class Expiration {
|
class Expiration {
|
||||||
|
|
||||||
public static function load() {
|
public static function load() {
|
||||||
add_filter('ogrealert/valid_id', array(__CLASS__, 'check'), 10, 2);
|
add_filter('ogrealert/valid_id', [__CLASS__, 'check'], 10, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function check($valid, $id) {
|
static function check($valid, $id) {
|
||||||
|
|||||||
@@ -11,25 +11,25 @@ if (!defined('ABSPATH')) exit;
|
|||||||
|
|
||||||
class Priority {
|
class Priority {
|
||||||
|
|
||||||
private static $priorities = array(
|
private static $priorities = [
|
||||||
'high',
|
'high',
|
||||||
'normal',
|
'normal',
|
||||||
'low',
|
'low',
|
||||||
);
|
];
|
||||||
|
|
||||||
public static function load() {
|
public static function load() {
|
||||||
add_filter('ogrealert/get_active', array(__CLASS__, 'order'), 10, 1);
|
add_filter('ogrealert/get_active', [__CLASS__, 'order'], 10, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function order($alerts) {
|
static function order($alerts) {
|
||||||
if (!is_array($alerts) || empty($alerts)) return $alerts;
|
if (!is_array($alerts) || empty($alerts)) return $alerts;
|
||||||
|
|
||||||
$_alerts = array();
|
$_alerts = [];
|
||||||
foreach ($alerts as $id) {
|
foreach ($alerts as $id) {
|
||||||
$_alerts[] = array(
|
$_alerts[] = [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'priority' => self::get($id),
|
'priority' => self::get($id),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($_alerts, function ($a, $b) {
|
usort($_alerts, function ($a, $b) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Settings {
|
|||||||
public static $message_low_background_color;
|
public static $message_low_background_color;
|
||||||
|
|
||||||
public static function init() {
|
public static function init() {
|
||||||
self::$defaults = array(
|
self::$defaults = [
|
||||||
'message_enabled' => '1',
|
'message_enabled' => '1',
|
||||||
'message_position' => 'bottom',
|
'message_position' => 'bottom',
|
||||||
'message_container' => '1200',
|
'message_container' => '1200',
|
||||||
@@ -57,7 +57,7 @@ class Settings {
|
|||||||
|
|
||||||
'message_low_text_color' => 'rgba(255, 255, 255, 1)',
|
'message_low_text_color' => 'rgba(255, 255, 255, 1)',
|
||||||
'message_low_background_color' => 'rgba(23, 162, 184, 1)',
|
'message_low_background_color' => 'rgba(23, 162, 184, 1)',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get($key) {
|
public static function get($key) {
|
||||||
@@ -97,7 +97,7 @@ class Settings {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
$options = get_option('ogrealert_options');
|
$options = get_option('ogrealert_options');
|
||||||
if (!is_array($options)) $options = array();
|
if (!is_array($options)) $options = [];
|
||||||
$options["ogrealert_settings_{$key}"] = $value;
|
$options["ogrealert_settings_{$key}"] = $value;
|
||||||
update_option('ogrealert_options', $options);
|
update_option('ogrealert_options', $options);
|
||||||
break;
|
break;
|
||||||
@@ -122,7 +122,7 @@ class Settings {
|
|||||||
$regex = '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/';
|
$regex = '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/';
|
||||||
if (preg_match($regex, $hex) != 1) return false;
|
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')) {
|
if (strlen($hex) == strlen('#000')) {
|
||||||
$dec['r'] = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
|
$dec['r'] = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
|
||||||
@@ -169,28 +169,28 @@ class Settings {
|
|||||||
class SettingsPage {
|
class SettingsPage {
|
||||||
|
|
||||||
public static function init() {
|
public static function init() {
|
||||||
add_action('admin_init', array(__CLASS__, 'register_settings'));
|
add_action('admin_init', [__CLASS__, 'register_settings']);
|
||||||
add_action('admin_menu', array(__CLASS__, 'menu'));
|
add_action('admin_menu', [__CLASS__, 'menu']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function menu() {
|
static function menu() {
|
||||||
if (!current_user_can(\OgreAlert\Settings::get('capability'))) return;
|
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'));
|
$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, array(__CLASS__, 'load_page'));
|
add_action('load-' . $page, [__CLASS__, 'load_page']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function load_page() {
|
static function load_page() {
|
||||||
if (!current_user_can(\OgreAlert\Settings::get('capability'))) return;
|
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() {
|
static function admin_enqueue_scripts() {
|
||||||
if (!wp_style_is('wp-color-picker', 'enqueued')) {
|
if (!wp_style_is('wp-color-picker', 'enqueued')) {
|
||||||
wp_enqueue_style('wp-color-picker');
|
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() {
|
static function register_settings() {
|
||||||
@@ -198,53 +198,53 @@ class SettingsPage {
|
|||||||
|
|
||||||
// Message Settings
|
// 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',
|
'id' => 'ogrealert_settings_message_enabled',
|
||||||
'default' => \OgreAlert\Settings::get_default('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',
|
'id' => 'ogrealert_settings_message_position',
|
||||||
'options' => array(
|
'options' => [
|
||||||
'top' => __('Fixed Top', 'ogrealert'),
|
'top' => __('Fixed Top', 'ogrealert'),
|
||||||
'bottom' => __('Fixed Bottom', 'ogrealert'),
|
'bottom' => __('Fixed Bottom', 'ogrealert'),
|
||||||
'footer' => __('After Footer', 'ogrealert'),
|
'footer' => __('After Footer', 'ogrealert'),
|
||||||
'custom' => __('Custom', 'ogrealert'),
|
'custom' => __('Custom', 'ogrealert'),
|
||||||
),
|
],
|
||||||
'default' => \OgreAlert\Settings::get_default('message_position'),
|
'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'),
|
'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',
|
'id' => 'ogrealert_settings_message_container',
|
||||||
'description' => 'A positive integer in pixels.',
|
'description' => 'A positive integer in pixels.',
|
||||||
'placeholder' => \OgreAlert\Settings::get_default('message_container'),
|
'placeholder' => \OgreAlert\Settings::get_default('message_container'),
|
||||||
'default' => \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',
|
'id' => 'ogrealert_settings_message_transition_duration',
|
||||||
'description' => 'A positive integer in milliseconds.',
|
'description' => 'A positive integer in milliseconds.',
|
||||||
'placeholder' => \OgreAlert\Settings::get_default('message_transition_duration'),
|
'placeholder' => \OgreAlert\Settings::get_default('message_transition_duration'),
|
||||||
'default' => \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',
|
'id' => 'ogrealert_settings_message_transition_animation',
|
||||||
'options' => array(
|
'options' => [
|
||||||
'slide' => __('Slide', 'ogrealert'),
|
'slide' => __('Slide', 'ogrealert'),
|
||||||
'fade' => __('Fade', 'ogrealert'),
|
'fade' => __('Fade', 'ogrealert'),
|
||||||
'custom' => __('Custom', 'ogrealert'),
|
'custom' => __('Custom', 'ogrealert'),
|
||||||
),
|
],
|
||||||
'default' => \OgreAlert\Settings::get_default('message_transition_animation'),
|
'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'),
|
'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',
|
'id' => 'ogrealert_settings_message_dismiss_duration',
|
||||||
'options' => array(
|
'options' => [
|
||||||
'none' => __('None', 'ogrealert'),
|
'none' => __('None', 'ogrealert'),
|
||||||
'page' => __('Page', 'ogrealert'),
|
'page' => __('Page', 'ogrealert'),
|
||||||
'minute' => __('Minute', 'ogrealert'),
|
'minute' => __('Minute', 'ogrealert'),
|
||||||
@@ -253,52 +253,52 @@ class SettingsPage {
|
|||||||
'week' => __('Week', 'ogrealert'),
|
'week' => __('Week', 'ogrealert'),
|
||||||
'month' => __('Month', 'ogrealert'),
|
'month' => __('Month', 'ogrealert'),
|
||||||
'year' => __('Year', 'ogrealert'),
|
'year' => __('Year', 'ogrealert'),
|
||||||
),
|
],
|
||||||
'default' => \OgreAlert\Settings::get_default('message_dismiss_duration'),
|
'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',
|
'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.',
|
'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'),
|
'placeholder' => \OgreAlert\Settings::get_default('message_index'),
|
||||||
'default' => \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',
|
'id' => 'ogrealert_settings_message_high_text_color',
|
||||||
'default' => \OgreAlert\Settings::get_default('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',
|
'id' => 'ogrealert_settings_message_high_background_color',
|
||||||
'default' => \OgreAlert\Settings::get_default('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',
|
'id' => 'ogrealert_settings_message_normal_text_color',
|
||||||
'default' => \OgreAlert\Settings::get_default('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',
|
'id' => 'ogrealert_settings_message_normal_background_color',
|
||||||
'default' => \OgreAlert\Settings::get_default('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',
|
'id' => 'ogrealert_settings_message_low_text_color',
|
||||||
'default' => \OgreAlert\Settings::get_default('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',
|
'id' => 'ogrealert_settings_message_low_background_color',
|
||||||
'default' => \OgreAlert\Settings::get_default('message_low_background_color'),
|
'default' => \OgreAlert\Settings::get_default('message_low_background_color'),
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function page() {
|
static function page() {
|
||||||
@@ -385,12 +385,12 @@ class SettingsPage {
|
|||||||
if (isset($args['default'])) $value = $args['default'];
|
if (isset($args['default'])) $value = $args['default'];
|
||||||
if (isset($options[$args['id']]) && !empty($options[$args['id']])) $value = $options[$args['id']];
|
if (isset($options[$args['id']]) && !empty($options[$args['id']])) $value = $options[$args['id']];
|
||||||
|
|
||||||
$settings = array(
|
$settings = [
|
||||||
'tinymce' => true,
|
'tinymce' => true,
|
||||||
'textarea_name' => 'ogrealert_options[' . $args['id'] . ']',
|
'textarea_name' => 'ogrealert_options[' . $args['id'] . ']',
|
||||||
'textarea_rows' => 15,
|
'textarea_rows' => 15,
|
||||||
'tabindex' => 1,
|
'tabindex' => 1,
|
||||||
);
|
];
|
||||||
wp_editor($value, $args['id'], $settings);
|
wp_editor($value, $args['id'], $settings);
|
||||||
|
|
||||||
if (isset($args['description']) && !empty($args['description'])) {
|
if (isset($args['description']) && !empty($args['description'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user