Update to 1.0.1

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@917807 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
Aricura 2014-05-20 11:33:11 +00:00
parent e702a0dca7
commit af44ed127a
22 changed files with 1071 additions and 796 deletions

105
classes/footnote.php Normal file
View file

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

View file

@ -0,0 +1,334 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/**
* Class Class_FootnotesSettings
* @since 1.0
*/
class Class_FootnotesSettings
{
/*
* attribute for default settings value
* @since 1.0
*/
public static $a_arr_Default_Settings = array(
FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL => 'yes',
FOOTNOTE_INPUTFIELD_REFERENCES_LABEL => 'References'
);
/*
* 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 = footnote_filter_options( FOOTNOTE_SETTINGS_CONTAINER );
/* validates the settings of the plugin and replaces them with the default settings if invalid */
add_option( FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings );
/* execute class includes on action-even: init, admin_init and admin_menu */
add_action( 'init', array( $this, 'LoadScriptsAndStylesheets' ) );
add_action( 'admin_init', array( $this, 'RegisterSettings' ) );
add_action( 'admin_init', array( $this, 'RegisterTab_General' ) );
add_action( 'admin_init', array( $this, 'RegisterTab_HowTo' ) );
add_action( 'admin_menu', array( $this, 'AddSettingsMenuPanel' ) );
}
/**
* initialize settings page, loads scripts and stylesheets needed for the layout
* called in class constructor @ init
* @since 1.0
*/
function LoadScriptsAndStylesheets()
{
/* add the jQuery plugin (already registered by WP) */
wp_enqueue_script( 'jquery' );
/* register public stylesheet */
wp_register_style( 'footnote_public_style', plugins_url( '../css/footnote.css', __FILE__ ) );
/* add public stylesheet */
wp_enqueue_style( 'footnote_public_style' );
/* register settings stylesheet */
wp_register_style( 'footnote_settings_style', plugins_url( '../css/settings.css', __FILE__ ) );
/* add settings stylesheet */
wp_enqueue_style( 'footnote_settings_style' );
}
/**
* register the settings field in the database for the "save" function
* called in class constructor @ admin_init
* @since 1.0
*/
function RegisterSettings()
{
register_setting( FOOTNOTE_SETTINGS_LABEL_GENERAL, FOOTNOTE_SETTINGS_CONTAINER );
}
/**
* sets the plugin's title for the admins settings menu
* called in class constructor @ admin_menu
* @since 1.0
*/
function AddSettingsMenuPanel()
{
/* current user needs the permission to update plugins for further access */
if ( !current_user_can( 'update_plugins' ) ) {
return;
}
/* submenu page title */
$l_str_PageTitle = 'footnotes';
/* submenu title */
$l_str_MenuTitle = 'footnotes';
/* Add a new submenu to the standard Settings panel */
$this->a_str_Pagehook = add_options_page( $l_str_PageTitle, $l_str_MenuTitle, 'administrator', FOOTNOTES_SETTINGS_PAGE_ID, array( $this, 'OutputSettingsPage' ) );
}
/**
* Plugin Options page rendering goes here, checks
* for active tab and replaces key with the related
* settings key. Uses the plugin_options_tabs method
* to render the tabs.
* @since 1.0
*/
function OutputSettingsPage()
{
/* gets active tag, or if nothing set the "general" tab will be set to active */
$l_str_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : FOOTNOTE_SETTINGS_LABEL_GENERAL;
/* outputs all tabs */
echo '<div class="wrap">';
$this->OutputSettingsPageTabs();
/* outputs a form with the content of the current active tab */
echo '<form method="post" action="options.php">';
wp_nonce_field( 'update-options' );
settings_fields( $l_str_tab );
/* outputs the settings field of the current active tab */
do_settings_sections( $l_str_tab );
/* adds a submit button to the current page */
submit_button();
echo '</form>';
echo '</div>';
}
/**
* Renders our tabs in the plugin options page,
* walks through the object's tabs array and prints
* them one by one. Provides the heading for the
* plugin_options_page method.
* @since 1.0
*/
function OutputSettingsPageTabs()
{
/* gets active tag, or if nothing set the "general" tab will be set to active */
$l_str_CurrentTab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : FOOTNOTE_SETTINGS_LABEL_GENERAL;
screen_icon();
echo '<h2 class="nav-tab-wrapper">';
foreach ( $this->a_arr_SettingsTabs as $l_str_TabKey => $l_str_TabCaption ) {
$active = $l_str_CurrentTab == $l_str_TabKey ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . $active . '" href="?page=' . FOOTNOTES_SETTINGS_PAGE_ID . '&tab=' . $l_str_TabKey . '">' . $l_str_TabCaption . '</a>';
}
echo '</h2>';
}
/**
* loads specific setting and returns an array with the keys [id, name, value]
* @since 1.0
* @param $p_str_FieldID
* @return array
*/
protected function LoadSetting( $p_str_FieldID )
{
$p_arr_Return = array();
$p_arr_Return[ "id" ] = $this->getFieldID( $p_str_FieldID );
$p_arr_Return[ "name" ] = $this->getFieldName( $p_str_FieldID );
$p_arr_Return[ "value" ] = esc_attr( $this->getFieldValue( $p_str_FieldID ) );
return $p_arr_Return;
}
/**
* access settings field by name
* @since 1.0
* @param string $p_str_FieldName
* @return string
*/
protected function getFieldName( $p_str_FieldName )
{
return sprintf( '%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldName );
}
/**
* 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 );
}
/**
* 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 ];
}
/**
* initialize general settings tab
* called in class constructor @ admin_init
* @since 1.0
*/
function RegisterTab_General()
{
$l_str_SectionName = "Footnote_Secion_Settings_General";
/* add tab to the tab array */
$this->a_arr_SettingsTabs[ FOOTNOTE_SETTINGS_LABEL_GENERAL ] = __( "General", FOOTNOTES_PLUGIN_NAME );
/* register settings tab */
add_settings_section( $l_str_SectionName, __( "Settings", FOOTNOTES_PLUGIN_NAME ), array( $this, 'RegisterTab_General_Description' ), FOOTNOTE_SETTINGS_LABEL_GENERAL );
add_settings_field( 'Register_References_Label', __( "References label:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_References_Label' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
add_settings_field( 'Register_Combine_Identical', __( "Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_Combine_Identical' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName );
}
/**
* adds a desciption to the general settings tab
* called in RegisterTab_General
* @since 1.0
*/
function RegisterTab_General_Description()
{
// unused description
}
/**
* outputs the settings field for the "references label"
* @since 1.0
*/
function Register_References_Label()
{
/* collect data for "combine identical" */
$l_arr_Data = $this->LoadSetting( FOOTNOTE_INPUTFIELD_REFERENCES_LABEL );
?>
<input class="footnote_plugin_50"
type="text"
name="<?php echo $l_arr_Data[ "name" ]; ?>"
id="<?php echo $l_arr_Data[ "id" ]; ?>"
value="<?php echo $l_arr_Data[ "value" ]; ?>"/>
<?php
}
/**
* outputs the settings field for the "combine identical footnotes"
* @since 1.0
*/
function Register_Combine_Identical()
{
/* collect data for "combine identical" */
$l_arr_Data = $this->LoadSetting( FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL );
?>
<select class="footnote_plugin_25"
id="<?php echo $l_arr_Data[ "id" ]; ?>"
name="<?php echo $l_arr_Data[ "name" ]; ?>">
<option value="yes"><?php echo __( "Yes", FOOTNOTES_PLUGIN_NAME ); ?></option>
<option value="no"><?php echo __( "No", FOOTNOTES_PLUGIN_NAME ); ?></option>
</select>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#<?php echo $l_arr_Data["id"]; ?> option[value='<?php echo $l_arr_Data["value"]; ?>']").prop("selected", true);
});
</script>
<?php
}
/**
* initialize howto settings tab
* called in class constructor @ admin_init
* @since 1.0
*/
function RegisterTab_HowTo()
{
$l_str_SectionName = "Footnote_Secion_Settings_Howto";
/* add tab to the tab array */
$this->a_arr_SettingsTabs[ FOOTNOTE_SETTINGS_LABEL_HOWTO ] = __( "HowTo", FOOTNOTES_PLUGIN_NAME );
/* register settings tab */
add_settings_section( $l_str_SectionName, __( "HowTo", FOOTNOTES_PLUGIN_NAME ), array( $this, 'RegisterTab_HowTo_Description' ), FOOTNOTE_SETTINGS_LABEL_HOWTO );
add_settings_field( 'Register_Howto_Box', "", array( $this, 'Register_Howto_Box' ), FOOTNOTE_SETTINGS_LABEL_HOWTO, $l_str_SectionName );
}
/**
* adds a descrption to the HowTo settings tab
* called int RegisterTab_HowTo
* @since 1.0
*/
function RegisterTab_HowTo_Description()
{
echo __( "This is a brief introduction in how to use the plugin.", FOOTNOTES_PLUGIN_NAME );
}
/**
* outputs the content of the HowTo settings tab
* @since 1.0
*/
function Register_Howto_Box()
{
?>
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __( "Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME ); ?>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_START; ?></span>
</p>
<p>
<?php echo __( "...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME ); ?>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_END; ?></span>
</p>
<div class="footnote_placeholder_box_example">
<p>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_START . __( "example string", FOOTNOTES_PLUGIN_NAME ) . FOOTNOTE_PLACEHOLDER_END; ?></span>
<?php echo __( "will be displayed as:", FOOTNOTES_PLUGIN_NAME ); ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo footnotes_replaceFootnotes( FOOTNOTE_PLACEHOLDER_START . __( "example string", FOOTNOTES_PLUGIN_NAME ) . FOOTNOTE_PLACEHOLDER_END, true ); ?>
</p>
</div>
<p>
<?php echo sprintf( __( "If you have any questions, please don't hesitate to %smail us%s.", FOOTNOTES_PLUGIN_NAME ), '<a href="mailto:admin@herndler.org" class="footnote_plugin">', '</a>' ); ?>
</p>
</div>
</div>
<?php
}
} /* Class Class_FootnotesSettings */

View file

@ -1,30 +0,0 @@
<?php
/**
* User: she
* Date: 30.04.14
* Time: 11:02
*/
/* plugin internal name */
define("FOOTNOTES_PLUGIN_NAME", "footnotes");
/* plugin direcotry name */
define("FOOTNOTES_PLUGIN_DIR_NAME", "footnotes");
/* page settings id */
define("FOOTNOTES_SETTINGS_PAGE_ID", "Footnotes");
define("FOOTNOTES_PLACEHOLDER", "((***))");
/* database container where all footnote settings are stored */
define("FOOTNOTE_SETTINGS_CONTAINER", "footnote_options");
/* id of input field for the combine identical setting */
define("FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME", "footnote_input_combine_identical_id");
/* id of input field for the references label setting */
define("FOOTNOTE_INPUT_REFERENCES_NAME", "footnote_input_references_id");
/* defines the start and end tag for the placeholder */
define("FOOTNOTE_PLACEHOLDER_START", "((");
define("FOOTNOTE_PLACEHOLDER_END", "))");

View file

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

@ -1,60 +1,69 @@
/**
* Created by Stefan on 15.05.14.
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/* overwrite some styling for labels */
label {
min-width: 160px !important;
}
/* overwrite some styling for inputs [type=text] and select-boxes */
input[type=text], select {
padding-left: 8px !important;
padding-left: 8px !important;
padding-right: 8px !important;
margin-left: 12px !important;
margin-left: 12px !important;
}
/* overwrite link layout on the settings page */
a.footnote_plugin {
text-decoration: underline;
cursor: pointer;
color: #202020;
}
/* settings container */
.footnote_plugin_container {
display: block !important;
width: 100% !important;
padding-bottom: 18px !important;
text-decoration: underline !important;
cursor: pointer !important;
color: #202020 !important;
}
/* setting with 25% width */
.footnote_plugin_25 {
width: 24% !important;
width: 25% !important;
}
/* setting with half width */
.footnote_plugin_50 {
width: 49% !important;
width: 50% !important;
}
/* setting with 75% width */
.footnote_plugin_75 {
width: 74% !important;
width: 75% !important;
}
/* setting with full width */
.footnote_plugin_100 {
width: 99% !important;
width: 100% !important;
}
/* container for the box holding the placeholder tags at the end */
.footnote_placeholder_box_container {
text-align: center;
width: auto;
display: inline-block;
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;
padding-left: 8px;
padding-right: 8px;
font-weight: bold !important;
padding-left: 8px !important;
padding-right: 8px !important;
}
.footnote_placeholder_box_example {
border: 2px solid #ff524b !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

@ -1,219 +0,0 @@
<?php
/**
* User: she
* Date: 30.04.14
* Time: 16:44
*/
/**
* reads a option field, filters the values and returns the filtered option array
* @param string $p_str_OptionsField
* @return array
*/
function footnote_filter_options($p_str_OptionsField)
{
$l_arr_Options = get_option($p_str_OptionsField);
/* loop through all keys in the array and filters them */
foreach ($l_arr_Options as $l_str_Key => $l_str_Value) {
$l_arr_Options[$l_str_Key] = stripcslashes($l_str_Value);
}
/* returns the filtered array */
return $l_arr_Options;
}
/**
* reads the wordpress langauge and returns only the language code lowercase
* removes the localization code
* @return string (only the "en" from "en_US")
*/
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);
}
/**
* loads the langauge file including localization if exists
* otherwise loads the langauge file without localization information
*/
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();
/* language file with localization exists */
if ($l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, dirname(__FILE__) . '/languages/' . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_locale . '.mo')) {
/* language file without localization exists */
} else if ($l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, dirname(__FILE__) . '/languages/' . 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, dirname(__FILE__) . '/languages/' . FOOTNOTES_PLUGIN_NAME . '-en.mo');
}
}
/**
* register and add a stylesheet to the public pages
*/
function footnotes_public_page_scripts() {
/* register stylesheet for the public page */
wp_register_style('footnote_public_style', plugins_url('css/footnote.css', __FILE__));
/* add stylesheet to the public page */
wp_enqueue_style('footnote_public_style');
}
/**
* @param string $p_str_FootnoteText
* @return string
*/
function footnote_example_replacer($p_str_FootnoteText) {
$l_int_FootnoteIndex = 1;
$l_str_FootnoteTemplate = file_get_contents(dirname(__FILE__) . "/templates/footnote.html");
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", $l_int_FootnoteIndex, $l_str_FootnoteTemplate);
$l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $p_str_FootnoteText, $l_str_ReplaceText);
return $l_str_ReplaceText;
}
/**
* replace the /forms.contact placeholders in the current public page
* @param string $p_str_Content
* @return string
*/
function footnotes_replace_public_placeholders($p_str_Content)
{
/* read settings */
$l_arr_Options = footnote_filter_options(FOOTNOTE_SETTINGS_CONTAINER);
/* get setting for combine identical footnotes */
$l_str_CombineIdentical = $l_arr_Options[FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME];
/* get setting for preferences label */
$l_str_ReferencesLabel = $l_arr_Options[FOOTNOTE_INPUT_REFERENCES_NAME];
/* convert it from string to boolean */
$l_bool_CombineIdentical = false;
if ($l_str_CombineIdentical == "yes") {
$l_bool_CombineIdentical = true;
}
/* contains the index for the next footnote on this page */
$l_int_FootnoteIndex = 1;
/* contains the inner text for the footnotes */
$l_str_FootnoteBody = array();
/* contains the starting position for the lookup of a footnote */
$l_int_PosStart = 0;
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents(dirname(__FILE__) . "/templates/footnote.html");
/* 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, FOOTNOTE_PLACEHOLDER_START, $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, FOOTNOTE_PLACEHOLDER_END, $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(FOOTNOTE_PLACEHOLDER_START), $l_int_Length - strlen(FOOTNOTE_PLACEHOLDER_START));
/* set replacer for the footnote */
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", $l_int_FootnoteIndex, $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(FOOTNOTE_PLACEHOLDER_END));
/* set footnote to the output box at the end */
$l_str_FootnoteBody[] = $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);
/* no footnotes has been replaced on this page */
if (count($l_str_FootnoteBody) == 0) {
/* return content */
return $p_str_Content;
}
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents(dirname(__FILE__) . "/templates/container.html");
/* loop through all footnotes found in the page */
for($l_str_Index = 0; $l_str_Index < count($l_str_FootnoteBody); $l_str_Index++) {
/* get footnote text */
$l_str_Footnote = $l_str_FootnoteBody[$l_str_Index];
/* if fottnote is empty, get to the next one */
if (empty($l_str_Footnote)) {
continue;
}
/* get footnote index */
$l_str_FirstFootnoteIndex = ($l_str_Index+1);
$l_str_FootnoteIndex = ($l_str_Index+1);
/* check if it isn't the last footnote in the array */
if ($l_str_Index+1 < count($l_str_FootnoteBody) && $l_bool_CombineIdentical) {
/* get all footnotes that I haven't passed yet */
for ($l_str_CheckIndex = $l_str_Index + 1; $l_str_CheckIndex < count($l_str_FootnoteBody); $l_str_CheckIndex++) {
/* check if a further footnote is the same as the actual one */
if ($l_str_Footnote == $l_str_FootnoteBody[$l_str_CheckIndex]) {
/* set the further footnote as empty so it won't be displayed later */
$l_str_FootnoteBody[$l_str_CheckIndex] = "";
/* add the footnote index to the actual index */
$l_str_FootnoteIndex .= ", " . ($l_str_CheckIndex + 1);
}
}
}
/* add a headline to the footer container in the bottom, but only once */
if ($l_str_Index == 0) {
$p_str_Content = $p_str_Content . '<div class="footnote_container_prepare"><p><span>' . $l_str_ReferencesLabel . '</span></p></div>';
}
/* add the footnote to the output box */
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX SHORT]]", $l_str_FirstFootnoteIndex, $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_Footnote, $l_str_ReplaceText);
/* add the footnote container to the output */
$p_str_Content = $p_str_Content . $l_str_ReplaceText;
}
/* return content */
return $p_str_Content;
}
/**
* add short links to the plugin main page
* @param array $links
* @param mixed $file
* @return array
*/
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);
/* return new links */
return $links;
}

33
includes/defines.php Normal file
View file

@ -0,0 +1,33 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/* 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 */
/* PLUGIN SETTINGS PAGE */
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 */
/* 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 */
/* PLUGIN DEFAULT PLACEHOLDER */
define( "FOOTNOTE_PLACEHOLDER_START", "((" ); /* defines the default start tag for the placeholder */
define( "FOOTNOTE_PLACEHOLDER_END", "))" ); /* defines the default end tag for the placeholder */
/* PLUGIN DIRECTORIES */
define( "FOOTNOTES_PLUGIN_DIR_NAME", "footnotes" );
define( "FOOTNOTES_LANGUAGE_DIR", dirname( __FILE__ ) . "/../languages/" );
define( "FOOTNOTES_TEMPLATES_DIR", dirname( __FILE__ ) . "/../templates/" );

55
includes/language.php Normal file
View file

@ -0,0 +1,55 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/**
* loads the langauge file including localization if exists
* otherwise loads the langauge file without localization information
* @since 1.0
*/
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();
/* 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' ) ) {
/* 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' );
}
}
/**
* reads the wordpress langauge and returns only the language code lowercase
* removes the localization code
* @since 1.0
* @return string (only the "en" from "en_US")
*/
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 );
}

View file

@ -0,0 +1,45 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/**
* add short links to the plugin main page
* @since 1.0
* @param array $links
* @param mixed $file
* @return array
*/
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 );
/* return new links */
return $links;
}
/**
* reads a option field, filters the values and returns the filtered option array
* @since 1.0
* @param string $p_str_OptionsField
* @return array
*/
function footnote_filter_options( $p_str_OptionsField )
{
$l_arr_Options = get_option( $p_str_OptionsField );
/* loop through all keys in the array and filters them */
foreach ( $l_arr_Options as $l_str_Key => $l_str_Value ) {
$l_arr_Options[ $l_str_Key ] = stripcslashes( $l_str_Value );
}
/* returns the filtered array */
return $l_arr_Options;
}

200
includes/replacer.php Normal file
View file

@ -0,0 +1,200 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/*
* collection of all footnotes found on the current page
* @since 1.0
*/
$g_arr_Footnotes = array();
/**
* starts listening for footnotes to be replaced
* output will be buffered and not displayed
* @since 1.0
* @param string $p_str_Content
* @return string
*/
function footnotes_startReplacing( $p_str_Content )
{
ob_start( "footnotes_replaceFootnotes" );
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 $p_str_Content;
}
/**
* stops buffering the output, automatically calls the ob_start() defined callback function
* replaces all footnotes in the whole buffer and outputs it
* @since 1.0
*/
function footnotes_StopReplacing()
{
ob_end_flush();
}
/**
* replaces all footnotes in the given content
* @since 1.0
* @param string $p_str_Content
* @param bool $p_bool_OutputReferences [default: true]
* @return string
*/
function footnotes_replaceFootnotes( $p_str_Content, $p_bool_OutputReferences = true )
{
/* get access to the global array */
global $g_arr_Footnotes;
/* 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;
}
/**
* replace all footnotes in the given string and adds them to an array
* @since 1.0
* @param string $p_str_Content
* @return string
*/
function footnotes_getFromString( $p_str_Content )
{
/* get access to the global array to store footnotes */
global $g_arr_Footnotes;
/* 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" );
/* 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, FOOTNOTE_PLACEHOLDER_START, $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, FOOTNOTE_PLACEHOLDER_END, $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( FOOTNOTE_PLACEHOLDER_START ), $l_int_Length - strlen( FOOTNOTE_PLACEHOLDER_START ) );
/* set replacer for the footnote */
$l_str_ReplaceText = str_replace( "[[FOOTNOTE INDEX]]", $l_int_FootnoteIndex, $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( FOOTNOTE_PLACEHOLDER_END ) );
/* 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;
}
/**
* @since 1.0
* @return string
*/
function footnotes_OutputReferenceContainer()
{
/* get access to the global array to read footnotes */
global $g_arr_Footnotes;
/* no footnotes has been replaced on this page */
if ( empty( $g_arr_Footnotes ) ) {
/* return empty string */
return "";
}
/* read settings */
$l_arr_Options = footnote_filter_options( FOOTNOTE_SETTINGS_CONTAINER );
/* get setting for combine identical footnotes */
$l_str_CombineIdentical = $l_arr_Options[ FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL ];
/* get setting for preferences label */
$l_str_ReferencesLabel = $l_arr_Options[ FOOTNOTE_INPUTFIELD_REFERENCES_LABEL ];
/* convert it from string to boolean */
$l_bool_CombineIdentical = false;
if ( $l_str_CombineIdentical == "yes" ) {
$l_bool_CombineIdentical = true;
}
/* output string */
$l_str_Output = '<div class="footnote_container_prepare"><p><span>' . $l_str_ReferencesLabel . '</span></p></div>';
/* 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 = ( $l_str_Index + 1 );
/* 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 .= ", " . ( $l_str_CheckIndex + 1 );
}
}
}
/* add the footnote to the output box */
$l_str_ReplaceText = str_replace( "[[FOOTNOTE INDEX SHORT]]", $l_str_FirstFootnoteIndex, $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;
}
/* return the output string */
return $l_str_Output;
}

34
includes/scripts.php Normal file
View file

@ -0,0 +1,34 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/**
* register and add the public stylesheet
* @since 1.0
*/
function footnotes_add_public_stylesheet()
{
/* 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 and add the settings stylesheet
* @since 1.0
*/
function footnotes_add_settings_stylesheet()
{
/* register settings stylesheet */
wp_register_style( 'footnote_settings_style', plugins_url( '../css/settings.css', __FILE__ ) );
/* add settings stylesheet */
wp_enqueue_style( 'footnote_settings_style' );
}

26
includes/uninstall.php Normal file
View file

@ -0,0 +1,26 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/* 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();
}
/* 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 ) );
}
/* 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 ) );
}

View file

@ -4,12 +4,11 @@
Plugin URI: http://www.herndler.org
Description: simple adding footnotes to your pages
Author: Mark Cheret, Stefan Herndler
Version: 1.0.0
Version: 1.1-alpha
Author URI: http://www.cheret.de
Text Domain: footnotes
Domain Path: /languages
*/
/*
Copyright 2014 Mark Cheret, Stefan Herndler (email : mark@cheret.de | admin@herndler.org)
@ -28,50 +27,63 @@
*/
/**
* User: she
* Date: 02.05.14
* Time: 16:22
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/* include all defines */
require_once(dirname(__FILE__) . "/constants.php");
/* require plugin global functions */
require_once(dirname(__FILE__) . "/functions.php");
/* include constants */
require_once( dirname( __FILE__ ) . "/includes/defines.php" );
/* include language functions */
require_once( dirname( __FILE__ ) . "/includes/language.php" );
/* include storage functions and global plugin functions */
require_once( dirname( __FILE__ ) . "/includes/plugin-settings.php" );
/* include script and stylesheet functions */
require_once( dirname( __FILE__ ) . "/includes/scripts.php" );
/* include script and stylesheet functions */
require_once( dirname( __FILE__ ) . "/includes/replacer.php" );
/* calls the wordpress filter function to replace content before displayed on public pages */
add_filter('the_content', 'footnotes_replace_public_placeholders');
add_filter('the_excerpt', 'footnotes_replace_public_placeholders');
/* calls the wordpress filter function to replace page content before displayed on public pages */
add_filter( 'the_content', 'footnotes_startReplacing' );
add_filter( 'the_excerpt', 'footnotes_DummyReplacing' );
add_filter('widget_title', 'footnotes_replace_public_placeholders', 11);
add_filter('widget_text', 'footnotes_replace_public_placeholders', 99 );
/* calls the wordpress filter function to replace widget text before displayed on public pages */
add_filter( 'widget_title', 'footnotes_DummyReplacing' );
add_filter( 'widget_text', 'footnotes_DummyReplacing' );
/* calls the wordpress action to display the footer */
add_action( 'get_footer', 'footnotes_StopReplacing' );
/* adds javascript and stylesheets to the public page */
add_action('wp_enqueue_scripts', 'footnotes_public_page_scripts');
add_action( 'wp_enqueue_scripts', 'footnotes_add_public_stylesheet' );
/* only admin is allowed to execute the plugin settings */
if (!function_exists('is_admin')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
if ( !function_exists( 'is_admin' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/* require plugin class */
require_once(dirname(__FILE__) . "/plugin.class.php");
require_once( dirname( __FILE__ ) . "/classes/footnote.php" );
/* require plugin settings class */
require_once(dirname(__FILE__) . "/settings.class.php");
require_once( dirname( __FILE__ ) . "/classes/footnote_settings.php" );
/* 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 footnotes_class_plugin();
if ( empty( $g_obj_FootnotesPlugin ) ) {
$g_obj_FootnotesPlugin = new Class_Footnotes();
}

Binary file not shown.

View file

@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: footnotes\n"
"POT-Creation-Date: 2014-05-15 21:40+0100\n"
"PO-Revision-Date: 2014-05-15 21:40+0100\n"
"POT-Creation-Date: 2014-05-16 20:06+0100\n"
"PO-Revision-Date: 2014-05-16 20:07+0100\n"
"Last-Translator: SHE <s.herndler@methis.at>\n"
"Language-Team: SHE <s.herndler@methis.at>\n"
"Language: de\n"
@ -18,55 +18,73 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"
#: functions.php:214 settings.class.php:170 settings.class.php:216
#: classes/footnote_settings.php:213
msgid "General"
msgstr "Allgemein"
#: classes/footnote_settings.php:215 includes/plugin-settings.php:22
msgid "Settings"
msgstr "Einstellungen"
#: settings.class.php:175 settings.class.php:193
msgid "Save"
msgstr "Speichern"
#: settings.class.php:217
msgid "General Information"
msgstr "Allgemeine Informationen"
#: settings.class.php:225
#: classes/footnote_settings.php:216
msgid "References label:"
msgstr "Überschrift \"Einzelnachweis\":"
#: settings.class.php:234
#: classes/footnote_settings.php:217
msgid "Combine identical footnotes:"
msgstr "Kombiniere meine Fußnoten:"
#: settings.class.php:237
#: classes/footnote_settings.php:260
msgid "Yes"
msgstr "Ja"
#: settings.class.php:238
#: classes/footnote_settings.php:261
msgid "No"
msgstr "Nein"
#: settings.class.php:257
#: classes/footnote_settings.php:282 classes/footnote_settings.php:284
msgid "HowTo"
msgstr "Hilfe"
#: classes/footnote_settings.php:295
msgid "This is a brief introduction in how to use the plugin."
msgstr "Eine kurze Anleitung für die Verwendung des Plugins."
#: classes/footnote_settings.php:308
msgid "Start your footnote with the following shortcode:"
msgstr "Starten Sie eine Fußnote mit:"
#: settings.class.php:261
#: classes/footnote_settings.php:313
msgid "...and end your footnote with this shortcode:"
msgstr "...und beenden Sie diese mit:"
#: settings.class.php:268 settings.class.php:271
#: classes/footnote_settings.php:320 classes/footnote_settings.php:323
msgid "example string"
msgstr "Beispieltext"
#: settings.class.php:269
#: classes/footnote_settings.php:321
msgid "will be displayed as:"
msgstr "wird dargestellt als:"
#: settings.class.php:277
#: classes/footnote_settings.php:329
#, php-format
msgid "If you have any questions, please don't hesitate to %smail us%s."
msgstr "Bei Fragen können Sie uns gerne eine %se-Mail%s senden."
#: includes/uninstall.php:20
msgid "You must be logged in to run this script."
msgstr "Sie müssen angemeldet sein um diese Funktion ausführen zu können."
#: includes/uninstall.php:25
msgid "You do not have permission to run this script."
msgstr "Sie haben nicht die Berechtigung diese Funktion auszuführen."
#~ msgid "Save"
#~ msgstr "Speichern"
#~ msgid "General Information"
#~ msgstr "Allgemeine Informationen"
#~ msgid ""
#~ "Insert the following shortcode where you want your footnotes to be "
#~ "displayed:"

Binary file not shown.

View file

@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: footnotes\n"
"POT-Creation-Date: 2014-05-15 21:40+0100\n"
"PO-Revision-Date: 2014-05-15 21:40+0100\n"
"POT-Creation-Date: 2014-05-16 20:06+0100\n"
"PO-Revision-Date: 2014-05-16 20:06+0100\n"
"Last-Translator: SHE <s.herndler@methis.at>\n"
"Language-Team: SHE <s.herndler@methis.at>\n"
"Language: en\n"
@ -18,55 +18,73 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"
#: functions.php:214 settings.class.php:170 settings.class.php:216
#: classes/footnote_settings.php:213
msgid "General"
msgstr "General"
#: classes/footnote_settings.php:215 includes/plugin-settings.php:22
msgid "Settings"
msgstr "Settings"
#: settings.class.php:175 settings.class.php:193
msgid "Save"
msgstr "Save"
#: settings.class.php:217
msgid "General Information"
msgstr "General Information"
#: settings.class.php:225
#: classes/footnote_settings.php:216
msgid "References label:"
msgstr "References label:"
#: settings.class.php:234
#: classes/footnote_settings.php:217
msgid "Combine identical footnotes:"
msgstr "Combine identical footnotes:"
#: settings.class.php:237
#: classes/footnote_settings.php:260
msgid "Yes"
msgstr "Yes"
#: settings.class.php:238
#: classes/footnote_settings.php:261
msgid "No"
msgstr "No"
#: settings.class.php:257
#: classes/footnote_settings.php:282 classes/footnote_settings.php:284
msgid "HowTo"
msgstr "HowTo"
#: classes/footnote_settings.php:295
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/footnote_settings.php:308
msgid "Start your footnote with the following shortcode:"
msgstr "Start your footnote with the following shortcode:"
#: settings.class.php:261
#: classes/footnote_settings.php:313
msgid "...and end your footnote with this shortcode:"
msgstr "...and end your footnote with this shortcode:"
#: settings.class.php:268 settings.class.php:271
#: classes/footnote_settings.php:320 classes/footnote_settings.php:323
msgid "example string"
msgstr "example string"
#: settings.class.php:269
#: classes/footnote_settings.php:321
msgid "will be displayed as:"
msgstr "will be displayed as:"
#: settings.class.php:277
#: classes/footnote_settings.php:329
#, php-format
msgid "If you have any questions, please don't hesitate to %smail us%s."
msgstr "If you have any questions, please don't hesitate to %smail us%s."
#: includes/uninstall.php:20
msgid "You must be logged in to run this script."
msgstr "You must be logged in to run this script."
#: includes/uninstall.php:25
msgid "You do not have permission to run this script."
msgstr "You do not have permission to run this script."
#~ msgid "Save"
#~ msgstr "Save"
#~ msgid "General Information"
#~ msgstr "General Information"
#~ msgid ""
#~ "Insert the following shortcode where you want your footnotes to be "
#~ "displayed:"

View file

@ -1,85 +0,0 @@
<?php
/**
* User: she
* Date: 30.04.14
* Time: 16:21
*/
/**
* Class footnotes_class_plugin
*/
class footnotes_class_plugin
{
var $settings, $options_page; /* class attributes */
/**
* @constructor
*/
function __construct()
{
/* load settings only if current wordpress user is admin */
if (is_admin()) {
/* create a new instance of the class settings */
$this->settings = new footnotes_class_settings();
}
/* execute class function: init, admin_init and admin_menu */
add_action('init', array($this, 'init'));
add_action('admin_init', array($this, 'admin_init'));
add_action('admin_menu', array($this, 'admin_menu'));
/* register hook for activating the plugin */
register_activation_hook(__FILE__, array($this, 'activate'));
/* register hook for deactivating the plugin */
register_deactivation_hook(__FILE__, array($this, 'deactivate'));
/* register hook for uninstalling the plugin */
register_uninstall_hook(__FILE__, array(__CLASS__, 'uninstall'));
}
/**
* activates the plugin
*/
function activate()
{
}
/**
* deactivates the plugin
*/
function deactivate()
{
}
/**
* uninstalls the plugin
*/
function uninstall()
{
require_once(PLUGIN_DIR . 'uninstall.php');
}
/**
* initialize function
* called in the class constructor
*/
function init()
{
}
/**
* do admin init stuff
* called in the class constructor
*/
function admin_init()
{
}
/**
* do admin menu stuff
* called in the class constructor
*/
function admin_menu()
{
}
} /* class footnotes_class_plugin */

View file

@ -34,7 +34,15 @@ coming soon
== Changelog ==
= 1.0.0 =
= 1.1-alpha =
* Separated functions in different files for a better overview
* Added a version control to each file / class / function / variable
* New layout for the settings menu, settings split in tabs and not a list-view
* Replacing footnotes in widget texts will show the reference container at the end of the page (bugfix)
* Updated translations for EN and DE
* Changed version number from 3 digits to 2 digits
= 1.0 =
* First development Version of the Plugin
== Feedback ==

View file

@ -1,283 +0,0 @@
<?php
/**
* User: she
* Date: 29.04.14
* Time: 15:01
*/
/**
* Class footnotes_class_settings
*/
class footnotes_class_settings
{
/* attribute for default settings value */
public static $default_settings = array(
FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME => 'yes',
FOOTNOTE_INPUT_REFERENCES_NAME => 'References'
);
var $pagehook, $page_id, $settings_field, $options; /* class attributes */
private $a_arr_CombineIdentical; /* contains the storage value for the "combine identical" setting */
private $a_arr_References; /* contains the storage value for the references setting */
/**
* @constructor
*/
function __construct()
{
$this->page_id = FOOTNOTES_SETTINGS_PAGE_ID;
/* This is the get_options slug used in the database to store our plugin option values. */
$this->settings_field = FOOTNOTE_SETTINGS_CONTAINER;
/* read plugin settings from database */
$this->options = footnote_filter_options($this->settings_field);
/* execute class functions: admin_init and admin_menu */
add_action('admin_init', array($this, 'admin_init'), 20);
add_action('admin_menu', array($this, 'admin_menu'), 20);
}
/**
* initialize settings page
* called in class constructor
*/
function admin_init()
{
/* add the jQuery plugin to the settings page */
wp_enqueue_script('jquery');
/* register stylesheet for the settings page */
wp_register_style('footnote_settings_style', plugins_url('css/settings.css', __FILE__));
/* add stylesheet to the settings page */
wp_enqueue_style('footnote_settings_style');
/* register stylesheet for the public page */
wp_register_style('footnote_public_style', plugins_url('css/footnote.css', __FILE__));
/* add stylesheet to the public page */
wp_enqueue_style('footnote_public_style');
/* Needed to allow metabox layout and close functionality */
wp_enqueue_script('postbox');
/* register the settings and sanitize the values loaded from database */
register_setting($this->settings_field, $this->settings_field, array($this, 'sanitize_theme_options'));
/* adds the values from database to the options array or adds the default values if the database values are invalid */
add_option($this->settings_field, self::$default_settings);
/* collect data for "combine identical" */
$this->a_arr_CombineIdentical = array();
$this->a_arr_CombineIdentical["id"] = $this->get_field_id(FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME);
$this->a_arr_CombineIdentical["name"] = $this->get_field_name(FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME);
$this->a_arr_CombineIdentical["value"] = esc_attr($this->get_field_value(FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME));
/* collect data for "references" label */
$this->a_arr_References = array();
$this->a_arr_References["id"] = $this->get_field_id(FOOTNOTE_INPUT_REFERENCES_NAME);
$this->a_arr_References["name"] = $this->get_field_name(FOOTNOTE_INPUT_REFERENCES_NAME);
$this->a_arr_References["value"] = esc_attr($this->get_field_value(FOOTNOTE_INPUT_REFERENCES_NAME));
}
/**
* add admin menu for plugin settings
* called in class constructor
*/
function admin_menu()
{
/* current user needs the permission to update plugins */
if (!current_user_can('update_plugins')) {
return;
}
/* submenu page title */
$l_str_PageTitle = "Footnotes";
/* submenu title */
$l_str_MenuTitle = "Footnotes";
/* Add a new submenu to the standard Settings panel */
$this->pagehook = $page = add_options_page( $l_str_PageTitle, $l_str_MenuTitle, 'administrator', $this->page_id, array($this, 'render'));
/* Executed on-load. Add all metaboxes. calls function: metaboxes */
add_action('load-' . $this->pagehook, array($this, 'metaboxes'));
/* Include js, css, or header *only* for our settings page, calls function: js_includes */
add_action("admin_print_scripts-$page", array($this, 'js_includes'));
/* calls function: admin_head */
add_action("admin_head-$page", array($this, 'admin_head'));
}
/**
* called in admin_menu()
*/
function admin_head()
{
}
/**
* called in admin_menu()
*/
function js_includes()
{
}
/**
* Sanitize our plugin settings array as needed.
* @param array $options
* @return array
*/
function sanitize_theme_options($options)
{
/* loop through all keys in the array and filters them */
foreach ($options as $l_str_Key => $l_str_Value) {
$options[$l_str_Key] = stripcslashes($l_str_Value);
}
return $options;
}
/**
* access settings field by name
* @param string $name
* @return string
*/
protected function get_field_name($name)
{
return sprintf('%s[%s]', $this->settings_field, $name);
}
/**
* access settings field by id
* @param string $id
* @return string
*/
protected function get_field_id($id)
{
return sprintf('%s[%s]', $this->settings_field, $id);
}
/**
* get settings field value
* @param string $key
* @return string
*/
protected function get_field_value($key)
{
return $this->options[$key];
}
/**
* Render settings page, display the page container
*/
function render()
{
global $wp_meta_boxes;
?>
<div class="wrap">
<h2><span class='METHIS'>Footnotes</span> <?php echo __("Settings", FOOTNOTES_PLUGIN_NAME); ?></h2>
<form method="post" action="options.php">
<p>
<input type="submit" class="button button-primary" name="save_options"
value="<?php echo __("Save", FOOTNOTES_PLUGIN_NAME); ?>"/>
</p>
<div class="metabox-holder">
<div class="postbox-container" style="width: 99%;">
<?php
/* Render metaboxes */
settings_fields($this->settings_field);
do_meta_boxes($this->pagehook, 'main', null);
if (isset($wp_meta_boxes[$this->pagehook]['layout'])) {
do_meta_boxes($this->pagehook, 'layout', null);
}
?>
</div>
</div>
<p>
<input type="submit" class="button button-primary" name="save_options"
value="<?php echo __("Save", FOOTNOTES_PLUGIN_NAME); ?>"/>
</p>
</form>
</div>
<!-- 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->pagehook; ?>');
});
</script>
<?php
}
/**
* add containers to the settings page
* displayed containers on the settings page
*/
function metaboxes()
{
add_meta_box('footnote-plugin-settings', __("Settings", FOOTNOTES_PLUGIN_NAME), array($this, 'settings_box'), $this->pagehook, 'main');
add_meta_box('footnote-plugin-general', __("General Information", FOOTNOTES_PLUGIN_NAME), array($this, 'placeholder_box'), $this->pagehook, 'main');
}
function settings_box() {
?>
<!-- setting references label -->
<div class="footnote_plugin_container">
<label class="footnote_plugin_25" for="<?php echo $this->a_arr_References["id"]; ?>">
<?php echo __("References label:", FOOTNOTES_PLUGIN_NAME); ?>
</label>
<input type="text" class="footnote_plugin_75" name="<?php echo $this->a_arr_References["name"]; ?>" id="<?php echo $this->a_arr_References["id"]; ?>"
value="<?php echo $this->a_arr_References["value"]; ?>"/>
</div>
<!-- setting combine identical -->
<div class="footnote_plugin_container">
<label class="footnote_plugin_25" for="<?php echo $this->a_arr_CombineIdentical["id"]; ?>">
<?php echo __("Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME); ?>
</label>
<select class="footnote_plugin_25" id="<?php echo FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME; ?>" name="<?php echo $this->a_arr_CombineIdentical["name"]; ?>">
<option value="yes"><?php echo __("Yes", FOOTNOTES_PLUGIN_NAME); ?></option>
<option value="no"><?php echo __("No", FOOTNOTES_PLUGIN_NAME); ?></option>
</select>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#<?php echo FOOTNOTE_INPUT_COMBINE_IDENTICAL_NAME; ?> option[value='<?php echo $this->a_arr_CombineIdentical["value"]; ?>']").prop("selected", true);
});
</script>
</div>
<?php
}
/**
* displays the placeholder tag container
*/
function placeholder_box() {
?>
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __("Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_START; ?></span>
</p>
<p>
<?php echo __("...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_END; ?></span>
</p>
<p>&nbsp;</p>
<p>
<span class="footnote_highlight_placeholder"><?php echo FOOTNOTE_PLACEHOLDER_START . __("example string", FOOTNOTES_PLUGIN_NAME) . FOOTNOTE_PLACEHOLDER_END; ?></span>
<?php echo __("will be displayed as:", FOOTNOTES_PLUGIN_NAME); ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo footnote_example_replacer(__("example string", FOOTNOTES_PLUGIN_NAME)); ?>
</p>
<p>&nbsp;</p>
<p>
<?php echo sprintf(__("If you have any questions, please don't hesitate to %smail us%s.", FOOTNOTES_PLUGIN_NAME), '<a href="mailto:admin@herndler.org" class="footnote_plugin">', '</a>'); ?>
</p>
</div>
</div>
<?php
}
} /* Class footnotes_class_settings */

View file

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

View file

@ -1,23 +0,0 @@
<?php
/**
* User: she
* Date: 29.04.14
* Time: 15:03
*/
/* 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();
}
/* 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.');
}
/* 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.');
}