- Update: Refactored the whole source code

- Add: Grouped the Plugin Settings into a new Menu Page called "ManFisher Plugins"
- Update: Moved the Diagnostics Sections to into a new Sub Page called "Diagnostics"
- Add: Sub Page to list all other Plugins of the Contributors
- Bugfix: Line up Footnotes with multiple lines in the Reference container

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@989695 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
Aricura 2014-09-14 20:32:59 +00:00
parent 1f5e0ed500
commit 0c01b80173
50 changed files with 3070 additions and 2107 deletions

54
class/config.php Normal file
View file

@ -0,0 +1,54 @@
<?php
/**
* Includes the Plugin Constants class to load all Plugin constant vars like Plugin name, etc.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*/
/**
* Contains all Plugin Constants. Contains no Method or Property.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Config {
/**
* Internal Plugin name.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_PLUGIN_NAME = "footnotes";
/**
* Public Plugin name.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_PLUGIN_PUBLIC_NAME = '<span class="footnote_tag_styling footnote_tag_styling_1">foot</span><span class="footnote_tag_styling footnote_tag_styling_2">notes</span>';
/**
* Html tag for the LOVE symbol.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_LOVE_SYMBOL = '<span style="color:#ff6d3b; font-weight:bold;">&hearts;</span>';
/**
* 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]]';
}

View file

@ -1,27 +1,29 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 11:45
* Version: 1.0
* Since: 1.3
* Includes the Convert Class.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*/
// define class only once
if (!class_exists("MCI_Footnotes_Convert")) :
/**
* Class MCI_Footnotes_Convert
* @since 1.3
* Converts data types and Footnotes specific values.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Convert {
/**
* converts a integer into the user-defined counter style for the footnotes
* @since 1.0-gamma
* @param int $p_int_Index
* @param string $p_str_ConvertStyle [counter style]
* @return string
* Converts a integer into the user-defined counter style for the footnotes.
*
* @author Stefan Herndler
* @since 1.5.0
* @param int $p_int_Index Index to be converted.
* @param string $p_str_ConvertStyle Style of the new/converted Index.
* @return string Converted Index as string in the defined counter style.
*/
public static function Index($p_int_Index, $p_str_ConvertStyle = "arabic_plain") {
switch ($p_str_ConvertStyle) {
@ -40,20 +42,16 @@ class MCI_Footnotes_Convert {
}
/**
* converts a integer into latin ascii characters, either lower or upper-case
* function available from A to ZZ ( means 676 footnotes at 1 page possible)
* Converts an integer into latin ascii characters, either lower or upper-case.
* Function available from A to ZZ ( means 676 footnotes at 1 page possible).
*
* @author Stefan Herndler
* @since 1.0-gamma
* @param int $p_int_Value
* @param bool $p_bool_UpperCase
* @param int $p_int_Value Value/Index to be converted.
* @param bool $p_bool_UpperCase True to convert the value to upper case letter, otherwise to lower case.
* @return string
*/
private static function toLatin($p_int_Value, $p_bool_UpperCase) {
// decimal value of the starting ascii character
$l_int_StartingASCII = 65 - 1; // = A
// if lower-case, change decimal to lower-case "a"
if (!$p_bool_UpperCase) {
$l_int_StartingASCII = 97 - 1; // = a
}
// output string
$l_str_Return = "";
$l_int_Offset = 0;
@ -65,19 +63,24 @@ class MCI_Footnotes_Convert {
}
// if offset set (more then Z), then add a new letter in front
if ($l_int_Offset > 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;
}

213
class/dashboard/init.php Normal file
View file

@ -0,0 +1,213 @@
<?php
/**
* Includes the Plugin settings menu.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:26
*/
/**
* Handles the Settings interface of the Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Layout_Init {
/**
* Slug for the Plugin main menu.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_MAIN_MENU_SLUG = "mfmmf";
/**
* Plugin main menu name.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_MAIN_MENU_TITLE = "ManFisher Plugins";
/**
*
* @author Stefan Herndler
* @since 1.5.0
* @var array
*/
private $a_arr_SubPageClasses = array();
/**
* Class Constructor. Initializes all WordPress hooks for the Plugin Settings.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function __construct() {
// iterate through each class define in the current script
foreach(get_declared_classes() as $l_str_ClassName) {
// accept only child classes of the layout engine
if(is_subclass_of($l_str_ClassName, 'MCI_Footnotes_LayoutEngine')) {
/** @var MCI_Footnotes_LayoutEngine $l_obj_Class */
$l_obj_Class = new $l_str_ClassName();
// append new instance of the layout engine sub class
$this->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("<br/><h3>%s</h3><br/>", __('Take a look on other Plugins we have developed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
echo '<div id="the-list">';
// iterate through each Plugin
foreach($l_arr_Plugins as $l_arr_PluginInfo) {
// replace Plugin information
$l_obj_Template->replace(
array(
"name" => $l_arr_PluginInfo["name"],
"title" => $l_arr_PluginInfo["title"]
)
);
// display Plugin
echo $l_obj_Template->getContent();
// reload template
$l_obj_Template->reload();
}
echo '</div>';
}
/**
* AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function getPluginMetaInformation() {
// get plugin internal name from POST data
$l_str_PluginName = array_key_exists("plugin", $_POST) ? $_POST["plugin"] : null;
if (empty($l_str_PluginName)) {
echo json_encode(array("error" => "Plugin name invalid."));
exit;
}
$l_str_Url = "https://api.wordpress.org/plugins/info/1.0/".$l_str_PluginName.".json";
// call URL and collect data
$l_arr_Response = wp_remote_get($l_str_Url);
// check if response is valid
if (is_wp_error($l_arr_Response)) {
echo json_encode(array("error" => "Can't get Plugin information."));
exit;
}
// get the body of the response
$l_str_Response = $l_arr_Response["body"];
// get plugin object
$l_arr_Plugin = json_decode($l_str_Response, true);
// return Plugin information as JSON encoded string
echo json_encode(
array(
"error" => "",
"PluginImage" => "",
"PluginDescription" => html_entity_decode($l_arr_Plugin["short_description"]),
"PluginUrl" => $l_arr_Plugin["homepage"],
"PluginVersion" => $l_arr_Plugin["version"]
)
);
exit;
}
}

449
class/dashboard/layout.php Normal file
View file

@ -0,0 +1,449 @@
<?php
/**
* Includes Layout Engine for the admin dashboard.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*/
/**
* Layout Engine for the administration dashboard.
*
* @author Stefan Herndler
* @since 1.5.0
*/
abstract class MCI_Footnotes_LayoutEngine {
/**
* Stores the Hook connection string for the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @var null|string
*/
protected $a_str_SubPageHook = null;
/**
* Stores all Sections for the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @var array
*/
protected $a_arr_Sections = array();
/**
* Returns a Priority index. Lower numbers have a higher Priority.
*
* @author Stefan Herndler
* @since 1.5.0
* @return int
*/
abstract public function getPriority();
/**
* Returns the unique slug of the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
abstract protected function getSubPageSlug();
/**
* Returns the title of the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
abstract protected function getSubPageTitle();
/**
* Returns an array of all registered sections for a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
abstract protected function getSections();
/**
* Returns an array of all registered meta boxes.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
abstract protected function getMetaBoxes();
/**
* Returns an array describing a sub page section.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_ID Unique ID suffix.
* @param string $p_str_Title Title of the section.
* @param int $p_int_SettingsContainerIndex Settings Container Index.
* @param bool $p_bool_hasSubmitButton Should a Submit Button be displayed for this section, default: true.
* @return array Array describing the section.
*/
protected function addSection($p_str_ID, $p_str_Title, $p_int_SettingsContainerIndex, $p_bool_hasSubmitButton = true) {
return array("id" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_ID, "title" => $p_str_Title, "submit" => $p_bool_hasSubmitButton, "container" => $p_int_SettingsContainerIndex);
}
/**
* Returns an array describing a meta box.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SectionID Parent Section ID.
* @param string $p_str_ID Unique ID suffix.
* @param string $p_str_Title Title for the meta box.
* @param string $p_str_CallbackFunctionName Class method name for callback.
* @return array meta box description to be able to append a meta box to the output.
*/
protected function addMetaBox($p_str_SectionID, $p_str_ID, $p_str_Title, $p_str_CallbackFunctionName) {
return array("parent" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_SectionID, "id" => $p_str_ID, "title" => $p_str_Title, "callback" => $p_str_CallbackFunctionName);
}
/**
* Registers a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function registerSubPage() {
global $submenu;
// iterate through each sub menu
foreach($submenu as $l_arr_SubMenu) {
// iterate through each sub menu attribute
foreach($l_arr_SubMenu as $l_str_Attribute) {
// sub menu already added, stop
if ($l_str_Attribute == MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug()) {
return;
}
}
}
$this->a_str_SubPageHook = add_submenu_page(
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, // parent slug
$this->getSubPageTitle(), // page title
$this->getSubPageTitle(), // menu title
'manage_options', // capability
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), // menu slug
array($this, 'displayContent') // function
);
}
/**
* Registers all sections for a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function registerSections() {
// iterate through each section
foreach($this->getSections() as $l_arr_Section) {
// append tab to the tab-array
$this->a_arr_Sections[$l_arr_Section["id"]] = $l_arr_Section;
add_settings_section(
$l_arr_Section["id"], // unique id
"", //$l_arr_Section["title"], // title
array($this, 'Description'), // callback function for the description
$l_arr_Section["id"] // parent sub page slug
);
$this->registerMetaBoxes($l_arr_Section["id"]);
}
}
/**
* Registers all Meta boxes for a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_ParentID Parent section unique id.
*/
private function registerMetaBoxes($p_str_ParentID) {
// iterate through each meta box
foreach($this->getMetaBoxes() as $l_arr_MetaBox) {
if ($l_arr_MetaBox["parent"] != $p_str_ParentID) {
continue;
}
add_meta_box(
$p_str_ParentID. "-" . $l_arr_MetaBox["id"], // unique id
$l_arr_MetaBox["title"], // meta box title
array($this, $l_arr_MetaBox["callback"]), // callback function to display (echo) the content
$p_str_ParentID, // post type = parent section id
'main' // context
);
}
}
/**
* Append javascript and css files for specific sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
private function appendScripts() {
// add jQuery to the sub menu page
wp_enqueue_script('jquery');
// enable meta boxes layout and close functionality
wp_enqueue_script('postbox');
// register stylesheet
wp_register_style('mci-footnotes-admin-styles', plugins_url('../../css/settings.css', __FILE__));
// add stylesheet to the output
wp_enqueue_style('mci-footnotes-admin-styles');
}
/**
* Displays the content of specific sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function displayContent() {
// register and enqueue scripts and styling
$this->appendScripts();
// 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];
// store settings
$l_bool_SettingsUpdated = false;
if (array_key_exists("save-settings", $_POST)) {
if ($_POST["save-settings"] == "save") {
$l_bool_SettingsUpdated = $this->saveSettings();
}
}
// display all sections and highlight the active section
echo '<div class="wrap">';
echo '<h2 class="nav-tab-wrapper">';
// iterate through all register sections
foreach ($this->a_arr_Sections as $l_str_ID => $l_arr_Description) {
echo sprintf(
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
$l_arr_ActiveSection["id"] == $l_str_ID ? ' nav-tab-active' : '',
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), $l_str_ID, $l_arr_Description["title"]
);
}
echo '</h2><br/>';
if ($l_bool_SettingsUpdated) {
echo sprintf('<div id="message" class="updated">%s</div>', __("Settings saved", MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
}
// form to submit the active section
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
settings_fields($l_arr_ActiveSection["container"]);
echo '<input type="hidden" name="save-settings" value="save" />';
// outputs the settings field of the active section
do_settings_sections($l_arr_ActiveSection["id"]);
do_meta_boxes($l_arr_ActiveSection["id"], 'main', NULL);
// add submit button to active section if defined
if ($l_arr_ActiveSection["submit"]) {
submit_button();
}
// close the form to submit data
echo '</form>';
// close container for the settings page
echo '</div>';
// output special javascript for the expand/collapse function of the meta boxes
echo '<script type="text/javascript">';
echo "jQuery(document).ready(function ($) {";
echo "jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');";
echo "postboxes.add_postbox_toggles('" . $this->a_str_SubPageHook . "');";
echo "});";
echo '</script>';
}
/**
* 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 '<br/>';
}
/**
* Returns a line break to have a space between two lines.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function addLineSpace() {
return '<br/><br/>';
}
/**
* Returns a simple text inside html <span> 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('<span>%s</span>', $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('<label for="%s">%s:</label>', $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('<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s" %s/>',
$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('<input type="checkbox" name="%s" id="%s" %s/>',
$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('<option value="%s" %s>%s</option>',
$l_str_Value,
$l_arr_Data["value"] == $l_str_Value ? "selected" : "",
$l_str_Caption);
}
return sprintf('<select name="%s" id="%s">%s</select>',
$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('<textarea name="%s" id="%s">%s</textarea>',
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]);
}
} // end of class

View file

@ -0,0 +1,130 @@
<?php
/**
* Includes the Plugin Class to display Diagnostics.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 14:47
*/
/**
* Displays Diagnostics of the web server, PHP and WordPress.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
/**
* Returns a Priority index. Lower numbers have a higher Priority.
*
* @author Stefan Herndler
* @since 1.5.0
* @return int
*/
public function getPriority() {
return 999;
}
/**
* Returns the unique slug of the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getSubPageSlug() {
return "-diagnostics";
}
/**
* Returns the title of the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getSubPageTitle() {
return __("Diagnostics", MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
}
/**
* Returns an array of all registered sections for the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
protected function getSections() {
return array(
$this->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 .= '<tr>';
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin["Name"] . '</td>';
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin["Version"] . ' [' . $l_arr_Plugin["PluginURI"] . ']' . '</td>';
$l_str_WordPressPlugins .= '</tr>';
}
// 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();
}
}

View file

@ -0,0 +1,393 @@
<?php
/**
* Includes the Plugin Class to display all Settings.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 14:47
*/
/**
* Displays and handles all Settings of the Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
/**
* Returns a Priority index. Lower numbers have a higher Priority.
*
* @author Stefan Herndler
* @since 1.5.0
* @return int
*/
public function getPriority() {
return 10;
}
/**
* Returns the unique slug of the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getSubPageSlug() {
return "-" . MCI_Footnotes_Config::C_STR_PLUGIN_NAME;
}
/**
* Returns the title of the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getSubPageTitle() {
return MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME;
}
/**
* Returns an array of all registered sections for the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
protected function getSections() {
return array(
$this->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 . '&nbsp;' . 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 = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
// 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(
"((" => "((",
"<fn>" => htmlspecialchars("<fn>"),
"[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(
"))" => "))",
"</fn>" => htmlspecialchars("</fn>"),
"[/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), '<a href="http://wordpress.org/support/plugin/footnotes" target="_blank" class="footnote_plugin">', '</a>')
)
);
// 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();
}
}

88
class/hooks.php Normal file
View file

@ -0,0 +1,88 @@
<?php
/**
* Handles all WordPress hooks of this Plugin.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*/
/**
* Registers all WordPress Hooks and executes them on demand.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Hooks {
/**
* Registers all WordPress hooks.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function registerHooks() {
register_activation_hook(dirname(__FILE__) . "/../index.php", array("MCI_Footnotes_Hook", "activatePlugin"));
register_deactivation_hook(dirname(__FILE__) . "/../index.php", array("MCI_Footnotes_Hook", "deactivatePlugin"));
register_uninstall_hook(dirname(__FILE__) . "/../index.php", array("MCI_Footnotes_Hook", "uninstallPlugin"));
}
/**
* Executed when the Plugin gets activated.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function activatePlugin() {
// currently unused
}
/**
* Executed when the Plugin gets deactivated.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function deactivatePlugin() {
// currently unused
}
/**
* Executed when the Plugin gets uninstalled.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function uninstallPlugin() {
// WordPress User has to be logged in
if (!is_user_logged_in()) {
wp_die(__('You must be logged in to run this script.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
}
// WordPress 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.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
}
// deletes all settings and restore the default values
MCI_Footnotes_Settings::instance()->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('<a href="http://wordpress.org/support/plugin/footnotes" target="_blank">%s</a>', __('Support', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
// append link to the Settings page
$p_arr_Links[] = sprintf('<a href="%s">%s</a>', 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('<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ" target="_blank">%s</a>', __('Donate', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
// return new links
return $p_arr_Links;
}
}

116
class/init.php Normal file
View file

@ -0,0 +1,116 @@
<?php
/**
* Includes the main Class of the Plugin.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*/
/**
* Entry point of the Plugin. Loads the Dashboard and executes the Task.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes {
/**
* Reference to the Plugin Task object.
*
* @author Stefan Herndler
* @since 1.5.0
* @var null|MCI_Footnotes_Task
*/
public $a_obj_Task = null;
/**
* Executes the Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function run() {
// register language
MCI_Footnotes_Language::registerHooks();
// register Button hooks
MCI_Footnotes_WYSIWYG::registerHooks();
// register general hooks
MCI_Footnotes_Hooks::registerHooks();
// register all Widgets of the Plugin.
$this->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');
}
}

68
class/language.php Normal file
View file

@ -0,0 +1,68 @@
<?php
/**
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 17:47
*/
/**
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Language {
/**
* Register WordPress Hook.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function registerHooks() {
add_action('plugins_loaded', array("MCI_Footnotes_Language", "loadTextDomain"));
}
/**
* Loads the text domain for current WordPress language if exists. Otherwise fallback "en" will be loaded.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function loadTextDomain() {
$l_str_LanguagePath = dirname(__FILE__) . "/../languages/" . MCI_Footnotes_Config::C_STR_PLUGIN_NAME - "-";
// language file with localization exists
$l_bool_DomainLoaded = load_textdomain(MCI_Footnotes_Config::C_STR_PLUGIN_NAME, $l_str_LanguagePath . apply_filters('plugin_locale', get_locale(), MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . '.mo');
if (!empty($l_bool_DomainLoaded)) {
return;
}
// language file without localization exists
$l_bool_DomainLoaded = load_textdomain(MCI_Footnotes_Config::C_STR_PLUGIN_NAME, $l_str_LanguagePath . self::getLanguageCode() . '.mo');
if (!empty($l_bool_DomainLoaded)) {
return;
}
// fallback to english
load_textdomain(MCI_Footnotes_Config::C_STR_PLUGIN_NAME, $l_str_LanguagePath . '-en.mo');
}
/**
* Returns the Language Code of the WordPress language. (only "en" from "en_US")
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
private static function getLanguageCode() {
// read current WordPress language
$l_str_locale = apply_filters('plugin_locale', get_locale(), MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
// check if WordPress language has a localization (e.g. "en_US" or "de_AT")
if (strpos($l_str_locale, "_") !== false) {
// remove localization code
$l_arr_languageCode = explode("_", $l_str_locale);
$l_str_languageCode = $l_arr_languageCode[0];
return $l_str_languageCode;
}
// return language code lowercase
return strtolower($l_str_locale);
}
}

370
class/settings.php Normal file
View file

@ -0,0 +1,370 @@
<?php
/**
* Includes the Settings class to handle all Plugin settings.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 10:43
*/
/**
* The class loads all Settings from each WordPress Settings container.
* It a Setting is not defined yet the default value will be used.
* Each Setting will be validated and sanitized when loaded from the container.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Settings {
/**
* Settings Container Key for the label of the reference container.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_REFERENCE_CONTAINER_NAME = "footnote_inputfield_references_label";
/**
* Settings Container Key to collapse the reference container by default.
*
* @author Stefan Herndler
* @since 1.5.0
* @var bool
*/
const C_BOOL_REFERENCE_CONTAINER_COLLAPSE = "footnote_inputfield_collapse_references";
/**
* Settings Container Key for the positioning of the reference container.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_REFERENCE_CONTAINER_POSITION = "footnote_inputfield_reference_container_place";
/**
* Settings Container Key to combine identical footnotes.
*
* @author Stefan Herndler
* @since 1.5.0
* @var bool
*/
const C_BOOL_COMBINE_IDENTICAL_FOOTNOTES = "footnote_inputfield_combine_identical";
/**
* Settings Container Key for the start of the footnotes short code.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_SHORT_CODE_START = "footnote_inputfield_placeholder_start";
/**
* Settings Container Key for the end of the footnotes short code.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_SHORT_CODE_END = "footnote_inputfield_placeholder_end";
/**
* Settings Container Key for the user defined start of the footnotes short code.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED = "footnote_inputfield_placeholder_start_user_defined";
/**
* Settings Container Key for the user defined end of the footnotes short code.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED = "footnote_inputfield_placeholder_end_user_defined";
/**
* Settings Container Key for the counter style of the footnotes.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_COUNTER_STYLE = "footnote_inputfield_counter_style";
/**
* Settings Container Key for the 'I love footnotes' text.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_LOVE = "footnote_inputfield_love";
/**
* Settings Container Key to look for footnotes in post excerpts.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_BOOL_FOOTNOTES_IN_EXCERPT = "footnote_inputfield_search_in_excerpt";
/**
* Settings Container Key for the styling before the footnotes index.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_STYLING_BEFORE = "footnote_inputfield_custom_styling_before";
/**
* Settings Container Key for the styling after the footnotes index.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_FOOTNOTES_STYLING_AFTER = "footnote_inputfield_custom_styling_after";
/**
* Settings Container Key for the Hyperlink arrow.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_HYPERLINK_ARROW = "footnote_inputfield_custom_hyperlink_symbol";
/**
* Settings Container Key for the user defined Hyperlink arrow.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_HYPERLINK_ARROW_USER_DEFINED = "footnote_inputfield_custom_hyperlink_symbol_user";
/**
* Settings Container Key for the user defined styling.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_CUSTOM_CSS = "footnote_inputfield_custom_css";
/**
* Stores a singleton reference of this class.
*
* @author Stefan Herndler
* @since 1.5.0
* @var MCI_Footnotes_Settings
*/
private static $a_obj_Instance = null;
/**
* Contains all Settings Container names.
*
* @author Stefan Herndler
* @since 1.5.0
* @var array
*/
private $a_arr_Container = array("footnotes_storage", "footnotes_storage_custom");
/**
* Contains all Default Settings for each Settings Container.
*
* @author Stefan Herndler
* @since 1.5.0
* @var array
*/
private $a_arr_Default = array(
"footnotes_storage" => 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 => '&#8593;',
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));
}
}
}

355
class/task.php Normal file
View file

@ -0,0 +1,355 @@
<?php
/**
* Includes the core function of the Plugin - Search and Replace the Footnotes.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0
*/
/**
* Looks for Footnotes short codes and replaces them. Also displays the Reference Container.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Task {
/**
* Contains all footnotes found on current public page.
*
* @author Stefan Herndler
* @since 1.5.0
* @var array
*/
public static $a_arr_Footnotes = array();
/**
* Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page.
*
* @author Stefan Herndler
* @since 1.5.0
* @var bool
*/
public static $a_bool_AllowLoveMe = true;
/**
* Register WordPress Hooks to replace Footnotes in the content of a public page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function registerHooks() {
// append custom css to the header
add_action('wp_head', array($this, "Header"));
// append the reference container to the footer if enabled
if (MCI_Footnotes_Settings::instance()->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() {
?>
<style type="text/css" media="screen"><?php echo MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS) ?></style>
<?php
// reset stored footnotes when displaying the header
self::$a_arr_Footnotes = array();
}
/**
* Displays the Reference Container if set to the footer.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function Footer() {
echo $this->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('<a href="http://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">%s</a>',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('<div style="text-align:center; color:#acacac;">%s</div>', $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)) ? '&nbsp;&nbsp;&nbsp;[ <a id="footnote_reference_container_collapse_button" style="cursor:pointer;" onclick="footnote_expand_collapse_reference_container();">+</a> ]' : '',
"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();
}
}

127
class/template.php Normal file
View file

@ -0,0 +1,127 @@
<?php
/**
* Includes the Template Engine to load and handle all Template files of the Plugin.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 10:58
*/
/**
* Handles each Template file for the Plugin Frontend (e.g. Settings Dashboard, Public pages, ...).
* Loads a template file, replaces all Placeholders and returns the replaced file content.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Template {
/**
* Directory name for dashboard templates.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_DASHBOARD = "dashboard";
/**
* Directory name for public templates.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_PUBLIC = "public";
/**
* Contains the content of the template after initialize.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
private $a_str_OriginalContent = "";
/**
* Contains the content of the template after initialize with replaced place holders.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
private $a_str_ReplacedContent = "";
/**
* Class Constructor. Reads and loads the template file without replace any placeholder.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_FileType Template file type (take a look on the Class constants).
* @param string $p_str_FileName Template file name inside the Template directory without the file extension.
*/
public function __construct($p_str_FileType, $p_str_FileName) {
// no template file type and/or file name set
if (empty($p_str_FileType) || empty($p_str_FileName)) {
return;
}
// get absolute path to the specified template file
$l_str_TemplateFile = dirname(__FILE__) . "/../templates/" . $p_str_FileType . "/" . $p_str_FileName . ".html";
// Template file does not exist
if (!file_exists($l_str_TemplateFile)) {
return;
}
// get Template file content
$this->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

75
class/widgets/base.php Normal file
View file

@ -0,0 +1,75 @@
<?php
/**
*
* @filesource
* @author Stefan Herndler
* @since x.x.x 14.09.14 14:30
*/
/**
* Base Class for all Plugin Widgets. Registers each Widget to WordPress.
* The following Methods MUST be overwritten in each sub class:
* **public function widget($args, $instance)** -> 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
);
}
}

View file

@ -0,0 +1,79 @@
<?php
/**
* Includes the Plugin Widget to put the Reference Container to the Widget area.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 14:26
*/
/**
* Registers a Widget to put the Reference Container to the widget area.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
/**
* Returns an unique ID as string used for the Widget Base ID.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getID() {
return "footnotes_widget";
}
/**
* Returns the Public name of the Widget to be displayed in the Configuration page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getName() {
return MCI_Footnotes_Config::C_STR_PLUGIN_NAME;
}
/**
* Returns the Description of the child widget.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getDescription() {
return __('The widget defines the position of the reference container if set to "widget area".', MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
}
/**
* Outputs the Settings of the Widget.
*
* @author Stefan Herndler
* @since 1.5.0
* @param mixed $instance
* @return void
*/
public function form($instance) {
echo __('The widget defines the position of the reference container if set to "widget area".', MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
}
/**
* Outputs the Content of the Widget.
*
* @author Stefan Herndler
* @since 1.5.0
* @param mixed $args
* @param mixed $instance
*/
public function widget($args, $instance) {
global $g_obj_MCI_Footnotes;
// reference container positioning is set to "widget area"
if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "widget") {
echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer();
}
}
}

78
class/wysiwyg.php Normal file
View file

@ -0,0 +1,78 @@
<?php
/**
* Includes the Class to handle the WYSIWYG-Buttons.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 17:30
*/
class MCI_Footnotes_WYSIWYG {
public static function registerHooks() {
add_filter("mce_buttons", array("MCI_Footnotes_WYSIWYG", "newVisualEditorButton"));
add_action("admin_print_footer_scripts", array("MCI_Footnotes_WYSIWYG", "newPlainTextEditorButton"));
add_filter("mce_external_plugins", array("MCI_Footnotes_WYSIWYG", "includeScripts"));
add_action("wp_ajax_nopriv_footnotes_getTags", array("MCI_Footnotes_WYSIWYG", "ajaxCallback"));
add_action("wp_ajax_footnotes_getTags", array("MCI_Footnotes_WYSIWYG", "ajaxCallback"));
}
/**
* Append a new Button to the WYSIWYG editor of Posts and Pages.
*
* @author Stefan Herndler
* @since 1.5.0
* @param array $p_arr_Buttons pre defined Buttons from WordPress.
* @return array
*/
public static function newVisualEditorButton($p_arr_Buttons) {
array_push($p_arr_Buttons, MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
return $p_arr_Buttons;
}
/**
* Add a new button to the plain text editor.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function newPlainTextEditorButton() {
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "editor-button");
$l_obj_Template->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;
}
}

View file

@ -1,402 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.7
* Since: 1.0
*/
// define class only once
if (!class_exists("MCI_Footnotes_Admin")) :
/**
* Class MCI_Footnotes_Admin
* @since 1.0
*/
class MCI_Footnotes_Admin {
// page hook for adding a new sub menu page to the settings
// @since 1.0
private $a_str_Pagehook = null;
// collection of settings values for this plugin
// @since 1.0
private $a_arr_Options = array();
// collection of tabs for the settings page of this plugin
// @since 1.0
private $a_arr_SettingsTabs = array();
// current active tab
public static $a_str_ActiveTab = null;
/**
* @constructor
* @since 1.0
*/
public function __construct() {
// include script and stylesheet functions
require_once(dirname(__FILE__) . "/../includes/wysiwyg-editor.php");
// load setting tabs
add_action('admin_init', array($this, 'Register'));
// register plugin in settings menu
add_action('admin_menu', array($this, 'RegisterMenu'));
}
/**
* register the settings field in the database for the "save" function
* called in class constructor @ admin_init
* @since 1.0
*/
public function Register() {
// register settings
register_setting(FOOTNOTES_SETTINGS_TAB_GENERAL, FOOTNOTES_SETTINGS_CONTAINER);
register_setting(FOOTNOTES_SETTINGS_TAB_CUSTOM, FOOTNOTES_SETTINGS_CONTAINER_CUSTOM);
// load tab 'general'
require_once(dirname( __FILE__ ) . "/tab_general.php");
new MCI_Footnotes_Tab_General($this->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 '<div class="wrap">';
echo '<h2 class="nav-tab-wrapper">';
// iterate through all register tabs
foreach ($this->a_arr_SettingsTabs as $l_str_TabKey => $l_str_TabCaption) {
$l_str_Active = self::$a_str_ActiveTab == $l_str_TabKey ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . $l_str_Active . '" href="?page=' . FOOTNOTES_SETTINGS_PAGE_ID . '&tab=' . $l_str_TabKey . '">' . $l_str_TabCaption . '</a>';
}
echo '</h2>';
// outputs a form with the content of the current active tab
echo '<form method="post" action="options.php">';
wp_nonce_field('update-options');
settings_fields(self::$a_str_ActiveTab);
// outputs the settings field of the current active tab
do_settings_sections(self::$a_str_ActiveTab);
do_meta_boxes(self::$a_str_ActiveTab, 'main', NULL);
// adds a submit button to the current page
if (self::$a_str_ActiveTab != FOOTNOTES_SETTINGS_TAB_HOWTO && self::$a_str_ActiveTab != FOOTNOTES_SETTINGS_TAB_DIAGNOSTICS) {
submit_button();
}
echo '</form>';
echo '</div>';
// output settings page specific javascript code
$this->OutputJavascript();
}
/**
* register and loads css and javascript files for settings
* @since 1.3
*/
private function LoadScriptsAndStylesheets() {
// register settings stylesheet
wp_register_style('footnote_settings_style', plugins_url('../css/settings.css', __FILE__));
// add settings stylesheet
wp_enqueue_style('footnote_settings_style');
// Needed to allow meta box layout and close functionality
wp_enqueue_script('postbox');
}
/**
* outputs page specific javascript code
* @since 1.0.7
*/
private function OutputJavascript() {
?>
<!-- Needed to allow meta box layout and close functionality. -->
<script type="text/javascript">
jQuery(document).ready(function ($) {
// close postboxes that should be closed
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// postboxes setup
postboxes.add_postbox_toggles('<?php echo $this->a_str_Pagehook; ?>');
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START); ?>').on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END); ?> option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END); ?>').on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START); ?> option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
footnotes_Display_UserDefined_Placeholders();
});
function footnotes_Display_UserDefined_Placeholders() {
if (jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START); ?>').val() == "userdefined") {
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED); ?>').show();
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED); ?>').show();
} else {
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED); ?>').hide();
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED); ?>').hide();
}
}
</script>
<?php
}
/**
* loads specific setting and returns an array with the keys [id, name, value]
* @since 1.0
* @param $p_str_FieldID
* @return array
*/
protected function LoadSetting($p_str_FieldID) {
// loads and filters the settings for this plugin
if (empty($this->a_arr_Options)) {
$this->a_arr_Options = MCI_Footnotes_getOptions(true);
}
$p_arr_Return = array();
$p_arr_Return["id"] = $this->getFieldID($p_str_FieldID);
$p_arr_Return["name"] = $this->getFieldName($p_str_FieldID);
$p_arr_Return["value"] = esc_attr($this->getFieldValue($p_str_FieldID));
return $p_arr_Return;
}
/**
* access settings field by name
* @since 1.0
* @param string $p_str_FieldName
* @return string
*/
protected function getFieldName($p_str_FieldName) {
// general setting
if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_GENERAL) {
return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName);
// custom setting
} else if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_CUSTOM) {
return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER_CUSTOM, $p_str_FieldName);
}
// undefined
return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName);
}
/**
* access settings field by id
* @since 1.0
* @param string $p_str_FieldID
* @return string
*/
protected function getFieldID($p_str_FieldID) {
return sprintf( '%s', $p_str_FieldID );
}
/**
* get settings field value
* @since 1.0
* @param string $p_str_Key
* @return string
*/
protected function getFieldValue($p_str_Key) {
return $this->a_arr_Options[$p_str_Key];
}
/**
* outputs a break to have a new line
* @since 1.0.7
*/
public function AddNewline() {
echo '<br/><br/>';
}
/**
* outputs a simple text
* @param string $p_str_Text
* @since 1.1.1
*/
public function AddText($p_str_Text) {
echo '<span>' . $p_str_Text . '</span>';
}
/**
* outputs a simple text with some highlight
* @param string $p_str_Text+
* @return string
* @since 1.1.1
*/
public function Highlight($p_str_Text) {
return '<b>' . $p_str_Text . '</b>';
}
/**
* outputs a label for a specific input/select box
* @param string $p_str_SettingsID
* @param string $p_str_Caption
* @param string $p_str_Styling
* @since 1.0.7
*/
public function AddLabel($p_str_SettingsID, $p_str_Caption, $p_str_Styling = "") {
// add styling tag if styling is set
if (!empty($p_str_Styling)) {
$p_str_Styling = ' style="' . $p_str_Styling . '"';
}
echo '<label for="' . $p_str_SettingsID . '"' . $p_str_Styling . '>' . $p_str_Caption . '</label>';
}
/**
* outputs a input type=text
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [css class name]
* @param int $p_str_MaxLength [max length for the input value]
* @param bool $p_bool_Readonly [input is readonly] in version 1.1.1
* @param bool $p_bool_Hidden [input is hidden by default] in version 1.1.2
* @since 1.0-beta
* removed optional parameter for a label in version 1.0.7
*/
public function AddTextbox($p_str_SettingsID, $p_str_ClassName = "", $p_str_MaxLength = 0, $p_bool_Readonly = false, $p_bool_Hidden = false) {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// optional add a max length to the input field
if (!empty($p_str_MaxLength)) {
$p_str_MaxLength = ' maxlength="' . $p_str_MaxLength . '"';
}
if ($p_bool_Readonly) {
$p_bool_Readonly = ' readonly="readonly"';
}
if ($p_bool_Hidden) {
$p_bool_Hidden = ' style="display:none;"';
}
// outputs an input field type TEXT
echo '<input type="text" ' . $p_str_ClassName . $p_str_MaxLength . $p_bool_Readonly . $p_bool_Hidden . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" value="' . $l_arr_Data["value"] . '"/>';
}
/**
* outputs a input type=checkbox
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
public function AddCheckbox($p_str_SettingsID, $p_str_ClassName = "") {
require_once(dirname(__FILE__) . "/convert.php");
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// lookup if the checkbox shall be pre-checked
$l_str_Checked = "";
if (MCI_Footnotes_Convert::toBool($l_arr_Data["value"])) {
$l_str_Checked = 'checked="checked"';
}
// outputs an input field type CHECKBOX
echo sprintf('<input type="checkbox" ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" %s/>', $l_str_Checked);
}
/**
* outputs a select box
* @param string $p_str_SettingsID [id of the settings field]
* @param array $p_arr_Options [array with options]
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
public function AddSelect($p_str_SettingsID, $p_arr_Options, $p_str_ClassName = "") {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// select starting tag
$l_str_Output = '<select ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '">';
// loop through all array keys
foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) {
if (!is_string($l_str_Value)) {
$l_str_Value = (string)$l_str_Value;
}
// add key as option value
$l_str_Output .= '<option value="' . $l_str_Value . '"';
// check if option value is set and has to be pre-selected
if ($l_arr_Data["value"] == $l_str_Value) {
$l_str_Output .= ' selected';
}
// write option caption and close option tag
$l_str_Output .= '>' . $l_str_Caption . '</option>';
}
// close select
$l_str_Output .= '</select>';
// outputs the SELECT field
echo $l_str_Output;
}
/**
* outputs a textarea
* @param string $p_str_SettingsID [id of the settings field]
* @param int $p_int_Rows [amount of rows]
* @param string $p_str_ClassName [css class name]
* @since 1.3
*/
public function AddTextarea($p_str_SettingsID, $p_int_Rows, $p_str_ClassName = "") {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// outputs an input field type TEXT
echo '<textarea ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" rows="'.$p_int_Rows.'">' . $l_arr_Data["value"] . '</textarea>';
}
}// class MCI_Footnotes_Admin
endif;

View file

@ -1,119 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.6
* Since: 1.0
*/
// define class only once
if (!class_exists( "MCI_Footnotes" )) :
/**
* Class MCI_Footnotes
* @since 1.0
*/
class MCI_Footnotes {
// object to the plugin settings
// @since 1.0
// @var MCI_Footnotes_Admin $a_obj_Settings
private $a_obj_Admin;
// replace task object
/** @var \MCI_Footnotes_Task $a_obj_Task */
public $a_obj_Task;
/**
* @constructor
* @since 1.0
*/
public function __construct() {
// load plugin widget
require_once(dirname( __FILE__ ) . "/widget.php");
// register footnotes widget
add_action('widgets_init', create_function('', 'return register_widget("MCI_Footnotes_Widget");'));
// load public css and javascript files
add_action('init', array($this, 'LoadScriptsAndStylesheets'));
// adds javascript and stylesheets to the public page
add_action('wp_enqueue_scripts', array($this, 'LoadScriptsAndStylesheets'));
// load plugin widget
require_once(dirname( __FILE__ ) . "/task.php");
$this->a_obj_Task = new MCI_Footnotes_Task();
$this->a_obj_Task->Register();
}
/**
* draw the dashboard setting
*/
public function generateLayout() {
// load plugin settings
require_once(dirname( __FILE__ ) . "/admin.php");
$this->a_obj_Admin = new MCI_Footnotes_Admin();
}
/**
* activates the plugin
* @since 1.0
*/
public static function activate() {
// unused
}
/**
* deactivates the plugin
* @since 1.0
*/
public static function deactivate() {
// unused
}
/**
* uninstalls the plugin
* updated file path in version 1.0.6
* @since 1.0
*/
public static function uninstall() {
// 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(FOOTNOTES_SETTINGS_CONTAINER);
delete_option(FOOTNOTES_SETTINGS_CONTAINER_CUSTOM);
}
/**
* load public styling and client function
* called in class constructor @ init
* @since 1.0
*/
public function LoadScriptsAndStylesheets() {
// register public stylesheets
wp_register_style('MCI_Footnotes_public_style_General', plugins_url('../css/footnotes.css', __FILE__));
wp_register_style('MCI_Footnotes_public_style_Tooltip', plugins_url('../css/tooltip.css', __FILE__));
wp_register_style('MCI_Footnotes_public_style_ReferenceContainer', plugins_url('../css/reference_container.css', __FILE__));
// add public stylesheets
wp_enqueue_style('MCI_Footnotes_public_style_General');
wp_enqueue_style('MCI_Footnotes_public_style_Tooltip');
wp_enqueue_style('MCI_Footnotes_public_style_ReferenceContainer');
// add the jQuery plugin (already registered by WP)
wp_enqueue_script('jquery');
// add jquery tools to public page
wp_enqueue_script('footnotes_public_script', plugins_url('../js/jquery.tools.min.js', __FILE__), array());
}
} // class MCI_Footnotes
endif;

View file

@ -1,127 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 10:53
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Tab_Custom")) :
/**
* Class MCI_Footnotes_Tab_Custom
* @since 1.3
*/
class MCI_Footnotes_Tab_Custom extends MCI_Footnotes_Admin {
/**
* register the meta boxes for the tab
* @constructor
* @since 1.3
* @param array $p_arr_Tabs
*/
public function __construct(&$p_arr_Tabs) {
// add tab to the tab array
$p_arr_Tabs[FOOTNOTES_SETTINGS_TAB_CUSTOM] = __("Customize", FOOTNOTES_PLUGIN_NAME);
// register settings tab
add_settings_section(
"MCI_Footnotes_Settings_Section_Custom",
"&nbsp;",
array($this, 'Description'),
FOOTNOTES_SETTINGS_TAB_CUSTOM
);
// superscript
add_meta_box(
'MCI_Footnotes_Tab_Custom_Superscript',
__("Superscript layout", FOOTNOTES_PLUGIN_NAME),
array($this, 'Superscript'),
FOOTNOTES_SETTINGS_TAB_CUSTOM,
'main'
);
// symbol hyperlink to footnotes index
add_meta_box(
'MCI_Footnotes_Tab_Custom_HyperlinkSymbol',
__("Hyperlink symbol in the Reference container", FOOTNOTES_PLUGIN_NAME),
array($this, 'HyperlinkSymbol'),
FOOTNOTES_SETTINGS_TAB_CUSTOM,
'main'
);
// custom css
add_meta_box(
'MCI_Footnotes_Tab_Custom_Customize',
__("Add custom CSS to the public page", FOOTNOTES_PLUGIN_NAME),
array($this, 'CSS'),
FOOTNOTES_SETTINGS_TAB_CUSTOM,
'main'
);
}
/**
* output a description for the tab
* @since 1.3
*/
public function Description() {
// unused
}
/**
* footnotes layout before and after the index in text
* @since 1.3.1
*/
public function Superscript() {
// setting for 'before footnotes'
$this->AddLabel(FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE, __("Before Footnotes index:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE, "footnote_plugin_50");
$this->AddNewline();
// setting for 'after footnotes'
$this->AddLabel(FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER, __("After Footnotes index:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER, "footnote_plugin_50");
$this->AddNewline();
}
/**
* layout of the hyperlink symbol to jump to the footnotes index inside post
* @since 1.3.2
* @return void
*/
public function HyperlinkSymbol() {
// load convert class
require_once(dirname(__FILE__) . "/convert.php");
$this->AddLabel(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL, __("Hyperlink symbol:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL, MCI_Footnotes_Convert::getArrow(), "footnote_plugin_15");
$this->AddNewline();
$this->AddLabel(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER, __("or enter a user defined symbol:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER, "footnote_plugin_15");
$this->AddText("&nbsp;&nbsp;&nbsp;");
$this->AddText("<i>" . __("if set it overrides the hyperlink symbol above", FOOTNOTES_PLUGIN_NAME) . "</i>");
}
/**
* customize css box for public page
* @since 1.3
*/
public function CSS() {
$l_str_Separator = " &rArr; ";
// setting for 'reference label'
$this->AddLabel(FOOTNOTES_INPUT_CUSTOM_CSS, __("Add custom CSS:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextarea(FOOTNOTES_INPUT_CUSTOM_CSS, 12, "footnote_plugin_100");
$this->AddNewline();
$this->AddText($this->Highlight(gettext("Available CSS classes to customize the footnotes and the reference container:")) . "<br/>");
echo "<blockquote>";
$this->AddText($this->Highlight(".footnote_plugin_tooltip_text") . $l_str_Separator . gettext("inline footnotes") . "<br/>");
$this->AddText($this->Highlight(".footnote_tooltip") . $l_str_Separator . gettext("inline footnotes, mouse over highlight box") . "<br/><br/>");
$this->AddText($this->Highlight(".footnote_plugin_index") . $l_str_Separator . gettext("reference container footnotes index") . "<br/>");
$this->AddText($this->Highlight(".footnote_plugin_link") . $l_str_Separator . gettext("reference container footnotes linked arrow") . "<br/>");
$this->AddText($this->Highlight(".footnote_plugin_text") . $l_str_Separator . gettext("reference container footnotes text"));
echo "</blockquote>";
}
} // class MCI_Footnotes_Tab_Custom
endif;

View file

@ -1,119 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 07.09.14 02:53
* Since: 1.4.0
*/
// define class only once
if (!class_exists("MCI_Footnotes_Tab_Diagnostics")) :
/**
* Class MCI_Footnotes_Tab_Diagnostics
* @since 1.4.0
*/
class MCI_Footnotes_Tab_Diagnostics extends MCI_Footnotes_Admin {
/**
* register the meta boxes for the tab
* @constructor
* @since 1.4.0
* @param array $p_arr_Tabs
*/
public function __construct(&$p_arr_Tabs) {
// add tab to the tab array
$p_arr_Tabs[FOOTNOTES_SETTINGS_TAB_DIAGNOSTICS] = __("Diagnostics", FOOTNOTES_PLUGIN_NAME);
// register settings tab
add_settings_section(
"MCI_Footnotes_Settings_Section_Diagnostics",
"&nbsp;",
array($this, 'Description'),
FOOTNOTES_SETTINGS_TAB_DIAGNOSTICS
);
// help
add_meta_box(
'MCI_Footnotes_Tab_Diagnostics_Display',
__("Displays information about the web server, PHP and WordPress.", FOOTNOTES_PLUGIN_NAME),
array($this, 'Display'),
FOOTNOTES_SETTINGS_TAB_DIAGNOSTICS,
'main'
);
}
/**
* output a description for the tab
* @since 1.4.0
*/
public function Description() {
// unused
}
/**
* outputs the diagnostics
* @since 1.4.0
*/
public function Display() {
global $wp_version;
echo '<table style="width: 100%;">';
echo '<tbody>';
// website
echo '<tr>';
echo '<td style="vertical-align:top; width: 20%;">' . $this->Highlight(__('Server name', FOOTNOTES_PLUGIN_NAME)) . '</td>';
echo '<td>' . $_SERVER["SERVER_NAME"] . '</td>';
echo '</tr>';
// PHP version
echo '<tr>';
echo '<td>' . $this->Highlight(__('PHP version', FOOTNOTES_PLUGIN_NAME)) . '</td>';
echo '<td>' . phpversion() . '</td>';
echo '</tr>';
// max. execution time
echo '<tr>';
echo '<td>' . $this->Highlight(__('Max execution time', FOOTNOTES_PLUGIN_NAME)) . '</td>';
echo '<td>' . ini_get('max_execution_time') . ' ' . __('seconds', FOOTNOTES_PLUGIN_NAME) . '</td>';
echo '</tr>';
// memory limit
echo '<tr>';
echo '<td>' . $this->Highlight(__('Memory limit', FOOTNOTES_PLUGIN_NAME)) . '</td>';
echo '<td>' . ini_get('memory_limit') . '</td>';
echo '</tr>';
// PHP extensions
echo '<tr>';
echo '<td>' . $this->Highlight(__('PHP extensions', FOOTNOTES_PLUGIN_NAME)) . '</td>';
echo '<td>';
foreach (get_loaded_extensions() as $l_int_Index => $l_str_Extension) {
if ($l_int_Index > 0) {
echo ' | ';
}
echo $l_str_Extension . ' ' . phpversion($l_str_Extension);
}
echo '</td>';
echo '</tr>';
// WordPress version
echo '<tr>';
echo '<td>' . $this->Highlight(__('WordPress version', FOOTNOTES_PLUGIN_NAME)) . '</td>';
echo '<td>' . $wp_version . '</td>';
echo '</tr>';
// WordPress Plugins installed
foreach (get_plugins() as $l_arr_Plugin) {
echo '<tr>';
echo '<td>' . $this->Highlight($l_arr_Plugin["Name"]) . '</td>';
echo '<td>' . $l_arr_Plugin["Version"] . ' [' . $l_arr_Plugin["PluginURI"] . ']' . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
} // class MCI_Footnotes_Tab_Diagnostics
endif;

View file

@ -1,190 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 10:37
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Tab_General")) :
/**
* Class MCI_Footnotes_Tab_General
* @since 1.3
*/
class MCI_Footnotes_Tab_General extends MCI_Footnotes_Admin {
/**
* register the meta boxes for the tab
* @constructor
* @since 1.3
* @param array $p_arr_Tabs
*/
public function __construct(&$p_arr_Tabs) {
// add tab to the tab array
$p_arr_Tabs[FOOTNOTES_SETTINGS_TAB_GENERAL] = __("General", FOOTNOTES_PLUGIN_NAME);
// register settings tab
add_settings_section(
"MCI_Footnotes_Settings_Section_General",
sprintf(__("%s Settings", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
array($this, 'Description'),
FOOTNOTES_SETTINGS_TAB_GENERAL
);
// reference container
add_meta_box(
'MCI_Footnotes_Tab_General_ReferenceContainer',
__("References Container", FOOTNOTES_PLUGIN_NAME),
array($this, 'ReferenceContainer'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
// styling
add_meta_box(
'MCI_Footnotes_Tab_General_Styling',
sprintf(__("%s styling", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
array($this, 'Styling'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
// love
add_meta_box(
'MCI_Footnotes_Tab_General_Love',
FOOTNOTES_PLUGIN_PUBLIC_NAME . '&nbsp;' . FOOTNOTES_LOVE_SYMBOL,
array($this, 'Love'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
// other
add_meta_box(
'MCI_Footnotes_Tab_General_Other',
__("Other", FOOTNOTES_PLUGIN_NAME),
array($this, 'Other'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
}
/**
* output a description for the tab
* @since 1.3
*/
public function Description() {
// unused
}
/**
* output the setting fields for the reference container
* @since 1.3
*/
public function ReferenceContainer() {
// setting for 'reference label'
$this->AddLabel(FOOTNOTES_INPUT_REFERENCES_LABEL, __("References label:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTES_INPUT_REFERENCES_LABEL, "footnote_plugin_50");
$this->AddNewline();
// setting for 'collapse reference container by default'
$this->AddLabel(FOOTNOTES_INPUT_COLLAPSE_REFERENCES, __("Collapse references by default:", FOOTNOTES_PLUGIN_NAME));
$this->AddCheckbox(FOOTNOTES_INPUT_COLLAPSE_REFERENCES);
$this->AddNewline();
// setting for 'placement of the reference container'
// @since 1.0.7
$l_arr_Options = array(
"footer" => __("in the footer", FOOTNOTES_PLUGIN_NAME),
"post_end" => __("at the end of the post", FOOTNOTES_PLUGIN_NAME),
"widget" => __("in the widget area", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE, __("Where shall the reference container appear:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE, $l_arr_Options, "footnote_plugin_50");
}
/**
* output the setting fields for the footnotes styling
* @since 1.3
*/
public function Styling() {
// setting for 'combine identical footnotes'
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_COMBINE_IDENTICAL, __("Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_COMBINE_IDENTICAL, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
// setting for 'footnote tag starts with'
$l_arr_Options = array(
"((" => "((",
"<fn>" => htmlspecialchars("<fn>"),
"[ref]" => "[ref]",
"userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_START, __("Footnote tag starts with:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_PLACEHOLDER_START, $l_arr_Options, "footnote_plugin_15");
// setting for 'footnote tag ends with'
$l_arr_Options = array(
"))" => "))",
"</fn>" => htmlspecialchars("</fn>"),
"[/ref]" => "[/ref]",
"userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_END, __("and ends with:", FOOTNOTES_PLUGIN_NAME) . '&nbsp;&nbsp;&nbsp;', 'text-align: right;');
$this->AddSelect(FOOTNOTES_INPUT_PLACEHOLDER_END, $l_arr_Options, "footnote_plugin_15");
$this->AddNewline();
// user defined setting for 'footnote start and end tag'
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED, "");
$this->AddTextbox(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED, "footnote_plugin_15", 14, false, true);
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED, "");
$this->AddTextbox(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED, "footnote_plugin_15", 14, false, true);
$this->AddNewline();
// setting for 'footnotes counter style'
$l_str_Space = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$l_arr_Options = array(
"arabic_plain" => __("Arabic Numbers - Plain", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, ...",
"arabic_leading" => __("Arabic Numbers - Leading 0", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, ...",
"latin_low" => __("Latin Character - lower case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, ...",
"latin_high" => __("Latin Character - upper case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, ...",
"romanic" => __("Roman Numerals", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, ..."
);
$this->AddLabel(FOOTNOTES_INPUT_COUNTER_STYLE, __('Counter style:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50");
}
/**
* output the setting fields to love and share the footnotes plugin
* @since 1.3
*/
public function Love() {
// setting for 'love and share this plugin in my footer'
$l_arr_Options = array(
"text-1" => sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME),
"text-2" => sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
"text-3" => sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
"random" => __('random text', FOOTNOTES_PLUGIN_NAME),
"no" => sprintf(__("Don't display a %s %s text in my footer.", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME, FOOTNOTES_LOVE_SYMBOL)
);
$this->AddLabel(FOOTNOTES_INPUT_LOVE, sprintf(__("Tell the world you're using %s:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME));
$this->AddSelect(FOOTNOTES_INPUT_LOVE, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
// no 'love me' on specific pages
$this->AddText(sprintf(__("Don't tell the world you're using %s on specific pages by adding the following short code:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME));
$this->AddText("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
$this->AddText(FOOTNOTES_NO_SLUGME_PLUG);
}
/**
* output settings fields with no specific topic
* @since 1.3
*/
public function Other() {
// setting for 'search footnotes tag in excerpt'
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_SEARCH_IN_EXCERPT, __('Allow footnotes on Summarized Posts:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_50");
}
} // class MCI_Footnotes_Tab_General
endif;

View file

@ -1,119 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 10:53
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Tab_HowTo")) :
/**
* Class MCI_Footnotes_Tab_HowTo
* @since 1.3
*/
class MCI_Footnotes_Tab_HowTo extends MCI_Footnotes_Admin {
/**
* register the meta boxes for the tab
* @constructor
* @since 1.3
* @param array $p_arr_Tabs
*/
public function __construct(&$p_arr_Tabs) {
// add tab to the tab array
$p_arr_Tabs[FOOTNOTES_SETTINGS_TAB_HOWTO] = __("How to", FOOTNOTES_PLUGIN_NAME);
// register settings tab
add_settings_section(
"MCI_Footnotes_Settings_Section_HowTo",
"&nbsp;",
array($this, 'Description'),
FOOTNOTES_SETTINGS_TAB_HOWTO
);
// help
add_meta_box(
'MCI_Footnotes_Tab_HowTo_Help',
__("Brief introduction in how to use the plugin", FOOTNOTES_PLUGIN_NAME),
array($this, 'Help'),
FOOTNOTES_SETTINGS_TAB_HOWTO,
'main'
);
// donate
add_meta_box(
'MCI_Footnotes_Tab_HowTo_Donate',
__("Help us to improve our Plugin.", FOOTNOTES_PLUGIN_NAME),
array($this, 'Donate'),
FOOTNOTES_SETTINGS_TAB_HOWTO,
'main'
);
}
/**
* output a description for the tab
* @since 1.3
*/
public function Description() {
// unused
}
/**
* outputs the help box
* @since 1.3
*/
public function Help() {
global $g_obj_MCI_Footnotes;
// load footnotes starting and end tag
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_START);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_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(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED);
}
$l_str_Example = "Hello" . $l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"] . " World!";
?>
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __("Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span class="footnote_highlight_placeholder">
<?php echo $l_arr_Footnote_StartingTag["value"]; ?>
</span>
</p>
<p>
<?php echo __("...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span class="footnote_highlight_placeholder">
<?php echo $l_arr_Footnote_EndingTag["value"]; ?>
</span>
</p>
<div class="footnote_placeholder_box_example">
<p>
<span class="footnote_highlight_placeholder"><?php echo $l_str_Example; ?></span>
<?php echo __("will be displayed as:", FOOTNOTES_PLUGIN_NAME); ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo $g_obj_MCI_Footnotes->a_obj_Task->exec($l_str_Example, true); ?>
</p>
</div>
<p>
<?php echo sprintf(__("For further information please check out our %ssupport forum%s on WordPress.org.", FOOTNOTES_PLUGIN_NAME), '<a href="http://wordpress.org/support/plugin/footnotes" target="_blank" class="footnote_plugin">', '</a>'); ?>
</p>
</div>
</div>
<?php
}
/**
* outputs the diagnostics
* @since 1.4.0
*/
public function Donate() {
$l_str_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ";
echo '<input type="button" class="button button-primary" value="'.__('Donate now',FOOTNOTES_PLUGIN_NAME).'" onclick="window.open(\''.$l_str_Url.'\');" />';
}
} // class MCI_Footnotes_Tab_HowTo
endif;

View file

@ -1,394 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 12:07
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Task")) :
/**
* Class MCI_Footnotes_Task
* @since 1.3
*/
class MCI_Footnotes_Task {
// array containing the settings
public $a_arr_Settings = array();
// bool admin allows the Love Me slug
public static $a_bool_AllowLoveMe = true;
// array containing all found footnotes
public static $a_arr_Footnotes = array();
/**
* @constructor
* @since 1.3
*/
public function __construct() {
require_once(dirname( __FILE__ ) . "/admin.php");
// load footnote settings
$this->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() {
?>
<style type="text/css" media="screen"><?php echo $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_CSS]; ?></style>
<?php
// reset stored footnotes when displaying the header
self::$a_arr_Footnotes = array();
}
/**
* replaces footnotes tags in the post content
* @since 1.3
* @param string $p_str_Content
* @return string
*/
public function Content($p_str_Content) {
// returns content
return $this->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 '<div style="text-align:center; color:#acacac;">' . $l_str_LoveMeText . '</div>';
}
/**
* 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 = '&nbsp;&nbsp;&nbsp;[ <a id="footnote_reference_container_collapse_button" style="cursor:pointer;" onclick="footnote_expand_collapse_reference_container();">+</a> ]';
}
// output string, prepare it with the reference label as headline
$l_str_Output = '<div class="footnote_container_prepare"><p><span onclick="footnote_expand_reference_container();">' . $l_str_ReferencesLabel . '</span><span>' .$l_str_CollapseButtons . '</span></p></div>';
// add a box around the footnotes
$l_str_Output .= '<div id="' . FOOTNOTES_REFERENCES_CONTAINER_ID . '"';
// add class to hide the references by default, if the user wants it
if ($l_bool_CollapseReference) {
$l_str_Output .= ' class="footnote_hide_box"';
}
$l_str_Output .= '>';
// contains the footnote template
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "container.html");
// 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), $l_str_CounterStyle);
// check if it isn't the last footnote in the array
if ($l_str_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && $l_bool_CombineIdentical) {
// 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), $l_str_CounterStyle);
}
}
}
// add the footnote to the output box
// added function to convert the counter style in the reference container (bugfix for the link to the footnote) in version 1.0.6
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX SHORT]]", MCI_Footnotes_Convert::Index($l_str_FirstFootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate);
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", $l_str_FootnoteIndex, $l_str_ReplaceText);
$l_str_ReplaceText = str_replace("[[HYPERLINK SYMBOL]]", $l_str_HyperlinkSymbol, $l_str_ReplaceText);
$l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText);
$l_str_ReplaceText = preg_replace('@[\s]{2,}@',' ',$l_str_ReplaceText);
// add the footnote container to the output
$l_str_Output .= $l_str_ReplaceText;
}
// add closing tag for the div of the references container
$l_str_Output .= '</div>';
// add a javascript to expand the reference container when clicking on a footnote or the reference label
$l_str_Output .= '
<script type="text/javascript">
function footnote_expand_reference_container(p_str_ID) {
jQuery("#' . FOOTNOTES_REFERENCES_CONTAINER_ID . '").show();
if (p_str_ID.length > 0) {
jQuery(p_str_ID).focus();
}
}
function footnote_expand_collapse_reference_container() {
var l_obj_ReferenceContainer = jQuery("#' . FOOTNOTES_REFERENCES_CONTAINER_ID . '");
if (l_obj_ReferenceContainer.is(":hidden")) {
l_obj_ReferenceContainer.show();
jQuery("#footnote_reference_container_collapse_button").text("-");
} else {
l_obj_ReferenceContainer.hide();
jQuery("#footnote_reference_container_collapse_button").text("+");
}
}
</script>
';
// free all found footnotes if reference container will be displayed
self::$a_arr_Footnotes = array();
// return the output string
return $l_str_Output;
}
} // class MCI_Footnotes_Task
endif;

View file

@ -1,70 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: Stefan
* Date: 24.05.14
* Time: 13:57
*/
// define class only once
if (!class_exists("MCI_Footnotes_Widget")) :
/**
* Class MCI_Footnotes_Widget
* @since 1.0
*/
class MCI_Footnotes_Widget extends WP_Widget {
/**
* @constructor
*/
public function __construct() {
// set widget class and description
$l_arr_WidgetMeta = array(
'classname' => 'Class_FootnotesWidget',
'description' => __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME)
);
// set widget layout information
$l_arr_WidgetLayout = array(
'width' => 300,
'height' => 350,
'id_base' => 'footnotes_widget'
);
// add widget to the list
$this->WP_Widget('footnotes_widget', FOOTNOTES_PLUGIN_NAME, $l_arr_WidgetMeta, $l_arr_WidgetLayout);
}
/**
* widget form creation
* @param $instance
* @return void
*/
public function form($instance) {
echo __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME);
}
/**
* widget update
* @param $new_instance
* @param $old_instance
* @return mixed
*/
public function update($new_instance, $old_instance) {
return $new_instance;
}
/**
* widget display
* @param $args
* @param $instance
*/
public function widget($args, $instance) {
global $g_obj_MCI_Footnotes;
// reference container positioning is set to "widget area"
if ($g_obj_MCI_Footnotes->a_obj_Task->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "widget") {
echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer();
}
}
} // class MCI_Footnotes_Widget
endif;

View file

@ -39,46 +39,28 @@
.footnote_container_prepare > p > span:last-child {
}
/* container for the footnote in the bottom */
.footnote_plugin_container {
display: block !important;
width: 100% !important;
padding-bottom: 14px !important;
}
/* footnote (bottom) index */
.footnote_plugin_index {
/*float: left !important;*/
min-width: 40px !important;
white-space: nowrap !important;
text-align: right !important;
display: inline-block;
}
/* footnote (bottom) text */
.footnote_plugin_text {
/*float: left !important;*/
padding-left: 16px !important;
display: inline;
}
/* footnote (bottom) link to the footnote implementation */
.footnote_plugin_link {
outline: none !important;
text-decoration: none !important;
cursor: pointer !important;
}
.footnote_plugin_link:hover {
/*color: #4777ff !important;*/
text-decoration: none !important;
}
/* footnote (bottom) styling end tag */
.footnote_plugin_end {
/*clear: left !important;*/
}
.footnote_hide_box {
display: none;
}
.footnote-reference-container {
width: 100%;
border: none;
}
.footnote-reference-container > tbody > tr > td:first-child {
white-space: nowrap;
padding-right: 5px;
text-align: left;
}
.footnote-reference-container > tbody > tr > td:nth-child(2) {
white-space: nowrap;
padding-right: 5px;
text-align: left;
}
.footnote-reference-container > tbody > tr > td:last-child {
width: 99%;
text-align: left;
}

View file

@ -8,71 +8,41 @@
*/
input[type=text], input[type=password], textarea, select {
padding-left: 8px !important;
padding-right: 8px !important;
padding-left: 8px !important;
padding-right: 8px !important;
width: 80% !important;
}
textarea {
height: 250px;
}
label {
width: 20% !important;
display: inline-block;
display: inline-block;
}
/*
* layout for the meta box container
* @since 1.0.7
*/
.postbox > h3 {
height: 32px !important;
line-height: 32px !important;
height: 32px !important;
line-height: 32px !important;
}
.postbox > h3 > span {
padding-left: 10px;
padding-left: 10px;
}
/* overwrite link layout on the settings page */
a.footnote_plugin {
text-decoration: underline !important;
cursor: pointer !important;
color: #202020 !important;
.postbox > .inside > table {
border: none !important;
}
/* setting with 15% width */
.footnote_plugin_15 {
width: 15% !important;
.postbox > .inside >table > tbody > tr > td:first-child {
width: 15% !important;
font-weight: bold !important;
}
/* setting with 25% width */
.footnote_plugin_25 {
width: 25% !important;
}
/* setting with half width */
.footnote_plugin_50 {
width: 50% !important;
}
/* setting with 75% width */
.footnote_plugin_75 {
width: 75% !important;
}
/* setting with full width */
.footnote_plugin_100 {
width: 100% !important;
}
/* container for the box holding the placeholder tags at the end */
.footnote_placeholder_box_container {
text-align: center !important;
/*width: auto;
display: inline-block;
padding-left: 20px;
padding-right: 20px;
margin-left: -210px;*/
}
/* highlight the placeholders */
span.footnote_highlight_placeholder {
font-weight: bold !important;
padding-left: 8px !important;
@ -87,4 +57,5 @@ span.footnote_highlight_placeholder {
width: 50% !important;
display: block !important;
margin: 20px auto !important;
text-align: center !important;
}

37
includes.php Normal file
View file

@ -0,0 +1,37 @@
<?php
/**
* Includes all common files.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 13:40
*/
/**
* Requires (require_once) all *.php files inside a specific Directory.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_Directory Absolute Directory path to lookup for *.php files
*/
function requirePhpFiles($p_str_Directory) {
// append slash at the end of the Directory if not exist
if (substr($p_str_Directory, -1) != "/") {
$p_str_Directory .= "/";
}
// get all PHP files inside Directory
$l_arr_Files = scandir($p_str_Directory);
// iterate through each class
foreach ($l_arr_Files as $l_str_FileName) {
// skip all non *.php files
if (strtolower(substr($l_str_FileName, -4)) != ".php") {
continue;
}
/** @noinspection PhpIncludeInspection */
require_once($p_str_Directory . $l_str_FileName);
}
}
requirePhpFiles(dirname(__FILE__) . "/class");
requirePhpFiles(dirname(__FILE__) . "/class/dashboard");
requirePhpFiles(dirname(__FILE__) . "/class/widgets");

View file

@ -1,66 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0-beta
* Since: 1.0
*/
// PLUGIN INTERNAL NAME
define("FOOTNOTES_PLUGIN_NAME", "footnotes");
// PLUGIN PUBLIC NAME WITH STYLING
// @since 1.0.7
define("FOOTNOTES_PLUGIN_PUBLIC_NAME", '<span class="footnote_tag_styling footnote_tag_styling_1">foot</span><span class="footnote_tag_styling footnote_tag_styling_2">notes</span>');
// PLUGIN PUBLIC NAME WITH STYLING AND LINK
// @since 1.2.2
define("FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED", '<a href="http://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">' . FOOTNOTES_PLUGIN_PUBLIC_NAME . '</a>');
// PLUGIN LOVE SYMBOL WITH STYLING
// @since 1.2.2
define("FOOTNOTES_LOVE_SYMBOL", '<span style="color:#ff6d3b; font-weight:bold;">&hearts;</span>');
// PLUGIN DIRECTORIES
define("FOOTNOTES_PLUGIN_DIR_NAME", "footnotes");
define("FOOTNOTES_LANGUAGE_DIR", dirname(__FILE__) . "/../languages/");
define("FOOTNOTES_TEMPLATES_DIR", dirname(__FILE__) . "/../templates/");
// SETTINGS CONTAINER
define("FOOTNOTES_SETTINGS_CONTAINER", "footnotes_storage"); // database container where all footnote settings are stored
define("FOOTNOTES_SETTINGS_CONTAINER_CUSTOM", "footnotes_storage_custom"); // database container where all 'custom' settings are stored
// PLUGIN SETTINGS PAGE
define("FOOTNOTES_SETTINGS_PAGE_ID", "footnotes"); // plugins setting page internal id
// PLUGIN SETTINGS PAGE TABS
define("FOOTNOTES_SETTINGS_TAB_GENERAL", "footnotes_general_settings"); // internal label for the plugins general settings tab
define("FOOTNOTES_SETTINGS_TAB_CUSTOM", "footnotes_custom_settings"); // internal label for the plugins custom settings tab
define("FOOTNOTES_SETTINGS_TAB_HOWTO", "footnotes_howto_settings"); // internal label for the plugins how to tab
define("FOOTNOTES_SETTINGS_TAB_DIAGNOSTICS", "footnotes_diagnostics_settings"); // internal label for the plugins diagnostics tab
// PLUGIN SETTINGS INPUT FIELDS
define("FOOTNOTES_INPUT_COMBINE_IDENTICAL", "footnote_inputfield_combine_identical"); // id of input field for the combine identical setting
define("FOOTNOTES_INPUT_REFERENCES_LABEL", "footnote_inputfield_references_label"); // id of input field for the references label setting
define("FOOTNOTES_INPUT_COLLAPSE_REFERENCES", "footnote_inputfield_collapse_references"); // id of input field for the "collapse references" setting
define("FOOTNOTES_INPUT_PLACEHOLDER_START", "footnote_inputfield_placeholder_start"); // id of input field for the "placeholder starting tag" setting
define("FOOTNOTES_INPUT_PLACEHOLDER_END", "footnote_inputfield_placeholder_end"); // id of input field for the "placeholder ending tag" setting
define("FOOTNOTES_INPUT_SEARCH_IN_EXCERPT", "footnote_inputfield_search_in_excerpt"); // id of input field for the "allow footnotes in the excerpt" setting
define("FOOTNOTES_INPUT_LOVE", "footnote_inputfield_love"); // id of input field for "love and share this plugin" setting
define("FOOTNOTES_INPUT_COUNTER_STYLE", "footnote_inputfield_counter_style"); // id of input field for "counter style of footnote index" setting
define("FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE", "footnote_inputfield_reference_container_place"); // id of input field "placement of reference container" setting
define("FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED", "footnote_inputfield_placeholder_start_user_defined"); // id of input field for 'user defined placeholder start tag
define("FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED", "footnote_inputfield_placeholder_end_user_defined"); // id of input field for 'user defined placeholder end tag
define("FOOTNOTES_INPUT_CUSTOM_CSS", "footnote_inputfield_custom_css"); // id of input field for 'custom css' setting
define("FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE", "footnote_inputfield_custom_styling_before"); // id of input field for 'footnotes styling before' setting
define("FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER", "footnote_inputfield_custom_styling_after"); // id of input field for 'footnotes styling after' setting
define("FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL", "footnote_inputfield_custom_hyperlink_symbol"); // id of input field for 'footnotes hyperlink symbol' setting
define("FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER", "footnote_inputfield_custom_hyperlink_symbol_user"); // id of input field for 'footnotes hyperlink symbol' user-defined setting
// PLUGIN REFERENCES CONTAINER ID
define("FOOTNOTES_REFERENCES_CONTAINER_ID", "footnote_references_container"); // id for the div surrounding the footnotes
define("FOOTNOTES_REFERENCE_CONTAINER_POSITION", "[[footnotes reference container position]]");
// PLUGIN PLACEHOLDER TO NOT DISPLAY THE 'LOVE ME' SLUG
// @since 1.1.1
define("FOOTNOTES_NO_SLUGME_PLUG", "[[no footnotes: love]]");

View file

@ -1,55 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
// action to locate language and load the WordPress-specific language file
add_action('plugins_loaded', 'MCI_Footnotes_LoadLanguage');
/**
* loads the language file including localization if exists
* otherwise loads the language file without localization information
* @since 1.0
*/
function MCI_Footnotes_LoadLanguage() {
// read current WordPress language
$l_str_locale = apply_filters('plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME);
// get only language code (removed localization code)
$l_str_languageCode = MCI_Footnotes_getLanguageCode();
// language file with localization exists
$l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_locale . '.mo');
if (empty($l_bool_loaded)) {
// language file without localization exists
$l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_languageCode . '.mo');
if (empty($l_bool_loaded)) {
// fallback to english
load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-en.mo');
}
}
}
/**
* reads the WordPress language and returns only the language code lowercase
* removes the localization code
* @since 1.0
* @return string (only the "en" from "en_US")
*/
function MCI_Footnotes_getLanguageCode() {
// read current WordPress language
$l_str_locale = apply_filters('plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME);
// check if WordPress language has a localization (e.g. "en_US" or "de_AT")
if (strpos($l_str_locale, "_") !== false) {
// remove localization code
$l_arr_languageCode = explode("_", $l_str_locale);
$l_str_languageCode = $l_arr_languageCode[0];
return $l_str_languageCode;
}
// return language code lowercase
return strtolower($l_str_locale);
}

View file

@ -1,117 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0-beta
* Since: 1.0
*/
// add link to the settings page in plugin main page
$l_str_plugin_file = FOOTNOTES_PLUGIN_DIR_NAME . '/index.php';
add_filter("plugin_action_links_{$l_str_plugin_file}", 'MCI_Footnotes_PluginLinks', 10, 2);
/**
* add short links to the plugin main page
* @since 1.0
* @param array $p_arr_Links
* @param string $p_str_File
* @return array
*/
function MCI_Footnotes_PluginLinks($p_arr_Links, $p_str_File) {
// add link to the footnotes plugin settings page
$l_str_Settings = '<a href="' . admin_url('options-general.php?page=' . FOOTNOTES_SETTINGS_PAGE_ID) . '">' . __('Settings', FOOTNOTES_PLUGIN_NAME) . '</a>';
// add link to the footnotes plugin support page on wordpress.org
$l_str_Support = '<a href="http://wordpress.org/support/plugin/footnotes" target="_blank">' . __('Support', FOOTNOTES_PLUGIN_NAME) . '</a>';
// add link to Donate
$l_str_Donate = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ" target="_blank">' . __('Donate', FOOTNOTES_PLUGIN_NAME) . '</a>';
// add defined links to the plugin main page
$p_arr_Links[] = $l_str_Support;
$p_arr_Links[] = $l_str_Settings;
$p_arr_Links[] = $l_str_Donate;
// return new links
return $p_arr_Links;
}
/**
* reads a option field, filters the values and returns the filtered option array
* fallback to default value since 1.0-gamma
* @since 1.0
* @param bool $p_bool_ConvertHtmlChars
* @return array
*/
function MCI_Footnotes_getOptions($p_bool_ConvertHtmlChars = true) {
// default settings for the 'general' settings container
$l_arr_Default_General = array(
FOOTNOTES_INPUT_COMBINE_IDENTICAL => 'yes',
FOOTNOTES_INPUT_REFERENCES_LABEL => 'References',
FOOTNOTES_INPUT_COLLAPSE_REFERENCES => '',
FOOTNOTES_INPUT_PLACEHOLDER_START => '((',
FOOTNOTES_INPUT_PLACEHOLDER_END => '))',
FOOTNOTES_INPUT_SEARCH_IN_EXCERPT => 'yes',
FOOTNOTES_INPUT_LOVE => 'no',
FOOTNOTES_INPUT_COUNTER_STYLE => 'arabic_plain',
FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE => 'post_end',
FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED => '',
FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED => ''
);
// default settings for the 'custom' settings container
$l_arr_Default_Custom = array(
FOOTNOTES_INPUT_CUSTOM_CSS => '',
FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE => '',
FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER => ')',
FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL => '&#8593;',
FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER => ''
);
$l_arr_General = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER), $l_arr_Default_General, $p_bool_ConvertHtmlChars);
$l_arr_Custom = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER_CUSTOM), $l_arr_Default_Custom, $p_bool_ConvertHtmlChars);
return array_merge($l_arr_General, $l_arr_Custom);
}
/**
* validate each option, fallback is the default value
* @since 1.3
* @param array $p_arr_Options
* @param array $p_arr_Default
* @param bool $p_bool_ConvertHtmlChars
* @return array
*/
function MCI_Footnotes_ValidateOptions($p_arr_Options, $p_arr_Default, $p_bool_ConvertHtmlChars) {
// if no settings set yet return default values
if (empty($p_arr_Options)) {
return $p_arr_Default;
}
// loop through all keys in the array and filters them
foreach ($p_arr_Options as $l_str_Key => $l_str_Value) {
// removes special chars from the settings value
$l_str_Value = stripcslashes($l_str_Value);
// if set, convert html special chars
if ($p_bool_ConvertHtmlChars) {
$l_str_Value = htmlspecialchars($l_str_Value);
}
// check if settings value is not empty, otherwise load the default value, or empty string if no default is defined
if (!empty($l_str_Value)) {
$p_arr_Options[$l_str_Key] = $l_str_Value;
// check if default value is defined
//} else if (array_key_exists($l_str_Key, $p_arr_Default)) {
// $p_arr_Options[$l_str_Key] = $p_arr_Default[$l_str_Key];
} else {
$p_arr_Options[$l_str_Key] = "";
}
}
// check if each key from the default values exist in return array
foreach($p_arr_Default as $l_str_Key => $l_str_Value) {
// if key not exists, add it with its default value
if (!array_key_exists($l_str_Key, $p_arr_Options)) {
$p_arr_Options[$l_str_Key] = $l_str_Value;
}
}
// returns the filtered array
return $p_arr_Options;
}

View file

@ -1,122 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: Stefan
* Date: 24.05.14
* Time: 14:47
* Version: 1.2.0
* Since: 1.2.0
*/
// add new button to the WYSIWYG - editor
add_filter("mce_buttons", "MCI_Footnotes_wysiwyg_editor_functions");
add_filter("mce_external_plugins", "MCI_Footnotes_wysiwyg_editor_buttons");
// add new button to the plain text editor
add_action("admin_print_footer_scripts", "MCI_Footnotes_text_editor_buttons");
// defines the callback function for the editor buttons
add_action("wp_ajax_nopriv_footnotes_getTags", "MCI_Footnotes_wysiwyg_ajax_callback");
add_action("wp_ajax_footnotes_getTags", "MCI_Footnotes_wysiwyg_ajax_callback");
/**
* adds a new button to the WYSIWYG editor for pages and posts
* @param array $buttons
* @return array
* @since 1.2.0
*/
function MCI_Footnotes_wysiwyg_editor_functions($buttons) {
array_push($buttons, FOOTNOTES_PLUGIN_NAME);
return $buttons;
}
/**
* includes a javascript file to have a on-click function for the new button in the WYSIWYG editor
* @param array $plugin_array
* @return array
* @since 1.2.0
*/
function MCI_Footnotes_wysiwyg_editor_buttons($plugin_array) {
$plugin_array[FOOTNOTES_PLUGIN_NAME] = plugins_url('/../js/wysiwyg-editor.js', __FILE__);
return $plugin_array;
}
/**
* adds a new button to the plain text editor for pages and posts
* @since 1.2.0
*/
function MCI_Footnotes_text_editor_buttons() {
?>
<script type="text/javascript">
/**
* adds a tag in at the beginning and at the end of a selected text in the specific text area
* @param string elementID
* @param string openTag
* @param string closeTag
*/
function MCI_Footnotes_wrapText(elementID, openTag, closeTag) {
var textArea = jQuery('#' + elementID);
var len = textArea.val().length;
var start = textArea[0].selectionStart;
var end = textArea[0].selectionEnd;
var selectedText = textArea.val().substring(start, end);
var replacement = openTag + selectedText + closeTag;
textArea.val(textArea.val().substring(0, start) + replacement + textArea.val().substring(end, len));
}
/**
* adds a new button to the plain text editor
*/
QTags.addButton( 'MCI_Footnotes_QuickTag_button', 'footnotes', MCI_Footnotes_text_editor_callback );
/**
* callback function when the button is clicked
* executes a ajax call to get the start and end tag for the footnotes and
* adds them in before and after the selected text
*/
function MCI_Footnotes_text_editor_callback() {
jQuery.ajax({
type: 'POST',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'footnotes_getTags',
data: ''
},
success: function(data, textStatus, XMLHttpRequest){
var l_arr_Tags = JSON.parse(data);
MCI_Footnotes_wrapText("content", l_arr_Tags['start'], l_arr_Tags['end']);
},
error: function(MLHttpRequest, textStatus, errorThrown){
}
});
}
</script>
<?php
}
/**
* callback function for the WYSIWYG editor button and the plain text editor button
* to get the start and end tag for the footnotes
* echos the tags as json-string ("start" | "end")
*/
function MCI_Footnotes_wysiwyg_ajax_callback() {
require_once(dirname(__FILE__) . "/defines.php");
require_once(dirname(__FILE__) . '/plugin-settings.php');
require_once(dirname(__FILE__) . '/../classes/admin.php');
/* load footnote settings */
$g_arr_FootnotesSettings = MCI_Footnotes_getOptions(true);
/* get footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_START];
/*get footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_END];
if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
/* get user defined footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED];
/*get user defined footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED];
}
echo json_encode(array("start" => $l_str_StartingTag, "end" => $l_str_EndingTag));
exit;
}

View file

@ -4,7 +4,7 @@
Plugin URI: http://wordpress.org/plugins/footnotes/
Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine.
Author: ManFisher Medien ManuFaktur
Version: 1.4.0
Version: 1.5.0
Author URI: http://manfisher.net/plugins/footnotes/
Text Domain: footnotes
Domain Path: /languages
@ -25,48 +25,20 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.1.1
* Since: 1.0
* @filesource
* @author Stefan Herndler
* @since 0.0.1
*/
// include constants
require_once(dirname(__FILE__) . "/includes/defines.php");
// include language functions
require_once(dirname(__FILE__) . "/includes/language.php");
// include storage functions and global plugin functions
require_once(dirname(__FILE__) . "/includes/plugin-settings.php");
// Get all common classes and functions
require_once(dirname(__FILE__) . "/includes.php");
// require plugin class
require_once(dirname( __FILE__ ) . "/classes/footnotes.php");
// initialize an object of the plugin class
global $g_obj_MCI_Footnotes;
// if object isn't initialized yet, initialize it now
if (empty($g_obj_MCI_Footnotes)) {
$g_obj_MCI_Footnotes = new MCI_Footnotes();
}
// generate the settings page in the dashboard settings
$g_obj_MCI_Footnotes->generateLayout();
// register hook for activating the plugin
register_activation_hook(__FILE__, array('MCI_Footnotes', 'activate'));
// register hook for deactivating the plugin
register_deactivation_hook(__FILE__, array('MCI_Footnotes', 'deactivate'));
// only admin is allowed to execute the following functions
if (!function_exists('is_admin')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
exit();
}
// register hook for uninstalling the plugin
register_uninstall_hook(__FILE__, array('MCI_Footnotes', 'uninstall'));
// add Plugin Links to the "installed plugins" page
$l_str_plugin_file = 'footnotes/index.php';
add_filter("plugin_action_links_{$l_str_plugin_file}", array("MCI_Footnotes_Hooks", "PluginLinks"), 10, 2);
// initialize the Plugin
$g_obj_MCI_Footnotes = new MCI_Footnotes();
// run the Plugin
$g_obj_MCI_Footnotes->run();

View file

@ -24,8 +24,7 @@
type: 'POST',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'footnotes_getTags',
data: ''
action: 'footnotes_getTags'
},
success: function(data, textStatus, XMLHttpRequest){
var l_arr_Tags = JSON.parse(data);
@ -62,15 +61,15 @@
*/
getInfo : function() {
return {
longname : 'insert footnotes tag',
author : 'media competence institute',
authorurl : 'http://cheret.co.uk/mci',
longname : 'Inserts the Footnotes short code.',
author : 'ManFisher Medien ManuFaktur',
authorurl : 'http://http://manfisher.net/',
infourl : 'http://wordpress.org/plugins/footnotes/',
version : "1.2.0"
version : "1.5.0"
};
}
});
// Register plugin
tinymce.PluginManager.add( 'footnotes', tinymce.plugins.Footnotes );
tinymce.PluginManager.add('footnotes', tinymce.plugins.Footnotes);
})();

View file

@ -72,6 +72,13 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest**
== Changelog ==
= 1.5.0 =
- Update: Refactored the whole source code
- Add: Grouped the Plugin Settings into a new Menu Page called "ManFisher Plugins"
- Update: Moved the Diagnostics Sections to into a new Sub Page called "Diagnostics"
- Add: Sub Page to list all other Plugins of the Contributors
- Bugfix: Line up Footnotes with multiple lines in the Reference container
= 1.4.0 =
- Feature: WPML Config XML file for easy multi language string translation (WPML String Translation Support File)
- Update: Changed e-Mail support address to the WordPress support forum

View file

@ -1,8 +0,0 @@
<div class="footnote_plugin_container">
<div class="footnote_plugin_index">[[FOOTNOTE INDEX]].</div>
<div class="footnote_plugin_text">
<a class="footnote_plugin_link" href="#footnote_plugin_tooltip_[[FOOTNOTE INDEX SHORT]]"
name="footnote_plugin_reference_[[FOOTNOTE INDEX SHORT]]"
id="footnote_plugin_reference_[[FOOTNOTE INDEX SHORT]]">[[HYPERLINK SYMBOL]]</a>&nbsp;[[FOOTNOTE TEXT]]</div>
<div class="footnote_plugin_end"></div>
</div>

View file

@ -0,0 +1,31 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-css]]</td>
<td>[[css]]</td>
</tr>
<tr>
<td colspan="2">[[headline]]</td>
</tr>
<tr>
<td>[[label-class-1]]</td>
<td>[[class-1]]</td>
</tr>
<tr>
<td>[[label-class-2]]</td>
<td>[[class-2]]</td>
</tr>
<tr>
<td>[[label-class-3]]</td>
<td>[[class-3]]</td>
</tr>
<tr>
<td>[[label-class-4]]</td>
<td>[[class-4]]</td>
</tr>
<tr>
<td>[[label-class-5]]</td>
<td>[[class-1]]</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,12 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-symbol]]</td>
<td>[[symbol]]</td>
</tr>
<tr>
<td>[[label-user-defined]]</td>
<td>[[user-defined]]<br/><i>[[comment]]</i></td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,12 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-before]]</td>
<td>[[before]]</td>
</tr>
<tr>
<td>[[label-after]]</td>
<td>[[after]]</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,29 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-server]]</td>
<td>[[server]]</td>
</tr>
<tr>
<td>[[label-php]]</td>
<td>[[php]]</td>
</tr>
<tr>
<td>[[label-max-execution-time]]</td>
<td>[[max-execution-time]]</td>
</tr>
<tr>
<td>[[label-memory-limit]]</td>
<td>[[memory-limit]]</td>
</tr>
<tr>
<td>[[label-php-extensions]]</td>
<td>[[php-extensions]]</td>
</tr>
<tr>
<td>[[label-wordpress]]</td>
<td>[[wordpress]]</td>
</tr>
[[plugins]]
</tbody>
</table>

View file

@ -0,0 +1,42 @@
<script type="text/javascript">
/**
* adds a tag in at the beginning and at the end of a selected text in the specific text area
* @param string elementID
* @param string openTag
* @param string closeTag
*/
function MCI_Footnotes_wrapText(elementID, openTag, closeTag) {
var textArea = jQuery('#' + elementID);
var len = textArea.val().length;
var start = textArea[0].selectionStart;
var end = textArea[0].selectionEnd;
var selectedText = textArea.val().substring(start, end);
var replacement = openTag + selectedText + closeTag;
textArea.val(textArea.val().substring(0, start) + replacement + textArea.val().substring(end, len));
}
/**
* adds a new button to the plain text editor
*/
QTags.addButton( 'MCI_Footnotes_QuickTag_button', 'footnotes', MCI_Footnotes_text_editor_callback );
/**
* callback function when the button is clicked
* executes a ajax call to get the start and end tag for the footnotes and
* adds them in before and after the selected text
*/
function MCI_Footnotes_text_editor_callback() {
jQuery.ajax({
type: 'POST',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'footnotes_getTags',
data: ''
},
success: function(data, textStatus, XMLHttpRequest){
var l_arr_Tags = JSON.parse(data);
MCI_Footnotes_wrapText("content", l_arr_Tags['start'], l_arr_Tags['end']);
},
error: function(MLHttpRequest, textStatus, errorThrown){
}
});
}
</script>

View file

@ -0,0 +1,2 @@
<input type="button" class="button button-primary" value="[[caption]]"
onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ');" />

View file

@ -0,0 +1,13 @@
<div class="footnote_placeholder_box_container">
[[label-start]]&nbsp;<b>[[start]]</b>
<br/>
[[label-end]]&nbsp;<b>[[end]]</b>
</div>
<div class="footnote_placeholder_box_example">
<span class="footnote_highlight_placeholder">[[example-code]]</span>[[example-string]]&nbsp;&nbsp;&nbsp;&nbsp;[[example]]
</div>
<div style="text-align:center;">
[[information]]
</div>

View file

@ -0,0 +1,42 @@
<div class="plugin-card">
<div class="plugin-card-top">
<div>
<h4><a href="" target="_blank" class="thickbox" id="[[name]]-url">[[title]]</a></h4>
</div>
<div class="action-links">
<ul class="plugin-action-buttons">
<li><a class="install-now button" href="" id="[[name]]-website">Website</a></li>
</ul>
</div>
<div>
<p id="[[name]]-description"></p>
</div>
</div>
<div class="plugin-card-bottom">
<div class="column-updated"><p id="[[name]]-version"></p></div>
</div>
</div>
<script type="text/javascript">
jQuery.ajax({
type: 'POST',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'footnotes_getPluginInfo',
plugin: '[[name]]'
},
dataType: 'json',
success: function (data, textStatus, XMLHttpRequest) {
if (data.error) {
alert(data.error);
} else {
jQuery("#[[name]]-url").attr("href", data.PluginUrl);
jQuery("#[[name]]-website").attr("href", data.PluginUrl);
jQuery("#[[name]]-description").text(data.PluginDescription);
jQuery("#[[name]]-version").text("Version: " + data.PluginVersion);
}
},
error: function (MLHttpRequest, textStatus, errorThrown) {
console.log(textStatus);
}
});
</script>

View file

@ -0,0 +1,12 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-love]]</td>
<td>[[love]]</td>
</tr>
<tr>
<td>[[label-no-love]]</td>
<td>[[no-love]]</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,8 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-excerpt]]</td>
<td>[[excerpt]]</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,16 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-name]]</td>
<td>[[name]]</td>
</tr>
<tr>
<td>[[label-collapse]]</td>
<td>[[collapse]]</td>
</tr>
<tr>
<td>[[label-position]]</td>
<td>[[position]]</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,56 @@
<table class="widefat fixed">
<tbody>
<tr>
<td>[[label-identical]]</td>
<td>[[identical]]</td>
</tr>
<tr>
<td>[[label-short-code-start]]</td>
<td>[[short-code-start]]</td>
</tr>
<tr>
<td>[[label-short-code-end]]</td>
<td>[[short-code-end]]</td>
</tr>
<tr>
<td>[[label-short-code-start-user]]</td>
<td>[[short-code-start-user]]</td>
</tr>
<tr>
<td>[[label-short-code-end-user]]</td>
<td>[[short-code-end-user]]</td>
</tr>
<tr>
<td>[[label-counter-style]]</td>
<td>[[counter-style]]</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var l_obj_ShortCodeStart = jQuery("#[[short-code-start-id]]");
var l_obj_ShortCodeEnd = jQuery("#[[short-code-end-id]]");
var l_obj_ShortCodeStartUserDefined = jQuery("#[[short-code-start-user-id]]");
var l_obj_ShortCodeEndUserDefined = jQuery("#[[short-code-end-user-id]]");
function footnotes_Display_UserDefined_Placeholders() {
if (l_obj_ShortCodeStart.val() == "userdefined") {
l_obj_ShortCodeStartUserDefined.parent().parent().show();
l_obj_ShortCodeEndUserDefined.parent().parent().show();
} else {
l_obj_ShortCodeStartUserDefined.parent().parent().hide();
l_obj_ShortCodeEndUserDefined.parent().parent().hide();
}
}
footnotes_Display_UserDefined_Placeholders();
l_obj_ShortCodeStart.on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#[[short-code-end-id]] option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
l_obj_ShortCodeEnd.on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#[[short-code-start-id]] option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
</script>

View file

@ -1,22 +0,0 @@
<a href="#footnote_plugin_reference_[[FOOTNOTE INDEX]]"
name="footnote_plugin_tooltip_[[FOOTNOTE INDEX]]"
id="footnote_plugin_tooltip_[[FOOTNOTE INDEX]]"
class="footnote_plugin_tooltip_text"
onclick="footnote_expand_reference_container('#footnote_plugin_reference_[[FOOTNOTE INDEX]]');"><sup>[[FOOTNOTE BEFORE]][[FOOTNOTE INDEX]][[FOOTNOTE AFTER]]</sup>
</a>
<span class="footnote_tooltip" id="footnote_plugin_tooltip_text_[[FOOTNOTE INDEX]]">
[[FOOTNOTE TEXT]]
</span>
<script type="text/javascript">
jQuery("#footnote_plugin_tooltip_[[FOOTNOTE INDEX]]").tooltip({
tip: "#footnote_plugin_tooltip_text_[[FOOTNOTE INDEX]]",
tipClass: "footnote_tooltip",
effect: "fade",
fadeOutSpeed: 100,
predelay: 400,
position: "top right",
relative: true,
offset: [10, 10]
});
</script>

14
templates/public/footnote.html Executable file
View file

@ -0,0 +1,14 @@
<a href="#footnote_plugin_reference_[[index]]" name="footnote_plugin_tooltip_[[index]]" id="footnote_plugin_tooltip_[[index]]" class="footnote_plugin_tooltip_text" onclick="footnote_expand_reference_container();"><sup>[[before]][[index]][[after]]</sup></a>
<span class="footnote_tooltip" id="footnote_plugin_tooltip_text_[[index]]">[[text]]</span>
<script type="text/javascript">
jQuery("#footnote_plugin_tooltip_[[index]]").tooltip({
tip: "#footnote_plugin_tooltip_text_[[index]]",
tipClass: "footnote_tooltip",
effect: "fade",
fadeOutSpeed: 100,
predelay: 400,
position: "top right",
relative: true,
offset: [10, 10]
});
</script>

View file

@ -0,0 +1,7 @@
<tr>
<td>[[index]].</td>
<td><a class="footnote_plugin_link" href="#footnote_plugin_tooltip_[[index-int]]"
name="footnote_plugin_reference_[[index-int]]"
id="footnote_plugin_reference_[[index-int]]">[[arrow]]</a></td>
<td>[[text]]</td>
</tr>

View file

@ -0,0 +1,26 @@
<div class="footnote_container_prepare">
<p><span onclick="footnote_expand_reference_container();">[[label]]</span><span>[[buttons]]</span></p>
</div>
<div id="[[id]]" class="[[class]]">
<table class="footnote-reference-container">
<tbody>
[[content]]
</tbody>
</table>
</div>
<script type="text/javascript">
function footnote_expand_reference_container() {
jQuery("#[[id]]").show();
}
function footnote_expand_collapse_reference_container() {
var l_obj_ReferenceContainer = jQuery("#[[id]]");
if (l_obj_ReferenceContainer.is(":hidden")) {
l_obj_ReferenceContainer.show();
jQuery("#footnote_reference_container_collapse_button").text("-");
} else {
l_obj_ReferenceContainer.hide();
jQuery("#footnote_reference_container_collapse_button").text("+");
}
}
</script>