Prepare for release version 1.5.2
- Add: Setting to enable/disable the mouse-over box - Add: Current WordPress Theme to the Diagnostics sub page - Add: ManFisher note in the "other Plugins" sub page - Update: Removed unnecessary hidden inputs from the Settings page - Update: Merged public CSS files to reduce the output and improve the performance - Update: Translations (EN and DE) - Bugfix: Removed the 'trim' function to allow whitespaces at the beginning and end of each setting - Bugfix: Convert the footnotes short code to HTML special chars when adding them into the page/post editor (visual and text) - Bugfix: Detailed error messages if other Plugins can't be loaded. Also added empty strings as default values to avoid 'undefined' git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@1000036 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
parent
a0d945d44c
commit
58b3dd27f6
26 changed files with 345 additions and 241 deletions
|
@ -200,13 +200,13 @@ class MCI_Footnotes_Convert {
|
|||
printf("</pre>");
|
||||
|
||||
} else if (is_numeric($p_mixed_Value) || is_int($p_mixed_Value)) {
|
||||
echo $p_mixed_Value;
|
||||
var_dump($p_mixed_Value);
|
||||
|
||||
} else if (is_date($p_mixed_Value)) {
|
||||
echo $p_mixed_Value;
|
||||
var_dump($p_mixed_Value);
|
||||
|
||||
} else {
|
||||
echo $p_mixed_Value;
|
||||
var_dump($p_mixed_Value);
|
||||
}
|
||||
echo "<br/>";
|
||||
}
|
||||
|
|
|
@ -141,10 +141,14 @@ class MCI_Footnotes_Layout_Init {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function displayOtherPlugins() {
|
||||
printf("<br/>");
|
||||
printf("<h3>%s</h3>", __('Take a look on other Plugins we have developed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
|
||||
printf("<br/><br/>");
|
||||
// load template file
|
||||
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "manfisher");
|
||||
echo $l_obj_Template->getContent();
|
||||
|
||||
printf('<em><a href="http://manfisher.net/" target="_blank">visit ManFisher Medien ManuFaktur</a></em>');
|
||||
printf("<br/><br/>");
|
||||
printf("<h3>%s</h3>", __('Take a look on other Plugins we have developed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
|
||||
/*
|
||||
// collect plugin list as JSON
|
||||
$l_arr_Response = wp_remote_get("http://herndler.org/wordpress/plugins/get.json");
|
||||
|
@ -204,22 +208,30 @@ class MCI_Footnotes_Layout_Init {
|
|||
$l_arr_Response = wp_remote_get($l_str_Url);
|
||||
// check if response is valid
|
||||
if (is_wp_error($l_arr_Response)) {
|
||||
echo json_encode(array("error" => "Can't get Plugin information."));
|
||||
echo json_encode(array("error" => "Error receiving Plugin Information from WordPress."));
|
||||
exit;
|
||||
}
|
||||
if (!array_key_exists("body", $l_arr_Response)) {
|
||||
echo json_encode(array("error" => "Error reading WordPress API response message."));
|
||||
exit;
|
||||
}
|
||||
// get the body of the response
|
||||
$l_str_Response = $l_arr_Response["body"];
|
||||
// get plugin object
|
||||
$l_arr_Plugin = json_decode($l_str_Response, true);
|
||||
if (empty($l_arr_Plugin)) {
|
||||
echo json_encode(array("error" => "Error reading Plugin meta information."));
|
||||
exit;
|
||||
}
|
||||
|
||||
// return Plugin information as JSON encoded string
|
||||
echo json_encode(
|
||||
array(
|
||||
"error" => "",
|
||||
"PluginImage" => "",
|
||||
"PluginDescription" => html_entity_decode($l_arr_Plugin["short_description"]),
|
||||
"PluginUrl" => $l_arr_Plugin["homepage"],
|
||||
"PluginVersion" => $l_arr_Plugin["version"]
|
||||
"PluginDescription" => array_key_exists("short_description", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["short_description"]) : "Error reading Plugin information",
|
||||
"PluginUrl" => array_key_exists("homepage", $l_arr_Plugin) ? $l_arr_Plugin["homepage"] : "",
|
||||
"PluginVersion" => array_key_exists("version", $l_arr_Plugin) ? $l_arr_Plugin["version"] : "---"
|
||||
)
|
||||
);
|
||||
exit;
|
||||
|
|
|
@ -216,6 +216,8 @@ abstract class MCI_Footnotes_LayoutEngine {
|
|||
$l_bool_SettingsUpdated = false;
|
||||
if (array_key_exists("save-settings", $_POST)) {
|
||||
if ($_POST["save-settings"] == "save") {
|
||||
unset($_POST["save-settings"]);
|
||||
unset($_POST["submit"]);
|
||||
$l_bool_SettingsUpdated = $this->saveSettings();
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +241,7 @@ abstract class MCI_Footnotes_LayoutEngine {
|
|||
|
||||
// form to submit the active section
|
||||
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
|
||||
settings_fields($l_arr_ActiveSection["container"]);
|
||||
//settings_fields($l_arr_ActiveSection["container"]);
|
||||
echo '<input type="hidden" name="save-settings" value="save" />';
|
||||
// outputs the settings field of the active section
|
||||
do_settings_sections($l_arr_ActiveSection["id"]);
|
||||
|
@ -270,19 +272,12 @@ abstract class MCI_Footnotes_LayoutEngine {
|
|||
* @return bool
|
||||
*/
|
||||
private function saveSettings() {
|
||||
// get only Footnotes settings
|
||||
$l_arr_Settings = array();
|
||||
foreach($_POST as $l_str_SettingsName => $l_str_Value) {
|
||||
if (substr($l_str_SettingsName, 0, 8) == "footnote") {
|
||||
$l_arr_Settings[$l_str_SettingsName] = $l_str_Value;
|
||||
}
|
||||
}
|
||||
// get current section
|
||||
reset($this->a_arr_Sections);
|
||||
$l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections);
|
||||
$l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID];
|
||||
// update settings
|
||||
return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $l_arr_Settings);
|
||||
return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $_POST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -90,6 +90,10 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
|||
}
|
||||
$l_str_PhpExtensions .= $l_str_Extension . ' ' . phpversion($l_str_Extension);
|
||||
}
|
||||
|
||||
/** @var WP_Theme $l_obj_CurrentTheme */
|
||||
$l_obj_CurrentTheme = wp_get_theme();
|
||||
|
||||
$l_str_WordPressPlugins = "";
|
||||
// iterate through each installed WordPress Plugin
|
||||
foreach (get_plugins() as $l_arr_Plugin) {
|
||||
|
@ -121,6 +125,9 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
|||
"label-wordpress" => __("WordPress version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"wordpress" => $wp_version,
|
||||
|
||||
"label-theme" => __("Active Theme", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"theme" => $l_obj_CurrentTheme->get("Name") . " " . $l_obj_CurrentTheme->get("Version") . ", " . $l_obj_CurrentTheme->get("Author"). " [" . $l_obj_CurrentTheme->get("AuthorURI") . "]",
|
||||
|
||||
"plugins" => $l_str_WordPressPlugins
|
||||
)
|
||||
);
|
||||
|
|
|
@ -78,6 +78,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
|
|||
$this->addMetaBox("settings", "other", __("Other", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Other"),
|
||||
|
||||
$this->addMetaBox("customize", "superscript", __("Superscript layout", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Superscript"),
|
||||
$this->addMetaBox("customize", "mouse-over-box", __("Mouse-over box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBox"),
|
||||
$this->addMetaBox("customize", "hyperlink-arrow", __("Hyperlink symbol in the Reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "HyperlinkArrow"),
|
||||
$this->addMetaBox("customize", "custom-css", __("Add custom CSS to the public page", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSS"),
|
||||
|
||||
|
@ -270,6 +271,31 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
|
|||
echo $l_obj_Template->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays all settings for the footnotes mouse-over box.
|
||||
*
|
||||
* @author Stefan Herndler
|
||||
* @since 1.5.2
|
||||
*/
|
||||
public function MouseOverBox() {
|
||||
// options for the Footnotes to be replaced in excerpt
|
||||
$l_arr_Enabled = array(
|
||||
"yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
|
||||
);
|
||||
// load template file
|
||||
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-mouse-over-box");
|
||||
// replace all placeholders
|
||||
$l_obj_Template->replace(
|
||||
array(
|
||||
"label-enable" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __("Enable the mouse-over box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
|
||||
"enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $l_arr_Enabled),
|
||||
)
|
||||
);
|
||||
// display template with replaced placeholders
|
||||
echo $l_obj_Template->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays all settings for the hyperlink arrow.
|
||||
*
|
||||
|
|
|
@ -105,12 +105,7 @@ class MCI_Footnotes {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function registerPublicStyling() {
|
||||
wp_register_style('mci_footnotes_css_general', plugins_url('../css/footnotes.css', __FILE__));
|
||||
wp_register_style('mci_footnotes_css_tooltip', plugins_url('../css/tooltip.css', __FILE__));
|
||||
wp_register_style('mci_footnotes_css_reference_container', plugins_url('../css/reference_container.css', __FILE__));
|
||||
|
||||
wp_enqueue_style('mci_footnotes_css_general');
|
||||
wp_enqueue_style('mci_footnotes_css_tooltip');
|
||||
wp_enqueue_style('mci_footnotes_css_reference_container');
|
||||
wp_register_style('mci_footnotes_css_public', plugins_url('../css/public.css', __FILE__));
|
||||
wp_enqueue_style('mci_footnotes_css_public');
|
||||
}
|
||||
}
|
|
@ -135,6 +135,15 @@ class MCI_Footnotes_Settings {
|
|||
*/
|
||||
const C_STR_FOOTNOTES_STYLING_AFTER = "footnote_inputfield_custom_styling_after";
|
||||
|
||||
/**
|
||||
* Settings Container Key for the mouse-over box to be enabled.
|
||||
*
|
||||
* @author Stefan Herndler
|
||||
* @since 1.5.2
|
||||
* @var string
|
||||
*/
|
||||
const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED = "footnote_inputfield_custom_mouse_over_box_enabled";
|
||||
|
||||
/**
|
||||
* Settings Container Key for the Hyperlink arrow.
|
||||
*
|
||||
|
@ -204,6 +213,7 @@ class MCI_Footnotes_Settings {
|
|||
"footnotes_storage_custom" => array(
|
||||
self::C_STR_FOOTNOTES_STYLING_BEFORE => '',
|
||||
self::C_STR_FOOTNOTES_STYLING_AFTER => ')',
|
||||
self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED => 'yes',
|
||||
self::C_STR_HYPERLINK_ARROW => '↑',
|
||||
self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '',
|
||||
self::C_STR_CUSTOM_CSS => ''
|
||||
|
@ -301,7 +311,7 @@ class MCI_Footnotes_Settings {
|
|||
// iterate through each setting in the container
|
||||
foreach($l_arr_Options as $l_str_Key => $l_str_Value) {
|
||||
// remove all whitespace at the beginning and end of a setting
|
||||
$l_str_Value = trim($l_str_Value);
|
||||
//$l_str_Value = trim($l_str_Value);
|
||||
// write the sanitized value back to the setting container
|
||||
$l_arr_Options[$l_str_Key] = $l_str_Value;
|
||||
}
|
||||
|
|
|
@ -42,25 +42,23 @@ class MCI_Footnotes_Task {
|
|||
*/
|
||||
public function registerHooks() {
|
||||
// append custom css to the header
|
||||
add_action('wp_head', array($this, "Header"));
|
||||
add_filter('wp_head', array($this, "Header"));
|
||||
|
||||
// append the reference container to the footer if enabled
|
||||
if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "footer") {
|
||||
add_action('get_footer', array($this, "Footer"));
|
||||
}
|
||||
// append the reference container to the footer
|
||||
add_filter('get_footer', array($this, "Footer"));
|
||||
|
||||
// append the love and share me slug to the footer
|
||||
add_action('wp_footer', array($this, "Love"));
|
||||
add_filter('wp_footer', array($this, "Love"));
|
||||
|
||||
// replace footnotes in the content of the page/post
|
||||
add_filter('the_content', array($this, "Content"), 10);
|
||||
add_filter('the_content', array($this, "Content"), PHP_INT_MAX);
|
||||
|
||||
// search for footnotes in the excerpt
|
||||
add_filter('the_excerpt', array($this, "Excerpt"), 1);
|
||||
add_filter('get_the_excerpt', array($this, "Excerpt"), 1);
|
||||
add_filter('the_excerpt', array($this, "Excerpt"), PHP_INT_MAX);
|
||||
add_filter('get_the_excerpt', array($this, "Excerpt"), PHP_INT_MAX);
|
||||
|
||||
// replace footnotes in the content of a widget
|
||||
add_filter('widget_text', array($this, "WidgetText"), 99);
|
||||
add_filter('widget_text', array($this, "WidgetText"), PHP_INT_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,6 +73,7 @@ class MCI_Footnotes_Task {
|
|||
<?php
|
||||
// reset stored footnotes when displaying the header
|
||||
self::$a_arr_Footnotes = array();
|
||||
//ob_start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +83,9 @@ class MCI_Footnotes_Task {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function Footer() {
|
||||
echo $this->ReferenceContainer();
|
||||
if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "footer") {
|
||||
echo $this->ReferenceContainer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,6 +95,10 @@ class MCI_Footnotes_Task {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function Love() {
|
||||
/*$l_str_Content = ob_get_contents();
|
||||
$l_str_Content = $this->exec($l_str_Content, false);
|
||||
ob_end_clean();
|
||||
echo $l_str_Content;*/
|
||||
// get setting for love and share this plugin
|
||||
$l_str_LoveMeIndex = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE);
|
||||
// check if the admin allows to add a link to the footer
|
||||
|
@ -159,7 +164,6 @@ class MCI_Footnotes_Task {
|
|||
return $this->exec($p_str_Content, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "post_end" ? true : false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replaces all footnotes that occur in the given content.
|
||||
*
|
||||
|
@ -170,7 +174,7 @@ class MCI_Footnotes_Task {
|
|||
* @param bool $p_bool_HideFootnotesText Hide footnotes found in the string.
|
||||
* @return string
|
||||
*/
|
||||
public function exec($p_str_Content, $p_bool_OutputReferences = true, $p_bool_HideFootnotesText = false) {
|
||||
public function exec($p_str_Content, $p_bool_OutputReferences = false, $p_bool_HideFootnotesText = false) {
|
||||
// replace all footnotes in the content, settings are converted to html characters
|
||||
$p_str_Content = $this->search($p_str_Content, true, $p_bool_HideFootnotesText);
|
||||
// replace all footnotes in the content, settings are NOT converted to html characters
|
||||
|
@ -225,8 +229,10 @@ class MCI_Footnotes_Task {
|
|||
if (!$p_bool_HideFootnotesText) {
|
||||
// load template file
|
||||
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote");
|
||||
$l_obj_TemplateTooltip = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "tooltip");
|
||||
} else {
|
||||
$l_obj_Template = null;
|
||||
$l_obj_TemplateTooltip = null;
|
||||
}
|
||||
|
||||
// search footnotes short codes in the content
|
||||
|
@ -251,11 +257,12 @@ class MCI_Footnotes_Task {
|
|||
$l_str_FootnoteReplaceText = "";
|
||||
// display the footnote as mouse-over box
|
||||
if (!$p_bool_HideFootnotesText) {
|
||||
$l_str_Index = MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
|
||||
// fill the footnotes template
|
||||
$l_obj_Template->replace(
|
||||
array(
|
||||
"index" => MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)),
|
||||
"text" => $l_str_FootnoteText,
|
||||
"index" => $l_str_Index,
|
||||
"text" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)) ? $l_str_FootnoteText : "",
|
||||
"before" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE),
|
||||
"after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER)
|
||||
)
|
||||
|
@ -263,6 +270,11 @@ class MCI_Footnotes_Task {
|
|||
$l_str_FootnoteReplaceText = $l_obj_Template->getContent();
|
||||
// reset the template
|
||||
$l_obj_Template->reload();
|
||||
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED))) {
|
||||
$l_obj_TemplateTooltip->replace(array("index" => $l_str_Index));
|
||||
$l_str_FootnoteReplaceText .= $l_obj_TemplateTooltip->getContent();
|
||||
$l_obj_TemplateTooltip->reload();
|
||||
}
|
||||
}
|
||||
// replace the footnote with the template
|
||||
$p_str_Content = substr_replace($p_str_Content, $l_str_FootnoteReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
|
||||
|
|
|
@ -60,14 +60,15 @@ class MCI_Footnotes_Template {
|
|||
* @since 1.5.0
|
||||
* @param string $p_str_FileType Template file type (take a look on the Class constants).
|
||||
* @param string $p_str_FileName Template file name inside the Template directory without the file extension.
|
||||
* @param string $p_str_Extension Optional Template file extension (default: html)
|
||||
*/
|
||||
public function __construct($p_str_FileType, $p_str_FileName) {
|
||||
public function __construct($p_str_FileType, $p_str_FileName, $p_str_Extension = "html") {
|
||||
// no template file type and/or file name set
|
||||
if (empty($p_str_FileType) || empty($p_str_FileName)) {
|
||||
return;
|
||||
}
|
||||
// get absolute path to the specified template file
|
||||
$l_str_TemplateFile = dirname(__FILE__) . "/../templates/" . $p_str_FileType . "/" . $p_str_FileName . ".html";
|
||||
$l_str_TemplateFile = dirname(__FILE__) . "/../templates/" . $p_str_FileType . "/" . $p_str_FileName . "." . $p_str_Extension;
|
||||
// Template file does not exist
|
||||
if (!file_exists($l_str_TemplateFile)) {
|
||||
return;
|
||||
|
|
|
@ -77,7 +77,7 @@ class MCI_Footnotes_WYSIWYG {
|
|||
$l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED);
|
||||
$l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED);
|
||||
}
|
||||
echo json_encode(array("start" => $l_str_StartingTag, "end" => $l_str_EndingTag));
|
||||
echo json_encode(array("start" => htmlspecialchars($l_str_StartingTag), "end" => htmlspecialchars($l_str_EndingTag)));
|
||||
exit;
|
||||
}
|
||||
}
|
Reference in a new issue