Support » Plugin: footnotes » Problem with Footnotes in excerpts of the Blog page

  • ResolvedPlugin Contributor martinneumannat

    (@martinneumannat)


    I have problems with footnotes in the beginning paragraph of an excerpt. Here how it looks like on the English site, which is correct rendering:
    Almost half of the Americans report that the pandemic is affecting their mental health.1)Coronavirus is harming the mental health of tens of millions of people in U.S., new poll finds. Washington Post, April 2, 2020 A federal disaster distress hotline ha seen a more than 10x spike in incoming text messages during the pandemic.2)The Health […]

    Now the same article on the Portuguese site renders like that:
    Quase metade dos americanos estão relatando que a pandemia está afetando sua saúde mental.((Coronavirus is harming the mental health of tens of millions of people in U.S., new poll finds. Washington Post, April 2, 2020)) Uma linha direta de apoio em caso de desastre no Estados Unidos vi um aumento de mais de 10 vezes nas mensagens de texto …

    Those are two sites within a Multisite network, on the same plugin version, but with different results. Is there anything I can do so that in the Portuguese site it replaces the footnotes in the brackets with the footnote symbol as well?

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat,

    Thank you for reporting this bug. Sorry please for the late reply. The settings for excerpts in the Footnotes plugin are ineffective, and any fix seemed pointless because basically we recommend the Advanced Excerpt plugin, that enables WordPress-using websites to display better formed excerpts of the posts. The process of converting a post into an excerpt depends on themes and has a stunning variety of outcomes. The most widespread behavior is to strip off any HTML tags, even markup for bold and italic. Inline scripts require special handling; mostly the script is cut off with the script tags, but under some circumstances it’s left alone.

    As a result, websites end up with idle footnote referrers plus the footnote text verbatim as part of the excerpt, contradicting the excerpt’s goal of providing a succinct idea. However I couldn’t find the reason why footnotes in excerpts can remain unprocessed, despite I used the same theme (lite version). But given either way of showing footnotes in excerpts is inconvenient, the Footnotes plugin recommends the Advanced Excerpt plugin. When this plugin is activated, the footnote referrers are correctly formatted and, if tooltips are enabled, have their tooltip as designed. If nothing goes wrong.

    Because when looking harder in response to your report, sadly I noticed that the tooltip script counts for 26 words, and when the referrer is at the excerpt end, the script is almost always cropped and disabled, so there is a risk of ending up with an idle referrer again. That brings the need of either implementing in Footnotes a fully-fledged excerpt handler, or managing to get footnotes actually deleted in the post string before it gets processed by the theme or plugin generating the excerpt.

    Yet another, brandnew bug is affecting the Footnotes tooltips due to the background color default changing from white to empty in response to the topic about illegible tooltips when the tooltip font color falling back to theme default is white, while the background color is set to white. Turns out that this inconsistency seemed to pay tribute to the lack of theme default background colors and to the inability to effectively set a background color for the body tag (although that works for the font color) and to get inheritance to work properly; don’t understand why tooltips in white divs on a black body cannot inherit the white background.

    I apologize for not duly testing what I considered an obvious fix to be delivered while scrambling to get Footnotes to work in forms. Then an awkward numbering bug affecting delimiter shortcodes with pointy brackets required redesigning the search algorithm, and v2.6.0 needed to be released in a rush based on v2.5.15, itself latest of an unreleased 2.5.x series starting with 2.5.11—based on 2.6.0d7 containing important accessibility fixes, an almost full AMP compatibility mode, and a refactored PHP codebase with respect to WordPress PHP Coding Standards—to address presumed underlying cybersecurity concerns. I forgot about the problem with the tooltip background, wondered why it is transparent on your Portuguese website and first tried an opacity fix before realizing that the new default of empty, meant to adapt to theme default background color, is the problem.

    Now one way I see to get the Footnotes plugin’s users out of trouble is to set both tooltip background color to white and font color to black by default, and to deliver the fix in a v2.7.0 adding support for handling excerpts, in a way I don’t know yet, because since the latest release accident on March 1st we must refrain from releasing any bugfix versions that would again blow up release frequency as it happened during the five months I’m trying to help fix bugs.

    Or would you be okay that we try to fix the Advanced Excerpt plugin for use with Footnotes, send them a pull request, and would you be fine with using Advanced Excerpt in the wake? Or would you like to add support for footnotes in Advanced Excerpt yourself?

    There are a number of options; hopefully one of them will fix the problem ASAP.

    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat,

    If you would download and install the just (19 minutes ago) committed v2.6.1 from https://downloads.wordpress.org/plugin/footnotes.2.6.1.zip then the tooltip background bug would be fixed without further action.

    Alternatively please open the dashboard under the Referrers and tooltips tab, and in the Tooltip appearance metabox please set the Background color to white or the color of your choice.

    To address cybersecurity concerns with unreleased although tagged bugfix versions, we share the publicly accessible SVN changeset related to this version, where all previous changesets can also be browsed:

    https://plugins.trac.wordpress.org/changeset/2504324/footnotes

    • This reply was modified 1 year, 4 months ago by pewgeuges.
    Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat,

    The excerpt bug’s origin has been found, and I’m currently working on a fix. Until now, the plugin processed already processed excerpts. Now the setting “Display footnotes in excerpts” in the “Footnotes in excerpts” metabox is becoming effective in that, if set to No, a new excerpt is being generated from scratch with all footnotes removed:

    
    /**
     * Replaces existing excerpt with new from scratch if enabled, else does nothing.
     *
     * @since 1.5.0
     * @param string  $p_str_excerpt  Excerpt content.
     * @return string $p_str_excerpt  Excerpt as-is.
     * The input is already the processed excerpt, no more foonotes to search.
     */
    public function footnotes_in_excerpt( $p_str_excerpt ) {
    	if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_IN_EXCERPT ) ) ) {
    		return $this->exec( $p_str_excerpt, false, true );
    	} else {
    		return $this->generate_excerpt( $p_str_excerpt );
    	}
    }
    
    public function generate_excerpt( $p_str_content ) {
    	$l_str_content  = get_the_content( get_the_id() );
    	$p_str_content  = preg_replace( '#\(\(.+?\)\)#', '', $l_str_content );
    	$p_str_content  = substr( $p_str_content, 0, 500 );
    	$p_str_content .= ' …';
    	return $p_str_content;
    }
    

    The existing excerpt is discarded, the full content is loaded, then all footnotes are removed to begin with, and only then the excerpt is generated. Because I don’t (yet) see a way to hook into the excerpt generation process as conducted by themes or plugins, and to remove footnotes upfront. That of course would probably be the best solution.

    The above is only a dummy excerpt generator for a quick POC. It works. Now the preg_replace() and substr() and horizontal ellipsis need to become state-of-the-art. To learn about general expectations, Advanced Excerpt is looked up but of course Footnotes isn’t able to do as much.

    Now I’d like to ask for your advice and expectations. Based on your report, we can assume that footnotes should be part of the excerpt, yet I wonder whether text without footnotes wouldn’t make for more expressive excerpts than when part of the allowance is used up to provide bibliographic references right in the excerpt, as opposed to providing them once the article is opened.

    • This reply was modified 1 year, 4 months ago by pewgeuges. Reason: …the excerpt is generated. Because I don’t (yet) see a way to hook into the excerpt generation process as conducted by themes or plugins, and to remove footnotes upfront. That of course would probably be the best solution
    Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat

    Sorry for not mentioning before, as I didn’t get it to work in my local sandbox, that an instant easy fix to make excerpts on your Portuguese site look like on your English site is perhaps to set priority for the_content to -1 (PHP_INT_MAX), under Scope and priority.

    In upcoming (tagged although unreleased) v2.6.2 the plugin shall offer excerpts without footnotes and excerpts with footnotes as referrers + tooltips.

    The AMP compatibility mode released with 2.6.0 has a bug in the Continue reading link in truncated tooltips I noticed 5 hours ago, so this fix must also be part of 2.6.2.

    Apologies for being late on all fronts. Probably we shouldn’t have spent time on WPCS compliance in an untimely fashion (and with a weird accidental release 4 weeks ago to make everything worse).

    Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat,

    Footnotes new unreleased bugfix v2.6.2 has just become available at https://downloads.wordpress.org/plugin/footnotes.2.6.2.zip and fixes the excerpts the WordPress way while removing the footnotes so they don’t display neither as text nor as referrers in the excerpts.

    The changeset of this version can be viewed at https://plugins.trac.wordpress.org/changeset/2504730/footnotes

    When looking at https://developer.wordpress.org/reference/functions/wp_trim_excerpt/ there seems to be no way to add a suitable filter but I may be wrong; the problem is now solved the other way around by copying the WordPress excerpt processing into Footnotes, and adding Footnotes-specific processing upfront to remove footnotes from the excerpt basis:

    
    /**
     * Replaces existing excerpt with new from scratch if enabled, else does nothing.
     *
     * @since 1.5.0
     * @param string  $p_str_excerpt  Excerpt content.
     * @return string $p_str_excerpt  Excerpt as-is.
     * The input is already the processed excerpt, no more foonotes to search.
     */
    public function footnotes_in_excerpt( $p_str_excerpt ) {
    	if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_IN_EXCERPT ) ) ) {
    		return $this->exec( $p_str_excerpt, false, true );
    	} else {
    		return $this->generate_excerpt( $p_str_excerpt );
    	}
    }
    
    /**
     * Generates excerpt from scratch.
     *
     * @since 2.6.2
     * @param string  $p_str_content          The post.
     * @param bool    $p_bool_keep_footnotes  Whether to keep or remove footnotes.
     * @return string $p_str_excerpt          An excerpt of the post.
     * Applies WordPress excerpt processing.
     * @link https://developer.wordpress.org/reference/functions/wp_trim_excerpt/
     */
    public function generate_excerpt( $p_str_content ) {
    
    	// Discard existing excerpt and start from scratch.
    	$l_str_content  = get_the_content( get_the_id() );
    
    	// Get delimiter shortcodes and harmonize them.
    	$p_str_content = self::harmonize_delimiters( $p_str_content );
    
    	// Remove footnotes.
    	$p_str_content = preg_replace( '#' . self::$a_str_start_tag_regex . '.+?' . self::$a_str_end_tag_regex . '#', '', $l_str_content );
    
    	// Apply WordPress excerpt processing.
    	$p_str_content = strip_shortcodes( $p_str_content );
    	$p_str_content = excerpt_remove_blocks( $p_str_content );
    	$p_str_content = apply_filters( 'the_content', $p_str_content );
    	$p_str_content = str_replace( ']]>', ']]>', $p_str_content );
    	$l_int_excerpt_length = (int) _x( '55', 'excerpt_length' );
    	$l_int_excerpt_length = (int) apply_filters( 'excerpt_length', $l_int_excerpt_length );
    	$l_str_excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' );
    	$p_str_content = wp_trim_words( $p_str_content, $l_int_excerpt_length, $l_str_excerpt_more );
    	
    	return $p_str_content;
    }
    

    The $p_bool_keep_footnotes is a remainder I forgot to delete when giving up trying to add support for footnotes in excerpts as an option.

    The tooltip background (since 2.6.1) and the AMP continue reading bugs are also fixed.

    Should removing footnotes from excerpts not be appropriate, or for any other feedback be sure to keep in touch, using this topic or opening a new one, we’ll be happy to assist. For the time being I’ll mark this as resolved for easy reference.

    Thank you for reporting and helping improve the plugin!

    Best regards.

    Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat,

    I don’t know why footnotes remain unprocessed in excerpts on your Portuguese website. When generating excerpts, WordPress applies all content filters, and Footnotes’ is part of them.

    But now I’m working on debugging the Yes option too. Footnotes are taken off the generation process so as to not alter the length, and when readded they’re processed at the end only so their integrity is maintained.

    All these and other fixes shall be RELEASED, and the version number will probably NOT be 2.7.0 as announced given it’s only about debugging an already present claim of Footnotes’ ability to control whether footnotes are present in excerpts or not, with a setting at the bottom of the first dashboard tab. That claim was ineffective because the plugin only attempted to process already finished excerpts where wrecked footnotes may be found consisting in idle baseline referrers plus the tooltip text inline as part of the excerpt and wasting their length part of the excerpt length. As a consequence, debugging the Footnotes plugin for excerpts is about making an end of fake footnotes in fake excerpts.

    We’re very sad that all this debugging happens only so late, after years of impacting blog, archive and category views, and five months that i’m on it without tackling this issue. Also I’ve marked this topic as unresolved again until the fixes are ready and released.

    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    • This reply was modified 1 year, 4 months ago by pewgeuges.
    Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat,

    I’ve now tested Footnotes in a multisite network set up for the purpose and found the plugin working correctly, also saving the settings on a per-site basis which means the plugin is multisite enabled.

    Today Footnotes v2.6.3 has been released. It generates excerpts with footnotes displayed or with footnotes removed, and its handling excerpts can be disabled by unchecking the hook the_excerpt. The previously ineffective setting in the “Footnotes in excerpts” metabox near the bottom of the first dashboard tab is now fully functional.

    No: The excerpt is generated the WordPress way on the basis of the post but, before it comes to processing the footnotes as part of the hook the_content, that Footnotes adds a filter to, the footnotes are removed from the string. The resulting excerpt has full length i.e. without footnotes using up part of the allowance (55 words, with all existing filters added, just as they are in the WordPress function).

    Yes: Only part of the WordPress excerpt process is applied. The footnotes are saved before being replaced with a randomized placeholder string. Then a simplified process close to what Advanced Excerpt does is run, including the way of counting words and skipping tags, but without the many options. Most importantly, the line-breaking tags for paragraphs, line breaks and list items are replaced with a separator (just a space for now). The footnotes are readded and processed at the end but not by calling the_content hook, because that would append the reference container for the footnotes present in the excerpt.

    Now the hope is that this new version will fix all your websites, the Portuguese one in the first place.

    Please let us know about the outcome, and about all issues you may continue to encounter.

    Plugin Contributor pewgeuges

    (@pewgeuges)

    @martinneumannat,

    We’d love to hear your feedback as in current v2.6.4, Footnotes comes with a fully fledged excerpt generator capable of either displaying footnotes with referrers and tooltips in full standard-length excerpts, not shortened for the sake of footnotes; or removing footnotes from excerpts and delivering what we know as WordPress excerpts.

    While some information and code are based on Advanced Excerpt, Footnotes is far away from what Advanced Excerpt offers as options, and it’s redesigned the algorithm to get the ability to actually handle footnotes in excerpts.

    We’ll much appreciate your help to fix remaining bugs as @mmallett reported in https://wordpress.org/support/topic/broken-662/

    Thanks in advance!

    • This reply was modified 1 year, 4 months ago by pewgeuges.
    Plugin Contributor martinneumannat

    (@martinneumannat)

    Thanks for all the efforts. I am sorry I was busy with some other issues I had to resolve. I found out when I needed to switch on filtering for the_excerpt hook and got the result I wanted in the archive pages. Just switching on the hook was messing up the excerpts of the latest post Gutenberg block, that I am using on the front page.

    I found out that the result depended also on the theme settings for the archive pages. I need to have it set to entry excerpts. If I had it on entry content, it would not process the footnotes on any way, no matter what settings I used in the footnotes plugin. I am using a Genesis theme, not sure how that would be with a different theme.

    So there is some progress. But until the Gutenberg block is fixed, I will not be able to make use of it.

    Plugin Author Mark Cheret

    (@markcheret)

    Hi @martinneumannat,

    can you please let me know how things are going with using footnotes right now?
    There have been a few releases in the meantime and I’m honestly not sure if a fix for the Gutenberg block was worked on and rolled up into the latest release.
    I’d appreciate your insight.

    best
    Mark

    Plugin Contributor martinneumannat

    (@martinneumannat)

    Yes with the current version it is working for me. Just to give you a note, option 3 in the selection of Process footnotes in excerpts does not seem to work right. But option 1 and 2 are giving me the output I want. So thanks for the update.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Problem with Footnotes in excerpts of the Blog page’ is closed to new replies.