Make WordPress Core

Opened 8 years ago

Closed 3 years ago

Last modified 2 years ago

#36734 closed feature request (wontfix)

Filter for preview button

Reported by: mitogh's profile mitogh Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: 2nd-opinion
Focuses: ui, administration Cc:

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 (4)

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


8 years ago

#2 @noisysocks
4 years ago

  • Component changed from Editor to Posts, Post Types
  • Keywords 2nd-opinion added

Hi @mitogh. This is possible at the post type level by setting publicly_queryable to false. Does this not suit your use case?

I don't think it makes sense to hide the Preview button but still allow previewing. Setting publicly_queryable to false will properly disable both.

#3 @mitogh
3 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Marking this as wontfix as this was open back in the day when Gutenberg was not present and headless CMS was in the beginning, at this point I don't think there's a real benefit in keep it open.

Thank, @noisysocks

#4 @desrosj
2 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.