Skip to content

Plugin sometimes ignores 'if' statement of function at first attempt. #1350

Open
@ethicalrevolution

Description

Quick summary

I have a function to add a hidden link to the start of the content of posts that are in specific categories on my Wordpress site.

The idea is that this link is visible on Fedi/Mastodon and gives followers a chance to click directly to the post to read it on the website rather than read a long post on Mastodon.

The issue I'm having is that the ActivityPub plugin sometimes ignores that this function is for specific categories only and includes the hidden link on posts from categories that are not included in the function. When this happens I have to revert the post to draft, wait 15 seconds or so and then republish it for the ActivitiyPub plugin to then update the federated post and correctly display the post on Fedi/Mastodon without the hidden link.

Steps to reproduce

The function:

function hidden_link($content){
  //add text at start of WordPress posts
  if( in_category( array( 1, 488, 498, 499 ) ) ) {
    $before = '<p class="hidden">' . __( '<a href="' . get_permalink() . '">[Read in full on NHAM]</a>' ) . '</p>';

    //modify the incoming content 
    $content = $before . $content ; 
  } 
  return $content; 
}
 
add_filter( 'the_content', 'hidden_link' );

Site owner impact

Fewer than 20% of the total website/platform users

Severity

Moderate

What other impact(s) does this issue have?

No response

If a workaround is available, please outline it here.

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions