- Update: Global styling for the public plugin name

- Update: Easier usage of the public plugin name in translations
- Update: New Layout for the settings page to group similar settings to get a better overview
- Update: Display settings submit button only if there is at least 1 editable setting in the current tab
- Add: setting where the reference container appears on public pages (needs some corrections!)
- Bugfix: displays only one reference container in front of the footer on category pages

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@918851 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
Aricura 2014-05-21 18:33:26 +00:00
parent 49c54b6a89
commit d25f770bc5
19 changed files with 1322 additions and 1096 deletions

View file

@ -4,7 +4,7 @@
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.6
* Version: 1.0.7
* Since: 1.0
*/
@ -27,7 +27,8 @@ class Class_FootnotesSettings
FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))',
FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT => 'yes',
FOOTNOTE_INPUTFIELD_LOVE => 'no',
FOOTNOTE_INPUTFIELD_COUNTER_STYLE => 'arabic_plain'
FOOTNOTE_INPUTFIELD_COUNTER_STYLE => 'arabic_plain',
FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE => 'post_end'
);
/*
* resulting pagehook for adding a new sub menu page to the settings
@ -81,6 +82,8 @@ class Class_FootnotesSettings
wp_register_style('footnote_settings_style', plugins_url('../css/settings.css', __FILE__));
/* add settings stylesheet */
wp_enqueue_style('footnote_settings_style');
/* Needed to allow metabox layout and close functionality */
wp_enqueue_script('postbox');
}
/**
@ -105,9 +108,9 @@ class Class_FootnotesSettings
return;
}
/* submenu page title */
$l_str_PageTitle = '<span style="color: #2bb975; ">foot</span><span style="color: #545f5a; ">notes</span>';
$l_str_PageTitle = FOOTNOTES_PLUGIN_PUBLIC_NAME;
/* submenu title */
$l_str_MenuTitle = '<span style="color: #2bb975; ">foot</span><span style="color: #545f5a; ">notes</span>';
$l_str_MenuTitle = FOOTNOTES_PLUGIN_PUBLIC_NAME;
/* Add a new submenu to the standard Settings panel */
$this->a_str_Pagehook = add_options_page($l_str_PageTitle, $l_str_MenuTitle, 'administrator', FOOTNOTES_SETTINGS_PAGE_ID, array($this, 'OutputSettingsPage'));
}
@ -132,10 +135,22 @@ class Class_FootnotesSettings
settings_fields($l_str_tab);
/* outputs the settings field of the current active tab */
do_settings_sections($l_str_tab);
do_meta_boxes($l_str_tab, 'main');
/* adds a submit button to the current page */
/*
* add submit button only if there are some settings on the current page
* @since version 1.0.7
*/
if ($l_str_tab == FOOTNOTE_SETTINGS_LABEL_GENERAL) {
submit_button();
}
echo '</form>';
echo '</div>';
/*
* output settings page specific javascript code
* @since 1.0.7
*/
$this->OutputJavascript();
}
/**
@ -158,6 +173,25 @@ class Class_FootnotesSettings
echo '</h2>';
}
/**
* outputs page specific javascript code
* @since 1.0.7
*/
function OutputJavascript()
{
?>
<!-- Needed to allow metabox 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; ?>');
});
</script>
<?php
}
/**
* loads specific setting and returns an array with the keys [id, name, value]
* @since 1.0
@ -208,15 +242,40 @@ class Class_FootnotesSettings
return $this->a_arr_Options[$p_str_Key];
}
/**
* outputs a break to have a new line
* @since 1.0.7
*/
function AddNewline()
{
echo '<br/><br/>';
}
/**
* 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
*/
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 string $p_str_Label [label text]
* @since 1.0-beta
* removed optional paremter for a label in version 1.0.7
*/
function AddTextbox($p_str_SettingsID, $p_str_ClassName="", $p_str_MaxLength=0, $p_str_Label="")
function AddTextbox($p_str_SettingsID, $p_str_ClassName = "", $p_str_MaxLength = 0)
{
/* collect data for given settings field */
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
@ -229,11 +288,6 @@ class Class_FootnotesSettings
if (!empty($p_str_MaxLength)) {
$p_str_MaxLength = ' maxlength="' . $p_str_MaxLength . '"';
}
/* optional add a label in front of the input field */
if (!empty($p_str_Label)) {
echo '<label for="'.$l_arr_Data[ "id" ].'">'.$p_str_Label.'</label>';
}
/* outputs an input field type TEXT */
echo '<input type="text" ' . $p_str_ClassName . $p_str_MaxLength . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" value="' . $l_arr_Data["value"] . '"/>';
}
@ -304,21 +358,17 @@ class Class_FootnotesSettings
* initialize general settings tab
* called in class constructor @ admin_init
* @since 1.0
* changed layout of settings form settings fields to meta boxes in version 1.0.7
*/
function RegisterTab_General()
{
$l_str_SectionName = "Footnote_Secion_Settings_General";
/* add tab to the tab array */
$this->a_arr_SettingsTabs[FOOTNOTE_SETTINGS_LABEL_GENERAL] = __("General", FOOTNOTES_PLUGIN_NAME);
/* register settings tab */
add_settings_section( $l_str_SectionName, sprintf(__( "%s Settings", FOOTNOTES_PLUGIN_NAME ), '<span style="color: #2bb975; ">foot</span><span style="color: #545f5a; ">notes</span>'), array( $this, 'RegisterTab_General_Description' ), FOOTNOTE_SETTINGS_LABEL_GENERAL );
add_settings_field( 'Register_References_Label', __( "References label:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_References_Label' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
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 %sfoot%snotes%s:", FOOTNOTES_PLUGIN_NAME ), '<span style="color: #2bb975; ">', '</span><span style="color: #545f5a; ">', '</span>'), array( $this, 'Register_LoveAndShare' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
add_settings_section("Footnote_Secion_Settings_General", sprintf(__("%s Settings", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME), array($this, 'RegisterTab_General_Description'), FOOTNOTE_SETTINGS_LABEL_GENERAL);
add_meta_box('Register_MetaBox_ReferenceContainer', __("References Container", FOOTNOTES_PLUGIN_NAME), array($this, 'Register_MetaBox_ReferenceContainer'), FOOTNOTE_SETTINGS_LABEL_GENERAL, 'main');
add_meta_box('Register_MetaBox_FootnoteStyling', __("Footnotes styling", FOOTNOTES_PLUGIN_NAME), array($this, 'Register_MetaBox_FootnoteStyling'), FOOTNOTE_SETTINGS_LABEL_GENERAL, 'main');
add_meta_box('Register_MetaBox_Other', __("Other", FOOTNOTES_PLUGIN_NAME), array($this, 'Register_MetaBox_Other'), FOOTNOTE_SETTINGS_LABEL_GENERAL, 'main');
}
/**
@ -332,62 +382,59 @@ class Class_FootnotesSettings
}
/**
* outputs the settings field for the "references label"
* @since 1.0
* outputs a container for the reference container settings
* @since 1.0.7
*/
function Register_References_Label()
function Register_MetaBox_ReferenceContainer()
{
/* add a textbox to the output */
/* setting for 'reference label' */
$this->AddLabel(FOOTNOTE_INPUTFIELD_REFERENCES_LABEL, __("References label:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTE_INPUTFIELD_REFERENCES_LABEL, "footnote_plugin_50");
}
$this->AddNewline();
/**
* outputs the settings field for the "references label"
* @since 1.0-beta
*/
function Register_Collapse_References()
{
/* add a checkbox to the output */
/* setting for 'collapse reference container by default' */
$this->AddLabel(FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES, __("Collapse references by default:", FOOTNOTES_PLUGIN_NAME));
$this->AddCheckbox(FOOTNOTE_INPUTFIELD_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)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE, __("Where shall the reference container appear:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE, $l_arr_Options, "footnote_plugin_50");
}
/**
* outputs the settings field for the "combine identical footnotes"
* @since 1.0
* outputs a container for the styling of footnotes
* @since 1.0.7
*/
function Register_Combine_Identical()
function Register_MetaBox_FootnoteStyling()
{
/* get array with option elements */
/* setting for 'combine identical footnotes' */
$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_COMBINE_IDENTICAL, $l_arr_Options, "footnote_plugin_25");
}
$this->AddLabel(FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL, __("Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
/**
* outputs the settings fields for the footnote starting and ending tag
* @since 1.0-gamma
*/
function Register_Placeholder_Tags()
{
/* add a textbox to the output */
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START, "", 14, __( "starts with:", FOOTNOTES_PLUGIN_NAME ));
/* small space between the two input fields */
echo '&nbsp;&nbsp;&nbsp;';
/* add a textbox to the output */
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, "", 14, __( "ends with:", FOOTNOTES_PLUGIN_NAME ));
}
/* setting for 'footnote tag starts with' */
$this->AddLabel(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START, __("Footnote tag starts with:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START, "footnote_plugin_15", 14);
/**
* outouts the settings field for the counter style
* @since 1.0-gamma
*/
function Register_CounterStyle()
{
/* setting for 'footnote tag ends with' */
$this->AddLabel(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, __("and ends with:", FOOTNOTES_PLUGIN_NAME) . '&nbsp;&nbsp;&nbsp;', 'text-align: right;');
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, "footnote_plugin_15", 14);
$this->AddNewline();
/* setting for 'footnotes counter style' */
$l_str_Space = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
/* 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, ...",
@ -395,70 +442,65 @@ class Class_FootnotesSettings
"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->AddLabel(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, __('Counter style:', FOOTNOTES_PLUGIN_NAME));
$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
* outputs other footnotes settings that doesn't match a special category
* @since 1.0.7
*/
function Register_SearchExcerpt()
function Register_MetaBox_Other()
{
/* get array with option elements */
/* setting for 'search footnotes tag in excerpt' */
$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");
}
$this->AddLabel(FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT, __('Allow footnotes on Summarized Posts:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
/**
* outputs the settings field for "love and share this plugin"
* @since 1.0-gamma
*/
function Register_LoveAndShare()
{
/* get array with option elements */
/* setting for 'love and share this plugin in my footer' */
$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");
$this->AddLabel(FOOTNOTE_INPUTFIELD_LOVE, sprintf(__("Tell the world you're using %s:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_LOVE, $l_arr_Options, "footnote_plugin_50");
}
/**
* initialize howto settings tab
* called in class constructor @ admin_init
* @since 1.0
* changed layout of settings form settings fields to meta boxes in version 1.0.7
*/
function RegisterTab_HowTo()
{
$l_str_SectionName = "Footnote_Secion_Settings_Howto";
/* add tab to the tab array */
$this->a_arr_SettingsTabs[FOOTNOTE_SETTINGS_LABEL_HOWTO] = __("HowTo", FOOTNOTES_PLUGIN_NAME);
/* register settings tab */
add_settings_section( $l_str_SectionName, __( "HowTo", FOOTNOTES_PLUGIN_NAME ), array( $this, 'RegisterTab_HowTo_Description' ), FOOTNOTE_SETTINGS_LABEL_HOWTO );
add_settings_field( 'Register_Howto_Box', "", array( $this, 'Register_Howto_Box' ), FOOTNOTE_SETTINGS_LABEL_HOWTO, $l_str_SectionName );
add_settings_section("Footnote_Secion_Settings_Howto", "&nbsp;", array($this, 'RegisterTab_HowTo_Description'), FOOTNOTE_SETTINGS_LABEL_HOWTO);
add_meta_box('Register_MetaBox_HowTo', __("Brief introduction in how to use the plugin", FOOTNOTES_PLUGIN_NAME), array($this, 'Register_MetaBox_HowTo'), FOOTNOTE_SETTINGS_LABEL_HOWTO, 'main');
}
/**
* adds a descrption to the HowTo settings tab
* called int RegisterTab_HowTo
* @since 1.0
* removed output of description in version 1.0.7
*/
function RegisterTab_HowTo_Description()
{
echo __( "This is a brief introduction in how to use the plugin.", FOOTNOTES_PLUGIN_NAME );
// unused
}
/**
* outputs the content of the HowTo settings tab
* @since 1.0
*/
function Register_Howto_Box()
function Register_MetaBox_HowTo()
{
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END);
@ -467,17 +509,20 @@ class Class_FootnotesSettings
<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>
<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>
<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_arr_Footnote_StartingTag["value"] . __( "example string", FOOTNOTES_PLUGIN_NAME ) . $l_arr_Footnote_EndingTag["value"]; ?></span>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"]; ?></span>
<?php echo __("will be displayed as:", FOOTNOTES_PLUGIN_NAME); ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo footnotes_replaceFootnotes($l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"], true, true); ?>

View file

@ -3,10 +3,27 @@
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.6
* Version: 1.0.7
* Since: 1.0
*/
/*
* styling for the 'footnotes' tag
* @since 1.0.7
*/
.footnote_tag_styling, .footnote_tag_styling:hover {
text-decoration: none;
font-weight: normal;
}
.footnote_tag_styling_1 {
color: #2bb975;
}
.footnote_tag_styling_2 {
color: #545f5a;
}
/* container before the footnote appears at the bottom to get a space between footnote and content */
.footnote_container_prepare {
display: block !important;

View file

@ -11,11 +11,30 @@
input[type=text], input[type=checkbox], input[type=password], textarea, select {
/*margin-left: 12px !important;*/
}
input[type=text], input[type=password], textarea, select {
padding-left: 8px !important;
padding-right: 8px !important;
}
label {
width: 20% !important;
display: inline-block;
}
/*
* layout for the meta box container
* @since 1.0.7
*/
.postbox > h3 {
height: 32px !important;
line-height: 32px !important;
}
.postbox > h3 > span {
padding-left: 10px;
}
/* overwrite link layout on the settings page */
a.footnote_plugin {
text-decoration: underline !important;
@ -23,6 +42,11 @@ a.footnote_plugin {
color: #202020 !important;
}
/* setting with 15% width */
.footnote_plugin_15 {
width: 15% !important;
}
/* setting with 25% width */
.footnote_plugin_25 {
width: 25% !important;

View file

@ -8,6 +8,12 @@
* Since: 1.0
*/
/*
* 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>');
/* GENERAL PLUGIN CONSTANTS */
define("FOOTNOTES_PLUGIN_NAME", "footnotes"); /* plugin's internal name */
define("FOOTNOTE_SETTINGS_CONTAINER", "footnotes_storage"); /* database container where all footnote settings are stored */
@ -28,6 +34,11 @@ define( "FOOTNOTE_INPUTFIELD_PLACEHOLDER_END", "footnote_inputfield_placeholder_
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 */
/*
* id of input field "placement of reference container" setting
* @since 1.0.7
*/
define("FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE", "footnote_inputfield_reference_container_place");
/* PLUGIN REFERENCES CONTAINER ID */
define("FOOTNOTE_REFERENCES_CONTAINER_ID", "footnote_references_container"); /* id for the div surrounding the footnotes */

View file

@ -67,7 +67,8 @@ function footnotes_filter_options( $p_str_OptionsField, $p_arr_DefaultValues, $p
* @param string $p_str_Value
* @return bool
*/
function footnotes_ConvertToBool($p_str_Value) {
function footnotes_ConvertToBool($p_str_Value)
{
/* 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 */

View file

@ -4,7 +4,7 @@
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.6
* Version: 1.0.7
* Since: 1.0
*/
@ -20,75 +20,136 @@ $g_arr_Footnotes = array();
*/
$g_arr_FootnotesSettings = array();
/*
* flag to know if the replacement already started for the current page
* @since 1.0.7
*/
$g_bool_FootnotesReplacementStarted = false;
/**
* register all functions needed for the replacement in the wordpress core
* @since 1.0-gamma
*/
function footnotes_RegisterReplacementFunctions() {
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 */
/* starts listening to the output for replacement */
add_action('wp_head', 'footnotes_startReplacing');
/* stops listening to the output and replaces the footnotes */
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);
/* moves these contents through the replacement function */
add_filter('the_content', 'footnotes_Replacer_Content');
add_filter('the_excerpt', 'footnotes_Replacer_Excerpt');
add_filter('widget_title', 'footnotes_Replacer_WidgetTitle');
add_filter('widget_text', 'footnotes_Replacer_WidgetText');
/* adds the love and share me slug to the footer */
add_filter('wp_footer', 'footnotes_LoveAndShareMe');
}
/**
* replacement action for the_excerpt
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_Content($p_str_Content)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for 'display reference container position' */
$l_str_ReferenceContainerPosition = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT];
/* check if reference container should be displayed at the end of a post */
if ($l_str_ReferenceContainerPosition == "post_end") {
footnotes_StopReplacing();
footnotes_startReplacing();
}
/* returns content */
return $p_str_Content;
}
/**
* replacement action for the_excerpt
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_Excerpt($p_str_Content)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* 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]);
/* search in the excerpt only if activated */
if ($l_bool_SearchExcerpt) {
footnotes_StopReplacing();
footnotes_startReplacing();
}
/* returns content */
return $p_str_Content;
}
/**
* replacement action for widget_title
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_WidgetTitle($p_str_Content)
{
/* returns content */
return $p_str_Content;
}
/**
* replacement action for widget_text
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_WidgetText($p_str_Content)
{
/* returns content */
return $p_str_Content;
}
/**
* starts listening for footnotes to be replaced
* output will be buffered and not displayed
* @since 1.0
* @param string $p_str_Content
* @return string
* added flag to only start 'stopping output' once in version 1.0.7
*/
function footnotes_startReplacing( $p_str_Content )
function footnotes_startReplacing()
{
/* global access to the replacement flag */
global $g_bool_FootnotesReplacementStarted;
/* stop output if flag is not set yet */
if (!$g_bool_FootnotesReplacementStarted) {
/* stop the output and move it to a buffer instead, defines a callback function */
ob_start("footnotes_replaceFootnotes");
/* return unchanged content */
return $p_str_Content;
/* set flag to only start stopping the output once */
$g_bool_FootnotesReplacementStarted = true;
}
/**
* dummy function to add the content to the buffer instead of output it
* @since 1.0
* @param string $p_str_Content
* @return string
*/
function footnotes_DummyReplacing( $p_str_Content )
{
/* return unchanged content */
return $p_str_Content;
}
/**
* stops buffering the output, automatically calls the ob_start() defined callback function
* replaces all footnotes in the whole buffer and outputs it
* @since 1.0
* cleared the flag in version 1.0.7
*/
function footnotes_StopReplacing()
{
/* global access to the replacement flag */
global $g_bool_FootnotesReplacementStarted;
/* un-set the flag as soon as the replacement function stops and the content will be displayed */
$g_bool_FootnotesReplacementStarted = false;
/* calls the callback function defined in ob_start(); */
ob_end_flush();
}
@ -99,16 +160,26 @@ function footnotes_StopReplacing()
*/
function footnotes_LoveAndShareMe()
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/*
* updated url to wordpress.org plugin page instead of the github page
* also updated the font-style and translation the string "footnotes"
* in version 1.0.6
*/
/*
* changed replacement of public plugin name to use global styling setting
* @since 1.0.7
*/
/* 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) {
echo '
<div style="text-align:center; color:#acacac;">' .
sprintf(__("Hey there, I'm using the awesome WordPress Plugin called %s", FOOTNOTES_PLUGIN_NAME), '<a href="http://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration: none;"><span style="color: #2bb975;">foot</span><span style="color: #545f5a;">notes</span></a>').
'</div>'
;
sprintf(__("Hey there, I'm using the awesome WordPress Plugin called %s", FOOTNOTES_PLUGIN_NAME), '<a href="http://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration: none;">' . FOOTNOTES_PLUGIN_PUBLIC_NAME . '</a>') .
'</div>';
}
}
/**

Binary file not shown.

View file

@ -1,9 +1,9 @@
msgid ""
msgstr ""
"Project-Id-Version: footnotes\n"
"POT-Creation-Date: 2014-05-20 17:59+0100\n"
"PO-Revision-Date: 2014-05-20 21:49+0100\n"
"Last-Translator: Mark Cheret <mark@cheret.de>\n"
"POT-Creation-Date: 2014-05-21 20:28+0100\n"
"PO-Revision-Date: 2014-05-21 20:30+0100\n"
"Last-Translator: Stefan Herndler <support@herndler.org>\n"
"Language-Team: SHE <s.herndler@methis.at>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
@ -18,107 +18,127 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"
#: classes/footnotes_settings.php:312
#: classes/footnotes_settings.php:366
msgid "General"
msgstr "Allgemein"
#: classes/footnotes_settings.php:314
#: classes/footnotes_settings.php:368
#, php-format
msgid "%s Settings"
msgstr "%s Einstellungen"
#: classes/footnotes_settings.php:315
#: classes/footnotes_settings.php:369
msgid "References Container"
msgstr "Einzelnachweise"
#: classes/footnotes_settings.php:370
msgid "Footnotes styling"
msgstr "Layout der Fußnoten"
#: classes/footnotes_settings.php:371
msgid "Other"
msgstr "Andere"
#: classes/footnotes_settings.php:391
msgid "References label:"
msgstr "Überschrift \"Einzelnachweis\":"
#: classes/footnotes_settings.php:316
#: classes/footnotes_settings.php:396
msgid "Collapse references by default:"
msgstr "Verstecke Einzelnachweise standardmäßig:"
#: classes/footnotes_settings.php:317
msgid "Combine identical footnotes:"
msgstr "Kombiniere meine Fußnoten:"
#: classes/footnotes_settings.php:405
msgid "in the footer"
msgstr "am Ende der Seite"
#: classes/footnotes_settings.php:318
msgid "Footnote tag:"
msgstr "Fußzeile einbinden:"
#: classes/footnotes_settings.php:406
msgid "at the end of the post"
msgstr "nach einem Beitrag"
#: classes/footnotes_settings.php:319
msgid "Counter style:"
msgstr "Fußnoten Zähler:"
#: classes/footnotes_settings.php:408
msgid "Where shall the reference container appear:"
msgstr "Positionierung der Einzelnachweise:"
#: classes/footnotes_settings.php:320
msgid "Allow footnotes on Summarized Posts:"
msgstr "Erlaube Fußnoten in Zusammenfassungen:"
#: classes/footnotes_settings.php:321
#, php-format
msgid "Tell the world you're using %sfoot%snotes%s:"
msgstr "Teile der Welt mit, dass du %sfoot%snotes%s verwendest:"
#: classes/footnotes_settings.php:362 classes/footnotes_settings.php:410
#: classes/footnotes_settings.php:425
#: classes/footnotes_settings.php:420 classes/footnotes_settings.php:457
#: classes/footnotes_settings.php:466
msgid "Yes"
msgstr "Ja"
#: classes/footnotes_settings.php:363 classes/footnotes_settings.php:411
#: classes/footnotes_settings.php:426
#: classes/footnotes_settings.php:421 classes/footnotes_settings.php:458
#: classes/footnotes_settings.php:467
msgid "No"
msgstr "Nein"
#: classes/footnotes_settings.php:376
msgid "starts with:"
msgstr "beginnt mit:"
#: classes/footnotes_settings.php:423
msgid "Combine identical footnotes:"
msgstr "Kombiniere meine Fußnoten:"
#: classes/footnotes_settings.php:380
msgid "ends with:"
msgstr "endet mit:"
#: classes/footnotes_settings.php:428
msgid "Footnote tag starts with:"
msgstr "Fußnoten starten mit:"
#: classes/footnotes_settings.php:392
#: classes/footnotes_settings.php:432
msgid "and ends with:"
msgstr "und endet mit:"
#: classes/footnotes_settings.php:439
msgid "Arabic Numbers - Plain"
msgstr "arabische Ziffern"
#: classes/footnotes_settings.php:393
#: classes/footnotes_settings.php:440
msgid "Arabic Numbers - Leading 0"
msgstr "arabisch Ziffern - führende Null"
#: classes/footnotes_settings.php:394
#: classes/footnotes_settings.php:441
msgid "Latin Character - lower case"
msgstr "alphabetisch - Kleinschreibung"
#: classes/footnotes_settings.php:395
#: classes/footnotes_settings.php:442
msgid "Latin Character - upper case"
msgstr "alphabetisch - Großschreibung"
#: classes/footnotes_settings.php:396
#: classes/footnotes_settings.php:443
msgid "Roman Numerals"
msgstr "Römische Ziffern"
#: classes/footnotes_settings.php:441 classes/footnotes_settings.php:443
#: classes/footnotes_settings.php:445
msgid "Counter style:"
msgstr "Fußnoten Zähler:"
#: classes/footnotes_settings.php:460
msgid "Allow footnotes on Summarized Posts:"
msgstr "Erlaube Fußnoten in Zusammenfassungen:"
#: classes/footnotes_settings.php:469
#, php-format
msgid "Tell the world you're using %s:"
msgstr "Teile der Welt mit, dass du %s verwendest:"
#: classes/footnotes_settings.php:482
msgid "HowTo"
msgstr "Hilfe"
#: classes/footnotes_settings.php:454
msgid "This is a brief introduction in how to use the plugin."
msgstr "Eine kurze Anleitung für die Verwendung des Plugins."
#: classes/footnotes_settings.php:485
msgid "Brief introduction in how to use the plugin"
msgstr "Kurze Anleitung für die Verwendung des Plugins."
#: classes/footnotes_settings.php:469
#: classes/footnotes_settings.php:511
msgid "Start your footnote with the following shortcode:"
msgstr "Starten Sie eine Fußnote mit:"
#: classes/footnotes_settings.php:474
#: classes/footnotes_settings.php:517
msgid "...and end your footnote with this shortcode:"
msgstr "...und beenden Sie diese mit:"
#: classes/footnotes_settings.php:480 classes/footnotes_settings.php:483
#: classes/footnotes_settings.php:525 classes/footnotes_settings.php:528
msgid "example string"
msgstr "Beispieltext"
#: classes/footnotes_settings.php:481
#: classes/footnotes_settings.php:526
msgid "will be displayed as:"
msgstr "wird dargestellt als:"
#: classes/footnotes_settings.php:488
#: classes/footnotes_settings.php:533
#, php-format
msgid "If you have any questions, please don't hesitate to %se-mail%s us."
msgstr "Bei Fragen können Sie uns gerne eine %se-Mail%s senden."
@ -127,7 +147,7 @@ msgstr "Bei Fragen können Sie uns gerne eine %se-Mail%s senden."
msgid "Settings"
msgstr "Einstellungen"
#: includes/replacer.php:109
#: includes/replacer.php:180
#, php-format
msgid "Hey there, I'm using the awesome WordPress Plugin called %s"
msgstr "Diese Seite verwendet das %s Plugin"
@ -140,6 +160,9 @@ msgstr "Sie müssen angemeldet sein um diese Funktion ausführen zu können."
msgid "You do not have permission to run this script."
msgstr "Sie haben nicht die Berechtigung diese Funktion auszuführen."
#~ msgid "starts with:"
#~ msgstr "beginnt mit:"
#~ msgid "Save"
#~ msgstr "Speichern"

Binary file not shown.

View file

@ -1,9 +1,9 @@
msgid ""
msgstr ""
"Project-Id-Version: footnotes\n"
"POT-Creation-Date: 2014-05-20 21:36+0100\n"
"PO-Revision-Date: 2014-05-20 21:50+0100\n"
"Last-Translator: Mark Cheret <mark@cheret.de>\n"
"POT-Creation-Date: 2014-05-21 20:28+0100\n"
"PO-Revision-Date: 2014-05-21 20:28+0100\n"
"Last-Translator: Stefan Herndler <support@herndler.org>\n"
"Language-Team: SHE <s.herndler@methis.at>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
@ -18,107 +18,127 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"
#: classes/footnotes_settings.php:312
#: classes/footnotes_settings.php:366
msgid "General"
msgstr "General"
#: classes/footnotes_settings.php:314
#: classes/footnotes_settings.php:368
#, php-format
msgid "%s Settings"
msgstr "%s Settings"
#: classes/footnotes_settings.php:315
#: classes/footnotes_settings.php:369
msgid "References Container"
msgstr "References Container"
#: classes/footnotes_settings.php:370
msgid "Footnotes styling"
msgstr "Footnotes styling"
#: classes/footnotes_settings.php:371
msgid "Other"
msgstr "Other"
#: classes/footnotes_settings.php:391
msgid "References label:"
msgstr "References label:"
#: classes/footnotes_settings.php:316
#: classes/footnotes_settings.php:396
msgid "Collapse references by default:"
msgstr "Collapse references by default:"
#: classes/footnotes_settings.php:317
msgid "Combine identical footnotes:"
msgstr "Combine identical footnotes:"
#: classes/footnotes_settings.php:405
msgid "in the footer"
msgstr "in the footer"
#: classes/footnotes_settings.php:318
msgid "Footnote tag:"
msgstr "Footnote tag:"
#: classes/footnotes_settings.php:406
msgid "at the end of the post"
msgstr "at the end of the post"
#: classes/footnotes_settings.php:319
msgid "Counter style:"
msgstr "Counter style:"
#: classes/footnotes_settings.php:408
msgid "Where shall the reference container appear:"
msgstr "Where shall the reference container appear:"
#: classes/footnotes_settings.php:320
msgid "Allow footnotes on Summarized Posts:"
msgstr "Allow footnotes on Summarized Posts:"
#: classes/footnotes_settings.php:321
#, php-format
msgid "Tell the world you're using %sfoot%snotes%s:"
msgstr "Tell the world you're using %sfoot%snotes%s:"
#: classes/footnotes_settings.php:362 classes/footnotes_settings.php:410
#: classes/footnotes_settings.php:425
#: classes/footnotes_settings.php:420 classes/footnotes_settings.php:457
#: classes/footnotes_settings.php:466
msgid "Yes"
msgstr "Yes"
#: classes/footnotes_settings.php:363 classes/footnotes_settings.php:411
#: classes/footnotes_settings.php:426
#: classes/footnotes_settings.php:421 classes/footnotes_settings.php:458
#: classes/footnotes_settings.php:467
msgid "No"
msgstr "No"
#: classes/footnotes_settings.php:376
msgid "starts with:"
msgstr "starts with:"
#: classes/footnotes_settings.php:423
msgid "Combine identical footnotes:"
msgstr "Combine identical footnotes:"
#: classes/footnotes_settings.php:380
msgid "ends with:"
msgstr "ends with:"
#: classes/footnotes_settings.php:428
msgid "Footnote tag starts with:"
msgstr "Footnote tag starts with:"
#: classes/footnotes_settings.php:392
#: classes/footnotes_settings.php:432
msgid "and ends with:"
msgstr "and ends with:"
#: classes/footnotes_settings.php:439
msgid "Arabic Numbers - Plain"
msgstr "Arabic Numbers - Plain"
#: classes/footnotes_settings.php:393
#: classes/footnotes_settings.php:440
msgid "Arabic Numbers - Leading 0"
msgstr "Arabic Numbers - Leading 0"
#: classes/footnotes_settings.php:394
#: classes/footnotes_settings.php:441
msgid "Latin Character - lower case"
msgstr "Latin Character - lower case"
#: classes/footnotes_settings.php:395
#: classes/footnotes_settings.php:442
msgid "Latin Character - upper case"
msgstr "Latin Character - upper case"
#: classes/footnotes_settings.php:396
#: classes/footnotes_settings.php:443
msgid "Roman Numerals"
msgstr "Roman Numerals"
#: classes/footnotes_settings.php:441 classes/footnotes_settings.php:443
#: classes/footnotes_settings.php:445
msgid "Counter style:"
msgstr "Counter style:"
#: classes/footnotes_settings.php:460
msgid "Allow footnotes on Summarized Posts:"
msgstr "Allow footnotes on Summarized Posts:"
#: classes/footnotes_settings.php:469
#, php-format
msgid "Tell the world you're using %s:"
msgstr "Tell the world you're using %s:"
#: classes/footnotes_settings.php:482
msgid "HowTo"
msgstr "HowTo"
#: classes/footnotes_settings.php:454
msgid "This is a brief introduction in how to use the plugin."
msgstr "This is a brief introduction in how to use the plugin."
#: classes/footnotes_settings.php:485
msgid "Brief introduction in how to use the plugin"
msgstr "Brief introduction in how to use the plugin"
#: classes/footnotes_settings.php:469
#: classes/footnotes_settings.php:511
msgid "Start your footnote with the following shortcode:"
msgstr "Start your footnote with the following shortcode:"
#: classes/footnotes_settings.php:474
#: classes/footnotes_settings.php:517
msgid "...and end your footnote with this shortcode:"
msgstr "...and end your footnote with this shortcode:"
#: classes/footnotes_settings.php:480 classes/footnotes_settings.php:483
#: classes/footnotes_settings.php:525 classes/footnotes_settings.php:528
msgid "example string"
msgstr "example string"
#: classes/footnotes_settings.php:481
#: classes/footnotes_settings.php:526
msgid "will be displayed as:"
msgstr "will be displayed as:"
#: classes/footnotes_settings.php:488
#: classes/footnotes_settings.php:533
#, php-format
msgid "If you have any questions, please don't hesitate to %se-mail%s us."
msgstr "If you have any questions, please don't hesitate to %se-mail%s us."
@ -127,7 +147,7 @@ msgstr "If you have any questions, please don't hesitate to %se-mail%s us."
msgid "Settings"
msgstr "Settings"
#: includes/replacer.php:109
#: includes/replacer.php:180
#, php-format
msgid "Hey there, I'm using the awesome WordPress Plugin called %s"
msgstr "Hey there, I'm using the awesome %s Plugin"
@ -140,6 +160,9 @@ msgstr "You must be logged in to run this script."
msgid "You do not have permission to run this script."
msgstr "You do not have permission to run this script."
#~ msgid "starts with:"
#~ msgstr "starts with:"
#~ msgid "Save"
#~ msgstr "Save"

View file

@ -38,6 +38,14 @@ No, this Plugin has been written from scratch. Of course some inspirations on ho
== Changelog ==
= next version =
- Update: Global styling for the public plugin name
- Update: Easier usage of the public plugin name in translations
- Update: New Layout for the settings page to group similar settings to get a better overview
- Update: Display settings submit button only if there is at least 1 editable setting in the current tab
- Add: setting where the reference container appears on public pages (needs some corrections!)
- Bugfix: displays only one reference container in front of the footer on category pages
= 1.0.6 =
- Bugfix: Uninstall function to delete all plugin settings
- Bugfix: Counter style internal name in the reference container to correctly link to the right footnote on the page above

View file

@ -3,7 +3,9 @@
[[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]]">
<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]]">
&#8593;
</a>
&nbsp;

View file

@ -1,4 +1,5 @@
<sup class="footnote_plugin_tooltip" name="footnote_plugin_tooltip_[[FOOTNOTE INDEX]]" onclick="footnote_expand_reference_container('#footnote_plugin_reference_[[FOOTNOTE INDEX]]');">
<sup class="footnote_plugin_tooltip" name="footnote_plugin_tooltip_[[FOOTNOTE INDEX]]"
onclick="footnote_expand_reference_container('#footnote_plugin_reference_[[FOOTNOTE INDEX]]');">
[[FOOTNOTE INDEX]])
<span>
[[FOOTNOTE TEXT]]