Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds filter to get the credits link as string #25

Closed
wants to merge 8 commits into from

Conversation

mlaetitia
Copy link

@mlaetitia mlaetitia commented Jan 31, 2024

Changes proposed in this Pull Request

  • New option return_output that basically allows the final site credits to be returned instead of echoed.
  • If no value is passed the default behavior keeps being the current one: credits are echoed.

This is needed cause when the string is echoed automatically the only way to catch it to pass it through in a filter, for instance, is to use ob_start etc... However, this doesn't work IF the filter is called within an existing ob_start already which is the case I am working on

Testing instructions

  • Checkout this and build the plugin
  • Install it on a site you own
  • Create a new page or post and add a shortcode block with the plugin's shortcode to confirm things still work
    • Bonus if you test the shortcode with the new arg to confirm nothing breaks (the new arg shouldn't be considered in the shortcode)
  • Add the following to the site (or to a snippet using the code snippets plugin):
add_action( 'wp_footer', function(){ do_action('team51_credits', array() ); } );
add_action( 'wp_footer', function(){ echo '<br/>'; } );
add_action( 'wp_footer', function () { echo apply_filters('team51_credits_filter', '', array('pressable' => '') ); },14);

…them directly. This can be used to catch that string and use it in filters, etc.
…t if do_action was called. This commit creates a new filter to get the resulting credits links and the wraps the old function around it to echo as was the previous behavior
@mlaetitia mlaetitia changed the title Adds option to return the result credits instead of outputting them Adds filter to get the credits link as string Jan 31, 2024
@georgestephanis
Copy link
Contributor

Noting that I'm working with @mlaetitia in Slack on the use case, and whether we can get nested output buffering working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants