diff --git a/classes/footnotes.php b/classes/footnotes.php index 6ad26d1..0eb5af3 100644 --- a/classes/footnotes.php +++ b/classes/footnotes.php @@ -36,13 +36,6 @@ class Class_Footnotes add_action('init', array($this, 'init')); add_action('admin_init', array($this, 'admin_init')); add_action('admin_menu', array($this, 'admin_menu')); - - /* register hook for activating the plugin */ - register_activation_hook(__FILE__, array($this, 'activate')); - /* register hook for deactivating the plugin */ - register_deactivation_hook(__FILE__, array($this, 'deactivate')); - /* register hook for uninstalling the plugin */ - register_uninstall_hook(__FILE__, array($this, 'uninstall')); } /** @@ -70,7 +63,21 @@ class Class_Footnotes */ function uninstall() { - require_once(dirname(__FILE__) . '/../includes/uninstall.php'); + /* uninstalling the plugin is only allowed for logged in users */ + if (!is_user_logged_in()) { + wp_die(__('You must be logged in to run this script.', FOOTNOTES_PLUGIN_NAME)); + } + + /* current user needs the permission to (un)install plugins */ + if (!current_user_can('install_plugins')) { + wp_die(__('You do not have permission to run this script.', FOOTNOTES_PLUGIN_NAME)); + } + + /* + * delete the settings container in the database + * @since 1.0.6 + */ + delete_option(FOOTNOTE_SETTINGS_CONTAINER); } /** diff --git a/includes/plugin-settings.php b/includes/plugin-settings.php index 1be7091..65b21ee 100644 --- a/includes/plugin-settings.php +++ b/includes/plugin-settings.php @@ -44,6 +44,10 @@ function footnotes_plugin_settings_link($links, $file) function footnotes_filter_options($p_str_OptionsField, $p_arr_DefaultValues, $p_bool_ConvertHtmlChars = true) { $l_arr_Options = get_option($p_str_OptionsField); + /* if no settings set yet return default values */ + if (empty($l_arr_Options)) { + return $p_arr_DefaultValues; + } /* loop through all keys in the array and filters them */ foreach ($l_arr_Options as $l_str_Key => $l_str_Value) { /* removes special chars from the settings value */ diff --git a/includes/uninstall.php b/includes/uninstall.php deleted file mode 100644 index 139ea88..0000000 --- a/includes/uninstall.php +++ /dev/null @@ -1,38 +0,0 @@ -