Version 1.0.2

* New setting to collapse the reference container by default
* Added link behind the footnotes to automatically jump to the reference container
* New function to easy output input fields for the settings page
* Updated translation for the new setting

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@917811 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
Aricura 2014-05-20 11:38:36 +00:00
parent 2e8614908f
commit ab368ba787
16 changed files with 655 additions and 60 deletions

105
classes/footnotes.php Normal file
View file

@ -0,0 +1,105 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/**
* Class Class_Footnotes
* @since 1.0
*/
class Class_Footnotes
{
/*
* object to the plugin's settings
* @since 1.0
*/
var $a_obj_Settings;
/**
* @constructor
* @since 1.0
*/
function __construct()
{
/* load settings only if current wordpress user is admin */
if ( is_admin() ) {
/* create a new instance of the class settings */
$this->a_obj_Settings = new Class_FootnotesSettings();
}
/* execute class function: init, admin_init and admin_menu */
add_action( 'init', array( $this, 'init' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
/* register hook for activating the plugin */
register_activation_hook( __FILE__, array( $this, 'activate' ) );
/* register hook for deactivating the plugin */
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
/* register hook for uninstalling the plugin */
register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
}
/**
* activates the plugin
* @since 1.0
*/
function activate()
{
// unused
}
/**
* deactivates the plugin
* @since 1.0
*/
function deactivate()
{
// unused
}
/**
* uninstalls the plugin
* @since 1.0
*/
function uninstall()
{
require_once( PLUGIN_DIR . '/includes/uninstall.php' );
}
/**
* initialize function
* called in the class constructor
* @since 1.0
*/
function init()
{
// unused
}
/**
* do admin init stuff
* called in the class constructor
* @since 1.0
*/
function admin_init()
{
// unused
}
/**
* do admin menu stuff
* called in the class constructor
* @since 1.0
*/
function admin_menu()
{
// unused
}
} /* class Class_Footnotes */

View file

@ -0,0 +1,411 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0-beta
* Since: 1.0
*/
/**
* Class Class_FootnotesSettings
* @since 1.0
*/
class Class_FootnotesSettings
{
/*
* attribute for default settings value
* @since 1.0
*/
public static $a_arr_Default_Settings = array(
FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL => 'yes',
FOOTNOTE_INPUTFIELD_REFERENCES_LABEL => 'References',
FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES => ''
);
/*
* resulting pagehook for adding a new sub menu page to the settings
* @since 1.0
*/
var $a_str_Pagehook;
/*
* collection of settings values for this plugin
* @since 1.0
*/
var $a_arr_Options;
/*
* collection of tabs for the settings page of this plugin
* @since 1.0
*/
private $a_arr_SettingsTabs = array();
/**
* @constructor
* @since 1.0
*/
function __construct()
{
/* validates the settings of the plugin and replaces them with the default settings if invalid */
add_option( FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings );
/* loads and filters the settings for this plugin */
$this->a_arr_Options = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER );
/* execute class includes on action-even: init, admin_init and admin_menu */
add_action( 'init', array( $this, 'LoadScriptsAndStylesheets' ) );
add_action( 'admin_init', array( $this, 'RegisterSettings' ) );
add_action( 'admin_init', array( $this, 'RegisterTab_General' ) );
add_action( 'admin_init', array( $this, 'RegisterTab_HowTo' ) );
add_action( 'admin_menu', array( $this, 'AddSettingsMenuPanel' ) );
}
/**
* initialize settings page, loads scripts and stylesheets needed for the layout
* called in class constructor @ init
* @since 1.0
*/
function LoadScriptsAndStylesheets()
{
/* add the jQuery plugin (already registered by WP) */
wp_enqueue_script( 'jquery' );
/* register public stylesheet */
wp_register_style( 'footnote_public_style', plugins_url( '../css/footnote.css', __FILE__ ) );
/* add public stylesheet */
wp_enqueue_style( 'footnote_public_style' );
/* register settings stylesheet */
wp_register_style( 'footnote_settings_style', plugins_url( '../css/settings.css', __FILE__ ) );
/* add settings stylesheet */
wp_enqueue_style( 'footnote_settings_style' );
}
/**
* register the settings field in the database for the "save" function
* called in class constructor @ admin_init
* @since 1.0
*/
function RegisterSettings()
{
register_setting( FOOTNOTE_SETTINGS_LABEL_GENERAL, FOOTNOTE_SETTINGS_CONTAINER );
}
/**
* sets the plugin's title for the admins settings menu
* called in class constructor @ admin_menu
* @since 1.0
*/
function AddSettingsMenuPanel()
{
/* current user needs the permission to update plugins for further access */
if ( !current_user_can( 'update_plugins' ) ) {
return;
}
/* submenu page title */
$l_str_PageTitle = 'footnotes';
/* submenu title */
$l_str_MenuTitle = 'footnotes';
/* 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' ) );
}
/**
* 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
*/
function OutputSettingsPage()
{
/* gets active tag, or if nothing set the "general" tab will be set to active */
$l_str_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : FOOTNOTE_SETTINGS_LABEL_GENERAL;
/* outputs all tabs */
echo '<div class="wrap">';
$this->OutputSettingsPageTabs();
/* 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( $l_str_tab );
/* outputs the settings field of the current active tab */
do_settings_sections( $l_str_tab );
/* adds a submit button to the current page */
submit_button();
echo '</form>';
echo '</div>';
}
/**
* Renders our tabs in the plugin options page,
* walks through the object's tabs array and prints
* them one by one. Provides the heading for the
* plugin_options_page method.
* @since 1.0
*/
function OutputSettingsPageTabs()
{
/* gets active tag, or if nothing set the "general" tab will be set to active */
$l_str_CurrentTab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : FOOTNOTE_SETTINGS_LABEL_GENERAL;
screen_icon();
echo '<h2 class="nav-tab-wrapper">';
foreach ( $this->a_arr_SettingsTabs as $l_str_TabKey => $l_str_TabCaption ) {
$active = $l_str_CurrentTab == $l_str_TabKey ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . $active . '" href="?page=' . FOOTNOTES_SETTINGS_PAGE_ID . '&tab=' . $l_str_TabKey . '">' . $l_str_TabCaption . '</a>';
}
echo '</h2>';
}
/**
* 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 )
{
$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 )
{
return sprintf( '%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldName );
//return sprintf( '%s', $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[%s]', FOOTNOTE_SETTINGS_CONTAINER, $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 input type=text
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [css class name]
* @since 1.0-beta
*/
function AddTextbox($p_str_SettingsID, $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 '<input type="text" '.$p_str_ClassName.' 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
*/
function AddCheckbox($p_str_SettingsID, $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 . '"';
}
/* lookup if the checkbox shall be pre-checked */
$l_str_Checked = "";
if (footnotes_ConvertToBool($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
*/
function AddSelectbox($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) {
/* 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;
}
/**
* initialize general settings tab
* called in class constructor @ admin_init
* @since 1.0
*/
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, __( "Settings", FOOTNOTES_PLUGIN_NAME ), 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 );
}
/**
* adds a desciption to the general settings tab
* called in RegisterTab_General
* @since 1.0
*/
function RegisterTab_General_Description()
{
// unused description
}
/**
* outputs the settings field for the "references label"
* @since 1.0
*/
function Register_References_Label()
{
/* add a textbox to the output */
$this->AddTextbox(FOOTNOTE_INPUTFIELD_REFERENCES_LABEL, "footnote_plugin_50");
}
/**
* outputs the settings field for the "references label"
* @since 1.0-beta
*/
function Register_Collapse_References()
{
/* add a checkbox to the output */
$this->AddCheckbox(FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES);
}
/**
* outputs the settings field for the "combine identical footnotes"
* @since 1.0
*/
function Register_Combine_Identical()
{
/* 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_COMBINE_IDENTICAL, $l_arr_Options, "footnote_plugin_25");
}
/**
* initialize howto settings tab
* called in class constructor @ admin_init
* @since 1.0
*/
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 );
}
/**
* adds a descrption to the HowTo settings tab
* called int RegisterTab_HowTo
* @since 1.0
*/
function RegisterTab_HowTo_Description()
{
echo __( "This is a brief introduction in how to use the plugin.", FOOTNOTES_PLUGIN_NAME );
}
/**
* outputs the content of the HowTo settings tab
* @since 1.0
*/
function Register_Howto_Box()
{
?>
<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 FOOTNOTE_PLACEHOLDER_START; ?></span>
</p>
<p>
<?php echo __( "...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME ); ?>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_END; ?></span>
</p>
<div class="footnote_placeholder_box_example">
<p>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_START . __( "example string", FOOTNOTES_PLUGIN_NAME ) . FOOTNOTE_PLACEHOLDER_END; ?></span>
<?php echo __( "will be displayed as:", FOOTNOTES_PLUGIN_NAME ); ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo footnotes_replaceFootnotes( FOOTNOTE_PLACEHOLDER_START . __( "example string", FOOTNOTES_PLUGIN_NAME ) . FOOTNOTE_PLACEHOLDER_END, true ); ?>
</p>
</div>
<p>
<?php echo sprintf( __( "If you have any questions, please don't hesitate to %smail us%s.", FOOTNOTES_PLUGIN_NAME ), '<a href="mailto:support@herndler.org" class="footnote_plugin">', '</a>' ); ?>
</p>
</div>
</div>
<?php
}
} /* Class Class_FootnotesSettings */

View file

@ -3,7 +3,7 @@
* User: Stefan * User: Stefan
* Date: 15.05.14 * Date: 15.05.14
* Time: 16:21 * Time: 16:21
* Version: 1.0 * Version: 1.0-beta
* Since: 1.0 * Since: 1.0
*/ */
@ -33,6 +33,11 @@
.footnote_container_prepare > p > span { .footnote_container_prepare > p > span {
padding-left: 20px !important; padding-left: 20px !important;
text-align: left !important; text-align: left !important;
cursor: pointer;
}
.footnote_hide_box {
display:none;
} }
/* container for the footnote in the bottom */ /* container for the footnote in the bottom */

View file

@ -3,15 +3,17 @@
* User: Stefan * User: Stefan
* Date: 15.05.14 * Date: 15.05.14
* Time: 16:21 * Time: 16:21
* Version: 1.0 * Version: 1.0-beta
* Since: 1.0 * Since: 1.0
*/ */
/* overwrite some styling for inputs [type=text] and select-boxes */ /* overwrite some styling for inputs [type=text] and select-boxes */
input[type=text], select { 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-left: 8px !important;
padding-right: 8px !important; padding-right: 8px !important;
margin-left: 12px !important;
} }
/* overwrite link layout on the settings page */ /* overwrite link layout on the settings page */

View file

@ -4,7 +4,7 @@
* User: Stefan * User: Stefan
* Date: 15.05.14 * Date: 15.05.14
* Time: 16:21 * Time: 16:21
* Version: 1.0 * Version: 1.0-beta
* Since: 1.0 * Since: 1.0
*/ */
@ -22,11 +22,15 @@ define( "FOOTNOTE_SETTINGS_LABEL_HOWTO", "footnotes_howto" ); /* internal label
/* PLUGIN SETTINGS INPUT FIELDS */ /* PLUGIN SETTINGS INPUT FIELDS */
define( "FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL", "footnote_inputfield_combine_identical" ); /* id of input field for the combine identical setting */ define( "FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL", "footnote_inputfield_combine_identical" ); /* id of input field for the combine identical setting */
define( "FOOTNOTE_INPUTFIELD_REFERENCES_LABEL", "footnote_inputfield_references_label" ); /* id of input field for the references label setting */ define( "FOOTNOTE_INPUTFIELD_REFERENCES_LABEL", "footnote_inputfield_references_label" ); /* id of input field for the references label setting */
define( "FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES", "footnote_inputfield_collapse_references" ); /* id of input field for the "collapse references" setting */
/* PLUGIN DEFAULT PLACEHOLDER */ /* PLUGIN DEFAULT PLACEHOLDER */
define( "FOOTNOTE_PLACEHOLDER_START", "((" ); /* defines the default start tag for the placeholder */ define( "FOOTNOTE_PLACEHOLDER_START", "((" ); /* defines the default start tag for the placeholder */
define( "FOOTNOTE_PLACEHOLDER_END", "))" ); /* defines the default end tag for the placeholder */ define( "FOOTNOTE_PLACEHOLDER_END", "))" ); /* defines the default end tag for the placeholder */
/* PLUGIN REFERENCES CONTAINER ID */
define( "FOOTNOTE_REFERENCES_CONTAINER_ID", "footnote_references_container" ); /* id for the div surrounding the footnotes */
/* PLUGIN DIRECTORIES */ /* PLUGIN DIRECTORIES */
define( "FOOTNOTES_PLUGIN_DIR_NAME", "footnotes" ); define( "FOOTNOTES_PLUGIN_DIR_NAME", "footnotes" );
define( "FOOTNOTES_LANGUAGE_DIR", dirname( __FILE__ ) . "/../languages/" ); define( "FOOTNOTES_LANGUAGE_DIR", dirname( __FILE__ ) . "/../languages/" );

View file

@ -4,7 +4,7 @@
* User: Stefan * User: Stefan
* Date: 15.05.14 * Date: 15.05.14
* Time: 16:21 * Time: 16:21
* Version: 1.0 * Version: 1.0-beta
* Since: 1.0 * Since: 1.0
*/ */
@ -33,7 +33,7 @@ function footnotes_plugin_settings_link( $links, $file )
* @param string $p_str_OptionsField * @param string $p_str_OptionsField
* @return array * @return array
*/ */
function footnote_filter_options( $p_str_OptionsField ) function footnotes_filter_options( $p_str_OptionsField )
{ {
$l_arr_Options = get_option( $p_str_OptionsField ); $l_arr_Options = get_option( $p_str_OptionsField );
/* loop through all keys in the array and filters them */ /* loop through all keys in the array and filters them */
@ -43,3 +43,25 @@ function footnote_filter_options( $p_str_OptionsField )
/* returns the filtered array */ /* returns the filtered array */
return $l_arr_Options; return $l_arr_Options;
} }
/**
* converts a string depending on its value to a boolean
* @since 1.0-beta
* @param string $p_str_Value
* @return bool
*/
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 */
switch($p_str_Value) {
case "checked":
case "yes":
case "true":
case "on":
case "1":
return true;
}
/* nothing found that says "true", so we return false */
return false;
}

View file

@ -14,6 +14,12 @@
*/ */
$g_arr_Footnotes = array(); $g_arr_Footnotes = array();
/*
* collection of all footnotes settings
* @since 1.0-beta
*/
$g_arr_FootnotesSettings = array();
/** /**
* starts listening for footnotes to be replaced * starts listening for footnotes to be replaced
* output will be buffered and not displayed * output will be buffered and not displayed
@ -23,7 +29,13 @@ $g_arr_Footnotes = array();
*/ */
function footnotes_startReplacing( $p_str_Content ) 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" ); ob_start( "footnotes_replaceFootnotes" );
/* load footnote settings */
$g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER );
/* return unchanged content */
return $p_str_Content; return $p_str_Content;
} }
@ -35,6 +47,7 @@ function footnotes_startReplacing( $p_str_Content )
*/ */
function footnotes_DummyReplacing( $p_str_Content ) function footnotes_DummyReplacing( $p_str_Content )
{ {
/* return unchanged content */
return $p_str_Content; return $p_str_Content;
} }
@ -45,6 +58,7 @@ function footnotes_DummyReplacing( $p_str_Content )
*/ */
function footnotes_StopReplacing() function footnotes_StopReplacing()
{ {
/* calls the callback function defined in ob_start(); */
ob_end_flush(); ob_end_flush();
} }
@ -130,6 +144,9 @@ function footnotes_getFromString( $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 * @since 1.0
* @return string * @return string
*/ */
@ -137,6 +154,8 @@ function footnotes_OutputReferenceContainer()
{ {
/* get access to the global array to read footnotes */ /* get access to the global array to read footnotes */
global $g_arr_Footnotes; global $g_arr_Footnotes;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* no footnotes has been replaced on this page */ /* no footnotes has been replaced on this page */
if ( empty( $g_arr_Footnotes ) ) { if ( empty( $g_arr_Footnotes ) ) {
@ -144,20 +163,22 @@ function footnotes_OutputReferenceContainer()
return ""; return "";
} }
/* read settings */ /* get setting for combine identical footnotes and convert it to boolean */
$l_arr_Options = footnote_filter_options( FOOTNOTE_SETTINGS_CONTAINER ); $l_bool_CombineIdentical = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL ]);
/* get setting for combine identical footnotes */
$l_str_CombineIdentical = $l_arr_Options[ FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL ];
/* get setting for preferences label */ /* get setting for preferences label */
$l_str_ReferencesLabel = $l_arr_Options[ FOOTNOTE_INPUTFIELD_REFERENCES_LABEL ]; $l_str_ReferencesLabel = $g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_REFERENCES_LABEL ];
/* convert it from string to boolean */ /* get setting for collapse reference footnotes and convert it to boolean */
$l_bool_CombineIdentical = false; $l_bool_CollapseReference = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES ]);
if ( $l_str_CombineIdentical == "yes" ) {
$l_bool_CombineIdentical = true;
}
/* output string */ /* output string, prepare it with the reference label as headline */
$l_str_Output = '<div class="footnote_container_prepare"><p><span>' . $l_str_ReferencesLabel . '</span></p></div>'; $l_str_Output = '<div class="footnote_container_prepare"><p><span onclick="footnote_expand_reference_container();">' . $l_str_ReferencesLabel . '</span></p></div>';
/* add a box around the footnotes */
$l_str_Output .= '<div id="'.FOOTNOTE_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 */ /* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents( FOOTNOTES_TEMPLATES_DIR . "container.html" ); $l_str_FootnoteTemplate = file_get_contents( FOOTNOTES_TEMPLATES_DIR . "container.html" );
@ -195,6 +216,17 @@ function footnotes_OutputReferenceContainer()
/* add the footnote container to the output */ /* add the footnote container to the output */
$l_str_Output = $l_str_Output . $l_str_ReplaceText; $l_str_Output = $l_str_Output . $l_str_ReplaceText;
} }
/* add closing tag for the div of the references container */
$l_str_Output = $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() {
jQuery("#'.FOOTNOTE_REFERENCES_CONTAINER_ID.'").show();
}
</script>
';
/* return the output string */ /* return the output string */
return $l_str_Output; return $l_str_Output;
} }

View file

@ -16,9 +16,9 @@
function footnotes_add_public_stylesheet() function footnotes_add_public_stylesheet()
{ {
/* register public stylesheet */ /* register public stylesheet */
wp_register_style( 'footnote_public_style', plugins_url( '../css/footnote.css', __FILE__ ) ); wp_register_style( 'footnotes_public_style', plugins_url( '../css/footnote.css', __FILE__ ) );
/* add public stylesheet */ /* add public stylesheet */
wp_enqueue_style( 'footnote_public_style' ); wp_enqueue_style( 'footnotes_public_style' );
} }
/** /**
@ -28,7 +28,7 @@ function footnotes_add_public_stylesheet()
function footnotes_add_settings_stylesheet() function footnotes_add_settings_stylesheet()
{ {
/* register settings stylesheet */ /* register settings stylesheet */
wp_register_style( 'footnote_settings_style', plugins_url( '../css/settings.css', __FILE__ ) ); wp_register_style( 'footnotes_settings_style', plugins_url( '../css/settings.css', __FILE__ ) );
/* add settings stylesheet */ /* add settings stylesheet */
wp_enqueue_style( 'footnote_settings_style' ); wp_enqueue_style( 'footnotes_settings_style' );
} }

View file

@ -4,13 +4,13 @@
Plugin URI: http://www.herndler.org Plugin URI: http://www.herndler.org
Description: simple adding footnotes to your pages Description: simple adding footnotes to your pages
Author: Mark Cheret, Stefan Herndler Author: Mark Cheret, Stefan Herndler
Version: 1.0.1 Version: 1.0.2
Author URI: http://www.cheret.de Author URI: http://www.cheret.de
Text Domain: footnotes Text Domain: footnotes
Domain Path: /languages Domain Path: /languages
*/ */
/* /*
Copyright 2014 Mark Cheret, Stefan Herndler (email : mark@cheret.de | admin@herndler.org) Copyright 2014 Mark Cheret, Stefan Herndler (email : mark@cheret.de | support@herndler.org)
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 3, as it under the terms of the GNU General Public License, version 3, as
@ -69,9 +69,9 @@ if ( !function_exists( 'is_admin' ) ) {
} }
/* require plugin class */ /* require plugin class */
require_once( dirname( __FILE__ ) . "/classes/footnote.php" ); require_once( dirname( __FILE__ ) . "/classes/footnotes.php" );
/* require plugin settings class */ /* require plugin settings class */
require_once( dirname( __FILE__ ) . "/classes/footnote_settings.php" ); require_once( dirname( __FILE__ ) . "/classes/footnotes_settings.php" );
/* action to locate language and load the wordpress-specific language file */ /* action to locate language and load the wordpress-specific language file */
add_action( 'plugins_loaded', 'footnotes_load_language' ); add_action( 'plugins_loaded', 'footnotes_load_language' );

Binary file not shown.

View file

@ -1,8 +1,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: footnotes\n" "Project-Id-Version: footnotes\n"
"POT-Creation-Date: 2014-05-16 20:06+0100\n" "POT-Creation-Date: 2014-05-16 21:52+0100\n"
"PO-Revision-Date: 2014-05-16 20:07+0100\n" "PO-Revision-Date: 2014-05-16 21:53+0100\n"
"Last-Translator: SHE <s.herndler@methis.at>\n" "Last-Translator: SHE <s.herndler@methis.at>\n"
"Language-Team: SHE <s.herndler@methis.at>\n" "Language-Team: SHE <s.herndler@methis.at>\n"
"Language: de\n" "Language: de\n"
@ -18,55 +18,59 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPath-0: .\n"
#: classes/footnote_settings.php:213 #: classes/footnotes_settings.php:298
msgid "General" msgid "General"
msgstr "Allgemein" msgstr "Allgemein"
#: classes/footnote_settings.php:215 includes/plugin-settings.php:22 #: classes/footnotes_settings.php:300 includes/plugin-settings.php:22
msgid "Settings" msgid "Settings"
msgstr "Einstellungen" msgstr "Einstellungen"
#: classes/footnote_settings.php:216 #: classes/footnotes_settings.php:301
msgid "References label:" msgid "References label:"
msgstr "Überschrift \"Einzelnachweis\":" msgstr "Überschrift \"Einzelnachweis\":"
#: classes/footnote_settings.php:217 #: classes/footnotes_settings.php:302
msgid "Collapse references by default:"
msgstr "Verstecke Einzelnachweise standardmäßig:"
#: classes/footnotes_settings.php:303
msgid "Combine identical footnotes:" msgid "Combine identical footnotes:"
msgstr "Kombiniere meine Fußnoten:" msgstr "Kombiniere meine Fußnoten:"
#: classes/footnote_settings.php:260 #: classes/footnotes_settings.php:344
msgid "Yes" msgid "Yes"
msgstr "Ja" msgstr "Ja"
#: classes/footnote_settings.php:261 #: classes/footnotes_settings.php:345
msgid "No" msgid "No"
msgstr "Nein" msgstr "Nein"
#: classes/footnote_settings.php:282 classes/footnote_settings.php:284 #: classes/footnotes_settings.php:360 classes/footnotes_settings.php:362
msgid "HowTo" msgid "HowTo"
msgstr "Hilfe" msgstr "Hilfe"
#: classes/footnote_settings.php:295 #: classes/footnotes_settings.php:373
msgid "This is a brief introduction in how to use the plugin." msgid "This is a brief introduction in how to use the plugin."
msgstr "Eine kurze Anleitung für die Verwendung des Plugins." msgstr "Eine kurze Anleitung für die Verwendung des Plugins."
#: classes/footnote_settings.php:308 #: classes/footnotes_settings.php:386
msgid "Start your footnote with the following shortcode:" msgid "Start your footnote with the following shortcode:"
msgstr "Starten Sie eine Fußnote mit:" msgstr "Starten Sie eine Fußnote mit:"
#: classes/footnote_settings.php:313 #: classes/footnotes_settings.php:391
msgid "...and end your footnote with this shortcode:" msgid "...and end your footnote with this shortcode:"
msgstr "...und beenden Sie diese mit:" msgstr "...und beenden Sie diese mit:"
#: classes/footnote_settings.php:320 classes/footnote_settings.php:323 #: classes/footnotes_settings.php:397 classes/footnotes_settings.php:400
msgid "example string" msgid "example string"
msgstr "Beispieltext" msgstr "Beispieltext"
#: classes/footnote_settings.php:321 #: classes/footnotes_settings.php:398
msgid "will be displayed as:" msgid "will be displayed as:"
msgstr "wird dargestellt als:" msgstr "wird dargestellt als:"
#: classes/footnote_settings.php:329 #: classes/footnotes_settings.php:405
#, php-format #, php-format
msgid "If you have any questions, please don't hesitate to %smail us%s." msgid "If you have any questions, please don't hesitate to %smail us%s."
msgstr "Bei Fragen können Sie uns gerne eine %se-Mail%s senden." msgstr "Bei Fragen können Sie uns gerne eine %se-Mail%s senden."

Binary file not shown.

View file

@ -1,8 +1,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: footnotes\n" "Project-Id-Version: footnotes\n"
"POT-Creation-Date: 2014-05-16 20:06+0100\n" "POT-Creation-Date: 2014-05-16 21:52+0100\n"
"PO-Revision-Date: 2014-05-16 20:06+0100\n" "PO-Revision-Date: 2014-05-16 21:52+0100\n"
"Last-Translator: SHE <s.herndler@methis.at>\n" "Last-Translator: SHE <s.herndler@methis.at>\n"
"Language-Team: SHE <s.herndler@methis.at>\n" "Language-Team: SHE <s.herndler@methis.at>\n"
"Language: en\n" "Language: en\n"
@ -18,55 +18,59 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPath-0: .\n"
#: classes/footnote_settings.php:213 #: classes/footnotes_settings.php:298
msgid "General" msgid "General"
msgstr "General" msgstr "General"
#: classes/footnote_settings.php:215 includes/plugin-settings.php:22 #: classes/footnotes_settings.php:300 includes/plugin-settings.php:22
msgid "Settings" msgid "Settings"
msgstr "Settings" msgstr "Settings"
#: classes/footnote_settings.php:216 #: classes/footnotes_settings.php:301
msgid "References label:" msgid "References label:"
msgstr "References label:" msgstr "References label:"
#: classes/footnote_settings.php:217 #: classes/footnotes_settings.php:302
msgid "Collapse references by default:"
msgstr "Collapse references by default:"
#: classes/footnotes_settings.php:303
msgid "Combine identical footnotes:" msgid "Combine identical footnotes:"
msgstr "Combine identical footnotes:" msgstr "Combine identical footnotes:"
#: classes/footnote_settings.php:260 #: classes/footnotes_settings.php:344
msgid "Yes" msgid "Yes"
msgstr "Yes" msgstr "Yes"
#: classes/footnote_settings.php:261 #: classes/footnotes_settings.php:345
msgid "No" msgid "No"
msgstr "No" msgstr "No"
#: classes/footnote_settings.php:282 classes/footnote_settings.php:284 #: classes/footnotes_settings.php:360 classes/footnotes_settings.php:362
msgid "HowTo" msgid "HowTo"
msgstr "HowTo" msgstr "HowTo"
#: classes/footnote_settings.php:295 #: classes/footnotes_settings.php:373
msgid "This is a brief introduction in how to use the plugin." msgid "This is a brief introduction in how to use the plugin."
msgstr "This is a brief introduction in how to use the plugin." msgstr "This is a brief introduction in how to use the plugin."
#: classes/footnote_settings.php:308 #: classes/footnotes_settings.php:386
msgid "Start your footnote with the following shortcode:" msgid "Start your footnote with the following shortcode:"
msgstr "Start your footnote with the following shortcode:" msgstr "Start your footnote with the following shortcode:"
#: classes/footnote_settings.php:313 #: classes/footnotes_settings.php:391
msgid "...and end your footnote with this shortcode:" msgid "...and end your footnote with this shortcode:"
msgstr "...and end your footnote with this shortcode:" msgstr "...and end your footnote with this shortcode:"
#: classes/footnote_settings.php:320 classes/footnote_settings.php:323 #: classes/footnotes_settings.php:397 classes/footnotes_settings.php:400
msgid "example string" msgid "example string"
msgstr "example string" msgstr "example string"
#: classes/footnote_settings.php:321 #: classes/footnotes_settings.php:398
msgid "will be displayed as:" msgid "will be displayed as:"
msgstr "will be displayed as:" msgstr "will be displayed as:"
#: classes/footnote_settings.php:329 #: classes/footnotes_settings.php:405
#, php-format #, php-format
msgid "If you have any questions, please don't hesitate to %smail us%s." msgid "If you have any questions, please don't hesitate to %smail us%s."
msgstr "If you have any questions, please don't hesitate to %smail us%s." msgstr "If you have any questions, please don't hesitate to %smail us%s."

View file

@ -5,7 +5,7 @@ Requires at least: 3.9
Tested up to: 3.9.1 Tested up to: 3.9.1
License: GPLv3 or later License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html
Stable Tag: 1.0.1 Stable tag: 1.0.2
== Description == == Description ==
@ -35,6 +35,12 @@ coming soon
== Changelog == == Changelog ==
= 1.0.2 =
* New setting to collapse the reference container by default
* Added link behind the footnotes to automatically jump to the reference container
* New function to easy output input fields for the settings page
* Updated translation for the new setting
= 1.0.1 = = 1.0.1 =
* Separated functions in different files for a better overview * Separated functions in different files for a better overview
* Added a version control to each file / class / function / variable * Added a version control to each file / class / function / variable

View file

@ -3,7 +3,7 @@
[[FOOTNOTE INDEX]]. [[FOOTNOTE INDEX]].
</div> </div>
<div class="footnote_plugin_text"> <div class="footnote_plugin_text">
<a class="footnote_plugin_link" href="#footnote_plugin_tooltip_[[FOOTNOTE INDEX SHORT]]"> <a class="footnote_plugin_link" href="#footnote_plugin_tooltip_[[FOOTNOTE INDEX SHORT]]" name="footnote_plugin_reference_[[FOOTNOTE INDEX SHORT]]">
&#8593; &#8593;
</a> </a>
&nbsp; &nbsp;

View file

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