Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Aggiungo bottone vista elenco WP ( admin )
- *
- * @uses : remove_query_arg, wp_get_referer
- * @see: http://wordpress.stackexchange.com/questions/149143/hide-the-post-count-behind-post-views-remove-all-published-and-trashed-in-cus
- * @see: https://developer.wordpress.org/reference/functions/remove_query_arg/
- * @see: https://developer.wordpress.org/reference/functions/wp_get_referer/
- *
- * Il filtro è "views_edit-{post_type}"
- *
- * carico il mio pulsante nell'array $views
- */
- add_filter('views_edit-annuncio', 'add_custom_clear_button', 10);
- function add_custom_clear_button($views){
- $button = '<a ';
- $button .= 'style="margin-right:5px" ';
- $button .= 'id="clear" ';
- $button .= 'href="'.remove_query_arg( array('fonte', 'localita', 'customer', 'performer', 'performance', 'telefono', 'email'),wp_get_referer()).'" ';
- $button .= 'class="button button-primary" ';
- $button .= '>' . __('Pulisci','safra');
- $button .= '</a>';
- $views['clear'] = $button;
- return $views;
- }
- /**
- * Sposto il bottone dove credo sia più indicato, non ci sono metodi più puliti per farlo
- *
- * @see : https://codex.wordpress.org/Plugin_API/Action_Reference/admin_head-(page_hook)
- *
- * L'azione è "views_edit-{post_type}"
- * Stampo javascript arbitrario per modificare il DOM a piacere
- */
- add_action('admin_head-edit.php', 'move_clear_button', 10);
- function move_clear_button(){
- $current_screen = get_current_screen();
- //Se mi trovo in "annunci"
- if( 'annuncio' == $current_screen->post_type ) : ?>
- <script type="text/javascript">
- jQuery(document).ready(function($){
- $('#clear').appendTo('.tablenav.top div.alignleft.actions:not(.bulkactions)');
- });
- </script>
- <?php endif;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement