- Bugfix: Remove footnotes from the excerpt if set to "don't display footnotes on summarized posts"
git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@997877 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
parent
eac463c643
commit
cac292a85a
1 changed files with 36 additions and 25 deletions
|
@ -53,15 +53,14 @@ class MCI_Footnotes_Task {
|
||||||
add_action('wp_footer', array($this, "Love"));
|
add_action('wp_footer', array($this, "Love"));
|
||||||
|
|
||||||
// replace footnotes in the content of the page/post
|
// replace footnotes in the content of the page/post
|
||||||
add_filter('the_content', array($this, "Content"));
|
add_filter('the_content', array($this, "Content"), 10);
|
||||||
|
|
||||||
// search for footnotes in the excerpt only if enabled
|
// search for footnotes in the excerpt
|
||||||
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT))) {
|
add_filter('the_excerpt', array($this, "Excerpt"), 1);
|
||||||
add_filter('the_excerpt', array($this, "Excerpt"));
|
add_filter('get_the_excerpt', array($this, "Excerpt"), 1);
|
||||||
}
|
|
||||||
|
|
||||||
// replace footnotes in the content of a widget
|
// replace footnotes in the content of a widget
|
||||||
add_filter('widget_text', array($this, "WidgetText"));
|
add_filter('widget_text', array($this, "WidgetText"), 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +143,7 @@ class MCI_Footnotes_Task {
|
||||||
* @return string Content with replaced footnotes.
|
* @return string Content with replaced footnotes.
|
||||||
*/
|
*/
|
||||||
public function Excerpt($p_str_Content) {
|
public function Excerpt($p_str_Content) {
|
||||||
return $this->exec($p_str_Content, false);
|
return $this->exec($p_str_Content, false, !MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,13 +167,14 @@ class MCI_Footnotes_Task {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @param string $p_str_Content Any string that may contain footnotes to be replaced.
|
* @param string $p_str_Content Any string that may contain footnotes to be replaced.
|
||||||
* @param bool $p_bool_OutputReferences Appends the Reference Container to the output if set to true, default true.
|
* @param bool $p_bool_OutputReferences Appends the Reference Container to the output if set to true, default true.
|
||||||
|
* @param bool $p_bool_HideFootnotesText Hide footnotes found in the string.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function exec($p_str_Content, $p_bool_OutputReferences = true) {
|
public function exec($p_str_Content, $p_bool_OutputReferences = true, $p_bool_HideFootnotesText = false) {
|
||||||
// replace all footnotes in the content, settings are converted to html characters
|
// replace all footnotes in the content, settings are converted to html characters
|
||||||
$p_str_Content = $this->search($p_str_Content, true);
|
$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
|
// replace all footnotes in the content, settings are NOT converted to html characters
|
||||||
$p_str_Content = $this->search($p_str_Content, false);
|
$p_str_Content = $this->search($p_str_Content, false, $p_bool_HideFootnotesText);
|
||||||
|
|
||||||
// append the reference container
|
// append the reference container
|
||||||
if ($p_bool_OutputReferences) {
|
if ($p_bool_OutputReferences) {
|
||||||
|
@ -197,9 +197,10 @@ class MCI_Footnotes_Task {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @param string $p_str_Content Content to be searched for footnotes.
|
* @param string $p_str_Content Content to be searched for footnotes.
|
||||||
* @param bool $p_bool_ConvertHtmlChars html encode settings, default true.
|
* @param bool $p_bool_ConvertHtmlChars html encode settings, default true.
|
||||||
|
* @param bool $p_bool_HideFootnotesText Hide footnotes found in the string.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function search($p_str_Content, $p_bool_ConvertHtmlChars = true) {
|
public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) {
|
||||||
// contains the index for the next footnote on this page
|
// contains the index for the next footnote on this page
|
||||||
$l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
|
$l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
|
||||||
// contains the starting position for the lookup of a footnote
|
// contains the starting position for the lookup of a footnote
|
||||||
|
@ -221,8 +222,12 @@ class MCI_Footnotes_Task {
|
||||||
return $p_str_Content;
|
return $p_str_Content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$p_bool_HideFootnotesText) {
|
||||||
// load template file
|
// load template file
|
||||||
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote");
|
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote");
|
||||||
|
} else {
|
||||||
|
$l_obj_Template = null;
|
||||||
|
}
|
||||||
|
|
||||||
// search footnotes short codes in the content
|
// search footnotes short codes in the content
|
||||||
do {
|
do {
|
||||||
|
@ -242,6 +247,10 @@ class MCI_Footnotes_Task {
|
||||||
$l_int_Length = $l_int_PosEnd - $l_int_PosStart;
|
$l_int_Length = $l_int_PosEnd - $l_int_PosStart;
|
||||||
// get footnote text
|
// get footnote text
|
||||||
$l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
|
$l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
|
||||||
|
// Text to be displayed instead of the footnote
|
||||||
|
$l_str_FootnoteReplaceText = "";
|
||||||
|
// display the footnote as mouse-over box
|
||||||
|
if (!$p_bool_HideFootnotesText) {
|
||||||
// fill the footnotes template
|
// fill the footnotes template
|
||||||
$l_obj_Template->replace(
|
$l_obj_Template->replace(
|
||||||
array(
|
array(
|
||||||
|
@ -251,10 +260,12 @@ class MCI_Footnotes_Task {
|
||||||
"after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER)
|
"after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// replace the footnote with the template
|
$l_str_FootnoteReplaceText = $l_obj_Template->getContent();
|
||||||
$p_str_Content = substr_replace($p_str_Content, $l_obj_Template->getContent(), $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
|
|
||||||
// reset the template
|
// reset the template
|
||||||
$l_obj_Template->reload();
|
$l_obj_Template->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));
|
||||||
// add footnote only if not empty
|
// add footnote only if not empty
|
||||||
if (!empty($l_str_FootnoteText)) {
|
if (!empty($l_str_FootnoteText)) {
|
||||||
// set footnote to the output box at the end
|
// set footnote to the output box at the end
|
||||||
|
|
Reference in a new issue