[wp-trac] [WordPress Trac] #36734: Filter for preview button

WordPress Trac noreply at wordpress.org
Mon May 2 15:41:28 UTC 2016


#36734: Filter for preview button
--------------------------------+-----------------------------
 Reporter:  mitogh              |      Owner:
     Type:  feature request     |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Editor              |    Version:
 Severity:  normal              |   Keywords:
  Focuses:  ui, administration  |
--------------------------------+-----------------------------
 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
 <?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!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36734>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list