diff --git a/class/config.php b/class/config.php
new file mode 100644
index 0000000..d996170
--- /dev/null
+++ b/class/config.php
@@ -0,0 +1,54 @@
+footnotes';
+
+ /**
+ * Html tag for the LOVE symbol.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @var string
+ */
+ const C_STR_LOVE_SYMBOL = '♥';
+
+ /**
+ * Short code to DON'T display the 'LOVE ME' slug on certain pages.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @var string
+ */
+ const C_STR_NO_LOVE_SLUG = '[[no footnotes: love]]';
+}
\ No newline at end of file
diff --git a/classes/convert.php b/class/convert.php
similarity index 56%
rename from classes/convert.php
rename to class/convert.php
index fc095f0..97ed2e5 100644
--- a/classes/convert.php
+++ b/class/convert.php
@@ -1,27 +1,29 @@
0) {
- $l_str_Return = chr($l_int_Offset + $l_int_StartingASCII);
+ $l_str_Return = chr($l_int_Offset + 64);
}
// add the origin letter
- $l_str_Return .= chr($p_int_Value + $l_int_StartingASCII);
+ $l_str_Return .= chr($p_int_Value + 64);
// return the latin character representing the integer
- return $l_str_Return;
+ if ($p_bool_UpperCase) {
+ return strtoupper($l_str_Return);
+ }
+ return strtolower($l_str_Return);
}
/**
- * converts a integer to a leading-0 integer
+ * Converts an integer to a leading-0 integer.
+ *
+ * @author Stefan Herndler
* @since 1.0-gamma
- * @param int $p_int_Value
- * @return string
+ * @param int $p_int_Value Value/Index to be converted.
+ * @return string Value with a leading zero.
*/
private static function toArabicLeading($p_int_Value) {
// add a leading 0 if number lower then 10
@@ -88,9 +91,11 @@ class MCI_Footnotes_Convert {
}
/**
- * converts a arabic integer value into a romanic letter value
+ * Converts an integer to a romanic letter.
+ *
+ * @author Stefan Herndler
* @since 1.0-gamma
- * @param int $p_int_Value
+ * @param int $p_int_Value Value/Index to be converted.
* @return string
*/
private static function toRomanic($p_int_Value) {
@@ -127,15 +132,17 @@ class MCI_Footnotes_Convert {
}
/**
- * converts a string depending on its value to a boolean
+ * Converts a string depending on its value to a boolean.
+ *
+ * @author Stefan Herndler
* @since 1.0-beta
- * @param string $p_str_Value
- * @return bool
+ * @param string $p_str_Value String to be converted to boolean.
+ * @return bool Boolean representing the string.
*/
public static function toBool($p_str_Value) {
- // convert string to lower-case to make it easier */
+ // convert string to lower-case to make it easier
$p_str_Value = strtolower($p_str_Value);
- // check if string seems to contain a "true" value */
+ // check if string seems to contain a "true" value
switch ($p_str_Value) {
case "checked":
case "yes":
@@ -144,14 +151,17 @@ class MCI_Footnotes_Convert {
case "1":
return true;
}
- // nothing found that says "true", so we return false */
+ // nothing found that says "true", so we return false
return false;
}
/**
+ * Get a html Array short code depending on Arrow-Array key index.
+ *
+ * @author Stefan Herndler
* @since 1.3.2
- * @param int $p_int_Index [default: -1 = all arrows, otherwise the arrow with the specified index]
- * @return array|string
+ * @param int $p_int_Index Index representing the Arrow. If empty all Arrows are specified.
+ * @return array|string Array of all Arrows if Index is empty otherwise html tag of a specific arrow.
*/
public static function getArrow($p_int_Index = -1) {
// define all possible arrows
@@ -167,6 +177,4 @@ class MCI_Footnotes_Convert {
// return a single arrow
return $l_arr_Arrows[$p_int_Index];
}
-} // class MCI_Footnotes_Convert
-
-endif;
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/class/dashboard/init.php b/class/dashboard/init.php
new file mode 100644
index 0000000..fc418ed
--- /dev/null
+++ b/class/dashboard/init.php
@@ -0,0 +1,213 @@
+a_arr_SubPageClasses[$l_obj_Class->getPriority()] = $l_obj_Class;
+ }
+ }
+ ksort($this->a_arr_SubPageClasses);
+
+ // register hooks/actions
+ add_action('admin_init', array($this, 'initializeSettings'));
+ add_action('admin_menu', array($this, 'registerMainMenu'));
+ // register AJAX callbacks for Plugin information
+ add_action("wp_ajax_nopriv_footnotes_getPluginInfo", array($this, "getPluginMetaInformation"));
+ add_action("wp_ajax_footnotes_getPluginInfo", array($this, "getPluginMetaInformation"));
+ }
+
+ /**
+ * Initializes all sub pages and registers the settings.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function initializeSettings() {
+ MCI_Footnotes_Settings::instance()->RegisterSettings();
+ // iterate though each sub class of the layout engine and register their sections
+ /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
+ foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) {
+ $l_obj_LayoutEngineSubClass->registerSections();
+ }
+ }
+
+ /**
+ * Registers the new main menu for the WordPress dashboard.
+ * Registers all sub menu pages for the new main menu.
+ *
+ * @author Stefan Herndler
+ * @since 2.0.2
+ * @see http://codex.wordpress.org/Function_Reference/add_menu_page
+ */
+ public function registerMainMenu() {
+ global $menu;
+ // iterate through each main menu
+ foreach($menu as $l_arr_MainMenu) {
+ // iterate through each main menu attribute
+ foreach($l_arr_MainMenu as $l_str_Attribute) {
+ // main menu already added, append sub pages and stop
+ if ($l_str_Attribute == self::C_STR_MAIN_MENU_SLUG) {
+ $this->registerSubPages();
+ return;
+ }
+ }
+ }
+
+ // add a new main menu page to the WordPress dashboard
+ add_menu_page(
+ self::C_STR_MAIN_MENU_TITLE, // page title
+ self::C_STR_MAIN_MENU_TITLE, // menu title
+ 'manage_options', // capability
+ self::C_STR_MAIN_MENU_SLUG, // menu slug
+ array($this, "displayOtherPlugins"), // function
+ '', // icon url
+ 81 // position
+ );
+ $this->registerSubPages();
+ }
+
+ /**
+ * Registers all SubPages for this Plugin.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ private function registerSubPages() {
+ // first registered sub menu page MUST NOT contain a unique slug suffix
+ // iterate though each sub class of the layout engine and register their sub page
+ /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
+ foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) {
+ $l_obj_LayoutEngineSubClass->registerSubPage();
+ }
+ }
+
+ /**
+ * Displays other Plugins from the developers.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function displayOtherPlugins() {
+ $l_arr_Plugins = array(
+ array("name" => "identity", "title" => "Identity"),
+ array("name" => "google-keyword-suggest", "title" => "Google Keyword Suggest"),
+ array("name" => "competition", "title" => "competition"),
+ array("name" => "formscontact", "title" => "/forms.contact"),
+ array("name" => "footnotes", "title" => "Footnotes")
+ );
+
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "other-plugins");
+
+ echo sprintf("
%s
", __('Take a look on other Plugins we have developed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
+
+ echo '
';
+
+ if ($l_bool_SettingsUpdated) {
+ echo sprintf('
%s
', __("Settings saved", MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
+ }
+
+ // form to submit the active section
+ echo '';
+ // close container for the settings page
+ echo '
';
+ // output special javascript for the expand/collapse function of the meta boxes
+ echo '';
+ }
+
+ /**
+ * Save all Plugin settings.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return bool
+ */
+ private function saveSettings() {
+ // get only Footnotes settings
+ $l_arr_Settings = array();
+ foreach($_POST as $l_str_SettingsName => $l_str_Value) {
+ if (substr($l_str_SettingsName, 0, 8) == "footnote") {
+ $l_arr_Settings[$l_str_SettingsName] = $l_str_Value;
+ }
+ }
+ // get current section
+ reset($this->a_arr_Sections);
+ $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections);
+ $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID];
+ // update settings
+ return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $l_arr_Settings);
+ }
+
+ /**
+ * Output the Description of a section. May be overwritten in any section.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Description() {
+ // default no description will be displayed
+ }
+
+ /**
+ * Loads specific setting and returns an array with the keys [id, name, value].
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_SettingKeyName Settings Array key name.
+ * @return array Contains Settings ID, Settings Name and Settings Value.
+ */
+ protected function LoadSetting($p_str_SettingKeyName) {
+ // get current section
+ reset($this->a_arr_Sections);
+ $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections);
+ $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID];
+
+ $p_arr_Return = array();
+ $p_arr_Return["id"] = sprintf('%s', $p_str_SettingKeyName);
+ //$p_arr_Return["name"] = sprintf('%s[%s]', MCI_Footnotes_Settings::instance()->getContainer($l_arr_ActiveSection["container"]), $p_str_SettingKeyName);
+ $p_arr_Return["name"] = sprintf('%s', $p_str_SettingKeyName);
+ $p_arr_Return["value"] = esc_attr(MCI_Footnotes_Settings::instance()->get($p_str_SettingKeyName));
+ return $p_arr_Return;
+ }
+
+ /**
+ * Returns a line break to start a new line.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return string
+ */
+ protected function addNewline() {
+ return ' ';
+ }
+
+ /**
+ * Returns a line break to have a space between two lines.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return string
+ */
+ protected function addLineSpace() {
+ return '
';
+ }
+
+ /**
+ * Returns a simple text inside html text.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_Text Message to be surrounded with simple html tag (span).
+ * @return string
+ */
+ protected function addText($p_str_Text) {
+ return sprintf('%s', $p_str_Text);
+ }
+
+ /**
+ * Returns the html tag for an input/select label.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_SettingName Name of the Settings key to connect the Label with the input/select field.
+ * @param string $p_str_Caption Label caption.
+ * @return string
+ */
+ protected function addLabel($p_str_SettingName, $p_str_Caption) {
+ if (empty($p_str_Caption)) {
+ return "";
+ }
+ return sprintf('', $p_str_SettingName, $p_str_Caption);
+ }
+
+ /**
+ * Returns the html tag for an input [type = text].
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_SettingName Name of the Settings key to pre load the input field.
+ * @param int $p_str_MaxLength Maximum length of the input, default 999 characters.
+ * @param bool $p_bool_Readonly Set the input to be read only, default false.
+ * @param bool $p_bool_Hidden Set the input to be hidden, default false.
+ * @return string
+ */
+ protected function addTextBox($p_str_SettingName, $p_str_MaxLength = 999, $p_bool_Readonly = false, $p_bool_Hidden = false) {
+ $l_str_Style = "";
+ // collect data for given settings field
+ $l_arr_Data = $this->LoadSetting($p_str_SettingName);
+ if ($p_bool_Hidden) {
+ $l_str_Style .= 'display:none;';
+ }
+ return sprintf('',
+ $l_arr_Data["name"], $l_arr_Data["id"], $p_str_MaxLength,
+ $l_str_Style, $l_arr_Data["value"], $p_bool_Readonly ? 'readonly="readonly"' : '');
+ }
+
+ /**
+ * Returns the html tag for an input [type = checkbox].
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_SettingName Name of the Settings key to pre load the input field.
+ * @return string
+ */
+ protected function addCheckbox($p_str_SettingName) {
+ // collect data for given settings field
+ $l_arr_Data = $this->LoadSetting($p_str_SettingName);
+ return sprintf('',
+ $l_arr_Data["name"], $l_arr_Data["id"],
+ MCI_Footnotes_Convert::toBool($l_arr_Data["value"]) ? 'checked="checked"' : '');
+ }
+
+ /**
+ * Returns the html tag for a select box.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_SettingName Name of the Settings key to pre select the current value.
+ * @param array $p_arr_Options Possible options to be selected.
+ * @return string
+ */
+ protected function addSelectBox($p_str_SettingName, $p_arr_Options) {
+ // collect data for given settings field
+ $l_arr_Data = $this->LoadSetting($p_str_SettingName);
+ $l_str_Options = "";
+
+ /* loop through all array keys */
+ foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) {
+ $l_str_Options .= sprintf('',
+ $l_str_Value,
+ $l_arr_Data["value"] == $l_str_Value ? "selected" : "",
+ $l_str_Caption);
+ }
+ return sprintf('',
+ $l_arr_Data["name"], $l_arr_Data["id"], $l_str_Options);
+ }
+
+ /**
+ * Returns the html tag for a text area.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_SettingName Name of the Settings key to pre fill the text area.
+ * @return string
+ */
+ protected function addTextArea($p_str_SettingName) {
+ // collect data for given settings field
+ $l_arr_Data = $this->LoadSetting($p_str_SettingName);
+ return sprintf('',
+ $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]);
+ }
+
+} // end of class
\ No newline at end of file
diff --git a/class/dashboard/subpage-diagnostics.php b/class/dashboard/subpage-diagnostics.php
new file mode 100644
index 0000000..b8ba7fd
--- /dev/null
+++ b/class/dashboard/subpage-diagnostics.php
@@ -0,0 +1,130 @@
+addSection("diagnostics", __("Diagnostics", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false)
+ );
+ }
+
+ /**
+ * Returns an array of all registered meta boxes for each section of the sub page.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return array
+ */
+ protected function getMetaBoxes() {
+ return array(
+ $this->addMetaBox("diagnostics", "diagnostics", __("Displays information about the web server, PHP and WordPress", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Diagnostics")
+ );
+ }
+
+ /**
+ * Displays a diagnostics about the web server, php and WordPress.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Diagnostics() {
+ global $wp_version;
+ $l_str_PhpExtensions = "";
+ // iterate through each PHP extension
+ foreach (get_loaded_extensions() as $l_int_Index => $l_str_Extension) {
+ if ($l_int_Index > 0) {
+ $l_str_PhpExtensions .= ' | ';
+ }
+ $l_str_PhpExtensions .= $l_str_Extension . ' ' . phpversion($l_str_Extension);
+ }
+ $l_str_WordPressPlugins = "";
+ // iterate through each installed WordPress Plugin
+ foreach (get_plugins() as $l_arr_Plugin) {
+ $l_str_WordPressPlugins .= '
';
+ }
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "diagnostics");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-server" => __("Server name", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "server" => $_SERVER["SERVER_NAME"],
+
+ "label-php" => __("PHP version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "php" => phpversion(),
+
+ "label-max-execution-time" => __("Max execution time", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "max-execution-time" => ini_get('max_execution_time') . ' ' . __('seconds', MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+
+ "label-memory-limit" => __("Memory limit", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "memory-limit" => ini_get('memory_limit'),
+
+ "label-php-extensions" => __("PHP extensions", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "php-extensions" => $l_str_PhpExtensions,
+
+ "label-wordpress" => __("WordPress version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "wordpress" => $wp_version,
+
+ "plugins" => $l_str_WordPressPlugins
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+}
\ No newline at end of file
diff --git a/class/dashboard/subpage-main.php b/class/dashboard/subpage-main.php
new file mode 100644
index 0000000..c426233
--- /dev/null
+++ b/class/dashboard/subpage-main.php
@@ -0,0 +1,393 @@
+addSection("settings", __("Settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 0, true),
+ $this->addSection("customize", __("Customize", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 1, true),
+ $this->addSection("how-to", __("How to", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false)
+ );
+ }
+
+ /**
+ * Returns an array of all registered meta boxes for each section of the sub page.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return array
+ */
+ protected function getMetaBoxes() {
+ return array(
+ $this->addMetaBox("settings", "reference-container", __("References Container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "ReferenceContainer"),
+ $this->addMetaBox("settings", "styling", sprintf(__("%s styling", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), "Styling"),
+ $this->addMetaBox("settings", "love", MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, "Love"),
+ $this->addMetaBox("settings", "other", __("Other", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Other"),
+
+ $this->addMetaBox("customize", "superscript", __("Superscript layout", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Superscript"),
+ $this->addMetaBox("customize", "hyperlink-arrow", __("Hyperlink symbol in the Reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "HyperlinkArrow"),
+ $this->addMetaBox("customize", "custom-css", __("Add custom CSS to the public page", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSS"),
+
+ $this->addMetaBox("how-to", "help", __("Brief introduction in how to use the plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Help"),
+ $this->addMetaBox("how-to", "donate", __("Help us to improve our Plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Donate")
+ );
+ }
+
+ /**
+ * Displays all settings for the reference container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function ReferenceContainer() {
+ // options for the positioning of the reference container
+ $l_arr_Positions = array(
+ "footer" => __("in the footer", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "post_end" => __("at the end of the post", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "widget" => __("in the widget area", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
+ );
+
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-reference-container");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-name" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME, __("References label", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "name" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME),
+
+ "label-collapse" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, __("Collapse references by default", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "collapse" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE),
+
+ "label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __("Where shall the reference container appear", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_Positions)
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays all settings for the footnotes styling.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Styling() {
+ // define some space for the output
+ $l_str_Space = " ";
+ // options for the combination of identical footnotes
+ $l_arr_CombineIdentical = array(
+ "yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
+ );
+ // options for the start of the footnotes short code
+ $l_arr_ShortCodeStart = array(
+ "((" => "((",
+ "" => htmlspecialchars(""),
+ "[ref]" => "[ref]",
+ "userdefined" => __('user defined', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
+ );
+ // options for the end of the footnotes short code
+ $l_arr_ShortCodeEnd = array(
+ "))" => "))",
+ "" => htmlspecialchars(""),
+ "[/ref]" => "[/ref]",
+ "userdefined" => __('user defined', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
+ );
+ // options for the counter style of the footnotes
+ $l_arr_CounterStyle = array(
+ "arabic_plain" => __("Arabic Numbers - Plain", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, ...",
+ "arabic_leading" => __("Arabic Numbers - Leading 0", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, ...",
+ "latin_low" => __("Latin Character - lower case", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, ...",
+ "latin_high" => __("Latin Character - upper case", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, ...",
+ "romanic" => __("Roman Numerals", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, ..."
+ );
+
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-styling");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-identical" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, __("Combine identical footnotes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "identical" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, $l_arr_CombineIdentical),
+
+ "label-short-code-start" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __("Footnote tag starts with", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "short-code-start" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, $l_arr_ShortCodeStart),
+
+ "label-short-code-end" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, __("and ends with", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "short-code-end" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, $l_arr_ShortCodeEnd),
+
+ "label-short-code-start-user" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED, ""),
+ "short-code-start-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED),
+
+ "label-short-code-end-user" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED, ""),
+ "short-code-end-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED),
+
+ "label-counter-style" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, __("Counter style", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "counter-style" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, $l_arr_CounterStyle),
+
+ "short-code-start-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START,
+ "short-code-end-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END,
+ "short-code-start-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED,
+ "short-code-end-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED,
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays all settings for 'I love Footnotes'.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Love() {
+ // options for the positioning of the reference container
+ $l_arr_Love = array(
+ "text-1" => sprintf(__('I %s %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME),
+ "text-2" => sprintf(__('this site uses the awesome %s Plugin', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME),
+ "text-3" => sprintf(__('extra smooth %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME),
+ "random" => __('random text', MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "no" => sprintf(__("Don't display a %s %s text in my footer.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL)
+ );
+
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-love");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-love" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, sprintf(__("Tell the world you're using %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)),
+ "love" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, $l_arr_Love),
+
+ "label-no-love" => $this->addText(sprintf(__("Don't tell the world you're using %s on specific pages by adding the following short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)),
+ "no-love" => $this->addText(MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG)
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays all settings that are not grouped in special meta boxes.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Other() {
+ // options for the Footnotes to be replaced in excerpt
+ $l_arr_Excerpt = array(
+ "yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
+ );
+
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-other");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-excerpt" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, __("Allow footnotes on Summarized Posts", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "excerpt" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, $l_arr_Excerpt)
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays all settings for the footnotes Superscript.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Superscript() {
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-superscript");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-before" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE, __("Before Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "before" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE),
+
+ "label-after" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER, __("After Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "after" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER)
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays all settings for the hyperlink arrow.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function HyperlinkArrow() {
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-hyperlink-arrow");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-symbol" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, __("Hyperlink symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "symbol" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, MCI_Footnotes_Convert::getArrow()),
+
+ "label-user-defined" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED, __("or enter a user defined symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "user-defined" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED),
+ "comment" => __("if set it overrides the hyperlink symbol above", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays the custom css box.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function CustomCSS() {
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-css");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-css" => $this->addLabel(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __("Add custom CSS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+ "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS),
+
+ "headline" => $this->addText(__("Available CSS classes to customize the footnotes and the reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+
+ "label-class-1" => ".footnote_plugin_tooltip_text",
+ "class-1" => $this->addText(__("inline footnotes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+
+ "label-class-2" => ".footnote_tooltip",
+ "class-2" => $this->addText(__("inline footnotes, mouse over highlight box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+
+ "label-class-3" => ".footnote_plugin_index",
+ "class-3" => $this->addText(__("reference container footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+
+ "label-class-4" => ".footnote_plugin_link",
+ "class-4" => $this->addText(__("reference container footnotes linked arrow", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
+
+ "label-class-5" => ".footnote_plugin_text",
+ "class-5" => $this->addText(__("reference container footnotes text", MCI_Footnotes_Config::C_STR_PLUGIN_NAME))
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays a short introduction of the Plugin.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Help() {
+ global $g_obj_MCI_Footnotes;
+ // load footnotes starting and end tag
+ $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START);
+ $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END);
+
+ if ($l_arr_Footnote_StartingTag["value"] == "userdefined" || $l_arr_Footnote_EndingTag["value"] == "userdefined") {
+ // load user defined starting and end tag
+ $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED);
+ $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED);
+ }
+ $l_str_Example = "Hello" . $l_arr_Footnote_StartingTag["value"] . __("example string", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"] . " World!";
+
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-help");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "label-start" => __("Start your footnote with the following short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "start" => $l_arr_Footnote_StartingTag["value"],
+
+ "label-end" => __("...and end your footnote with this short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "end" => $l_arr_Footnote_EndingTag["value"],
+
+ "example-code" => $l_str_Example,
+ "example-string" => __("will be displayed as:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
+ "example" => $g_obj_MCI_Footnotes->a_obj_Task->exec($l_str_Example, true),
+
+ "information" => sprintf(__("For further information please check out our %ssupport forum%s on WordPress.org.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '', '')
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+
+ /**
+ * Displays all Donate button to support the developers.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Donate() {
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-donate");
+ // replace all placeholders
+ $l_obj_Template->replace(
+ array(
+ "caption" => __('Donate now',MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
+ )
+ );
+ // display template with replaced placeholders
+ echo $l_obj_Template->getContent();
+ }
+}
\ No newline at end of file
diff --git a/class/hooks.php b/class/hooks.php
new file mode 100644
index 0000000..598a179
--- /dev/null
+++ b/class/hooks.php
@@ -0,0 +1,88 @@
+ClearAll();
+ }
+
+ /**
+ * Add Links to the Plugin in the "installed Plugins" page.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param array $p_arr_Links Current Links.
+ * @param string $p_str_PluginFileName Plugins init file name.
+ * @return array
+ */
+ public static function PluginLinks($p_arr_Links, $p_str_PluginFileName) {
+ // append link to the WordPress Plugin page
+ $p_arr_Links[] = sprintf('%s', __('Support', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
+ // append link to the Settings page
+ $p_arr_Links[] = sprintf('%s', admin_url('options-general.php?page=mfmmf-footnotes'), __('Settings', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
+ // append link to the PlayPal Donate function
+ $p_arr_Links[] = sprintf('%s', __('Donate', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
+ // return new links
+ return $p_arr_Links;
+ }
+}
\ No newline at end of file
diff --git a/class/init.php b/class/init.php
new file mode 100644
index 0000000..c3fa01e
--- /dev/null
+++ b/class/init.php
@@ -0,0 +1,116 @@
+initializeWidgets();
+ // initialize the Plugin Dashboard
+ $this->initializeDashboard();
+ // initialize the Plugin Task
+ $this->initializeTask();
+
+ // Register all Public Stylesheets
+ add_action('init', array($this, 'registerPublicStyling'));
+ // Register all Public Scripts
+ add_action('init', array($this, 'registerPublicScripts'));
+ // Enqueue all Public Stylesheets
+ add_action('wp_enqueue_scripts', array($this, 'registerPublicStyling'));
+ // Enqueue all Public Scripts
+ add_action('wp_enqueue_scripts', array($this, 'registerPublicScripts'));
+ }
+
+ /**
+ * Initializes all Widgets of the Plugin.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ private function initializeWidgets() {
+ add_action('widgets_init', create_function('', 'return register_widget("MCI_Footnotes_Widget_ReferenceContainer");'));
+ }
+
+ /**
+ * Initializes the Dashboard of the Plugin and loads them.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ private function initializeDashboard() {
+ new MCI_Footnotes_Layout_Init();
+ }
+
+ /**
+ * Initializes the Plugin Task and registers the Task hooks.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ private function initializeTask() {
+ $this->a_obj_Task = new MCI_Footnotes_Task();
+ $this->a_obj_Task->registerHooks();
+ }
+
+ /**
+ * Registers and enqueue scripts to the public pages.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function registerPublicScripts() {
+ // add the jQuery plugin (already registered by WordPress)
+ wp_enqueue_script('jquery');
+ wp_enqueue_script('mci_footnotes_js_jquery_tools', plugins_url('../js/jquery.tools.min.js', __FILE__), array());
+ }
+
+ /**
+ * Registers and enqueue stylesheets to the public pages.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function registerPublicStyling() {
+ wp_register_style('mci_footnotes_css_general', plugins_url('../css/footnotes.css', __FILE__));
+ wp_register_style('mci_footnotes_css_tooltip', plugins_url('../css/tooltip.css', __FILE__));
+ wp_register_style('mci_footnotes_css_reference_container', plugins_url('../css/reference_container.css', __FILE__));
+
+ wp_enqueue_style('mci_footnotes_css_general');
+ wp_enqueue_style('mci_footnotes_css_tooltip');
+ wp_enqueue_style('mci_footnotes_css_reference_container');
+ }
+}
\ No newline at end of file
diff --git a/class/language.php b/class/language.php
new file mode 100644
index 0000000..ba582dd
--- /dev/null
+++ b/class/language.php
@@ -0,0 +1,68 @@
+ array(
+ self::C_STR_REFERENCE_CONTAINER_NAME => 'References',
+ self::C_BOOL_REFERENCE_CONTAINER_COLLAPSE => '',
+ self::C_STR_REFERENCE_CONTAINER_POSITION => 'post_end',
+ self::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES => 'yes',
+ self::C_STR_FOOTNOTES_SHORT_CODE_START => '((',
+ self::C_STR_FOOTNOTES_SHORT_CODE_END => '))',
+ self::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED => '',
+ self::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED => '',
+ self::C_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain',
+ self::C_STR_FOOTNOTES_LOVE => 'no',
+ self::C_BOOL_FOOTNOTES_IN_EXCERPT => 'yes'
+ ),
+ "footnotes_storage_custom" => array(
+ self::C_STR_FOOTNOTES_STYLING_BEFORE => '',
+ self::C_STR_FOOTNOTES_STYLING_AFTER => ')',
+ self::C_STR_HYPERLINK_ARROW => '↑',
+ self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '',
+ self::C_STR_CUSTOM_CSS => ''
+ )
+ );
+
+ /**
+ * Contains all Settings from each Settings container as soon as this class is initialized.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @var array
+ */
+ private $a_arr_Settings = array();
+
+ /**
+ * Class Constructor. Loads all Settings from each WordPress Settings container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ private function __construct() {
+ $this->loadAll();
+ }
+
+ /**
+ * Returns a singleton of this class.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return MCI_Footnotes_Settings
+ */
+ public static function instance() {
+ // no instance defined yet, load it
+ if (self::$a_obj_Instance === null) {
+ self::$a_obj_Instance = new self();
+ }
+ // return a singleton of this class
+ return self::$a_obj_Instance;
+ }
+
+ /**
+ * Returns the name of a specified Settings Container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param int $p_int_Index Settings Container Array Key Index.
+ * @return string Settings Container name.
+ */
+ public function getContainer($p_int_Index) {
+ return $this->a_arr_Container[$p_int_Index];
+ }
+
+ /**
+ * Loads all Settings from each Settings container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ private function loadAll() {
+ // clear current settings
+ $this->a_arr_Settings = array();
+ for ($i = 0; $i < count($this->a_arr_Container); $i++) {
+ // load settings
+ $this->a_arr_Settings = array_merge($this->a_arr_Settings, $this->Load($i));
+ }
+ }
+
+ /**
+ * Loads all Settings from specified Settings Container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param int $p_int_Index Settings Container Array Key Index.
+ * @return array Settings loaded from Container of Default Settings if Settings Container is empty (first usage).
+ */
+ private function Load($p_int_Index) {
+ // load all settings from container
+ $l_arr_Options = get_option($this->getContainer($p_int_Index));
+ // load all default settings
+ $l_arr_Default = $this->a_arr_Default[$this->getContainer($p_int_Index)];
+
+ // no settings found, set them to their default value
+ if (empty($l_arr_Options)) {
+ return $l_arr_Default;
+ }
+ // iterate through all available settings ( = default values)
+ foreach($l_arr_Default as $l_str_Key => $l_str_Value) {
+ // available setting not found in the container
+ if (!array_key_exists($l_str_Key, $l_arr_Options)) {
+ // define the setting with its default value
+ $l_arr_Options[$l_str_Key] = $l_str_Value;
+ }
+ }
+ // iterate through each setting in the container
+ foreach($l_arr_Options as $l_str_Key => $l_str_Value) {
+ // remove all whitespace at the beginning and end of a setting
+ $l_str_Value = trim($l_str_Value);
+ // write the sanitized value back to the setting container
+ $l_arr_Options[$l_str_Key] = $l_str_Value;
+ }
+ // return settings loaded from Container
+ return $l_arr_Options;
+ }
+
+ /**
+ * Updates a whole Settings container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param int $p_int_Index Index of the Settings container.
+ * @param array $p_arr_newValues new Settings.
+ * @return bool
+ */
+ public function saveOptions($p_int_Index, $p_arr_newValues) {
+ if (update_option($this->getContainer($p_int_Index), $p_arr_newValues)) {
+ $this->loadAll();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the value of specified Settings name.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_Key Settings Array Key name.
+ * @return mixed Value of the Setting on Success or Null in Settings name is invalid.
+ */
+ public function get($p_str_Key) {
+ return array_key_exists($p_str_Key, $this->a_arr_Settings) ? $this->a_arr_Settings[$p_str_Key] : null;
+ }
+
+ /**
+ * Deletes each Settings Container and loads the default values for each Settings Container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function ClearAll() {
+ // iterate through each Settings Container
+ for ($i = 0; $i < count($this->a_arr_Container); $i++) {
+ // delete the settings container
+ delete_option($this->getContainer($i));
+ }
+ // set settings back to the default values
+ $this->a_arr_Settings = $this->a_arr_Default;
+ }
+
+ /**
+ * Register all Settings Container for the Plugin Settings Page in the Dashboard.
+ * Settings Container Label will be the same as the Settings Container Name.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function RegisterSettings() {
+ // register all settings
+ for ($i = 0; $i < count($this->a_arr_Container); $i++) {
+ register_setting($this->getContainer($i), $this->getContainer($i));
+ }
+ }
+}
\ No newline at end of file
diff --git a/class/task.php b/class/task.php
new file mode 100644
index 0000000..d3e84a9
--- /dev/null
+++ b/class/task.php
@@ -0,0 +1,355 @@
+get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "footer") {
+ add_action('get_footer', array($this, "Footer"));
+ }
+
+ // append the love and share me slug to the footer
+ add_action('wp_footer', array($this, "Love"));
+
+ // replace footnotes in the content of the page/post
+ add_filter('the_content', array($this, "Content"));
+
+ // search for footnotes in the excerpt only if enabled
+ if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT))) {
+ add_filter('the_excerpt', array($this, "Excerpt"));
+ }
+
+ // replace footnotes in the content of a widget
+ add_filter('widget_text', array($this, "WidgetText"));
+ }
+
+ /**
+ * Outputs the custom css to the header of the public page.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Header() {
+ ?>
+
+ ReferenceContainer();
+ }
+
+ /**
+ * Displays the 'LOVE FOOTNOTES' slug if enabled.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function Love() {
+ // get setting for love and share this plugin
+ $l_str_LoveMeIndex = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE);
+ // check if the admin allows to add a link to the footer
+ if (empty($l_str_LoveMeIndex) || strtolower($l_str_LoveMeIndex) == "no" || !self::$a_bool_AllowLoveMe) {
+ return;
+ }
+ // set a hyperlink to the word "footnotes" in the Love slug
+ $l_str_LinkedName = sprintf('%s',MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME);
+ // get random love me text
+ if (strtolower($l_str_LoveMeIndex) == "random") {
+ $l_str_LoveMeIndex = "text-" . rand(1,3);
+ }
+ switch ($l_str_LoveMeIndex) {
+ case "text-1":
+ $l_str_LoveMeText = sprintf(__('I %s %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, $l_str_LinkedName);
+ break;
+ case "text-2":
+ $l_str_LoveMeText = sprintf(__('this site uses the awesome %s Plugin', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName);
+ break;
+ case "text-3":
+ default:
+ $l_str_LoveMeText = sprintf(__('extra smooth %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName);
+ break;
+ }
+ echo sprintf('
%s
', $l_str_LoveMeText);
+ }
+
+ /**
+ * Replaces footnotes in the content of the current page/post.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_Content Page/Post content.
+ * @return string Content with replaced footnotes.
+ */
+ public function Content($p_str_Content) {
+ // appends the reference container if set to "post_end"
+ return $this->exec($p_str_Content, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "post_end" ? true : false);
+ }
+
+ /**
+ * Replaces footnotes in the excerpt of the current page/post.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_Content Page/Post content.
+ * @return string Content with replaced footnotes.
+ */
+ public function Excerpt($p_str_Content) {
+ return $this->exec($p_str_Content, false);
+ }
+
+ /**
+ * Replaces footnotes in the content of the current widget.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_Content Widget content.
+ * @return string Content with replaced footnotes.
+ */
+ public function WidgetText($p_str_Content) {
+ // appends the reference container if set to "post_end"
+ return $this->exec($p_str_Content, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "post_end" ? true : false);
+ }
+
+
+ /**
+ * Replaces all footnotes that occur in the given content.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_Content Any string that may contain footnotes to be replaced.
+ * @param bool $p_bool_OutputReferences Appends the Reference Container to the output if set to true, default true.
+ * @return string
+ */
+ public function exec($p_str_Content, $p_bool_OutputReferences = true) {
+ // replace all footnotes in the content, settings are converted to html characters
+ $p_str_Content = $this->search($p_str_Content, true);
+ // replace all footnotes in the content, settings are NOT converted to html characters
+ $p_str_Content = $this->search($p_str_Content, false);
+
+ // append the reference container
+ if ($p_bool_OutputReferences) {
+ $p_str_Content = $p_str_Content . $this->ReferenceContainer();
+ }
+
+ // take a look if the LOVE ME slug should NOT be displayed on this page/post, remove the short code if found
+ if (strpos($p_str_Content, MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG) !== false) {
+ self::$a_bool_AllowLoveMe = false;
+ $p_str_Content = str_replace(MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG, "", $p_str_Content);
+ }
+ // return the content with replaced footnotes and optional reference container append
+ return $p_str_Content;
+ }
+
+ /**
+ * Replaces all footnotes in the given content and appends them to the static property.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param string $p_str_Content Content to be searched for footnotes.
+ * @param bool $p_bool_ConvertHtmlChars html encode settings, default true.
+ * @return string
+ */
+ public function search($p_str_Content, $p_bool_ConvertHtmlChars = true) {
+ // contains the index for the next footnote on this page
+ $l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
+ // contains the starting position for the lookup of a footnote
+ $l_int_PosStart = 0;
+ // get start and end tag for the footnotes short code
+ $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START);
+ $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END);
+ if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
+ $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED);
+ $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED);
+ }
+ // decode html special chars
+ if ($p_bool_ConvertHtmlChars) {
+ $l_str_StartingTag = htmlspecialchars($l_str_StartingTag);
+ $l_str_EndingTag = htmlspecialchars($l_str_EndingTag);
+ }
+ // if footnotes short code is empty, return the content without changes
+ if (empty($l_str_StartingTag) || empty($l_str_EndingTag)) {
+ return $p_str_Content;
+ }
+
+ // load template file
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote");
+
+ // search footnotes short codes in the content
+ do {
+ // get first occurrence of the footnote short code [start]
+ $l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart);
+ // no short code found, stop here
+ if ($l_int_PosStart === false) {
+ break;
+ }
+ // get first occurrence of a footnote short code [end]
+ $l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart);
+ // no short code found, stop here
+ if ($l_int_PosEnd === false) {
+ break;
+ }
+ // calculate the length of the footnote
+ $l_int_Length = $l_int_PosEnd - $l_int_PosStart;
+ // get footnote text
+ $l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
+ // fill the footnotes template
+ $l_obj_Template->replace(
+ array(
+ "index" => MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)),
+ "text" => $l_str_FootnoteText,
+ "before" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE),
+ "after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER)
+ )
+ );
+ // replace the footnote with the template
+ $p_str_Content = substr_replace($p_str_Content, $l_obj_Template->getContent(), $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
+ // reset the template
+ $l_obj_Template->reload();
+ // add footnote only if not empty
+ if (!empty($l_str_FootnoteText)) {
+ // set footnote to the output box at the end
+ self::$a_arr_Footnotes[] = $l_str_FootnoteText;
+ // increase footnote index
+ $l_int_FootnoteIndex++;
+ }
+ // add offset to the new starting position
+ $l_int_PosStart += $l_int_Length + strlen($l_str_EndingTag);
+ } while (true);
+
+ // return content
+ return $p_str_Content;
+ }
+
+ /**
+ * Generates the reference container.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return string
+ */
+ public function ReferenceContainer() {
+ // no footnotes has been replaced on this page
+ if (empty(self::$a_arr_Footnotes)) {
+ return "";
+ }
+ // get html arrow
+ $l_str_Arrow = MCI_Footnotes_Convert::getArrow(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW));
+ // set html arrow to the first one if invalid index defined
+ if (is_array($l_str_Arrow)) {
+ $l_str_Arrow = MCI_Footnotes_Convert::getArrow(0);
+ }
+ // get user defined arrow
+ $l_str_ArrowUserDefined = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED);
+ if (!empty($l_str_ArrowUserDefined)) {
+ $l_str_Arrow = $l_str_ArrowUserDefined;
+ }
+
+ // load template file
+ $l_str_Body = "";
+ $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body");
+
+ // loop through all footnotes found in the page
+ for ($l_str_Index = 0; $l_str_Index < count(self::$a_arr_Footnotes); $l_str_Index++) {
+ // get footnote text
+ $l_str_FootnoteText = self::$a_arr_Footnotes[$l_str_Index];
+ // if footnote is empty, get to the next one
+ if (empty($l_str_FootnoteText)) {
+ continue;
+ }
+ // get footnote index
+ $l_str_FirstFootnoteIndex = ($l_str_Index + 1);
+ $l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_str_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
+
+ // check if it isn't the last footnote in the array
+ if ($l_str_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
+ // get all footnotes that I haven't passed yet
+ for ($l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count(self::$a_arr_Footnotes); $l_str_CheckIndex++) {
+ // check if a further footnote is the same as the actual one
+ if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_str_CheckIndex]) {
+ // set the further footnote as empty so it won't be displayed later
+ self::$a_arr_Footnotes[$l_str_CheckIndex] = "";
+ // add the footnote index to the actual index
+ $l_str_FootnoteIndex .= ", " . MCI_Footnotes_Convert::Index(($l_str_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
+ }
+ }
+ }
+ // replace all placeholders in the template
+ $l_obj_Template->replace(
+ array(
+ "index" => $l_str_FootnoteIndex,
+ "index-int" => MCI_Footnotes_Convert::Index($l_str_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)),
+ "arrow" => $l_str_Arrow,
+ "text" => $l_str_FootnoteText
+ )
+ );
+ $l_str_Body .= $l_obj_Template->getContent();
+ $l_obj_Template->reload();
+ }
+
+ // load template file
+ $l_obj_TemplateContainer = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container");
+ $l_obj_TemplateContainer->replace(
+ array(
+ "label" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME),
+ "buttons" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? ' [ + ]' : '',
+ "id" => "footnote_references_container",
+ "class" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? 'footnote_hide_box' : '',
+ "content" => $l_str_Body
+ )
+ );
+
+ // free all found footnotes if reference container will be displayed
+ self::$a_arr_Footnotes = array();
+ return $l_obj_TemplateContainer->getContent();
+ }
+}
\ No newline at end of file
diff --git a/class/template.php b/class/template.php
new file mode 100644
index 0000000..993cb88
--- /dev/null
+++ b/class/template.php
@@ -0,0 +1,127 @@
+a_str_OriginalContent = str_replace("\n", "", file_get_contents($l_str_TemplateFile));
+ $this->a_str_OriginalContent = str_replace("\r", "", $this->a_str_OriginalContent);
+ $this->reload();
+ }
+
+ /**
+ * Replace all placeholders specified in array.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param array $p_arr_Placeholders Placeholders (key = placeholder, value = value).
+ * @return bool True on Success, False if Placeholders invalid.
+ */
+ public function replace($p_arr_Placeholders) {
+ // no placeholders set
+ if (empty($p_arr_Placeholders)) {
+ return false;
+ }
+ // template content is empty
+ if (empty($this->a_str_ReplacedContent)) {
+ return false;
+ }
+ // iterate through each placeholder and replace it with its value
+ foreach($p_arr_Placeholders as $l_str_Placeholder => $l_str_Value) {
+ $this->a_str_ReplacedContent = str_replace("[[" . $l_str_Placeholder . "]]", $l_str_Value, $this->a_str_ReplacedContent);
+ }
+ // success
+ return true;
+ }
+
+ /**
+ * Reloads the original content of the template file.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function reload() {
+ $this->a_str_ReplacedContent = $this->a_str_OriginalContent;
+ }
+
+ /**
+ * Returns the content of the template file with replaced placeholders.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return string Template content with replaced placeholders.
+ */
+ public function getContent() {
+ return $this->a_str_ReplacedContent;
+ }
+
+} // end of class
\ No newline at end of file
diff --git a/class/widgets/base.php b/class/widgets/base.php
new file mode 100644
index 0000000..a9a3616
--- /dev/null
+++ b/class/widgets/base.php
@@ -0,0 +1,75 @@
+ echo the Widget Content
+ * **public function form($instance)** -> echo the Settings of the Widget
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+abstract class MCI_Footnotes_WidgetBase extends WP_Widget {
+
+ /**
+ * Returns an unique ID as string used for the Widget Base ID.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return string
+ */
+ abstract protected function getID();
+
+ /**
+ * Returns the Public name of child Widget to be displayed in the Configuration page.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return string
+ */
+ abstract protected function getName();
+
+ /**
+ * Returns the Description of the child widget.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return string
+ */
+ abstract protected function getDescription();
+
+ /**
+ * Returns the width of the Widget. Default width is 250 pixel.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @return int
+ */
+ protected function getWidgetWidth() {
+ return 250;
+ }
+
+ /**
+ * Class Constructor. Registers the child Widget to WordPress.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public function __construct() {
+ $l_arr_WidgetOptions = array("classname" => __CLASS__, "description" => $this->getDescription());
+ $l_arr_ControlOptions = array("id_base" => strtolower($this->getID()), "width" => $this->getWidgetWidth());
+ // registers the Widget
+ $this->WP_Widget(
+ strtolower($this->getID()), // unique ID for the widget, has to be lowercase
+ $this->getName(), // Plugin name to be displayed
+ $l_arr_WidgetOptions, // Optional Widget Options
+ $l_arr_ControlOptions // Optional Widget Control Options
+ );
+ }
+}
\ No newline at end of file
diff --git a/class/widgets/reference-container.php b/class/widgets/reference-container.php
new file mode 100644
index 0000000..58a5747
--- /dev/null
+++ b/class/widgets/reference-container.php
@@ -0,0 +1,79 @@
+get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "widget") {
+ echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer();
+ }
+ }
+}
\ No newline at end of file
diff --git a/class/wysiwyg.php b/class/wysiwyg.php
new file mode 100644
index 0000000..87d8b55
--- /dev/null
+++ b/class/wysiwyg.php
@@ -0,0 +1,78 @@
+getContent();
+ }
+
+ /**
+ * Includes the Plugins WYSIWYG editor script.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ * @param array $p_arr_Plugins Scripts to be included to the editor.
+ * @return array
+ */
+ public static function includeScripts($p_arr_Plugins) {
+ $p_arr_Plugins[MCI_Footnotes_Config::C_STR_PLUGIN_NAME] = plugins_url('/../js/wysiwyg-editor.js', __FILE__);
+ return $p_arr_Plugins;
+ }
+
+ /**
+ * AJAX Callback function when the Footnotes Button is clicked. Either in the Plain text or Visual editor.
+ * Returns an JSON encoded array with the Footnotes start and end short code.
+ *
+ * @author Stefan Herndler
+ * @since 1.5.0
+ */
+ public static function ajaxCallback() {
+ // get start and end tag for the footnotes short code
+ $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START);
+ $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END);
+ if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
+ $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED);
+ $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED);
+ }
+ echo json_encode(array("start" => $l_str_StartingTag, "end" => $l_str_EndingTag));
+ exit;
+ }
+}
\ No newline at end of file
diff --git a/classes/admin.php b/classes/admin.php
deleted file mode 100644
index 7f8dacd..0000000
--- a/classes/admin.php
+++ /dev/null
@@ -1,402 +0,0 @@
-a_arr_SettingsTabs);
- // load tab 'custom'
- require_once(dirname( __FILE__ ) . "/tab_custom.php");
- new MCI_Footnotes_Tab_Custom($this->a_arr_SettingsTabs);
- // load tab 'how to'
- require_once(dirname( __FILE__ ) . "/tab_howto.php");
- new MCI_Footnotes_Tab_HowTo($this->a_arr_SettingsTabs);
- // load tab 'diagnostics'
- require_once(dirname( __FILE__ ) . "/tab_diagnostics.php");
- new MCI_Footnotes_Tab_Diagnostics($this->a_arr_SettingsTabs);
- }
-
- /**
- * sets the plugin's title for the admins settings menu
- * called in class constructor @ admin_menu
- * @since 1.0
- */
- public function RegisterMenu() {
- // current user needs the permission to update plugins for further access
- if (!current_user_can('update_plugins')) {
- return;
- }
- // Add a new sub menu to the standard Settings panel
- $this->a_str_Pagehook = add_options_page(
- FOOTNOTES_PLUGIN_PUBLIC_NAME,
- FOOTNOTES_PLUGIN_PUBLIC_NAME,
- 'administrator',
- FOOTNOTES_SETTINGS_PAGE_ID,
- array($this, 'DisplaySettings')
- );
- }
-
- /**
- * Plugin Options page rendering goes here, checks
- * for active tab and replaces key with the related
- * settings key. Uses the plugin_options_tabs method
- * to render the tabs.
- * @since 1.0
- */
- public function DisplaySettings() {
- // load stylesheets and scripts
- $this->LoadScriptsAndStylesheets();
-
- // gets active tab, or if nothing set the "general" tab will be set to active
- self::$a_str_ActiveTab = isset($_GET['tab']) ? $_GET['tab'] : FOOTNOTES_SETTINGS_TAB_GENERAL;
- // outputs all tabs
- echo '
- ';
- }
-} // class MCI_Footnotes_Tab_HowTo
-
-endif;
\ No newline at end of file
diff --git a/classes/task.php b/classes/task.php
deleted file mode 100644
index be54f79..0000000
--- a/classes/task.php
+++ /dev/null
@@ -1,394 +0,0 @@
-a_arr_Settings = MCI_Footnotes_getOptions(false);
- }
-
- /**
- * add WordPress hooks
- * @since 1.3
- */
- public function Register() {
- // adds the custom css to the header
- add_action('wp_head', array($this, "Header"));
- // stops listening to the output and replaces the footnotes
- add_action('get_footer', array($this, "Footer"));
- // adds the love and share me slug to the footer
- add_action('wp_footer', array($this, "Love"));
-
- // moves these contents through the replacement function
- add_filter('the_content', array($this, "Content"));
- add_filter('the_excerpt', array($this, "Excerpt"));
- add_filter('widget_title', array($this, "WidgetTitle"));
- add_filter('widget_text', array($this, "WidgetText"));
- }
-
- /**
- * outputs the custom css to the header
- * @since 1.3
- */
- public function Header() {
- ?>
-
- exec($p_str_Content, $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "post_end" ? true : false);
- }
-
- /**
- * replaces footnotes tags in the post excerpt
- * @since 1.3
- * @param string $p_str_Content
- * @return string
- */
- public function Excerpt($p_str_Content) {
- require_once(dirname( __FILE__ ) . "/convert.php");
- // search in the excerpt only if activated
- if (MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_SEARCH_IN_EXCERPT])) {
- return $this->exec($p_str_Content, false);
- }
- // returns content
- return $p_str_Content;
- }
-
- /**
- * replaces footnotes tags in the widget title
- * @since 1.3
- * @param string $p_str_Content
- * @return string
- */
- public function WidgetTitle($p_str_Content) {
- // returns content
- return $p_str_Content;
- }
-
- /**
- * replaces footnotes tags in the widget text
- * @since 1.3
- * @param string $p_str_Content
- * @return string
- */
- public function WidgetText($p_str_Content) {
- // returns content
- return $this->exec($p_str_Content, $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "post_end" ? true : false);
- }
-
- /**
- * outputs the reference container to the footer
- * @since 1.3
- */
- public function Footer() {
- if ($this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "footer") {
- echo $this->ReferenceContainer();
- }
- }
-
- /**
- * output the love me slug in the footer
- * @since 1.3
- */
- public function Love() {
- // get setting for love and share this plugin and convert it to boolean
- $l_str_LoveMeText = $this->a_arr_Settings[FOOTNOTES_INPUT_LOVE];
- // check if the admin allows to add a link to the footer
- if (empty($l_str_LoveMeText) || strtolower($l_str_LoveMeText) == "no" || !self::$a_bool_AllowLoveMe) {
- return;
- }
- // get random love me text
- if (strtolower($l_str_LoveMeText) == "random") {
- $l_str_LoveMeText = "text-" . rand(1,3);
- }
- switch ($l_str_LoveMeText) {
- case "text-1":
- $l_str_LoveMeText = sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
- break;
- case "text-2":
- $l_str_LoveMeText = sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
- break;
- case "text-3":
- default:
- $l_str_LoveMeText = sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
- break;
- }
- echo '
' . $l_str_LoveMeText . '
';
- }
-
-
- /**
- * replaces all footnotes in the given content
- * loading settings if not happened yet since 1.0-gamma
- * @since 1.0
- * @param string $p_str_Content
- * @param bool $p_bool_OutputReferences [default: true]
- * @return string
- */
- public function exec($p_str_Content, $p_bool_OutputReferences = true) {
- // replace all footnotes in the content
- $p_str_Content = $this->Lookup($p_str_Content, true);
- $p_str_Content = $this->Lookup($p_str_Content, false);
-
- // add the reference list if set
- if ($p_bool_OutputReferences) {
- $p_str_Content = $p_str_Content . $this->ReferenceContainer();
- }
- // checks if the user doesn't want to have a 'love me' on current page
- // @since 1.1.1
- if (strpos($p_str_Content, FOOTNOTES_NO_SLUGME_PLUG) !== false) {
- self::$a_bool_AllowLoveMe = false;
- $p_str_Content = str_replace(FOOTNOTES_NO_SLUGME_PLUG, "", $p_str_Content);
- }
- // return the replaced content
- return $p_str_Content;
- }
-
- /**
- * replace all footnotes in the given string and adds them to an array
- * using a personal starting and ending tag for the footnotes since 1.0-gamma
- * @since 1.0
- * @param string $p_str_Content
- * @param bool $p_bool_ConvertHtmlChars
- * @return string
- */
- public function Lookup($p_str_Content, $p_bool_ConvertHtmlChars = true) {
- require_once(dirname( __FILE__ ) . "/convert.php");
- // contains the index for the next footnote on this page
- $l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
- // contains the starting position for the lookup of a footnote
- $l_int_PosStart = 0;
- // contains the footnote template
- $l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "footnote.html");
- // get footnote starting tag
- $l_str_StartingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_START];
- // get footnote ending tag
- $l_str_EndingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_END];
- // get footnote counter style
- $l_str_CounterStyle = $this->a_arr_Settings[FOOTNOTES_INPUT_COUNTER_STYLE];
- // get footnote layout before index
- $l_str_BeforeIndex = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE];
- // get footnote layout after index
- $l_str_AfterIndex = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER];
-
- if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
- // get user defined footnote starting tag
- $l_str_StartingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED];
- // get user defined footnote ending tag
- $l_str_EndingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED];
- }
-
- // decode html special chars
- if ($p_bool_ConvertHtmlChars) {
- $l_str_StartingTag = htmlspecialchars($l_str_StartingTag);
- $l_str_EndingTag = htmlspecialchars($l_str_EndingTag);
- }
- // if footnotes short code is empty, return the content without changes
- if (empty($l_str_StartingTag) || empty($l_str_EndingTag)) {
- return $p_str_Content;
- }
-
- // check for a footnote placeholder in the current page
- do {
- // get first occurrence of a footnote starting tag
- $l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart);
- // tag not found
- if ($l_int_PosStart === false) {
- break;
- }
- // get first occurrence of a footnote ending tag after the starting tag
- $l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart);
- // tag not found
- if ($l_int_PosEnd === false) {
- break;
- }
- // get length of footnote text
- $l_int_Length = $l_int_PosEnd - $l_int_PosStart;
- // get text inside footnote
- $l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
- // set replacing string for the footnote
- $l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate);
- $l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText);
- $l_str_ReplaceText = str_replace("[[FOOTNOTE BEFORE]]", $l_str_BeforeIndex, $l_str_ReplaceText);
- $l_str_ReplaceText = str_replace("[[FOOTNOTE AFTER]]", $l_str_AfterIndex, $l_str_ReplaceText);
- $l_str_ReplaceText = preg_replace('@[\s]{2,}@',' ',$l_str_ReplaceText);
- // replace footnote in content
- $p_str_Content = substr_replace($p_str_Content, $l_str_ReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
- // add footnote only if not empty
- if (!empty($l_str_FootnoteText)) {
- // set footnote to the output box at the end
- self::$a_arr_Footnotes[] = $l_str_FootnoteText;
- // increase footnote index
- $l_int_FootnoteIndex++;
- }
- // add offset to the new starting position
- $l_int_PosStart += $l_int_Length + strlen($l_str_EndingTag);
- } while (true);
-
- // return content
- return $p_str_Content;
- }
-
- /**
- * looks through all footnotes that has been replaced in the current content and
- * adds a reference to the footnote at the end of the content
- * function to collapse the reference container since 1.0-beta
- * @since 1.0
- * @return string
- */
- public function ReferenceContainer() {
- // no footnotes has been replaced on this page
- if (empty(self::$a_arr_Footnotes)) {
- return "";
- }
- require_once(dirname( __FILE__ ) . "/convert.php");
-
- // get setting for combine identical footnotes and convert it to boolean
- $l_bool_CombineIdentical = MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_COMBINE_IDENTICAL]);
- // get setting for preferences label
- $l_str_ReferencesLabel = $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCES_LABEL];
- // get setting for collapse reference footnotes and convert it to boolean
- $l_bool_CollapseReference = MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_COLLAPSE_REFERENCES]);
- // get footnote counter style
- $l_str_CounterStyle = $this->a_arr_Settings[FOOTNOTES_INPUT_COUNTER_STYLE];
- // get hyperlink symbol index
- $l_int_HyperlinkSymbolIndex = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL];
- // get html arrow
- $l_str_HyperlinkSymbol = MCI_Footnotes_Convert::getArrow($l_int_HyperlinkSymbolIndex);
- // set html arrow to the first one if invalid index defined
- if (is_array($l_str_HyperlinkSymbol)) {
- $l_str_HyperlinkSymbol = MCI_Footnotes_Convert::getArrow(0);
- }
- // get user defined hyperlink symbol
- $l_int_HyperlinkSymbol_UserDefined = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER];
- if (!empty($l_int_HyperlinkSymbol_UserDefined)) {
- // override hyperlink symbol with user defined symbol
- $l_str_HyperlinkSymbol = $l_int_HyperlinkSymbol_UserDefined;
- }
-
- // add expand/collapse buttons to the reference label if collapsed by default
- // @since 1.2.2
- $l_str_CollapseButtons = "";
- if ($l_bool_CollapseReference) {
- $l_str_CollapseButtons = ' [ + ]';
- }
-
- // output string, prepare it with the reference label as headline
- $l_str_Output = '
\ No newline at end of file
diff --git a/templates/dashboard/customize-css.html b/templates/dashboard/customize-css.html
new file mode 100644
index 0000000..72a005f
--- /dev/null
+++ b/templates/dashboard/customize-css.html
@@ -0,0 +1,31 @@
+
+
+
+
[[label-css]]
+
[[css]]
+
+
+
[[headline]]
+
+
+
[[label-class-1]]
+
[[class-1]]
+
+
+
[[label-class-2]]
+
[[class-2]]
+
+
+
[[label-class-3]]
+
[[class-3]]
+
+
+
[[label-class-4]]
+
[[class-4]]
+
+
+
[[label-class-5]]
+
[[class-1]]
+
+
+
\ No newline at end of file
diff --git a/templates/dashboard/customize-hyperlink-arrow.html b/templates/dashboard/customize-hyperlink-arrow.html
new file mode 100644
index 0000000..6a0fdfa
--- /dev/null
+++ b/templates/dashboard/customize-hyperlink-arrow.html
@@ -0,0 +1,12 @@
+
+
+
+
[[label-symbol]]
+
[[symbol]]
+
+
+
[[label-user-defined]]
+
[[user-defined]] [[comment]]
+
+
+
\ No newline at end of file
diff --git a/templates/dashboard/customize-superscript.html b/templates/dashboard/customize-superscript.html
new file mode 100644
index 0000000..fb80826
--- /dev/null
+++ b/templates/dashboard/customize-superscript.html
@@ -0,0 +1,12 @@
+
+
+
+
[[label-before]]
+
[[before]]
+
+
+
[[label-after]]
+
[[after]]
+
+
+
\ No newline at end of file
diff --git a/templates/dashboard/diagnostics.html b/templates/dashboard/diagnostics.html
new file mode 100644
index 0000000..982c2e5
--- /dev/null
+++ b/templates/dashboard/diagnostics.html
@@ -0,0 +1,29 @@
+
+
+
+
[[label-server]]
+
[[server]]
+
+
+
[[label-php]]
+
[[php]]
+
+
+
[[label-max-execution-time]]
+
[[max-execution-time]]
+
+
+
[[label-memory-limit]]
+
[[memory-limit]]
+
+
+
[[label-php-extensions]]
+
[[php-extensions]]
+
+
+
[[label-wordpress]]
+
[[wordpress]]
+
+ [[plugins]]
+
+
\ No newline at end of file
diff --git a/templates/dashboard/editor-button.html b/templates/dashboard/editor-button.html
new file mode 100644
index 0000000..df47ef5
--- /dev/null
+++ b/templates/dashboard/editor-button.html
@@ -0,0 +1,42 @@
+
\ No newline at end of file
diff --git a/templates/dashboard/how-to-donate.html b/templates/dashboard/how-to-donate.html
new file mode 100644
index 0000000..97c825b
--- /dev/null
+++ b/templates/dashboard/how-to-donate.html
@@ -0,0 +1,2 @@
+
\ No newline at end of file
diff --git a/templates/dashboard/how-to-help.html b/templates/dashboard/how-to-help.html
new file mode 100644
index 0000000..5a9acce
--- /dev/null
+++ b/templates/dashboard/how-to-help.html
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/templates/dashboard/other-plugins.html b/templates/dashboard/other-plugins.html
new file mode 100644
index 0000000..86c9c0c
--- /dev/null
+++ b/templates/dashboard/other-plugins.html
@@ -0,0 +1,42 @@
+
+
\ No newline at end of file
diff --git a/templates/dashboard/settings-love.html b/templates/dashboard/settings-love.html
new file mode 100644
index 0000000..70dd4f2
--- /dev/null
+++ b/templates/dashboard/settings-love.html
@@ -0,0 +1,12 @@
+
+
+
+
[[label-love]]
+
[[love]]
+
+
+
[[label-no-love]]
+
[[no-love]]
+
+
+
\ No newline at end of file
diff --git a/templates/dashboard/settings-other.html b/templates/dashboard/settings-other.html
new file mode 100644
index 0000000..9e2a1eb
--- /dev/null
+++ b/templates/dashboard/settings-other.html
@@ -0,0 +1,8 @@
+
+
+
+
[[label-excerpt]]
+
[[excerpt]]
+
+
+
\ No newline at end of file
diff --git a/templates/dashboard/settings-reference-container.html b/templates/dashboard/settings-reference-container.html
new file mode 100644
index 0000000..37e950d
--- /dev/null
+++ b/templates/dashboard/settings-reference-container.html
@@ -0,0 +1,16 @@
+
+
+
+
[[label-name]]
+
[[name]]
+
+
+
[[label-collapse]]
+
[[collapse]]
+
+
+
[[label-position]]
+
[[position]]
+
+
+
\ No newline at end of file
diff --git a/templates/dashboard/settings-styling.html b/templates/dashboard/settings-styling.html
new file mode 100644
index 0000000..f81c780
--- /dev/null
+++ b/templates/dashboard/settings-styling.html
@@ -0,0 +1,56 @@
+
+
+
+
[[label-identical]]
+
[[identical]]
+
+
+
[[label-short-code-start]]
+
[[short-code-start]]
+
+
+
[[label-short-code-end]]
+
[[short-code-end]]
+
+
+
[[label-short-code-start-user]]
+
[[short-code-start-user]]
+
+
+
[[label-short-code-end-user]]
+
[[short-code-end-user]]
+
+
+
[[label-counter-style]]
+
[[counter-style]]
+
+
+
+
\ No newline at end of file
diff --git a/templates/footnote.html b/templates/footnote.html
deleted file mode 100755
index bd808ad..0000000
--- a/templates/footnote.html
+++ /dev/null
@@ -1,22 +0,0 @@
-[[FOOTNOTE BEFORE]][[FOOTNOTE INDEX]][[FOOTNOTE AFTER]]
-
-
- [[FOOTNOTE TEXT]]
-
-
-
\ No newline at end of file
diff --git a/templates/public/footnote.html b/templates/public/footnote.html
new file mode 100755
index 0000000..35de087
--- /dev/null
+++ b/templates/public/footnote.html
@@ -0,0 +1,14 @@
+[[before]][[index]][[after]]
+[[text]]
+
\ No newline at end of file
diff --git a/templates/public/reference-container-body.html b/templates/public/reference-container-body.html
new file mode 100755
index 0000000..c82a747
--- /dev/null
+++ b/templates/public/reference-container-body.html
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/templates/public/reference-container.html b/templates/public/reference-container.html
new file mode 100644
index 0000000..4b41c91
--- /dev/null
+++ b/templates/public/reference-container.html
@@ -0,0 +1,26 @@
+