111 lines
3.9 KiB
PHP
111 lines
3.9 KiB
PHP
<?php
|
|
/*
|
|
Plugin Name: OgreAlert
|
|
Plugin URI: https://plugins.cleverogre.com/plugin/ogrealert/
|
|
Description: OgreAlert is a plugin developed by CleverOgre in Pensacola, Florida.
|
|
Version: 0.2.2
|
|
Author: CleverOgre
|
|
Author URI: https://cleverogre.com/
|
|
Icon1x: https://plugins.cleverogre.com/plugin/ogrealert/?asset=icon-sm
|
|
Icon2x: https://plugins.cleverogre.com/plugin/ogrealert/?asset=icon
|
|
BannerHigh: https://plugins.cleverogre.com/plugin/ogrealert/?asset=banner
|
|
BannerLow: https://plugins.cleverogre.com/plugin/ogrealert/?asset=banner-sm
|
|
Text Domain: ogrealert
|
|
License: GPLv2 or later
|
|
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
Copyright: © 2020 CleverOgre, Inc. All rights reserved.
|
|
*/
|
|
|
|
namespace OgreAlert;
|
|
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
class Plugin {
|
|
|
|
public static function init() {
|
|
$path = self::get_path(__FILE__);
|
|
|
|
// Initialize Settings
|
|
include_once($path . 'inc/settings.php');
|
|
\OgreAlert\Settings::init();
|
|
|
|
// Default Settings
|
|
\OgreAlert\Settings::set('name', 'OgreAlert');
|
|
\OgreAlert\Settings::set('version', '0.2.2');
|
|
\OgreAlert\Settings::set('capability', 'edit_posts');
|
|
\OgreAlert\Settings::set('path', $path);
|
|
\OgreAlert\Settings::set('dir', self::get_dir(__FILE__));
|
|
\OgreAlert\Settings::set('hook', self::get_hook(__FILE__));
|
|
|
|
// Setup Plugin Updates
|
|
global $wppul_server, $wppul_license_required, $wppul_plugin_file;
|
|
$wppul_server = 'https://plugins.cleverogre.com';
|
|
$wppul_license_required = false;
|
|
$wppul_plugin_file = __FILE__;
|
|
$dir = trailingslashit(dirname(__FILE__));
|
|
require_once($dir . 'lib/wp-package-updater-lib/plugin-update-checker/plugin-update-checker.php');
|
|
require_once($dir . 'lib/wp-package-updater-lib/package-updater.php');
|
|
|
|
// Set Text Domain
|
|
load_plugin_textdomain('ogrealert', false, plugin_basename(dirname(__FILE__)) . '/lang');
|
|
|
|
// Plugin Filters
|
|
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'action_links'));
|
|
|
|
// Delay loading
|
|
add_action('plugins_loaded', array(__CLASS__, 'load'), 10, 0);
|
|
}
|
|
|
|
static function load() {
|
|
// Load Core Classes
|
|
include_once(\OgreAlert\Settings::get('path') . 'inc/alert.php');
|
|
include_once(\OgreAlert\Settings::get('path') . 'inc/expiration.php');
|
|
include_once(\OgreAlert\Settings::get('path') . 'inc/priority.php');
|
|
include_once(\OgreAlert\Settings::get('path') . 'inc/display.php');
|
|
}
|
|
|
|
// Plugin Action Links
|
|
|
|
static function action_links($links) {
|
|
array_unshift($links, '<a href="' . esc_url(admin_url('edit.php?post_type=alert&page=ogrealert_settings')) . '">' . __('Settings', 'ogrealert') . '</a>');
|
|
return $links;
|
|
}
|
|
|
|
// Plugin File Path Calculations
|
|
|
|
private static function get_path($file) {
|
|
return trailingslashit(dirname($file));
|
|
}
|
|
private static function get_dir($file) {
|
|
$dir = trailingslashit(dirname($file));
|
|
$count = 0;
|
|
|
|
// Sanitize for Win32 installs
|
|
$dir = str_replace('\\', '/', $dir);
|
|
|
|
// If file is in plugins folder
|
|
$wp_plugin_dir = str_replace('\\', '/', WP_PLUGIN_DIR);
|
|
$dir = str_replace($wp_plugin_dir, plugins_url(), $dir, $count);
|
|
|
|
if ($count < 1) {
|
|
// If file is in wp-content folder
|
|
$wp_content_dir = str_replace('\\', '/', WP_CONTENT_DIR);
|
|
$dir = str_replace($wp_content_dir, content_url(), $dir, $count);
|
|
}
|
|
|
|
if ($count < 1) {
|
|
// If file is in ??? folder
|
|
$wp_dir = str_replace('\\', '/', ABSPATH);
|
|
$dir = str_replace($wp_dir, site_url('/'), $dir);
|
|
}
|
|
|
|
return $dir;
|
|
}
|
|
private static function get_hook($file) {
|
|
return basename(dirname($file)) . '/' . basename($file);
|
|
}
|
|
|
|
}
|
|
|
|
\OgreAlert\Plugin::init();
|