Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'the_title', 'change_my_title' );
- function change_my_title( $title ) {
- return str_replace( '–', $title );
- // nor preg_replace or – or — work
- }
- add_action('admin_head',function(){
- global $pagenow;
- // check current page.
- if( $pagenow == 'edit.php' ){ ?>
- <script>
- jQuery(function($){
- var post_title = $('.wp-list-table').find('a.row-title');
- $.each(post_title,function(index,em){
- var text = $(em).html();
- // Replace all dashes to *
- $(em).html(text.replace(/—/g ,'*'));
- });
- });
- </script>
- <?php
- }
- });
- add_filter( 'manage_pages_columns', 'wpse248405_columns', 25, 1 );
- function wpse248405_columns ($cols) {
- // remove title column
- unset( $cols['title'] );
- // add custom column in second place
- $cols = array('cb' => $cols['cb']) + array('title' => __( 'Title', 'textdomain' )) + $cols;
- // return columns
- return $cols;
- }
- add_action( 'manage_pages_custom_column', 'wpse248405_custom_column', 10, 2 );
- function wpse248405_custom_column( $col, $post_id ) {
- if ($col == 'title') {
- $post = get_post( $post_id );
- $title = _draft_or_post_title();
- $can_edit_post = current_user_can( 'edit_post', $post->ID );
- // set up row actions
- $actions = array();
- if ( $can_edit_post && 'trash' != $post->post_status ) {
- $actions['title'] = '<strong><a href="' . get_edit_post_link( $post->ID, true ) . '" aria-label="' . $title . esc_attr( __( 'Edit this item' ) ) . '">' . $title . '</a></strong>';
- // invoke row actions
- $table = new WP_Posts_List_Table;
- echo $table->row_actions( $actions, true );
- }
- }
- }
- $pad = str_repeat( '— ', $this->current_level );
- echo "<strong>";
- $format = get_post_format( $post->ID );
- if ( $format ) {
- $label = get_post_format_string( $format );
- $format_class = 'post-state-format post-format-icon post-format-' . $format;
- $format_args = array(
- 'post_format' => $format,
- 'post_type' => $post->post_type
- );
- echo $this->get_edit_link( $format_args, $label . ':', $format_class );
- }
- $can_edit_post = current_user_can( 'edit_post', $post->ID );
- $title = _draft_or_post_title();
- if ( $can_edit_post && $post->post_status != 'trash' ) {
- printf(
- '<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
- get_edit_post_link( $post->ID ),
- /* translators: %s: post title */
- esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ),
- $pad,
- $title
- );
- } else {
- echo $pad . $title;
- }
Add Comment
Please, Sign In to add comment