Compare commits
10 Commits
4025007901
...
457c17d5d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
457c17d5d3 | ||
|
|
7743278185 | ||
|
|
dd02b7546b | ||
|
|
24efd02e0a | ||
|
|
b3ea11c7ce | ||
|
|
60e924ba32 | ||
|
|
bb08ce8a51 | ||
|
|
0dfafdbf68 | ||
|
|
f383778510 | ||
|
|
400b1109f7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
/assets/sass/*.css
|
||||
*.map
|
||||
/OgreAlert
|
||||
OgreAlert.zip
|
||||
ogrealert.zip
|
||||
|
||||
11
Makefile
11
Makefile
@@ -1,9 +1,10 @@
|
||||
PACKAGE = OgreAlert
|
||||
SLUG = ogrealert
|
||||
DIR = ./$(PACKAGE)
|
||||
|
||||
all: $(PACKAGE).zip
|
||||
all: $(SLUG).zip
|
||||
|
||||
$(PACKAGE).zip: clean dir copy zip
|
||||
$(SLUG).zip: clean dir copy zip
|
||||
|
||||
dir:
|
||||
mkdir $(DIR)
|
||||
@@ -16,16 +17,16 @@ copy:
|
||||
cp -f ./* $(DIR) || true
|
||||
|
||||
rm $(DIR)/Makefile
|
||||
rm $(DIR)/$(PACKAGE).zip || true
|
||||
rm $(DIR)/$(SLUG).zip || true
|
||||
|
||||
rm -r $(DIR)/assets/sass/lib
|
||||
rm $(DIR)/assets/sass/*.scss
|
||||
rm $(DIR)/assets/sass/*.map
|
||||
|
||||
zip:
|
||||
zip -r ./$(PACKAGE).zip $(DIR)
|
||||
zip -r ./$(SLUG).zip $(DIR)
|
||||
rm -r $(DIR) || true
|
||||
|
||||
clean:
|
||||
rm -r $(DIR) || true
|
||||
rm ./$(PACKAGE).zip || true
|
||||
rm ./$(SLUG).zip || true
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Plugin Name: OgreAlert
|
||||
Plugin URI: https://plugins.cleverogre.com/plugin/ogrealert/
|
||||
Description: OgreAlert is a plugin developed by CleverOgre in Pensacola, Florida.
|
||||
Version: 0.1.7
|
||||
Version: 0.1.9
|
||||
Author: CleverOgre
|
||||
Author URI: https://cleverogre.com/
|
||||
Icon1x: https://plugins.cleverogre.com/plugin/ogrealert/?asset=icon-sm
|
||||
@@ -29,7 +29,7 @@ Copyright: © 2020 CleverOgre, Inc. All rights reserved.
|
||||
`'---' `--' `" `'-'
|
||||
*/
|
||||
|
||||
jQuery(function ($) {
|
||||
(function ($) {
|
||||
if (typeof ogrealert === 'undefined' || ogrealert == null || ogrealert.length <= 0) return falase;
|
||||
|
||||
// Cookie functions
|
||||
@@ -196,4 +196,4 @@ jQuery(function ($) {
|
||||
}
|
||||
|
||||
$(document).ready(documentReady);
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -29,8 +29,8 @@ Copyright: © 2020 CleverOgre, Inc. All rights reserved.
|
||||
`'---' `--' `" `'-'
|
||||
*/
|
||||
|
||||
jQuery(function ($) {
|
||||
$(document).on('ready', function () {
|
||||
(function ($) {
|
||||
$(document).ready(function () {
|
||||
if ($.fn.datepicker) {
|
||||
// Not using datepicker atm
|
||||
/* $('.ogrealert-date-picker').datepicker({
|
||||
@@ -40,4 +40,4 @@ jQuery(function ($) {
|
||||
console.log('OgreAlert Error: datepicker does not exist.');
|
||||
}
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
@@ -29,12 +29,12 @@ Copyright: © 2020 CleverOgre, Inc. All rights reserved.
|
||||
`'---' `--' `" `'-'
|
||||
*/
|
||||
|
||||
jQuery(function ($) {
|
||||
$(document).on('ready', function () {
|
||||
(function ($) {
|
||||
$(document).ready(function () {
|
||||
if ($.fn.wpColorPicker) {
|
||||
$('.ogrealert-color-picker').wpColorPicker();
|
||||
} else {
|
||||
console.log('OgreAlert Error: wpColorPicker does not exist.');
|
||||
}
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Plugin Name: OgreAlert
|
||||
Plugin URI: https://plugins.cleverogre.com/plugin/ogrealert/
|
||||
Description: OgreAlert is a plugin developed by CleverOgre in Pensacola, Florida.
|
||||
Version: 0.1.8
|
||||
Version: 0.1.9
|
||||
Author: CleverOgre
|
||||
Author URI: https://cleverogre.com/
|
||||
Icon1x: https://plugins.cleverogre.com/plugin/ogrealert/?asset=icon-sm
|
||||
@@ -57,15 +57,13 @@ $content-line: 1.5 * $content-text;
|
||||
|
||||
$icon-text: $content-line;
|
||||
|
||||
// Layering
|
||||
|
||||
$messages-index: 10001;
|
||||
|
||||
/*******************
|
||||
* Message *
|
||||
*******************/
|
||||
|
||||
section.ogrealert-messages {
|
||||
--messages-index: 10001;
|
||||
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
@@ -73,7 +71,7 @@ section.ogrealert-messages {
|
||||
padding: 0;
|
||||
|
||||
position: relative;
|
||||
z-index: $messages-index;
|
||||
z-index: var(--messages-index);
|
||||
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* @package CleverOgre
|
||||
* @subpackage OgreAlert
|
||||
* @since OgreAlert 0.1.7
|
||||
* @since OgreAlert 0.1.9
|
||||
*/
|
||||
|
||||
namespace OgreAlert;
|
||||
@@ -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');
|
||||
@@ -22,13 +22,13 @@ class Alert {
|
||||
add_filter('ogrealert/content', 'wpautop');
|
||||
add_filter('ogrealert/content', 'shortcode_unautop');
|
||||
add_filter('ogrealert/content', 'prepend_attachment');
|
||||
add_filter('ogrealert/content', 'wp_make_content_images_responsive');
|
||||
add_filter('ogrealert/content', 'wp_filter_content_tags');
|
||||
add_filter('ogrealert/content', 'do_shortcode', 11); // After wpautop
|
||||
}
|
||||
|
||||
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,13 +133,16 @@ class Alert {
|
||||
'post_type' => 'alert',
|
||||
'post_stauts' => 'publish',
|
||||
'fields' => 'ids',
|
||||
)));
|
||||
]));
|
||||
$alerts = !is_wp_error($alerts) && !empty($alerts) ? $alerts : false;
|
||||
|
||||
self::validate_ids($alerts);
|
||||
|
||||
return apply_filters('ogrealert/get_active', $alerts);
|
||||
}
|
||||
public static function has_active() {
|
||||
return apply_filters('ogrealert/has_active', !empty(self::get_active()));
|
||||
}
|
||||
|
||||
public static function get_random() {
|
||||
$alerts = self::get_active();
|
||||
@@ -170,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'
|
||||
@@ -203,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'),
|
||||
@@ -240,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>';
|
||||
}
|
||||
|
||||
@@ -258,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]);
|
||||
}
|
||||
@@ -272,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 = '';
|
||||
@@ -321,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);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* @package CleverOgre
|
||||
* @subpackage OgreAlert
|
||||
* @since OgreAlert 0.1.8
|
||||
* @since OgreAlert 0.1.9
|
||||
*/
|
||||
|
||||
namespace OgreAlert;
|
||||
@@ -14,50 +14,62 @@ class Display {
|
||||
public static function load() {
|
||||
if (is_admin()) return;
|
||||
|
||||
add_action('wp', array(__CLASS__, 'init'));
|
||||
add_action('wp', [__CLASS__, 'init']);
|
||||
}
|
||||
|
||||
static function init() {
|
||||
if (empty(\OgreAlert\Alert::get_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');
|
||||
switch ($position) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
case 'footer':
|
||||
add_action('wp_footer', array(__CLASS__, 'display_alerts'));
|
||||
add_action('wp_footer', [__CLASS__, 'display_alerts']);
|
||||
break;
|
||||
case 'custom':
|
||||
add_action('display_alerts', array(__CLASS__, 'display_alerts'));
|
||||
add_action('display_alerts', [__CLASS__, 'display_alerts']);
|
||||
break;
|
||||
}
|
||||
|
||||
add_filter('body_class', [__CLASS__, 'body_class'], 10, 1);
|
||||
}
|
||||
|
||||
static function enqueue_scripts() {
|
||||
wp_enqueue_style('ogrealert', \OgreAlert\Settings::get('dir') . 'assets/sass/style.css', array(), \OgreAlert\Settings::get('version'), 'all');
|
||||
wp_enqueue_script('ogrealert', \OgreAlert\Settings::get('dir') . 'assets/js/display.js', array('jquery'), \OgreAlert\Settings::get('version'), true);
|
||||
wp_localize_script('ogrealert', 'ogrealert', array(
|
||||
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', ['jquery'], \OgreAlert\Settings::get('version'), true);
|
||||
wp_localize_script('ogrealert', 'ogrealert', [
|
||||
'text_color' => \OgreAlert\Settings::get('message_text_color'),
|
||||
'background_color' => \OgreAlert\Settings::get('message_background_color'),
|
||||
'transition_duration' => intval(\OgreAlert\Settings::get('message_transition_duration')),
|
||||
'transition_animation' => \OgreAlert\Settings::get('message_transition_animation'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
static function display_alerts() {
|
||||
$ids = \OgreAlert\Alert::get_active();
|
||||
if (empty($ids)) return;
|
||||
if (!\OgreAlert\Alert::has_active()) return;
|
||||
|
||||
self::load_template('loop-start');
|
||||
foreach ($ids as $id) {
|
||||
self::load_template('alert', \OgreAlert\Priority::get($id), true, array('id' => $id));
|
||||
foreach (\OgreAlert\Alert::get_active() as $id) {
|
||||
self::load_template('alert', \OgreAlert\Priority::get($id), true, ['id' => $id]);
|
||||
}
|
||||
self::load_template('loop-end');
|
||||
}
|
||||
|
||||
private static function load_template($filename, $filepart = '', $echo = true, $vars = array()) {
|
||||
static function body_class($classes) {
|
||||
if (is_admin() || !\OgreAlert\Alert::has_active()) return $classes;
|
||||
|
||||
$classes[] = 'has-alert';
|
||||
foreach (\OgreAlert\Alert::get_active() as $id) {
|
||||
$classes[] = sprintf('has-alert-%d', $id);
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
private static function load_template($filename, $filepart = '', $echo = true, $vars = []) {
|
||||
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '-' . $filepart . '.php';
|
||||
if (!file_exists($path)) {
|
||||
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '.php';
|
||||
|
||||
@@ -12,7 +12,7 @@ if (!defined('ABSPATH')) exit;
|
||||
class Expiration {
|
||||
|
||||
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) {
|
||||
|
||||
@@ -11,25 +11,25 @@ if (!defined('ABSPATH')) exit;
|
||||
|
||||
class Priority {
|
||||
|
||||
private static $priorities = array(
|
||||
private static $priorities = [
|
||||
'high',
|
||||
'normal',
|
||||
'low',
|
||||
);
|
||||
];
|
||||
|
||||
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) {
|
||||
if (!is_array($alerts) || empty($alerts)) return $alerts;
|
||||
|
||||
$_alerts = array();
|
||||
$_alerts = [];
|
||||
foreach ($alerts as $id) {
|
||||
$_alerts[] = array(
|
||||
$_alerts[] = [
|
||||
'id' => $id,
|
||||
'priority' => self::get($id),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
usort($_alerts, function ($a, $b) {
|
||||
|
||||
101
inc/settings.php
101
inc/settings.php
@@ -28,6 +28,7 @@ class Settings {
|
||||
public static $message_transition_duration;
|
||||
public static $message_transition_animation;
|
||||
public static $message_dismiss_duration;
|
||||
public static $message_index;
|
||||
|
||||
public static $message_high_text_color;
|
||||
public static $message_high_background_color;
|
||||
@@ -39,13 +40,14 @@ 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',
|
||||
'message_transition_duration' => '250',
|
||||
'message_dismiss_duration' => 'day',
|
||||
'message_animation' => 'slide',
|
||||
'message_index' => '10001',
|
||||
|
||||
'message_high_text_color' => 'rgba(255, 255, 255, 1)',
|
||||
'message_high_background_color' => 'rgba(220, 53, 69, 1)',
|
||||
@@ -55,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) {
|
||||
@@ -95,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;
|
||||
@@ -120,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));
|
||||
@@ -167,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() {
|
||||
@@ -196,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'),
|
||||
@@ -251,45 +253,52 @@ class SettingsPage {
|
||||
'week' => __('Week', 'ogrealert'),
|
||||
'month' => __('Month', 'ogrealert'),
|
||||
'year' => __('Year', 'ogrealert'),
|
||||
),
|
||||
],
|
||||
'default' => \OgreAlert\Settings::get_default('message_dismiss_duration'),
|
||||
));
|
||||
]);
|
||||
|
||||
add_settings_section('ogrealert_section_high', __('High Priority', 'ogrealert'), array(__CLASS__, 'section'), 'ogrealert');
|
||||
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_field('ogrealert_message_high_text_color', __('Text Color', 'ogrealert'), array(__CLASS__, 'field_color'), 'ogrealert', 'ogrealert_section_high', array(
|
||||
add_settings_section('ogrealert_section_high', __('High Priority', 'ogrealert'), [__CLASS__, 'section'], 'ogrealert');
|
||||
|
||||
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() {
|
||||
@@ -376,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'])) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Plugin Name: OgreAlert
|
||||
Plugin URI: https://plugins.cleverogre.com/plugin/ogrealert/
|
||||
Description: OgreAlert is a plugin developed by CleverOgre in Pensacola, Florida.
|
||||
Version: 0.1.8
|
||||
Version: 0.1.9
|
||||
Author: CleverOgre
|
||||
Author URI: https://cleverogre.com/
|
||||
Icon1x: https://plugins.cleverogre.com/plugin/ogrealert/?asset=icon-sm
|
||||
@@ -45,7 +45,7 @@ class Plugin {
|
||||
|
||||
// Default Settings
|
||||
\OgreAlert\Settings::set('name', 'OgreAlert');
|
||||
\OgreAlert\Settings::set('version', '0.1.8');
|
||||
\OgreAlert\Settings::set('version', '0.1.9');
|
||||
\OgreAlert\Settings::set('capability', 'edit_posts');
|
||||
\OgreAlert\Settings::set('path', $path);
|
||||
\OgreAlert\Settings::set('dir', self::get_dir(__FILE__));
|
||||
|
||||
@@ -4,7 +4,7 @@ Donate link: https://cleverogre.com/
|
||||
Tags: development, warning, modal, dismissable
|
||||
Requires at least: 4.8.0
|
||||
Tested up to: 5.7.1
|
||||
Stable tag: 0.1.8
|
||||
Stable tag: 0.1.9
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@@ -62,6 +62,11 @@ By default, the OgreAlert plugin will be able to update without an activated lic
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 0.1.9 - 05-24-2021 =
|
||||
* NEW: Z-index field in OgreAlert settings.
|
||||
* BUG: Replaced wp_make_content_images_responsive filter with wp_filter_content_tags for WP 5.5.0 compatibility.
|
||||
* BUG: Renamed display.js to frontend.js to prevent ad blockers.
|
||||
|
||||
= 0.1.8 - 05-12-2021 =
|
||||
* DEV: Moved FontAwesome webfonts to separated folder in assets.
|
||||
* DEV: Added plugin packaging makefile.
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
$index = \OgreAlert\Settings::get('message_index');
|
||||
if (!is_numeric($index)) $index = 10001;
|
||||
|
||||
?>
|
||||
<section class="ogrealert-messages ogrealert-position-<?php esc_attr_e(\OgreAlert\Settings::get('message_position')); ?>">
|
||||
<section class="ogrealert-messages ogrealert-position-<?php esc_attr_e(\OgreAlert\Settings::get('message_position')); ?>" style="--messages-index: <?php echo intval($index); ?>">
|
||||
<ul class="ogrealert-messages__list">
|
||||
|
||||
Reference in New Issue
Block a user