2014-05-20 11:33:11 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by Stefan Herndler.
|
|
|
|
* User: Stefan
|
|
|
|
* Date: 15.05.14
|
|
|
|
* Time: 16:21
|
2014-05-20 11:38:36 +00:00
|
|
|
* Version: 1.0-beta
|
2014-05-20 11:33:11 +00:00
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add short links to the plugin main page
|
|
|
|
* @since 1.0
|
|
|
|
* @param array $links
|
|
|
|
* @param mixed $file
|
|
|
|
* @return array
|
|
|
|
*/
|
2014-05-21 18:33:26 +00:00
|
|
|
function footnotes_plugin_settings_link($links, $file)
|
2014-05-20 11:33:11 +00:00
|
|
|
{
|
2014-05-22 12:57:26 +00:00
|
|
|
/* add link to the footnotes plugin settings page */
|
|
|
|
$l_str_SettingsLink = '<a href="' . admin_url('options-general.php?page=' . FOOTNOTES_SETTINGS_PAGE_ID) . '">' . __('Settings', FOOTNOTES_PLUGIN_NAME) . '</a>';
|
|
|
|
/* add link to the footnotes plugin support page on wordpress.org */
|
|
|
|
$l_str_SupportLink = '<a href="http://wordpress.org/support/plugin/footnotes" target="_blank">' . __('Support', FOOTNOTES_PLUGIN_NAME) . '</a>';
|
|
|
|
|
|
|
|
/* add defined links to the plugin main page */
|
|
|
|
$links[] = $l_str_SupportLink;
|
|
|
|
$links[] = $l_str_SettingsLink;
|
2014-05-20 11:33:11 +00:00
|
|
|
|
2014-05-21 18:33:26 +00:00
|
|
|
/* return new links */
|
|
|
|
return $links;
|
2014-05-20 11:33:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* reads a option field, filters the values and returns the filtered option array
|
2014-05-20 11:42:07 +00:00
|
|
|
* fallback to default value since 1.0-gamma
|
2014-05-20 11:33:11 +00:00
|
|
|
* @since 1.0
|
|
|
|
* @param string $p_str_OptionsField
|
2014-05-20 11:42:07 +00:00
|
|
|
* @param array $p_arr_DefaultValues
|
Version 1.0.4
* Updated replacing function when footnote is a link (bugfix)
* Footnote hover box remains until cursor leaves footnote or hover box
* Links in the footnote hover box are click able
* New setting to allow footnotes on Summarized Posts
* New setting to tell the world you're using footnotes plugin
* New setting for the counter style of the footnote index
** Arabic Numbers (1, 2, 3, 4, 5, ...)
** Arabic Numbers leading 0 (01, 02, 03, 04, 05, ...)
** Latin Characters lower-case (a, b, c, d, e, ...)
** Latin Characters upper-case (A, B, C, D, E, ...)
** Roman Numerals (I, II, III, IV, V, ...)
* Adding a link to the WordPress plugin in the footer if the WP-admin accepts it
* Updated translations for the new settings
* re-changed the version number to have 3 digits
git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@917816 b8457f37-d9ea-0310-8a92-e5e31aec5664
2014-05-20 11:44:38 +00:00
|
|
|
* @param bool $p_bool_ConvertHtmlChars
|
2014-05-20 11:33:11 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2014-05-21 18:33:26 +00:00
|
|
|
function footnotes_filter_options($p_str_OptionsField, $p_arr_DefaultValues, $p_bool_ConvertHtmlChars = true)
|
2014-05-20 11:33:11 +00:00
|
|
|
{
|
2014-05-21 18:33:26 +00:00
|
|
|
$l_arr_Options = get_option($p_str_OptionsField);
|
2014-05-22 13:33:57 +00:00
|
|
|
/* if no settings set yet return default values */
|
|
|
|
if (empty($l_arr_Options)) {
|
|
|
|
return $p_arr_DefaultValues;
|
|
|
|
}
|
2014-05-21 18:33:26 +00:00
|
|
|
/* loop through all keys in the array and filters them */
|
|
|
|
foreach ($l_arr_Options as $l_str_Key => $l_str_Value) {
|
|
|
|
/* removes special chars from the settings value */
|
|
|
|
$l_str_Value = stripcslashes($l_str_Value);
|
|
|
|
/* if set, convert html special chars */
|
|
|
|
if ($p_bool_ConvertHtmlChars) {
|
|
|
|
$l_str_Value = htmlspecialchars($l_str_Value);
|
|
|
|
}
|
|
|
|
/* check if settings value is not empty, otherwise load the default value, or empty string if no default is defined */
|
|
|
|
if (!empty($l_str_Value)) {
|
|
|
|
$l_arr_Options[$l_str_Key] = stripcslashes($l_str_Value);
|
|
|
|
/* check if default value is defined */
|
|
|
|
} else if (array_key_exists($l_str_Key, $p_arr_DefaultValues)) {
|
|
|
|
$l_arr_Options[$l_str_Key] = $p_arr_DefaultValues[$l_str_Key];
|
|
|
|
} else {
|
|
|
|
$l_arr_Options[$l_str_Key] = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* returns the filtered array */
|
|
|
|
return $l_arr_Options;
|
2014-05-20 11:38:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* converts a string depending on its value to a boolean
|
|
|
|
* @since 1.0-beta
|
|
|
|
* @param string $p_str_Value
|
|
|
|
* @return bool
|
|
|
|
*/
|
2014-05-21 18:33:26 +00:00
|
|
|
function footnotes_ConvertToBool($p_str_Value)
|
|
|
|
{
|
|
|
|
/* convert string to lower-case to make it easier */
|
|
|
|
$p_str_Value = strtolower($p_str_Value);
|
|
|
|
/* check if string seems to contain a "true" value */
|
|
|
|
switch ($p_str_Value) {
|
|
|
|
case "checked":
|
|
|
|
case "yes":
|
|
|
|
case "true":
|
|
|
|
case "on":
|
|
|
|
case "1":
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
/* nothing found that says "true", so we return false */
|
|
|
|
return false;
|
2014-05-20 11:33:11 +00:00
|
|
|
}
|