mirror of
https://github.com/kremalicious/Badged.git
synced 2024-12-28 07:37:43 +01:00
Make the plugin work if symlinked; added some code comments; tagged 0.3.2
This commit is contained in:
parent
bc564ae0cf
commit
5400c1122b
69
badged.php
69
badged.php
@ -5,35 +5,74 @@
|
||||
* Description: Transforms the standard WordPress update & comment notification badges into iOS-styled ones. Just activate and enjoy the red Badges.
|
||||
* Author: Matthias Kretschmann
|
||||
* Author URI: http://matthiaskretschmann.com
|
||||
* Version: 0.3
|
||||
* Version: 0.3.2
|
||||
* License: GPL
|
||||
*/
|
||||
|
||||
|
||||
if (function_exists('load_plugin_textdomain')) {
|
||||
load_plugin_textdomain('bdgd', false, dirname(plugin_basename(__FILE__)).'/languages' );
|
||||
|
||||
/**
|
||||
* Make the plugin work if symlinked
|
||||
*
|
||||
* Thanks to:
|
||||
* http://alexking.org/blog/2011/12/15/wordpress-plugins-and-symlinks
|
||||
*
|
||||
* @since 0.3.2
|
||||
*
|
||||
*/
|
||||
|
||||
$badged_plugin_file = __FILE__;
|
||||
|
||||
if (isset($plugin)) {
|
||||
$badged_plugin_file = $plugin;
|
||||
}
|
||||
|
||||
else if (isset($mu_plugin)) {
|
||||
$badged_plugin_file = $mu_plugin;
|
||||
}
|
||||
else if (isset($network_plugin)) {
|
||||
$badged_plugin_file = $network_plugin;
|
||||
}
|
||||
|
||||
define('BADGED_PLUGIN_FILE', $badged_plugin_file);
|
||||
define('BADGED_PLUGIN_PATH', WP_PLUGIN_DIR.'/'.basename(dirname($badged_plugin_file)));
|
||||
|
||||
|
||||
/**
|
||||
* Load translation
|
||||
*
|
||||
*/
|
||||
if (function_exists('load_plugin_textdomain')) {
|
||||
load_plugin_textdomain('bdgd', false, BADGED_PLUGIN_PATH.'/languages' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the styles depending on options
|
||||
*
|
||||
*/
|
||||
function badged_init() {
|
||||
badged_register_settings();
|
||||
if ( get_option('menu') == 'yes') {
|
||||
wp_register_style('badged-menu-css', plugins_url('css/badged-menu.css', __FILE__), false, '9001');
|
||||
wp_register_style('badged-menu-css', plugins_url('css/badged-menu.css', BADGED_PLUGIN_FILE), false, '9001');
|
||||
wp_enqueue_style('badged-menu-css');
|
||||
}
|
||||
|
||||
if ( get_option('bar') == 'yes') {
|
||||
wp_register_style('badged-bar-css', plugins_url('css/badged-bar.css', __FILE__), false, '9001');
|
||||
wp_register_style('badged-bar-css', plugins_url('css/badged-bar.css', BADGED_PLUGIN_FILE), false, '9001');
|
||||
wp_enqueue_style('badged-bar-css');
|
||||
}
|
||||
}
|
||||
|
||||
function badged_bar_only_init() {
|
||||
if ( get_option('bar') == 'yes') {
|
||||
wp_register_style('badged-bar-css', plugins_url('css/badged-bar.css', __FILE__), false, '9001');
|
||||
wp_register_style('badged-bar-css', plugins_url('css/badged-bar.css', BADGED_PLUGIN_FILE), false, '9001');
|
||||
wp_enqueue_style('badged-bar-css');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the options page with our settings
|
||||
*
|
||||
*/
|
||||
function badged_settings() {
|
||||
add_options_page('Badged Options', 'Badged', 'manage_options', 'badged_settings', 'badged_settings_page');
|
||||
}
|
||||
@ -47,6 +86,11 @@ function badged_settings_page() {
|
||||
require_once('badged-settings.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set default options upon activation
|
||||
*
|
||||
*/
|
||||
function badged_activation() {
|
||||
badged_register_settings();
|
||||
update_option('menu', 'yes');
|
||||
@ -60,17 +104,20 @@ if ( is_admin() ) {
|
||||
add_action('admin_bar_init', 'badged_bar_only_init');
|
||||
}
|
||||
|
||||
register_activation_hook(__FILE__, 'badged_activation');
|
||||
register_activation_hook(BADGED_PLUGIN_FILE, 'badged_activation');
|
||||
|
||||
|
||||
// Add settings link on plugin page
|
||||
/**
|
||||
* Add settings link on plugin page
|
||||
*
|
||||
*/
|
||||
function badged_settings_link($links) {
|
||||
$settings_link = '<a href="options-general.php?page=badged_settings">'. __('Settings') .'</a>';
|
||||
array_unshift($links, $settings_link);
|
||||
return $links;
|
||||
}
|
||||
|
||||
$plugin = plugin_basename(__FILE__);
|
||||
$plugin = plugin_basename(BADGED_PLUGIN_FILE);
|
||||
add_filter('plugin_action_links_'.$plugin, 'badged_settings_link' );
|
||||
|
||||
?>
|
@ -4,7 +4,7 @@ Donate link: http://kremalicious.com/
|
||||
Tags: notification, adminmenu, toolbar, ios, badge
|
||||
Requires at least: 2.7
|
||||
Tested up to: 3.3
|
||||
Stable tag: 0.3.1
|
||||
Stable tag: 0.3.2
|
||||
|
||||
iOS Style Notification Badges for WordPress
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user