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
|
|
|
|
*/
|
|
|
|
|
2014-07-31 10:17:38 +00:00
|
|
|
// 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}", 'MCI_Footnotes_PluginLinks', 10, 2);
|
2014-05-20 11:33:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* add short links to the plugin main page
|
|
|
|
* @since 1.0
|
2014-07-31 10:17:38 +00:00
|
|
|
* @param array $p_arr_Links
|
|
|
|
* @param string $p_str_File
|
2014-05-20 11:33:11 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2014-07-31 10:17:38 +00:00
|
|
|
function MCI_Footnotes_PluginLinks($p_arr_Links, $p_str_File) {
|
|
|
|
// add link to the footnotes plugin settings page
|
2014-05-22 12:57:26 +00:00
|
|
|
$l_str_SettingsLink = '<a href="' . admin_url('options-general.php?page=' . FOOTNOTES_SETTINGS_PAGE_ID) . '">' . __('Settings', FOOTNOTES_PLUGIN_NAME) . '</a>';
|
2014-07-31 10:17:38 +00:00
|
|
|
// add link to the footnotes plugin support page on wordpress.org
|
2014-05-22 12:57:26 +00:00
|
|
|
$l_str_SupportLink = '<a href="http://wordpress.org/support/plugin/footnotes" target="_blank">' . __('Support', FOOTNOTES_PLUGIN_NAME) . '</a>';
|
|
|
|
|
2014-07-31 10:17:38 +00:00
|
|
|
// add defined links to the plugin main page
|
|
|
|
$p_arr_Links[] = $l_str_SupportLink;
|
|
|
|
$p_arr_Links[] = $l_str_SettingsLink;
|
2014-05-20 11:33:11 +00:00
|
|
|
|
2014-07-31 10:17:38 +00:00
|
|
|
// return new links
|
|
|
|
return $p_arr_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
|
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-07-31 10:17:38 +00:00
|
|
|
function MCI_Footnotes_getOptions($p_bool_ConvertHtmlChars = true) {
|
|
|
|
// default settings for the 'general' settings container
|
|
|
|
$l_arr_Default_General = array(
|
|
|
|
FOOTNOTES_INPUT_COMBINE_IDENTICAL => 'yes',
|
|
|
|
FOOTNOTES_INPUT_REFERENCES_LABEL => 'References',
|
|
|
|
FOOTNOTES_INPUT_COLLAPSE_REFERENCES => '',
|
|
|
|
FOOTNOTES_INPUT_PLACEHOLDER_START => '((',
|
|
|
|
FOOTNOTES_INPUT_PLACEHOLDER_END => '))',
|
|
|
|
FOOTNOTES_INPUT_SEARCH_IN_EXCERPT => 'yes',
|
|
|
|
FOOTNOTES_INPUT_LOVE => 'no',
|
|
|
|
FOOTNOTES_INPUT_COUNTER_STYLE => 'arabic_plain',
|
|
|
|
FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE => 'post_end',
|
|
|
|
FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED => '',
|
|
|
|
FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED => ''
|
|
|
|
);
|
|
|
|
// default settings for the 'custom' settings container
|
|
|
|
$l_arr_Default_Custom = array(
|
|
|
|
FOOTNOTES_INPUT_CUSTOM_CSS => ''
|
|
|
|
);
|
|
|
|
|
|
|
|
$l_arr_General = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER), $l_arr_Default_General, $p_bool_ConvertHtmlChars);
|
|
|
|
$l_arr_Custom = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER_CUSTOM), $l_arr_Default_Custom, $p_bool_ConvertHtmlChars);
|
|
|
|
|
|
|
|
return array_merge($l_arr_General, $l_arr_Custom);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* validate each option, fallback is the default value
|
|
|
|
* @since 1.3
|
|
|
|
* @param array $p_arr_Options
|
|
|
|
* @param array $p_arr_Default
|
|
|
|
* @param bool $p_bool_ConvertHtmlChars
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function MCI_Footnotes_ValidateOptions($p_arr_Options, $p_arr_Default, $p_bool_ConvertHtmlChars) {
|
|
|
|
// if no settings set yet return default values
|
|
|
|
if (empty($p_arr_Options)) {
|
|
|
|
return $p_arr_Default;
|
|
|
|
}
|
|
|
|
// loop through all keys in the array and filters them
|
|
|
|
foreach ($p_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)) {
|
|
|
|
$p_arr_Options[$l_str_Key] = $l_str_Value;
|
|
|
|
// check if default value is defined
|
|
|
|
} else if (array_key_exists($l_str_Key, $p_arr_Default)) {
|
|
|
|
$p_arr_Options[$l_str_Key] = $p_arr_Default[$l_str_Key];
|
|
|
|
} else {
|
|
|
|
$p_arr_Options[$l_str_Key] = "";
|
|
|
|
}
|
2014-05-22 13:33:57 +00:00
|
|
|
}
|
2014-06-10 08:51:02 +00:00
|
|
|
|
|
|
|
// check if each key from the default values exist in return array
|
2014-07-31 10:17:38 +00:00
|
|
|
foreach($p_arr_Default as $l_str_Key => $l_str_Value) {
|
2014-06-10 08:51:02 +00:00
|
|
|
// if key not exists, add it with its default value
|
2014-07-31 10:17:38 +00:00
|
|
|
if (!array_key_exists($l_str_Key, $p_arr_Options)) {
|
|
|
|
$p_arr_Options[$l_str_Key] = $l_str_Value;
|
2014-06-10 08:51:02 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-31 10:17:38 +00:00
|
|
|
// returns the filtered array
|
|
|
|
return $p_arr_Options;
|
2014-05-20 11:33:11 +00:00
|
|
|
}
|