diff --git a/classes/footnote.php b/classes/footnote.php
new file mode 100644
index 0000000..57ab322
--- /dev/null
+++ b/classes/footnote.php
@@ -0,0 +1,105 @@
+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 */
\ No newline at end of file
diff --git a/classes/footnote_settings.php b/classes/footnote_settings.php
new file mode 100644
index 0000000..a58c773
--- /dev/null
+++ b/classes/footnote_settings.php
@@ -0,0 +1,334 @@
+ '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 '
';
+ $this->OutputSettingsPageTabs();
+ /* outputs a form with the content of the current active tab */
+ echo '';
+ echo '
';
+ }
+
+ /**
+ * 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 '';
+ foreach ( $this->a_arr_SettingsTabs as $l_str_TabKey => $l_str_TabCaption ) {
+ $active = $l_str_CurrentTab == $l_str_TabKey ? 'nav-tab-active' : '';
+ echo '' . $l_str_TabCaption . '';
+ }
+ echo '
';
+ }
+
+ /**
+ * 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 );
+ ?>
+ "
+ id=""
+ value=""/>
+ LoadSetting( FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL );
+ ?>
+
+
+
+ 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()
+ {
+ ?>
+
+
+
+ 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;
}
\ No newline at end of file
diff --git a/css/settings.css b/css/settings.css
index 2e96f73..a2d2710 100755
--- a/css/settings.css
+++ b/css/settings.css
@@ -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;
}
\ No newline at end of file
diff --git a/functions.php b/functions.php
deleted file mode 100755
index 9d48374..0000000
--- a/functions.php
+++ /dev/null
@@ -1,219 +0,0 @@
- $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 . '';
- }
-
- /* 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 = '' . __('Settings', FOOTNOTES_PLUGIN_NAME) . '';
- array_unshift($links, $settings_link);
-
- /* return new links */
- return $links;
-}
\ No newline at end of file
diff --git a/includes/defines.php b/includes/defines.php
new file mode 100644
index 0000000..71d0d23
--- /dev/null
+++ b/includes/defines.php
@@ -0,0 +1,33 @@
+' . __( 'Settings', FOOTNOTES_PLUGIN_NAME ) . '';
+ 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;
+}
\ No newline at end of file
diff --git a/includes/replacer.php b/includes/replacer.php
new file mode 100644
index 0000000..a06fe1e
--- /dev/null
+++ b/includes/replacer.php
@@ -0,0 +1,200 @@
+' . $l_str_ReferencesLabel . '
';
+
+ /* 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;
+}
\ No newline at end of file
diff --git a/includes/scripts.php b/includes/scripts.php
new file mode 100644
index 0000000..f329b5a
--- /dev/null
+++ b/includes/scripts.php
@@ -0,0 +1,34 @@
+\n"
"Language-Team: SHE \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:"
diff --git a/languages/footnotes-en.mo b/languages/footnotes-en.mo
index ea7a5a3..255593c 100755
Binary files a/languages/footnotes-en.mo and b/languages/footnotes-en.mo differ
diff --git a/languages/footnotes-en.po b/languages/footnotes-en.po
index 1355535..f7c4529 100755
--- a/languages/footnotes-en.po
+++ b/languages/footnotes-en.po
@@ -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 \n"
"Language-Team: SHE \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:"
diff --git a/plugin.class.php b/plugin.class.php
deleted file mode 100755
index b49071d..0000000
--- a/plugin.class.php
+++ /dev/null
@@ -1,85 +0,0 @@
-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 */
\ No newline at end of file
diff --git a/readme.txt b/readme.txt
index df6cffc..48d74d2 100755
--- a/readme.txt
+++ b/readme.txt
@@ -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 ==
diff --git a/settings.class.php b/settings.class.php
deleted file mode 100755
index 4220a90..0000000
--- a/settings.class.php
+++ /dev/null
@@ -1,283 +0,0 @@
- '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;
- ?>
-
-
-
-
-
- pagehook, 'main');
- add_meta_box('footnote-plugin-general', __("General Information", FOOTNOTES_PLUGIN_NAME), array($this, 'placeholder_box'), $this->pagehook, 'main');
- }
-
- function settings_box() {
- ?>
-
-
-
-
-
-
-
-
-
-
diff --git a/uninstall.php b/uninstall.php
deleted file mode 100755
index f6f14b4..0000000
--- a/uninstall.php
+++ /dev/null
@@ -1,23 +0,0 @@
-