- 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

@ -27,22 +27,22 @@ class Class_Footnotes
function __construct()
{
/* load settings only if current wordpress user is admin */
if ( 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' ) );
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_activation_hook(__FILE__, array($this, 'activate'));
/* register hook for deactivating the plugin */
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
register_deactivation_hook(__FILE__, array($this, 'deactivate'));
/* register hook for uninstalling the plugin */
register_uninstall_hook( __FILE__, array( $this, 'uninstall' ) );
register_uninstall_hook(__FILE__, array($this, 'uninstall'));
}
/**
@ -70,7 +70,7 @@ class Class_Footnotes
*/
function uninstall()
{
require_once( dirname(__FILE__) . '/../includes/uninstall.php' );
require_once(dirname(__FILE__) . '/../includes/uninstall.php');
}
/**

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
@ -52,16 +53,16 @@ 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, true );
$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' ) );
add_action( 'admin_init', array( $this, 'RegisterSettings' ) );
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_init', array($this, 'RegisterTab_General'));
add_action('admin_init', array($this, 'RegisterTab_HowTo'));
add_action( 'admin_menu', array( $this, 'AddSettingsMenuPanel' ) );
add_action('admin_menu', array($this, 'AddSettingsMenuPanel'));
}
/**
@ -72,15 +73,17 @@ class Class_FootnotesSettings
function LoadScriptsAndStylesheets()
{
/* add the jQuery plugin (already registered by WP) */
wp_enqueue_script( 'jquery' );
wp_enqueue_script('jquery');
/* register public stylesheet */
wp_register_style( 'footnote_public_style', plugins_url( '../css/footnote.css', __FILE__ ) );
wp_register_style('footnote_public_style', plugins_url('../css/footnote.css', __FILE__));
/* add public stylesheet */
wp_enqueue_style( 'footnote_public_style' );
wp_enqueue_style('footnote_public_style');
/* register settings stylesheet */
wp_register_style( 'footnote_settings_style', plugins_url( '../css/settings.css', __FILE__ ) );
wp_register_style('footnote_settings_style', plugins_url('../css/settings.css', __FILE__));
/* add settings stylesheet */
wp_enqueue_style( 'footnote_settings_style' );
wp_enqueue_style('footnote_settings_style');
/* Needed to allow metabox layout and close functionality */
wp_enqueue_script('postbox');
}
/**
@ -90,7 +93,7 @@ class Class_FootnotesSettings
*/
function RegisterSettings()
{
register_setting( FOOTNOTE_SETTINGS_LABEL_GENERAL, FOOTNOTE_SETTINGS_CONTAINER );
register_setting(FOOTNOTE_SETTINGS_LABEL_GENERAL, FOOTNOTE_SETTINGS_CONTAINER);
}
/**
@ -101,15 +104,15 @@ class Class_FootnotesSettings
function AddSettingsMenuPanel()
{
/* current user needs the permission to update plugins for further access */
if ( !current_user_can( 'update_plugins' ) ) {
if (!current_user_can('update_plugins')) {
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' ) );
$this->a_str_Pagehook = add_options_page($l_str_PageTitle, $l_str_MenuTitle, 'administrator', FOOTNOTES_SETTINGS_PAGE_ID, array($this, 'OutputSettingsPage'));
}
/**
@ -122,20 +125,32 @@ class Class_FootnotesSettings
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;
$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 );
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 );
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();
}
/**
@ -148,28 +163,47 @@ class Class_FootnotesSettings
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;
$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 ) {
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>';
}
/**
* 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
* @param $p_str_FieldID
* @return array
*/
protected function LoadSetting( $p_str_FieldID )
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 ) );
$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;
}
@ -179,9 +213,9 @@ class Class_FootnotesSettings
* @param string $p_str_FieldName
* @return string
*/
protected function getFieldName( $p_str_FieldName )
protected function getFieldName($p_str_FieldName)
{
return sprintf( '%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldName );
return sprintf('%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldName);
//return sprintf( '%s', $p_str_FieldName );
}
@ -191,9 +225,9 @@ class Class_FootnotesSettings
* @param string $p_str_FieldID
* @return string
*/
protected function getFieldID( $p_str_FieldID )
protected function getFieldID($p_str_FieldID)
{
return sprintf( '%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldID );
return sprintf('%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldID);
//return sprintf( '%s', $p_str_FieldID );
}
@ -203,9 +237,34 @@ class Class_FootnotesSettings
* @param string $p_str_Key
* @return string
*/
protected function getFieldValue( $p_str_Key )
protected function getFieldValue($p_str_Key)
{
return $this->a_arr_Options[ $p_str_Key ];
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>';
}
/**
@ -213,13 +272,13 @@ class Class_FootnotesSettings
* @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 );
$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)) {
@ -227,15 +286,10 @@ class Class_FootnotesSettings
}
/* optional add a maxlength to the input field */
if (!empty($p_str_MaxLength)) {
$p_str_MaxLength = ' maxlength="'.$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" ].'"/>';
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"] . '"/>';
}
/**
@ -244,10 +298,10 @@ class Class_FootnotesSettings
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
function AddCheckbox($p_str_SettingsID, $p_str_ClassName="")
function AddCheckbox($p_str_SettingsID, $p_str_ClassName = "")
{
/* collect data for given settings field */
$l_arr_Data = $this->LoadSetting( $p_str_SettingsID );
$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)) {
@ -261,7 +315,7 @@ class Class_FootnotesSettings
}
/* 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);
echo sprintf('<input type="checkbox" ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" %s/>', $l_str_Checked);
}
/**
@ -271,10 +325,10 @@ class Class_FootnotesSettings
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
function AddSelectbox($p_str_SettingsID, $p_arr_Options, $p_str_ClassName="")
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 );
$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)) {
@ -282,11 +336,11 @@ class Class_FootnotesSettings
}
/* select starting tag */
$l_str_Output = '<select ' . $p_str_ClassName . ' name="'.$l_arr_Data[ "name" ].'" id="'.$l_arr_Data[ "id" ].'">';
$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) {
foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) {
/* add key as option value */
$l_str_Output .= '<option value="'.$l_str_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';
@ -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 );
$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,133 +382,125 @@ 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();
/**
* outputs the settings field for the "combine identical footnotes"
* @since 1.0
/*
* setting for 'placement of the reference container'
* @since 1.0.7
*/
function Register_Combine_Identical()
{
/* get array with option elements */
$l_arr_Options = array(
"yes" => __( "Yes", FOOTNOTES_PLUGIN_NAME ),
"no" => __( "No", FOOTNOTES_PLUGIN_NAME )
"footer" => __("in the footer", FOOTNOTES_PLUGIN_NAME),
"post_end" => __("at the end of the post", 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_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 fields for the footnote starting and ending tag
* @since 1.0-gamma
* outputs a container for the styling of footnotes
* @since 1.0.7
*/
function Register_Placeholder_Tags()
function Register_MetaBox_FootnoteStyling()
{
/* 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 'combine identical footnotes' */
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$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();
/**
* outouts the settings field for the counter style
* @since 1.0-gamma
*/
function Register_CounterStyle()
{
/* 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);
/* 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, ...",
"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, ..."
"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->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 )
"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 )
"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 );
$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);
@ -466,26 +508,29 @@ class Class_FootnotesSettings
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __( "Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME ); ?>
<span class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"]; ?></span>
<?php echo __("Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"]; ?></span>
</p>
<p>
<?php echo __( "...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME ); ?>
<span class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_EndingTag["value"]; ?></span>
<?php echo __("...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_EndingTag["value"]; ?></span>
</p>
<div class="footnote_placeholder_box_example">
<p>
<span class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"] . __( "example string", FOOTNOTES_PLUGIN_NAME ) . $l_arr_Footnote_EndingTag["value"]; ?></span>
<?php echo __( "will be displayed as:", FOOTNOTES_PLUGIN_NAME ); ?>
<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 ); ?>
<?php echo footnotes_replaceFootnotes($l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"], true, true); ?>
</p>
</div>
<p>
<?php echo sprintf( __( "If you have any questions, please don't hesitate to %se-mail%s us.", FOOTNOTES_PLUGIN_NAME ), '<a href="mailto:mci@cheret.co.uk" class="footnote_plugin">', '</a>' ); ?>
<?php echo sprintf(__("If you have any questions, please don't hesitate to %se-mail%s us.", FOOTNOTES_PLUGIN_NAME), '<a href="mailto:mci@cheret.co.uk" class="footnote_plugin">', '</a>'); ?>
</p>
</div>
</div>

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;
@ -37,7 +54,7 @@
}
.footnote_hide_box {
display:none;
display: none;
}
/* container for the footnote in the bottom */

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

@ -16,9 +16,9 @@
* @param string $p_str_ConvertStyle [counter style]
* @return string
*/
function footnote_convert_index($p_int_Index, $p_str_ConvertStyle="arabic_plain")
function footnote_convert_index($p_int_Index, $p_str_ConvertStyle = "arabic_plain")
{
switch($p_str_ConvertStyle) {
switch ($p_str_ConvertStyle) {
case "romanic":
return footnote_convert_to_romanic($p_int_Index);
case "latin_high":
@ -44,16 +44,16 @@ function footnote_convert_index($p_int_Index, $p_str_ConvertStyle="arabic_plain"
function footnote_convert_to_latin($p_int_Value, $p_bool_UpperCase)
{
/* decimal value of the starting ascii character */
$l_int_StartinAscii = 65-1; // = A
$l_int_StartinAscii = 65 - 1; // = A
/* if lower-case, change decimal to lower-case "a" */
if (!$p_bool_UpperCase) {
$l_int_StartinAscii = 97-1; // = a
$l_int_StartinAscii = 97 - 1; // = a
}
/* output string */
$l_str_Return = "";
$l_int_Offset = 0;
/* check if the value is higher then 26 = Z */
while($p_int_Value > 26) {
while ($p_int_Value > 26) {
/* increase offset and reduce counter */
$l_int_Offset++;
$p_int_Value -= 26;
@ -92,13 +92,13 @@ function footnote_convert_to_arabic_leading($p_int_Value)
function footnote_convert_to_romanic($p_int_Value)
{
/* table containing all necessary romanic letters */
$l_arr_RomanicLetters = array('M'=>1000, 'CM'=>900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1);
$l_arr_RomanicLetters = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1);
/* return value */
$l_str_Return = '';
/* loop through integer value until it is reduced to 0 */
while($p_int_Value > 0) {
foreach($l_arr_RomanicLetters as $l_str_Romanic => $l_int_Arabic) {
if($p_int_Value >= $l_int_Arabic) {
while ($p_int_Value > 0) {
foreach ($l_arr_RomanicLetters as $l_str_Romanic => $l_int_Arabic) {
if ($p_int_Value >= $l_int_Arabic) {
$p_int_Value -= $l_int_Arabic;
$l_str_Return .= $l_str_Romanic;
break;

View file

@ -8,31 +8,42 @@
* 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 */
define("FOOTNOTES_PLUGIN_NAME", "footnotes"); /* plugin's internal name */
define("FOOTNOTE_SETTINGS_CONTAINER", "footnotes_storage"); /* database container where all footnote settings are stored */
/* PLUGIN SETTINGS PAGE */
define( "FOOTNOTES_SETTINGS_PAGE_ID", "footnotes" ); /* plugin's setting page internal id */
define("FOOTNOTES_SETTINGS_PAGE_ID", "footnotes"); /* plugin's setting page internal id */
/* PLUGIN SETTINGS PAGE TABS */
define( "FOOTNOTE_SETTINGS_LABEL_GENERAL", "footnotes_general_settings" ); /* internal label for the plugin's settings tab */
define( "FOOTNOTE_SETTINGS_LABEL_HOWTO", "footnotes_howto" ); /* internal label for the plugin's settings tab */
define("FOOTNOTE_SETTINGS_LABEL_GENERAL", "footnotes_general_settings"); /* internal label for the plugin's settings tab */
define("FOOTNOTE_SETTINGS_LABEL_HOWTO", "footnotes_howto"); /* internal label for the plugin's settings tab */
/* 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_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 */
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 */
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_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 */
/*
* 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 */
define("FOOTNOTE_REFERENCES_CONTAINER_ID", "footnote_references_container"); /* id for the div surrounding the footnotes */
/* PLUGIN DIRECTORIES */
define( "FOOTNOTES_PLUGIN_DIR_NAME", "footnotes" );
define( "FOOTNOTES_LANGUAGE_DIR", dirname( __FILE__ ) . "/../languages/" );
define( "FOOTNOTES_TEMPLATES_DIR", dirname( __FILE__ ) . "/../templates/" );
define("FOOTNOTES_PLUGIN_DIR_NAME", "footnotes");
define("FOOTNOTES_LANGUAGE_DIR", dirname(__FILE__) . "/../languages/");
define("FOOTNOTES_TEMPLATES_DIR", dirname(__FILE__) . "/../templates/");

View file

@ -17,19 +17,19 @@
function footnotes_load_language()
{
/* read current wordpress langauge */
$l_str_locale = apply_filters( 'plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME );
$l_str_locale = apply_filters('plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME);
/* get only language code (removed localization code) */
$l_str_languageCode = footnotes_getLanguageCode();
/* language file with localization exists */
if ( $l_bool_loaded = load_textdomain( FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_locale . '.mo' ) ) {
if ($l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_locale . '.mo')) {
/* language file without localization exists */
} else if ( $l_bool_loaded = load_textdomain( FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_languageCode . '.mo' ) ) {
} else if ($l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_languageCode . '.mo')) {
/* load default language file, nothing will happen: default language will be used (=english) */
} else {
load_textdomain( FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-en.mo' );
load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-en.mo');
}
}
@ -42,14 +42,14 @@ function footnotes_load_language()
function footnotes_getLanguageCode()
{
/* read current wordpress langauge */
$l_str_locale = apply_filters( 'plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME );
$l_str_locale = apply_filters('plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME);
/* check if wordpress language has a localization (e.g. "en_US" or "de_AT") */
if ( strpos( $l_str_locale, "_" ) !== false ) {
if (strpos($l_str_locale, "_") !== false) {
/* remove localization code */
$l_arr_languageCode = explode( "_", $l_str_locale );
$l_str_languageCode = $l_arr_languageCode[ 0 ];
$l_arr_languageCode = explode("_", $l_str_locale);
$l_str_languageCode = $l_arr_languageCode[0];
return $l_str_languageCode;
}
/* return language code lowercase */
return strtolower( $l_str_locale );
return strtolower($l_str_locale);
}

View file

@ -16,11 +16,11 @@
* @param mixed $file
* @return array
*/
function footnotes_plugin_settings_link( $links, $file )
function footnotes_plugin_settings_link($links, $file)
{
/* add link to the /forms.contact plugin's settings page */
$settings_link = '<a href="' . admin_url( 'options-general.php?page=' . FOOTNOTES_SETTINGS_PAGE_ID ) . '">' . __( 'Settings', FOOTNOTES_PLUGIN_NAME ) . '</a>';
array_unshift( $links, $settings_link );
$settings_link = '<a href="' . admin_url('options-general.php?page=' . FOOTNOTES_SETTINGS_PAGE_ID) . '">' . __('Settings', FOOTNOTES_PLUGIN_NAME) . '</a>';
array_unshift($links, $settings_link);
/* return new links */
return $links;
@ -36,25 +36,25 @@ function footnotes_plugin_settings_link( $links, $file )
* @param bool $p_bool_ConvertHtmlChars
* @return array
*/
function footnotes_filter_options( $p_str_OptionsField, $p_arr_DefaultValues, $p_bool_ConvertHtmlChars=true )
function footnotes_filter_options($p_str_OptionsField, $p_arr_DefaultValues, $p_bool_ConvertHtmlChars = true)
{
$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 */
foreach ( $l_arr_Options as $l_str_Key => $l_str_Value ) {
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 );
$l_str_Value = stripcslashes($l_str_Value);
/* if set, convert html special chars */
if ($p_bool_ConvertHtmlChars) {
$l_str_Value = htmlspecialchars( $l_str_Value );
$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 );
$l_arr_Options[$l_str_Key] = stripcslashes($l_str_Value);
/* check if default value is defined */
} else if (array_key_exists($l_str_Key, $p_arr_DefaultValues)) {
$l_arr_Options[ $l_str_Key ] = $p_arr_DefaultValues[$l_str_Key];
$l_arr_Options[$l_str_Key] = $p_arr_DefaultValues[$l_str_Key];
} else {
$l_arr_Options[ $l_str_Key ] = "";
$l_arr_Options[$l_str_Key] = "";
}
}
/* returns the filtered array */
@ -67,11 +67,12 @@ 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 */
switch($p_str_Value) {
switch ($p_str_Value) {
case "checked":
case "yes":
case "true":

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 ]);
$g_arr_FootnotesSettings = footnotes_filter_options(FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, false);
/* calls the wordpress filter function to replace page content before displayed on public pages */
add_filter( 'the_content', 'footnotes_startReplacing' );
/* 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');
/* 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) {
add_filter( 'the_excerpt', 'footnotes_DummyReplacing' );
footnotes_StopReplacing();
footnotes_startReplacing();
}
/* returns content */
return $p_str_Content;
}
/* 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' );
/**
* 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;
}
/* 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);
}
/**
* 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;
}
/**
* 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;
ob_start("footnotes_replaceFootnotes");
/* set flag to only start stopping the output once */
$g_bool_FootnotesReplacementStarted = true;
}
}
/**
* 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>'
;
<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;">' . FOOTNOTES_PLUGIN_PUBLIC_NAME . '</a>') .
'</div>';
}
}
/**
@ -120,19 +191,19 @@ function footnotes_LoveAndShareMe()
* @param bool $p_bool_ReplaceHtmlChars [ default: false]
* @return string
*/
function footnotes_replaceFootnotes( $p_str_Content, $p_bool_OutputReferences = true, $p_bool_ReplaceHtmlChars = false )
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;
/* load footnote settings */
$g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, $p_bool_ReplaceHtmlChars );
$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 );
$p_str_Content = footnotes_getFromString($p_str_Content);
/* add the reference list if set */
if ( $p_bool_OutputReferences ) {
if ($p_bool_OutputReferences) {
$p_str_Content = $p_str_Content . footnotes_OutputReferenceContainer();
/* free all found footnotes if reference container will be displayed */
$g_arr_Footnotes = array();
@ -148,7 +219,7 @@ function footnotes_replaceFootnotes( $p_str_Content, $p_bool_OutputReferences =
* @param string $p_str_Content
* @return string
*/
function footnotes_getFromString( $p_str_Content )
function footnotes_getFromString($p_str_Content)
{
/* get access to the global array to store footnotes */
global $g_arr_Footnotes;
@ -159,7 +230,7 @@ function footnotes_getFromString( $p_str_Content )
/* contains the starting position for the lookup of a footnote */
$l_int_PosStart = 0;
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents( FOOTNOTES_TEMPLATES_DIR . "footnote.html" );
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "footnote.html");
/* get footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START];
/*get footnote ending tag */
@ -170,28 +241,28 @@ function footnotes_getFromString( $p_str_Content )
/* check for a footnote placeholder in the current page */
do {
/* get first occurence of a footnote starting tag */
$l_int_PosStart = strpos( $p_str_Content, $l_str_StartingTag, $l_int_PosStart );
$l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart);
/* tag found */
if ( $l_int_PosStart !== false ) {
if ($l_int_PosStart !== false) {
/* get first occurence of a footnote ending tag after the starting tag */
$l_int_PosEnd = strpos( $p_str_Content, $l_str_EndingTag, $l_int_PosStart );
$l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart);
/* tag found */
if ( $l_int_PosEnd !== false ) {
if ($l_int_PosEnd !== false) {
/* get length of footnote text */
$l_int_Length = $l_int_PosEnd - $l_int_PosStart;
/* get text inside footnote */
$l_str_FootnoteText = substr( $p_str_Content, $l_int_PosStart + strlen( $l_str_StartingTag ), $l_int_Length - strlen( $l_str_StartingTag ) );
$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]]", 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 );
$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 ) );
$p_str_Content = substr_replace($p_str_Content, $l_str_ReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
/* set footnote to the output box at the end */
$g_arr_Footnotes[ ] = $l_str_FootnoteText;
$g_arr_Footnotes[] = $l_str_FootnoteText;
/* increase footnote index */
$l_int_FootnoteIndex++;
/* add offset to the new starting position */
$l_int_PosStart += ( $l_int_PosEnd - $l_int_PosStart );
$l_int_PosStart += ($l_int_PosEnd - $l_int_PosStart);
/* no ending tag found */
} else {
$l_int_PosStart++;
@ -200,7 +271,7 @@ function footnotes_getFromString( $p_str_Content )
} else {
break;
}
} while ( true );
} while (true);
/* return content */
return $p_str_Content;
@ -221,24 +292,24 @@ function footnotes_OutputReferenceContainer()
global $g_arr_FootnotesSettings;
/* no footnotes has been replaced on this page */
if ( empty( $g_arr_Footnotes ) ) {
if (empty($g_arr_Footnotes)) {
/* return empty string */
return "";
}
/* get setting for combine identical footnotes and convert it to boolean */
$l_bool_CombineIdentical = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL ]);
$l_bool_CombineIdentical = footnotes_ConvertToBool($g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL]);
/* get setting for preferences label */
$l_str_ReferencesLabel = $g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_REFERENCES_LABEL ];
$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 ]);
$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 = '<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.'"';
$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"';
@ -246,30 +317,30 @@ function footnotes_OutputReferenceContainer()
$l_str_Output .= '>';
/* 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");
/* loop through all footnotes found in the page */
for ( $l_str_Index = 0; $l_str_Index < count( $g_arr_Footnotes ); $l_str_Index++ ) {
for ($l_str_Index = 0; $l_str_Index < count($g_arr_Footnotes); $l_str_Index++) {
/* get footnote text */
$l_str_FootnoteText = $g_arr_Footnotes[ $l_str_Index ];
$l_str_FootnoteText = $g_arr_Footnotes[$l_str_Index];
/* if fottnote is empty, get to the next one */
if ( empty( $l_str_FootnoteText ) ) {
if (empty($l_str_FootnoteText)) {
continue;
}
/* get footnote index */
$l_str_FirstFootnoteIndex = ( $l_str_Index + 1 );
$l_str_FootnoteIndex = footnote_convert_index(( $l_str_Index + 1 ),$l_str_CounterStyle);
$l_str_FirstFootnoteIndex = ($l_str_Index + 1);
$l_str_FootnoteIndex = footnote_convert_index(($l_str_Index + 1), $l_str_CounterStyle);
/* check if it isn't the last footnote in the array */
if ( $l_str_FirstFootnoteIndex < count( $g_arr_Footnotes ) && $l_bool_CombineIdentical ) {
if ($l_str_FirstFootnoteIndex < count($g_arr_Footnotes) && $l_bool_CombineIdentical) {
/* get all footnotes that I haven't passed yet */
for ( $l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count( $g_arr_Footnotes ); $l_str_CheckIndex++ ) {
for ($l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count($g_arr_Footnotes); $l_str_CheckIndex++) {
/* check if a further footnote is the same as the actual one */
if ( $l_str_FootnoteText == $g_arr_Footnotes[ $l_str_CheckIndex ] ) {
if ($l_str_FootnoteText == $g_arr_Footnotes[$l_str_CheckIndex]) {
/* set the further footnote as empty so it won't be displayed later */
$g_arr_Footnotes[ $l_str_CheckIndex ] = "";
$g_arr_Footnotes[$l_str_CheckIndex] = "";
/* add the footnote index to the actual index */
$l_str_FootnoteIndex .= ", " . footnote_convert_index(( $l_str_CheckIndex + 1 ),$l_str_CounterStyle);
$l_str_FootnoteIndex .= ", " . footnote_convert_index(($l_str_CheckIndex + 1), $l_str_CounterStyle);
}
}
}
@ -278,9 +349,9 @@ function footnotes_OutputReferenceContainer()
/*
* added function to convert the counter style in the reference container (bugfix for the link to the footnote) in version 1.0.6
*/
$l_str_ReplaceText = str_replace( "[[FOOTNOTE INDEX SHORT]]", footnote_convert_index($l_str_FirstFootnoteIndex,$l_str_CounterStyle), $l_str_FootnoteTemplate );
$l_str_ReplaceText = str_replace( "[[FOOTNOTE INDEX]]", $l_str_FootnoteIndex, $l_str_ReplaceText );
$l_str_ReplaceText = str_replace( "[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText );
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX SHORT]]", footnote_convert_index($l_str_FirstFootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate);
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", $l_str_FootnoteIndex, $l_str_ReplaceText);
$l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText);
/* add the footnote container to the output */
$l_str_Output = $l_str_Output . $l_str_ReplaceText;
}
@ -290,7 +361,7 @@ function footnotes_OutputReferenceContainer()
$l_str_Output .= '
<script type="text/javascript">
function footnote_expand_reference_container(p_str_ID) {
jQuery("#'.FOOTNOTE_REFERENCES_CONTAINER_ID.'").show();
jQuery("#' . FOOTNOTE_REFERENCES_CONTAINER_ID . '").show();
if (p_str_ID.length > 0) {
jQuery(p_str_ID).focus();
}

View file

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

View file

@ -9,9 +9,9 @@
*/
/* check if the wordpress function to uninstall plugins is active */
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
if (!defined('WP_UNINSTALL_PLUGIN')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
exit();
}
@ -22,13 +22,13 @@ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
require_once(dirname(__FILE__) . '/defines.php');
/* uninstalling the plugin is only allowed for logged in users */
if ( !is_user_logged_in() ) {
wp_die( __( 'You must be logged in to run this script.', FOOTNOTES_PLUGIN_NAME ) );
if (!is_user_logged_in()) {
wp_die(__('You must be logged in to run this script.', FOOTNOTES_PLUGIN_NAME));
}
/* current user needs the permission to (un)install plugins */
if ( !current_user_can( 'install_plugins' ) ) {
wp_die( __( 'You do not have permission to run this script.', FOOTNOTES_PLUGIN_NAME ) );
if (!current_user_can('install_plugins')) {
wp_die(__('You do not have permission to run this script.', FOOTNOTES_PLUGIN_NAME));
}
/*

View file

@ -37,47 +37,47 @@
/* include constants */
require_once( dirname( __FILE__ ) . "/includes/defines.php" );
require_once(dirname(__FILE__) . "/includes/defines.php");
/* include language functions */
require_once( dirname( __FILE__ ) . "/includes/language.php" );
require_once(dirname(__FILE__) . "/includes/language.php");
/* include storage functions and global plugin functions */
require_once( dirname( __FILE__ ) . "/includes/plugin-settings.php" );
require_once(dirname(__FILE__) . "/includes/plugin-settings.php");
/* include script and stylesheet functions */
require_once( dirname( __FILE__ ) . "/includes/scripts.php" );
require_once(dirname(__FILE__) . "/includes/scripts.php");
/* include script and stylesheet functions */
require_once( dirname( __FILE__ ) . "/includes/convert.php" );
require_once(dirname(__FILE__) . "/includes/convert.php");
/* include script and stylesheet functions */
require_once( dirname( __FILE__ ) . "/includes/replacer.php" );
require_once(dirname(__FILE__) . "/includes/replacer.php");
/* require plugin class */
require_once( dirname( __FILE__ ) . "/classes/footnotes.php" );
require_once(dirname(__FILE__) . "/classes/footnotes.php");
/* require plugin settings class */
require_once( dirname( __FILE__ ) . "/classes/footnotes_settings.php" );
require_once(dirname(__FILE__) . "/classes/footnotes_settings.php");
/* register functions for the footnote replacement */
footnotes_RegisterReplacementFunctions();
/* adds javascript and stylesheets to the public page */
add_action( 'wp_enqueue_scripts', 'footnotes_add_public_stylesheet' );
add_action('wp_enqueue_scripts', 'footnotes_add_public_stylesheet');
/* only admin is allowed to execute the plugin settings */
if ( !function_exists( 'is_admin' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
if (!function_exists('is_admin')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
exit();
}
/* 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');
/* add link to the settings page in plugin main page */
$l_str_plugin_file = FOOTNOTES_PLUGIN_DIR_NAME . '/index.php';
add_filter( "plugin_action_links_{$l_str_plugin_file}", 'footnotes_plugin_settings_link', 10, 2 );
add_filter("plugin_action_links_{$l_str_plugin_file}", 'footnotes_plugin_settings_link', 10, 2);
/* initialize an object of the plugin class */
global $g_obj_FootnotesPlugin;
/* if object isn't initialized yet, initialize it now */
if ( empty( $g_obj_FootnotesPlugin ) ) {
if (empty($g_obj_FootnotesPlugin)) {
$g_obj_FootnotesPlugin = new Class_Footnotes();
}

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]]