WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 6 months ago

#36734 new feature request

Filter for preview button

Reported by: mitogh Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: ui, administration Cc:
PR Number:

Description

Hey guys.

First of all thank you for the great job you do every day with this project. Before I created a PR I would like to ask if we can have a filter for the Preview button. At the moment we can "hide" the button via inline CSS on the admin or JS but I would like to know if there is a chance to include a filter that we can use from our themes or plugins to hide this button where is required.. Since I saw the only way to hide this field is if the publicly_queryable is false.

I think if we have a filter that we can use to easily hide this button under certain circumstances might be useful for some scenarios such as:

  • WP is used only to manage and create and API and the view is consumed via a APP or a FE that is not linked with the WP Themes such as an Angular or React project.

Plus this filter will not have any side effect on the current or normal sites that still uses the normal WP Themes.

Thank you for your work again, and please let me know what are the next steps on this one and I will be happy to send a PR for adding the required filter, just wanted to make sure you are ok with this type of changes.

So far this might be a possible approach:

<?php
$show_preview_button = apply_filters( 'show_preview_button', true, $post );
if ( $show_preview_button && is_post_type_viewable( $post_type_object ) ) :
 // Preview button here
endif; 

Thank you!

Change History (1)

This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.


3 years ago

Note: See TracTickets for help on using tickets.