From 660d32edc3c6e6dfae7145db52786a975fd6b3f0 Mon Sep 17 00:00:00 2001
From: Aricura
Date: Tue, 20 May 2014 11:44:38 +0000
Subject: [PATCH] Version 1.0.4 * Updated replacing function when footnote is a
link (bugfix) * Footnote hover box remains until cursor leaves footnote or
hover box * Links in the footnote hover box are click able * New setting to
allow footnotes on Summarized Posts * New setting to tell the world you're
using footnotes plugin * New setting for the counter style of the footnote
index ** Arabic Numbers (1, 2, 3, 4, 5, ...) ** Arabic Numbers leading 0 (01,
02, 03, 04, 05, ...) ** Latin Characters lower-case (a, b, c, d, e, ...) **
Latin Characters upper-case (A, B, C, D, E, ...) ** Roman Numerals (I, II,
III, IV, V, ...) * Adding a link to the WordPress plugin in the footer if the
WP-admin accepts it * Updated translations for the new settings * re-changed
the version number to have 3 digits
git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@917816 b8457f37-d9ea-0310-8a92-e5e31aec5664
---
classes/footnotes_settings.php | 61 +++++++++++++++++++++++--
css/footnote.css | 15 ++++---
css/settings.css | 2 +-
includes/defines.php | 3 ++
includes/plugin-settings.php | 7 ++-
includes/replacer.php | 80 ++++++++++++++++++++++++++-------
index.php | 20 +++------
languages/footnotes-de.mo | Bin 2112 -> 2907 bytes
languages/footnotes-de.po | 78 ++++++++++++++++++++++++--------
languages/footnotes-en.mo | Bin 2078 -> 2848 bytes
languages/footnotes-en.po | 78 ++++++++++++++++++++++++--------
readme.txt | 18 +++++++-
templates/container.html | 2 +-
templates/footnote.html | 12 +++--
14 files changed, 288 insertions(+), 88 deletions(-)
diff --git a/classes/footnotes_settings.php b/classes/footnotes_settings.php
index 499b5ac..0e59fed 100644
--- a/classes/footnotes_settings.php
+++ b/classes/footnotes_settings.php
@@ -23,7 +23,10 @@ class Class_FootnotesSettings
FOOTNOTE_INPUTFIELD_REFERENCES_LABEL => 'References',
FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES => '',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_START => '((',
- FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))'
+ FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))',
+ FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT => 'yes',
+ FOOTNOTE_INPUTFIELD_LOVE => 'yes',
+ FOOTNOTE_INPUTFIELD_COUNTER_STYLE => 'arabic_plain'
);
/*
* resulting pagehook for adding a new sub menu page to the settings
@@ -48,7 +51,7 @@ class Class_FootnotesSettings
function __construct()
{
/* loads and filters the settings for this plugin */
- $this->a_arr_Options = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings );
+ $this->a_arr_Options = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings, true );
/* execute class includes on action-even: init, admin_init and admin_menu */
add_action( 'init', array( $this, 'LoadScriptsAndStylesheets' ) );
@@ -312,6 +315,9 @@ class Class_FootnotesSettings
add_settings_field( 'Register_Collapse_References', __( "Collapse references by default:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_Collapse_References' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
add_settings_field( 'Register_Combine_Identical', __( "Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_Combine_Identical' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
add_settings_field( 'Register_Placeholder_Tags', __( "Footnote tag:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_Placeholder_Tags' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
+ add_settings_field( 'Register_CounterStyle', __( "Counter style:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_CounterStyle' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
+ add_settings_field( 'Register_SearchExcerpt', __( "Allow footnotes on Summarized Posts:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_SearchExcerpt' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
+ add_settings_field( 'Register_LoveAndShare', sprintf(__( "Tell the world you're using %sfootnotes%s:", FOOTNOTES_PLUGIN_NAME ), '', ''), array( $this, 'Register_LoveAndShare' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
}
/**
@@ -373,6 +379,55 @@ class Class_FootnotesSettings
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, "", 14, __( "ends with:", FOOTNOTES_PLUGIN_NAME ));
}
+ /**
+ * outouts the settings field for the counter style
+ * @since 1.0-gamma
+ */
+ function Register_CounterStyle()
+ {
+ $l_str_Space = " ";
+ /* get array with option elements */
+ $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, ..."
+ );
+ /* add a select box to the output */
+ $this->AddSelectbox(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50");
+ }
+
+ /**
+ * outputs the settings field for "allow searching in summarized posts"
+ * @since 1.0-gamma
+ */
+ function Register_SearchExcerpt()
+ {
+ /* get array with option elements */
+ $l_arr_Options = array(
+ "yes" => __( "Yes", FOOTNOTES_PLUGIN_NAME ),
+ "no" => __( "No", FOOTNOTES_PLUGIN_NAME )
+ );
+ /* add a select box to the output */
+ $this->AddSelectbox(FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_25");
+ }
+
+ /**
+ * outputs the settings field for "love and share this plugin"
+ * @since 1.0-gamma
+ */
+ function Register_LoveAndShare()
+ {
+ /* get array with option elements */
+ $l_arr_Options = array(
+ "yes" => __( "Yes", FOOTNOTES_PLUGIN_NAME ),
+ "no" => __( "No", FOOTNOTES_PLUGIN_NAME )
+ );
+ /* add a select box to the output */
+ $this->AddSelectbox(FOOTNOTE_INPUTFIELD_LOVE, $l_arr_Options, "footnote_plugin_25");
+ }
+
/**
* initialize howto settings tab
* called in class constructor @ admin_init
@@ -424,7 +479,7 @@ class Class_FootnotesSettings
-
+
diff --git a/css/footnote.css b/css/footnote.css
index ec270e9..f6b2ea5 100755
--- a/css/footnote.css
+++ b/css/footnote.css
@@ -79,32 +79,33 @@
}
/* tooltip */
-a.footnote_plugin_tooltip {
+.footnote_plugin_tooltip {
outline: none !important;
color: #4777ff !important;
text-decoration: none !important;
cursor: pointer !important;
}
-a.footnote_plugin_tooltip strong {
+.footnote_plugin_tooltip strong {
line-height: 30px !important;
}
-a.footnote_plugin_tooltip:hover {
+.footnote_plugin_tooltip:hover {
text-decoration: none !important;
}
-a.footnote_plugin_tooltip span {
+.footnote_plugin_tooltip span {
z-index: 10 !important;
display: none !important;
padding: 14px 20px !important;
margin-top: -30px !important;
- margin-left: 28px !important;
+ /*margin-left: 28px !important;*/
/*width: 240px;*/
line-height: 16px !important;
+ cursor: default;
}
-a.footnote_plugin_tooltip:hover span {
+.footnote_plugin_tooltip:hover span, .footnote_plugin_tooltip span:hover {
display: inline !important;
position: absolute !important;
color: #474747 !important;
@@ -121,7 +122,7 @@ a.footnote_plugin_tooltip:hover span {
}
/*CSS3 extras*/
-a.footnote_plugin_tooltip span {
+.footnote_plugin_tooltip span {
border-radius: 4px !important;
-moz-border-radius: 4px !important;
-webkit-border-radius: 4px !important;
diff --git a/css/settings.css b/css/settings.css
index e7005f8..cc597a2 100755
--- a/css/settings.css
+++ b/css/settings.css
@@ -9,7 +9,7 @@
/* overwrite some styling for inputs [type=text] and select-boxes */
input[type=text], input[type=checkbox], input[type=password], textarea, select {
- margin-left: 12px !important;
+ /*margin-left: 12px !important;*/
}
input[type=text], input[type=password], textarea, select {
padding-left: 8px !important;
diff --git a/includes/defines.php b/includes/defines.php
index fcb8423..18f56bd 100644
--- a/includes/defines.php
+++ b/includes/defines.php
@@ -25,6 +25,9 @@ define( "FOOTNOTE_INPUTFIELD_REFERENCES_LABEL", "footnote_inputfield_references_
define( "FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES", "footnote_inputfield_collapse_references" ); /* id of input field for the "collapse references" setting */
define( "FOOTNOTE_INPUTFIELD_PLACEHOLDER_START", "footnote_inputfield_placeholder_start"); /* id of input field for the "placeholder starting tag" setting */
define( "FOOTNOTE_INPUTFIELD_PLACEHOLDER_END", "footnote_inputfield_placeholder_end"); /* id of input field for the "placeholder ending tag" setting */
+define( "FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT", "footnote_inputfield_search_in_excerpt"); /* id of input field for the "allow footnotes in the excerpt" setting */
+define( "FOOTNOTE_INPUTFIELD_LOVE", "footnote_inputfield_love"); /* id of input field for "love and share this plugin" setting */
+define( "FOOTNOTE_INPUTFIELD_COUNTER_STYLE", "footnote_inputfield_counter_style"); /* id of input field for "counter style of footnote index" setting */
/* PLUGIN REFERENCES CONTAINER ID */
define( "FOOTNOTE_REFERENCES_CONTAINER_ID", "footnote_references_container" ); /* id for the div surrounding the footnotes */
diff --git a/includes/plugin-settings.php b/includes/plugin-settings.php
index 415a0f1..e7d5f10 100644
--- a/includes/plugin-settings.php
+++ b/includes/plugin-settings.php
@@ -33,15 +33,20 @@ function footnotes_plugin_settings_link( $links, $file )
* @since 1.0
* @param string $p_str_OptionsField
* @param array $p_arr_DefaultValues
+ * @param bool $p_bool_ConvertHtmlChars
* @return array
*/
-function footnotes_filter_options( $p_str_OptionsField, $p_arr_DefaultValues )
+function footnotes_filter_options( $p_str_OptionsField, $p_arr_DefaultValues, $p_bool_ConvertHtmlChars=true )
{
$l_arr_Options = get_option( $p_str_OptionsField );
/* loop through all keys in the array and filters them */
foreach ( $l_arr_Options as $l_str_Key => $l_str_Value ) {
/* removes special chars from the settings value */
$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)) {
$l_arr_Options[ $l_str_Key ] = stripcslashes( $l_str_Value );
diff --git a/includes/replacer.php b/includes/replacer.php
index 145b3ae..ae67dfb 100644
--- a/includes/replacer.php
+++ b/includes/replacer.php
@@ -20,6 +20,41 @@ $g_arr_Footnotes = array();
*/
$g_arr_FootnotesSettings = array();
+/**
+ * register all functions needed for the replacement in the wordpress core
+ * @since 1.0-gamma
+ */
+function footnotes_RegisterReplacementFunctions() {
+ /* access to the global settings collection */
+ global $g_arr_FootnotesSettings;
+ /* load footnote settings */
+ $g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, false );
+ /* get setting for accepting footnotes in the excerpt and convert it to boolean */
+ $l_bool_SearchExcerpt = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT ]);
+
+ /* calls the wordpress filter function to replace page content before displayed on public pages */
+ add_filter( 'the_content', 'footnotes_startReplacing' );
+ /* search in the excerpt only if activated */
+ if ($l_bool_SearchExcerpt) {
+ add_filter( 'the_excerpt', 'footnotes_DummyReplacing' );
+ }
+
+ /* calls the wordpress filter function to replace widget text before displayed on public pages */
+ add_filter( 'widget_title', 'footnotes_DummyReplacing' );
+ add_filter( 'widget_text', 'footnotes_DummyReplacing' );
+
+ /* calls the wordpress action to display the footer */
+ add_action( 'get_footer', 'footnotes_StopReplacing' );
+
+ /* get setting for love and share this plugin and convert it to boolean */
+ $l_bool_LoveMe = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_LOVE ]);
+ /* check if the admin allows to add a link to the footer */
+ if ($l_bool_LoveMe) {
+ /* calls the wordpress action to hook to the footer */
+ add_filter('wp_footer', 'footnotes_LoveAndShareMe', 0);
+ }
+}
+
/**
* starts listening for footnotes to be replaced
* output will be buffered and not displayed
@@ -29,12 +64,8 @@ $g_arr_FootnotesSettings = array();
*/
function footnotes_startReplacing( $p_str_Content )
{
- /* access to the global settings collection */
- global $g_arr_FootnotesSettings;
/* stop the output and move it to a buffer instead, defines a callback function */
ob_start( "footnotes_replaceFootnotes" );
- /* load footnote settings */
- $g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings );
/* return unchanged content */
return $p_str_Content;
}
@@ -62,26 +93,36 @@ function footnotes_StopReplacing()
ob_end_flush();
}
+/**
+ * outputs a link to love and share this awesome plugin
+ * @since 1.0-gamma
+ */
+function footnotes_LoveAndShareMe()
+{
+ echo '
+ '.
+ sprintf(__("Hey there, I'm using the awesome WordPress Plugin called %sfootnotes%s", FOOTNOTES_PLUGIN_NAME), '
', '').
+ '
'
+ ;
+}
+
/**
* 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]
+ * @param bool $p_bool_ReplaceHtmlChars [ default: false]
* @return string
*/
-function footnotes_replaceFootnotes( $p_str_Content, $p_bool_OutputReferences = true )
+function footnotes_replaceFootnotes( $p_str_Content, $p_bool_OutputReferences = true, $p_bool_ReplaceHtmlChars = false )
{
/* get access to the global array */
global $g_arr_Footnotes;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
- /* check if settings are already loaded, otherwise load them */
- if (empty($g_arr_FootnotesSettings)) {
- /* load footnote settings */
- $g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings );
- }
-
+ /* load footnote settings */
+ $g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, $p_bool_ReplaceHtmlChars );
/* replace all footnotes in the content */
$p_str_Content = footnotes_getFromString( $p_str_Content );
@@ -118,6 +159,8 @@ function footnotes_getFromString( $p_str_Content )
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START];
/*get footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_END];
+ /*get footnote counter style */
+ $l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
/* check for a footnote placeholder in the current page */
do {
@@ -134,7 +177,7 @@ function footnotes_getFromString( $p_str_Content )
/* 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 replacer for the footnote */
- $l_str_ReplaceText = str_replace( "[[FOOTNOTE INDEX]]", $l_int_FootnoteIndex, $l_str_FootnoteTemplate );
+ $l_str_ReplaceText = str_replace( "[[FOOTNOTE INDEX]]", footnote_convert_index($l_int_FootnoteIndex,$l_str_CounterStyle), $l_str_FootnoteTemplate );
$l_str_ReplaceText = str_replace( "[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $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 ) );
@@ -184,9 +227,11 @@ function footnotes_OutputReferenceContainer()
$l_str_ReferencesLabel = $g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_REFERENCES_LABEL ];
/* get setting for collapse reference footnotes and convert it to boolean */
$l_bool_CollapseReference = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES ]);
+ /*get footnote counter style */
+ $l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
/* output string, prepare it with the reference label as headline */
- $l_str_Output = '';
+ $l_str_Output = '';
/* add a box around the footnotes */
$l_str_Output .= '