- 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

@ -14,93 +14,93 @@
*/
class Class_Footnotes
{
/*
* object to the plugin's settings
* @since 1.0
*/
var $a_obj_Settings;
/*
* 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();
}
/**
* @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' ) );
/* 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( $this, 'uninstall' ) );
}
/* 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($this, 'uninstall'));
}
/**
* activates the plugin
* @since 1.0
*/
function activate()
{
// unused
}
/**
* activates the plugin
* @since 1.0
*/
function activate()
{
// unused
}
/**
* deactivates the plugin
* @since 1.0
*/
function deactivate()
{
// unused
}
/**
* deactivates the plugin
* @since 1.0
*/
function deactivate()
{
// unused
}
/**
* uninstalls the plugin
* updated file path in version 1.0.6
* @since 1.0
*/
function uninstall()
{
require_once( dirname(__FILE__) . '/../includes/uninstall.php' );
}
/**
* uninstalls the plugin
* updated file path in version 1.0.6
* @since 1.0
*/
function uninstall()
{
require_once(dirname(__FILE__) . '/../includes/uninstall.php');
}
/**
* initialize function
* called in the class constructor
* @since 1.0
*/
function init()
{
// unused
}
/**
* 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 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
}
/**
* do admin menu stuff
* called in the class constructor
* @since 1.0
*/
function admin_menu()
{
// unused
}
} /* class Class_Footnotes */

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
*/
@ -14,481 +14,526 @@
*/
class Class_FootnotesSettings
{
/*
* attribute for default settings value
* updated default value for 'FOOTNOTE_INPUTFIELD_LOVE' to default: 'no' in version 1.0.6
* @since 1.0
*/
public static $a_arr_Default_Settings = array(
FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL => 'yes',
FOOTNOTE_INPUTFIELD_REFERENCES_LABEL => 'References',
FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES => '',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_START => '((',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))',
FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT => 'yes',
FOOTNOTE_INPUTFIELD_LOVE => 'no',
FOOTNOTE_INPUTFIELD_COUNTER_STYLE => 'arabic_plain'
);
/*
* 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();
/*
* attribute for default settings value
* updated default value for 'FOOTNOTE_INPUTFIELD_LOVE' to default: 'no' in version 1.0.6
* @since 1.0
*/
public static $a_arr_Default_Settings = array(
FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL => 'yes',
FOOTNOTE_INPUTFIELD_REFERENCES_LABEL => 'References',
FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES => '',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_START => '((',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))',
FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT => 'yes',
FOOTNOTE_INPUTFIELD_LOVE => 'no',
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
* @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()
{
/* loads and filters the settings for this plugin */
$this->a_arr_Options = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings, true );
/**
* @constructor
* @since 1.0
*/
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);
/* 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' ) );
/* 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_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'));
}
/**
* 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' );
}
/**
* 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');
/* Needed to allow metabox layout and close functionality */
wp_enqueue_script('postbox');
}
/**
* 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 );
}
/**
* 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 = '<span style="color: #2bb975; ">foot</span><span style="color: #545f5a; ">notes</span>';
/* submenu title */
$l_str_MenuTitle = '<span style="color: #2bb975; ">foot</span><span style="color: #545f5a; ">notes</span>';
/* 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' ) );
}
/**
* 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_PLUGIN_PUBLIC_NAME;
/* submenu title */
$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'));
}
/**
* 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>';
}
/**
* 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);
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();
}
/**
* 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>';
}
/**
* 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;
}
/**
* 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
}
/**
* 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 );
}
/**
* 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 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 );
}
/**
* 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 );
}
/**
* 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 ];
}
/**
* 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 );
}
/**
* outputs a input type=text
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [css class name]
* @param int $p_str_MaxLength [max length for the input value]
* @param string $p_str_Label [label text]
* @since 1.0-beta
*/
function AddTextbox($p_str_SettingsID, $p_str_ClassName="", $p_str_MaxLength=0, $p_str_Label="")
{
/* collect data for given settings field */
$l_arr_Data = $this->LoadSetting( $p_str_SettingsID );
/**
* 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];
}
/* if input shall have a css class, add the style tag for it */
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
/* optional add a maxlength to the input field */
if (!empty($p_str_MaxLength)) {
$p_str_MaxLength = ' maxlength="'.$p_str_MaxLength.'"';
}
/* optional add a label in front of the input field */
if (!empty($p_str_Label)) {
echo '<label for="'.$l_arr_Data[ "id" ].'">'.$p_str_Label.'</label>';
}
/**
* outputs a break to have a new line
* @since 1.0.7
*/
function AddNewline()
{
echo '<br/><br/>';
}
/* 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" ].'"/>';
}
/**
* outputs a label for a specific input/select box
* @param string $p_str_SettingsID
* @param string $p_str_Caption
* @param string $p_str_Styling
* @since 1.0.7
*/
function AddLabel($p_str_SettingsID, $p_str_Caption, $p_str_Styling = "")
{
/* add styling tag if styling is set */
if (!empty($p_str_Styling)) {
$p_str_Styling = ' style="' . $p_str_Styling . '"';
}
echo '<label for="' . $p_str_SettingsID . '"' . $p_str_Styling . '>' . $p_str_Caption . '</label>';
}
/**
* outputs a input type=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 );
/**
* outputs a input type=text
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [css class name]
* @param int $p_str_MaxLength [max length for the input value]
* @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)
{
/* 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 . '"';
}
/* if input shall have a css class, add the style tag for it */
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
/* optional add a maxlength to the input field */
if (!empty($p_str_MaxLength)) {
$p_str_MaxLength = ' maxlength="' . $p_str_MaxLength . '"';
}
/* 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"] . '"/>';
}
/* lookup if the checkbox shall be pre-checked */
$l_str_Checked = "";
if (footnotes_ConvertToBool($l_arr_Data["value"])) {
$l_str_Checked = 'checked="checked"';
}
/**
* 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);
/* 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);
}
/* 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 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 );
/* lookup if the checkbox shall be pre-checked */
$l_str_Checked = "";
if (footnotes_ConvertToBool($l_arr_Data["value"])) {
$l_str_Checked = 'checked="checked"';
}
/* 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 CHECKBOX */
echo sprintf('<input type="checkbox" ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" %s/>', $l_str_Checked);
}
/* 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;
}
/**
* 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);
/**
* 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, 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 );
}
/* 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 . '"';
}
/**
* adds a desciption to the general settings tab
* called in RegisterTab_General
* @since 1.0
*/
function RegisterTab_General_Description()
{
// unused description
}
/* 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;
}
/**
* 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");
}
/**
* 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()
{
/* add tab to the tab array */
$this->a_arr_SettingsTabs[FOOTNOTE_SETTINGS_LABEL_GENERAL] = __("General", FOOTNOTES_PLUGIN_NAME);
/* register settings tab */
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');
}
/**
* 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);
}
/**
* 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 "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");
}
/**
* outputs a container for the reference container settings
* @since 1.0.7
*/
function Register_MetaBox_ReferenceContainer()
{
/* 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 fields for the footnote starting and ending tag
* @since 1.0-gamma
*/
function Register_Placeholder_Tags()
{
/* add a textbox to the output */
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START, "", 14, __( "starts with:", FOOTNOTES_PLUGIN_NAME ));
/* small space between the two input fields */
echo '&nbsp;&nbsp;&nbsp;';
/* add a textbox to the output */
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, "", 14, __( "ends with:", FOOTNOTES_PLUGIN_NAME ));
}
/* setting for '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();
/**
* outouts the settings field for the counter style
* @since 1.0-gamma
*/
function Register_CounterStyle()
{
$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, ..."
);
/* add a select box to the output */
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50");
}
/*
* setting for 'placement of the reference container'
* @since 1.0.7
*/
$l_arr_Options = array(
"footer" => __("in the footer", FOOTNOTES_PLUGIN_NAME),
"post_end" => __("at the end of the post", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE, __("Where shall the reference container appear:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE, $l_arr_Options, "footnote_plugin_50");
}
/**
* outputs the settings field for "allow searching in summarized posts"
* @since 1.0-gamma
*/
function Register_SearchExcerpt()
{
/* get array with option elements */
$l_arr_Options = array(
"yes" => __( "Yes", FOOTNOTES_PLUGIN_NAME ),
"no" => __( "No", FOOTNOTES_PLUGIN_NAME )
);
/* add a select box to the output */
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_25");
}
/**
* outputs a container for the styling of footnotes
* @since 1.0.7
*/
function Register_MetaBox_FootnoteStyling()
{
/* 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();
/**
* outputs the settings field for "love and share this plugin"
* @since 1.0-gamma
*/
function Register_LoveAndShare()
{
/* get array with option elements */
$l_arr_Options = array(
"yes" => __( "Yes", FOOTNOTES_PLUGIN_NAME ),
"no" => __( "No", FOOTNOTES_PLUGIN_NAME )
);
/* add a select box to the output */
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_LOVE, $l_arr_Options, "footnote_plugin_25");
}
/* 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);
/**
* 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 );
}
/* 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();
/**
* 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 );
}
/* setting for 'footnotes counter style' */
$l_str_Space = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$l_arr_Options = array(
"arabic_plain" => __("Arabic Numbers - Plain", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, ...",
"arabic_leading" => __("Arabic Numbers - Leading 0", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, ...",
"latin_low" => __("Latin Character - lower case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, ...",
"latin_high" => __("Latin Character - upper case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, ...",
"romanic" => __("Roman Numerals", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, ..."
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, __('Counter style:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50");
}
/**
* outputs the content of the HowTo settings tab
* @since 1.0
*/
function Register_Howto_Box()
{
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END);
?>
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __( "Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME ); ?>
<span class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"]; ?></span>
</p>
/**
* outputs other footnotes settings that doesn't match a special category
* @since 1.0.7
*/
function Register_MetaBox_Other()
{
/* setting for 'search footnotes tag in excerpt' */
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$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();
<p>
<?php echo __( "...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME ); ?>
<span class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_EndingTag["value"]; ?></span>
</p>
/* setting for 'love and share this plugin in my footer' */
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$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");
}
<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 ); ?>
&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 ); ?>
</p>
</div>
/**
* 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()
{
/* add tab to the tab array */
$this->a_arr_SettingsTabs[FOOTNOTE_SETTINGS_LABEL_HOWTO] = __("HowTo", FOOTNOTES_PLUGIN_NAME);
/* register settings tab */
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');
}
<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>' ); ?>
</p>
</div>
</div>
<?php
}
/**
* 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()
{
// unused
}
/**
* outputs the content of the HowTo settings tab
* @since 1.0
*/
function Register_MetaBox_HowTo()
{
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END);
?>
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __("Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"]; ?></span>
</p>
<p>
<?php echo __("...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_EndingTag["value"]; ?></span>
</p>
<div class="footnote_placeholder_box_example">
<p>
<span
class="footnote_highlight_placeholder"><?php echo $l_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); ?>
</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>'); ?>
</p>
</div>
</div>
<?php
}
} /* Class Class_FootnotesSettings */

View file

@ -3,135 +3,152 @@
* 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;
padding-top: 24px !important;
display: block !important;
padding-top: 24px !important;
}
.footnote_container_prepare > p {
font-size: 1.5em !important;
margin-top: 1em !important;
margin-bottom: 0.25em !important;
padding: 0 !important;
line-height: 1.3 !important;
font-weight: normal !important;
overflow: hidden !important;
border-bottom: 1px solid #aaaaaa !important;
display: block !important;
-webkit-margin-before: 0.83em !important;
-webkit-margin-after: 0.83em !important;
-webkit-margin-start: 0px !important;
-webkit-margin-end: 0px !important;
text-align: left !important;
font-size: 1.5em !important;
margin-top: 1em !important;
margin-bottom: 0.25em !important;
padding: 0 !important;
line-height: 1.3 !important;
font-weight: normal !important;
overflow: hidden !important;
border-bottom: 1px solid #aaaaaa !important;
display: block !important;
-webkit-margin-before: 0.83em !important;
-webkit-margin-after: 0.83em !important;
-webkit-margin-start: 0px !important;
-webkit-margin-end: 0px !important;
text-align: left !important;
}
.footnote_container_prepare > p > span {
padding-left: 20px !important;
text-align: left !important;
cursor: pointer;
padding-left: 20px !important;
text-align: left !important;
cursor: pointer;
}
.footnote_hide_box {
display:none;
display: none;
}
/* container for the footnote in the bottom */
.footnote_plugin_container {
display: block !important;
width: 100% !important;
padding-bottom: 14px !important;
display: block !important;
width: 100% !important;
padding-bottom: 14px !important;
}
/* footnote (bottom) index */
.footnote_plugin_index {
float: left !important;
min-width: 40px !important;
white-space: nowrap !important;
text-align: right !important;
float: left !important;
min-width: 40px !important;
white-space: nowrap !important;
text-align: right !important;
}
/* footnote (bottom) text */
.footnote_plugin_text {
float: left !important;
padding-left: 16px !important;
float: left !important;
padding-left: 16px !important;
}
/* footnote (bottom) link to the footnote implementation */
.footnote_plugin_link {
outline: none !important;
text-decoration: none !important;
cursor: pointer !important;
outline: none !important;
text-decoration: none !important;
cursor: pointer !important;
}
.footnote_plugin_link:hover {
color: #4777ff !important;
text-decoration: none !important;
color: #4777ff !important;
text-decoration: none !important;
}
/* footnote (bottom) styling end tag */
.footnote_plugin_end {
clear: left !important;
clear: left !important;
}
/* tooltip */
.footnote_plugin_tooltip {
outline: none !important;
color: #4777ff !important;
text-decoration: none !important;
cursor: pointer !important;
outline: none !important;
color: #4777ff !important;
text-decoration: none !important;
cursor: pointer !important;
}
.footnote_plugin_tooltip strong {
line-height: 30px !important;
line-height: 30px !important;
}
.footnote_plugin_tooltip:hover {
text-decoration: none !important;
text-decoration: none !important;
}
.footnote_plugin_tooltip span {
z-index: 10 !important;
display: none !important;
padding: 14px 20px !important;
margin-top: -30px !important;
/*margin-left: 28px !important;*/
/*width: 240px;*/
line-height: 16px !important;
cursor: default;
z-index: 10 !important;
display: none !important;
padding: 14px 20px !important;
margin-top: -30px !important;
/*margin-left: 28px !important;*/
/*width: 240px;*/
line-height: 16px !important;
cursor: default;
}
/*
* added width and white-space styling in version 1.0.6
*/
.footnote_plugin_tooltip:hover span, .footnote_plugin_tooltip span:hover {
display: inline !important;
position: absolute !important;
color: #474747 !important;
border: 1px solid #ddccaa !important;
background: #fffaf0 !important;
width: auto;
white-space: nowrap;
display: inline !important;
position: absolute !important;
color: #474747 !important;
border: 1px solid #ddccaa !important;
background: #fffaf0 !important;
width: auto;
white-space: nowrap;
}
.callout {
z-index: 20 !important;
position: absolute !important;
top: 30px !important;
border: 0 !important;
left: -12px !important;
z-index: 20 !important;
position: absolute !important;
top: 30px !important;
border: 0 !important;
left: -12px !important;
}
/*CSS3 extras*/
.footnote_plugin_tooltip span {
border-radius: 4px !important;
-moz-border-radius: 4px !important;
-webkit-border-radius: 4px !important;
-moz-box-shadow: 5px 5px 8px #cccccc !important;
-webkit-box-shadow: 5px 5px 8px #cccccc !important;
box-shadow: 5px 5px 8px #cccccc !important;
border-radius: 4px !important;
-moz-border-radius: 4px !important;
-webkit-border-radius: 4px !important;
-moz-box-shadow: 5px 5px 8px #cccccc !important;
-webkit-box-shadow: 5px 5px 8px #cccccc !important;
box-shadow: 5px 5px 8px #cccccc !important;
}

View file

@ -9,63 +9,87 @@
/* overwrite some styling for inputs [type=text] and select-boxes */
input[type=text], input[type=checkbox], input[type=password], textarea, select {
/*margin-left: 12px !important;*/
/*margin-left: 12px !important;*/
}
input[type=text], input[type=password], textarea, select {
padding-left: 8px !important;
padding-right: 8px !important;
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;
cursor: pointer !important;
color: #202020 !important;
text-decoration: underline !important;
cursor: pointer !important;
color: #202020 !important;
}
/* setting with 15% width */
.footnote_plugin_15 {
width: 15% !important;
}
/* setting with 25% width */
.footnote_plugin_25 {
width: 25% !important;
width: 25% !important;
}
/* setting with half width */
.footnote_plugin_50 {
width: 50% !important;
width: 50% !important;
}
/* setting with 75% width */
.footnote_plugin_75 {
width: 75% !important;
width: 75% !important;
}
/* setting with full width */
.footnote_plugin_100 {
width: 100% !important;
width: 100% !important;
}
/* container for the box holding the placeholder tags at the end */
.footnote_placeholder_box_container {
text-align: center !important;
/*width: auto;
display: inline-block;
padding-left: 20px;
padding-right: 20px;
margin-left: -210px;*/
text-align: center !important;
/*width: auto;
display: inline-block;
padding-left: 20px;
padding-right: 20px;
margin-left: -210px;*/
}
/* highlight the placeholders */
span.footnote_highlight_placeholder {
font-weight: bold !important;
padding-left: 8px !important;
padding-right: 8px !important;
font-weight: bold !important;
padding-left: 8px !important;
padding-right: 8px !important;
}
.footnote_placeholder_box_example {
border: 2px solid #2bb975 !important;
border-radius: 4px !important;
padding-top: 16px !important;
padding-bottom: 16px !important;
width: 50% !important;
display: block !important;
margin: 20px auto !important;
border: 2px solid #2bb975 !important;
border-radius: 4px !important;
padding-top: 16px !important;
padding-bottom: 16px !important;
width: 50% !important;
display: block !important;
margin: 20px auto !important;
}

View file

@ -16,21 +16,21 @@
* @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) {
case "romanic":
return footnote_convert_to_romanic($p_int_Index);
case "latin_high":
return footnote_convert_to_latin($p_int_Index, true);
case "latin_low":
return footnote_convert_to_latin($p_int_Index, false);
case "arabic_leading":
return footnote_convert_to_arabic_leading($p_int_Index);
case "arabic_plain":
default:
return $p_int_Index;
}
switch ($p_str_ConvertStyle) {
case "romanic":
return footnote_convert_to_romanic($p_int_Index);
case "latin_high":
return footnote_convert_to_latin($p_int_Index, true);
case "latin_low":
return footnote_convert_to_latin($p_int_Index, false);
case "arabic_leading":
return footnote_convert_to_arabic_leading($p_int_Index);
case "arabic_plain":
default:
return $p_int_Index;
}
}
/**
@ -43,29 +43,29 @@ 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
/* if lower-case, change decimal to lower-case "a" */
if (!$p_bool_UpperCase) {
$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) {
/* increase offset and reduce counter */
$l_int_Offset++;
$p_int_Value -= 26;
}
/* if offset set (more then Z), then add a new letter in fron */
if ($l_int_Offset > 0) {
$l_str_Return = chr($l_int_Offset + $l_int_StartinAscii);
}
/* add the origin letter */
$l_str_Return .= chr($p_int_Value + $l_int_StartinAscii);
/* return the latin character representing the integer */
return $l_str_Return;
/* decimal value of the starting ascii character */
$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
}
/* output string */
$l_str_Return = "";
$l_int_Offset = 0;
/* check if the value is higher then 26 = Z */
while ($p_int_Value > 26) {
/* increase offset and reduce counter */
$l_int_Offset++;
$p_int_Value -= 26;
}
/* if offset set (more then Z), then add a new letter in fron */
if ($l_int_Offset > 0) {
$l_str_Return = chr($l_int_Offset + $l_int_StartinAscii);
}
/* add the origin letter */
$l_str_Return .= chr($p_int_Value + $l_int_StartinAscii);
/* return the latin character representing the integer */
return $l_str_Return;
}
/**
@ -76,11 +76,11 @@ function footnote_convert_to_latin($p_int_Value, $p_bool_UpperCase)
*/
function footnote_convert_to_arabic_leading($p_int_Value)
{
/* add a leading 0 if number lower then 10 */
if ($p_int_Value < 10) {
return "0" . $p_int_Value;
}
return $p_int_Value;
/* add a leading 0 if number lower then 10 */
if ($p_int_Value < 10) {
return "0" . $p_int_Value;
}
return $p_int_Value;
}
/**
@ -91,20 +91,20 @@ 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);
/* 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) {
$p_int_Value -= $l_int_Arabic;
$l_str_Return .= $l_str_Romanic;
break;
}
}
}
/* return romanic letters as string */
return $l_str_Return;
/* 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);
/* 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) {
$p_int_Value -= $l_int_Arabic;
$l_str_Return .= $l_str_Romanic;
break;
}
}
}
/* return romanic letters as string */
return $l_str_Return;
}

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

@ -16,21 +16,21 @@
*/
function footnotes_load_language()
{
/* read current wordpress langauge */
$l_str_locale = apply_filters( 'plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME );
/* get only language code (removed localization code) */
$l_str_languageCode = footnotes_getLanguageCode();
/* read current wordpress langauge */
$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' ) ) {
/* language file with localization exists */
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' ) ) {
/* 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')) {
/* 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 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');
}
}
/**
@ -41,15 +41,15 @@ function footnotes_load_language()
*/
function footnotes_getLanguageCode()
{
/* read current wordpress langauge */
$l_str_locale = apply_filters( 'plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME );
/* check if wordpress language has a localization (e.g. "en_US" or "de_AT") */
if ( strpos( $l_str_locale, "_" ) !== false ) {
/* remove localization code */
$l_arr_languageCode = explode( "_", $l_str_locale );
$l_str_languageCode = $l_arr_languageCode[ 0 ];
return $l_str_languageCode;
}
/* return language code lowercase */
return strtolower( $l_str_locale );
/* read current wordpress langauge */
$l_str_locale = apply_filters('plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME);
/* check if wordpress language has a localization (e.g. "en_US" or "de_AT") */
if (strpos($l_str_locale, "_") !== false) {
/* remove localization code */
$l_arr_languageCode = explode("_", $l_str_locale);
$l_str_languageCode = $l_arr_languageCode[0];
return $l_str_languageCode;
}
/* return language code lowercase */
return strtolower($l_str_locale);
}

View file

@ -16,14 +16,14 @@
* @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 );
/* 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);
/* return new links */
return $links;
/* return new links */
return $links;
}
@ -36,29 +36,29 @@ 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 );
/* loop through all keys in the array and filters them */
foreach ( $l_arr_Options as $l_str_Key => $l_str_Value ) {
/* removes special chars from the settings value */
$l_str_Value = stripcslashes( $l_str_Value );
/* if set, convert html special chars */
if ($p_bool_ConvertHtmlChars) {
$l_str_Value = htmlspecialchars( $l_str_Value );
}
/* check if settings value is not empty, otherwise load the default value, or empty string if no default is defined */
if (!empty($l_str_Value)) {
$l_arr_Options[ $l_str_Key ] = stripcslashes( $l_str_Value );
/* 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];
} else {
$l_arr_Options[ $l_str_Key ] = "";
}
}
/* returns the filtered array */
return $l_arr_Options;
$l_arr_Options = get_option($p_str_OptionsField);
/* loop through all keys in the array and filters them */
foreach ($l_arr_Options as $l_str_Key => $l_str_Value) {
/* removes special chars from the settings value */
$l_str_Value = stripcslashes($l_str_Value);
/* if set, convert html special chars */
if ($p_bool_ConvertHtmlChars) {
$l_str_Value = htmlspecialchars($l_str_Value);
}
/* check if settings value is not empty, otherwise load the default value, or empty string if no default is defined */
if (!empty($l_str_Value)) {
$l_arr_Options[$l_str_Key] = stripcslashes($l_str_Value);
/* 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];
} else {
$l_arr_Options[$l_str_Key] = "";
}
}
/* returns the filtered array */
return $l_arr_Options;
}
/**
@ -67,18 +67,19 @@ function footnotes_filter_options( $p_str_OptionsField, $p_arr_DefaultValues, $p
* @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;
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

@ -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,77 +20,138 @@ $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() {
/* 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 ]);
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);
/* calls the wordpress filter function to replace page content before displayed on public pages */
add_filter( 'the_content', 'footnotes_startReplacing' );
/* search in the excerpt only if activated */
if ($l_bool_SearchExcerpt) {
add_filter( 'the_excerpt', 'footnotes_DummyReplacing' );
}
/* 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');
/* 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' );
/* 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');
/* calls the wordpress action to display the footer */
add_action( 'get_footer', 'footnotes_StopReplacing' );
/* adds the love and share me slug to the footer */
add_filter('wp_footer', 'footnotes_LoveAndShareMe');
/* 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 the_excerpt
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_Content($p_str_Content)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for 'display reference container position' */
$l_str_ReferenceContainerPosition = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT];
/* check if reference container should be displayed at the end of a post */
if ($l_str_ReferenceContainerPosition == "post_end") {
footnotes_StopReplacing();
footnotes_startReplacing();
}
/* returns content */
return $p_str_Content;
}
/**
* replacement action for the_excerpt
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_Excerpt($p_str_Content)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for accepting footnotes in the excerpt and convert it to boolean */
$l_bool_SearchExcerpt = footnotes_ConvertToBool($g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT]);
/* search in the excerpt only if activated */
if ($l_bool_SearchExcerpt) {
footnotes_StopReplacing();
footnotes_startReplacing();
}
/* returns content */
return $p_str_Content;
}
/**
* replacement action for widget_title
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_WidgetTitle($p_str_Content)
{
/* returns content */
return $p_str_Content;
}
/**
* replacement action for widget_text
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_WidgetText($p_str_Content)
{
/* returns content */
return $p_str_Content;
}
/**
* starts listening for footnotes to be replaced
* output will be buffered and not displayed
* @since 1.0
* @param string $p_str_Content
* @return string
* added flag to only start 'stopping output' once in version 1.0.7
*/
function footnotes_startReplacing( $p_str_Content )
function footnotes_startReplacing()
{
/* 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;
/* 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");
/* 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()
{
/* calls the callback function defined in ob_start(); */
ob_end_flush();
/* 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()
{
/*
* 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
*/
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>'
;
/* 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;">' . FOOTNOTES_PLUGIN_PUBLIC_NAME . '</a>') .
'</div>';
}
}
/**
@ -116,29 +187,29 @@ function footnotes_LoveAndShareMe()
* loading settings if not happened yet since 1.0-gamma
* @since 1.0
* @param string $p_str_Content
* @param bool $p_bool_OutputReferences [default: true]
* @param bool $p_bool_OutputReferences [default: true]
* @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 );
/* replace all footnotes in the content */
$p_str_Content = footnotes_getFromString( $p_str_Content );
/* 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);
/* replace all footnotes in the content */
$p_str_Content = footnotes_getFromString($p_str_Content);
/* add the reference list if set */
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();
}
/* return the replaced content */
return $p_str_Content;
/* add the reference list if set */
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();
}
/* return the replaced content */
return $p_str_Content;
}
/**
@ -148,62 +219,62 @@ 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;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* contains the index for the next footnote on this page */
$l_int_FootnoteIndex = 1;
/* contains the starting position for the lookup of a footnote */
$l_int_PosStart = 0;
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents( FOOTNOTES_TEMPLATES_DIR . "footnote.html" );
/* get footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START];
/*get footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_END];
/*get footnote counter style */
$l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
/* get access to the global array to store footnotes */
global $g_arr_Footnotes;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* contains the index for the next footnote on this page */
$l_int_FootnoteIndex = 1;
/* contains the starting position for the lookup of a footnote */
$l_int_PosStart = 0;
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "footnote.html");
/* get footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START];
/*get footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_END];
/*get footnote counter style */
$l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
/* check for a footnote placeholder in the current page */
do {
/* get first occurence of a footnote starting tag */
$l_int_PosStart = strpos( $p_str_Content, $l_str_StartingTag, $l_int_PosStart );
/* tag found */
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 );
/* tag found */
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 ) );
/* 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 );
/* 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 ) );
/* set footnote to the output box at the end */
$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 );
/* no ending tag found */
} else {
$l_int_PosStart++;
}
/* no starting tag found */
} else {
break;
}
} while ( true );
/* 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);
/* tag found */
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);
/* tag found */
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));
/* 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);
/* 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));
/* set footnote to the output box at the end */
$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);
/* no ending tag found */
} else {
$l_int_PosStart++;
}
/* no starting tag found */
} else {
break;
}
} while (true);
/* return content */
return $p_str_Content;
/* return content */
return $p_str_Content;
}
/**
@ -215,82 +286,82 @@ function footnotes_getFromString( $p_str_Content )
*/
function footnotes_OutputReferenceContainer()
{
/* get access to the global array to read footnotes */
global $g_arr_Footnotes;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get access to the global array to read footnotes */
global $g_arr_Footnotes;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* no footnotes has been replaced on this page */
if ( empty( $g_arr_Footnotes ) ) {
/* return empty string */
return "";
}
/* no footnotes has been replaced on this page */
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 ]);
/* get setting for preferences 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 ]);
/*get footnote counter style */
$l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
/* get setting for combine identical footnotes and convert it to boolean */
$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];
/* get setting for collapse reference footnotes and convert it to boolean */
$l_bool_CollapseReference = footnotes_ConvertToBool($g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES]);
/*get footnote counter style */
$l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
/* output string, prepare it with the reference label as headline */
$l_str_Output = '<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 .= '>';
/* 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 . '"';
/* add class to hide the references by default, if the user wants it */
if ($l_bool_CollapseReference) {
$l_str_Output .= ' class="footnote_hide_box"';
}
$l_str_Output .= '>';
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents( FOOTNOTES_TEMPLATES_DIR . "container.html" );
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "container.html");
/* loop through all footnotes found in the page */
for ( $l_str_Index = 0; $l_str_Index < count( $g_arr_Footnotes ); $l_str_Index++ ) {
/* get footnote text */
$l_str_FootnoteText = $g_arr_Footnotes[ $l_str_Index ];
/* if fottnote is empty, get to the next one */
if ( empty( $l_str_FootnoteText ) ) {
continue;
}
/* get footnote index */
$l_str_FirstFootnoteIndex = ( $l_str_Index + 1 );
$l_str_FootnoteIndex = footnote_convert_index(( $l_str_Index + 1 ),$l_str_CounterStyle);
/* loop through all footnotes found in the page */
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];
/* if fottnote is empty, get to the next one */
if (empty($l_str_FootnoteText)) {
continue;
}
/* get footnote index */
$l_str_FirstFootnoteIndex = ($l_str_Index + 1);
$l_str_FootnoteIndex = 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 ) {
/* 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++ ) {
/* check if a further footnote is the same as the actual one */
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 ] = "";
/* add the footnote index to the actual index */
$l_str_FootnoteIndex .= ", " . footnote_convert_index(( $l_str_CheckIndex + 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) {
/* 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++) {
/* check if a further footnote is the same as the actual one */
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] = "";
/* add the footnote index to the actual index */
$l_str_FootnoteIndex .= ", " . footnote_convert_index(($l_str_CheckIndex + 1), $l_str_CounterStyle);
}
}
}
/* add the footnote to the output box */
/*
* added function to convert the counter style in the reference container (bugfix for the link to the footnote) in version 1.0.6
*/
$l_str_ReplaceText = str_replace( "[[FOOTNOTE INDEX SHORT]]", 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;
}
/* 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 .= '
/* add the footnote to the output box */
/*
* added function to convert the counter style in the reference container (bugfix for the link to the footnote) in version 1.0.6
*/
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX SHORT]]", 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;
}
/* 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(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();
}
@ -298,6 +369,6 @@ function footnotes_OutputReferenceContainer()
</script>
';
/* return the output string */
return $l_str_Output;
/* return the output string */
return $l_str_Output;
}

View file

@ -15,10 +15,10 @@
*/
function footnotes_add_public_stylesheet()
{
/* register public stylesheet */
wp_register_style( 'footnotes_public_style', plugins_url( '../css/footnote.css', __FILE__ ) );
/* add public stylesheet */
wp_enqueue_style( 'footnotes_public_style' );
/* register public stylesheet */
wp_register_style('footnotes_public_style', plugins_url('../css/footnote.css', __FILE__));
/* add public stylesheet */
wp_enqueue_style('footnotes_public_style');
}
/**
@ -27,8 +27,8 @@ 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__ ) );
/* add settings stylesheet */
wp_enqueue_style( 'footnotes_settings_style' );
/* register settings stylesheet */
wp_register_style('footnotes_settings_style', plugins_url('../css/settings.css', __FILE__));
/* add settings stylesheet */
wp_enqueue_style('footnotes_settings_style');
}

View file

@ -9,10 +9,10 @@
*/
/* 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' );
exit();
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' );
exit();
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 ) ) {
$g_obj_FootnotesPlugin = new Class_Footnotes();
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

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

View file

@ -1,5 +1,6 @@
<sup class="footnote_plugin_tooltip" name="footnote_plugin_tooltip_[[FOOTNOTE INDEX]]" onclick="footnote_expand_reference_container('#footnote_plugin_reference_[[FOOTNOTE INDEX]]');">
[[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]]
</span>