diff --git a/classes/footnotes_settings.php b/classes/footnotes_settings.php index 499b5ac..0e59fed 100644 --- a/classes/footnotes_settings.php +++ b/classes/footnotes_settings.php @@ -23,7 +23,10 @@ class Class_FootnotesSettings FOOTNOTE_INPUTFIELD_REFERENCES_LABEL => 'References', FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES => '', FOOTNOTE_INPUTFIELD_PLACEHOLDER_START => '((', - FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))' + FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))', + FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT => 'yes', + FOOTNOTE_INPUTFIELD_LOVE => 'yes', + FOOTNOTE_INPUTFIELD_COUNTER_STYLE => 'arabic_plain' ); /* * resulting pagehook for adding a new sub menu page to the settings @@ -48,7 +51,7 @@ class Class_FootnotesSettings function __construct() { /* loads and filters the settings for this plugin */ - $this->a_arr_Options = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings ); + $this->a_arr_Options = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings, true ); /* execute class includes on action-even: init, admin_init and admin_menu */ add_action( 'init', array( $this, 'LoadScriptsAndStylesheets' ) ); @@ -312,6 +315,9 @@ class Class_FootnotesSettings add_settings_field( 'Register_Collapse_References', __( "Collapse references by default:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_Collapse_References' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName ); add_settings_field( 'Register_Combine_Identical', __( "Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_Combine_Identical' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName ); add_settings_field( 'Register_Placeholder_Tags', __( "Footnote tag:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_Placeholder_Tags' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName ); + add_settings_field( 'Register_CounterStyle', __( "Counter style:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_CounterStyle' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName ); + add_settings_field( 'Register_SearchExcerpt', __( "Allow footnotes on Summarized Posts:", FOOTNOTES_PLUGIN_NAME ), array( $this, 'Register_SearchExcerpt' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName ); + add_settings_field( 'Register_LoveAndShare', sprintf(__( "Tell the world you're using %sfootnotes%s:", FOOTNOTES_PLUGIN_NAME ), '', ''), array( $this, 'Register_LoveAndShare' ), FOOTNOTE_SETTINGS_LABEL_GENERAL, $l_str_SectionName ); } /** @@ -373,6 +379,55 @@ class Class_FootnotesSettings $this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, "", 14, __( "ends with:", FOOTNOTES_PLUGIN_NAME )); } + /** + * outouts the settings field for the counter style + * @since 1.0-gamma + */ + function Register_CounterStyle() + { + $l_str_Space = " "; + /* get array with option elements */ + $l_arr_Options = array( + "arabic_plain" => __( "Arabic Numbers - Plain", FOOTNOTES_PLUGIN_NAME ) .$l_str_Space. "1, 2, 3, 4, 5, ...", + "arabic_leading" => __( "Arabic Numbers - Leading 0", FOOTNOTES_PLUGIN_NAME ) .$l_str_Space. "01, 02, 03, 04, 05, ...", + "latin_low" => __( "Latin Character - lower case", FOOTNOTES_PLUGIN_NAME ) .$l_str_Space. "a, b, c, d, e, ...", + "latin_high" => __( "Latin Character - upper case", FOOTNOTES_PLUGIN_NAME ) .$l_str_Space. "A, B, C, D, E, ...", + "romanic" => __( "Roman Numerals", FOOTNOTES_PLUGIN_NAME ) .$l_str_Space. "I, II, III, IV, V, ..." + ); + /* add a select box to the output */ + $this->AddSelectbox(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50"); + } + + /** + * outputs the settings field for "allow searching in summarized posts" + * @since 1.0-gamma + */ + function Register_SearchExcerpt() + { + /* get array with option elements */ + $l_arr_Options = array( + "yes" => __( "Yes", FOOTNOTES_PLUGIN_NAME ), + "no" => __( "No", FOOTNOTES_PLUGIN_NAME ) + ); + /* add a select box to the output */ + $this->AddSelectbox(FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_25"); + } + + /** + * outputs the settings field for "love and share this plugin" + * @since 1.0-gamma + */ + function Register_LoveAndShare() + { + /* get array with option elements */ + $l_arr_Options = array( + "yes" => __( "Yes", FOOTNOTES_PLUGIN_NAME ), + "no" => __( "No", FOOTNOTES_PLUGIN_NAME ) + ); + /* add a select box to the output */ + $this->AddSelectbox(FOOTNOTE_INPUTFIELD_LOVE, $l_arr_Options, "footnote_plugin_25"); + } + /** * initialize howto settings tab * called in class constructor @ admin_init @@ -424,7 +479,7 @@ class Class_FootnotesSettings - +
diff --git a/css/footnote.css b/css/footnote.css index ec270e9..f6b2ea5 100755 --- a/css/footnote.css +++ b/css/footnote.css @@ -79,32 +79,33 @@ } /* tooltip */ -a.footnote_plugin_tooltip { +.footnote_plugin_tooltip { outline: none !important; color: #4777ff !important; text-decoration: none !important; cursor: pointer !important; } -a.footnote_plugin_tooltip strong { +.footnote_plugin_tooltip strong { line-height: 30px !important; } -a.footnote_plugin_tooltip:hover { +.footnote_plugin_tooltip:hover { text-decoration: none !important; } -a.footnote_plugin_tooltip span { +.footnote_plugin_tooltip span { z-index: 10 !important; display: none !important; padding: 14px 20px !important; margin-top: -30px !important; - margin-left: 28px !important; + /*margin-left: 28px !important;*/ /*width: 240px;*/ line-height: 16px !important; + cursor: default; } -a.footnote_plugin_tooltip:hover span { +.footnote_plugin_tooltip:hover span, .footnote_plugin_tooltip span:hover { display: inline !important; position: absolute !important; color: #474747 !important; @@ -121,7 +122,7 @@ a.footnote_plugin_tooltip:hover span { } /*CSS3 extras*/ -a.footnote_plugin_tooltip span { +.footnote_plugin_tooltip span { border-radius: 4px !important; -moz-border-radius: 4px !important; -webkit-border-radius: 4px !important; diff --git a/css/settings.css b/css/settings.css index e7005f8..cc597a2 100755 --- a/css/settings.css +++ b/css/settings.css @@ -9,7 +9,7 @@ /* overwrite some styling for inputs [type=text] and select-boxes */ input[type=text], input[type=checkbox], input[type=password], textarea, select { - margin-left: 12px !important; + /*margin-left: 12px !important;*/ } input[type=text], input[type=password], textarea, select { padding-left: 8px !important; diff --git a/includes/defines.php b/includes/defines.php index fcb8423..18f56bd 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -25,6 +25,9 @@ define( "FOOTNOTE_INPUTFIELD_REFERENCES_LABEL", "footnote_inputfield_references_ define( "FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES", "footnote_inputfield_collapse_references" ); /* id of input field for the "collapse references" setting */ define( "FOOTNOTE_INPUTFIELD_PLACEHOLDER_START", "footnote_inputfield_placeholder_start"); /* id of input field for the "placeholder starting tag" setting */ define( "FOOTNOTE_INPUTFIELD_PLACEHOLDER_END", "footnote_inputfield_placeholder_end"); /* id of input field for the "placeholder ending tag" setting */ +define( "FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT", "footnote_inputfield_search_in_excerpt"); /* id of input field for the "allow footnotes in the excerpt" setting */ +define( "FOOTNOTE_INPUTFIELD_LOVE", "footnote_inputfield_love"); /* id of input field for "love and share this plugin" setting */ +define( "FOOTNOTE_INPUTFIELD_COUNTER_STYLE", "footnote_inputfield_counter_style"); /* id of input field for "counter style of footnote index" setting */ /* PLUGIN REFERENCES CONTAINER ID */ define( "FOOTNOTE_REFERENCES_CONTAINER_ID", "footnote_references_container" ); /* id for the div surrounding the footnotes */ diff --git a/includes/plugin-settings.php b/includes/plugin-settings.php index 415a0f1..e7d5f10 100644 --- a/includes/plugin-settings.php +++ b/includes/plugin-settings.php @@ -33,15 +33,20 @@ function footnotes_plugin_settings_link( $links, $file ) * @since 1.0 * @param string $p_str_OptionsField * @param array $p_arr_DefaultValues + * @param bool $p_bool_ConvertHtmlChars * @return array */ -function footnotes_filter_options( $p_str_OptionsField, $p_arr_DefaultValues ) +function footnotes_filter_options( $p_str_OptionsField, $p_arr_DefaultValues, $p_bool_ConvertHtmlChars=true ) { $l_arr_Options = get_option( $p_str_OptionsField ); /* loop through all keys in the array and filters them */ foreach ( $l_arr_Options as $l_str_Key => $l_str_Value ) { /* removes special chars from the settings value */ $l_str_Value = stripcslashes( $l_str_Value ); + /* if set, convert html special chars */ + if ($p_bool_ConvertHtmlChars) { + $l_str_Value = htmlspecialchars( $l_str_Value ); + } /* check if settings value is not empty, otherwise load the default value, or empty string if no default is defined */ if (!empty($l_str_Value)) { $l_arr_Options[ $l_str_Key ] = stripcslashes( $l_str_Value ); diff --git a/includes/replacer.php b/includes/replacer.php index 145b3ae..ae67dfb 100644 --- a/includes/replacer.php +++ b/includes/replacer.php @@ -20,6 +20,41 @@ $g_arr_Footnotes = array(); */ $g_arr_FootnotesSettings = array(); +/** + * register all functions needed for the replacement in the wordpress core + * @since 1.0-gamma + */ +function footnotes_RegisterReplacementFunctions() { + /* access to the global settings collection */ + global $g_arr_FootnotesSettings; + /* load footnote settings */ + $g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, false ); + /* get setting for accepting footnotes in the excerpt and convert it to boolean */ + $l_bool_SearchExcerpt = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT ]); + + /* calls the wordpress filter function to replace page content before displayed on public pages */ + add_filter( 'the_content', 'footnotes_startReplacing' ); + /* search in the excerpt only if activated */ + if ($l_bool_SearchExcerpt) { + add_filter( 'the_excerpt', 'footnotes_DummyReplacing' ); + } + + /* 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' ); + + /* get setting for love and share this plugin and convert it to boolean */ + $l_bool_LoveMe = footnotes_ConvertToBool($g_arr_FootnotesSettings[ FOOTNOTE_INPUTFIELD_LOVE ]); + /* check if the admin allows to add a link to the footer */ + if ($l_bool_LoveMe) { + /* calls the wordpress action to hook to the footer */ + add_filter('wp_footer', 'footnotes_LoveAndShareMe', 0); + } +} + /** * starts listening for footnotes to be replaced * output will be buffered and not displayed @@ -29,12 +64,8 @@ $g_arr_FootnotesSettings = array(); */ function footnotes_startReplacing( $p_str_Content ) { - /* access to the global settings collection */ - global $g_arr_FootnotesSettings; /* stop the output and move it to a buffer instead, defines a callback function */ ob_start( "footnotes_replaceFootnotes" ); - /* load footnote settings */ - $g_arr_FootnotesSettings = footnotes_filter_options( FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings ); /* return unchanged content */ return $p_str_Content; } @@ -62,26 +93,36 @@ function footnotes_StopReplacing() ob_end_flush(); } +/** + * outputs a link to love and share this awesome plugin + * @since 1.0-gamma + */ +function footnotes_LoveAndShareMe() +{ + echo ' +' . $l_str_ReferencesLabel . '
' . $l_str_ReferencesLabel . '