Guest User

Untitled

a guest
Nov 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. add_filter( 'the_title', 'change_my_title' );
  2. function change_my_title( $title ) {
  3. return str_replace( '–', $title );
  4. // nor preg_replace or – or — work
  5. }
  6.  
  7. add_action('admin_head',function(){
  8.  
  9.  
  10. global $pagenow;
  11.  
  12. // check current page.
  13. if( $pagenow == 'edit.php' ){ ?>
  14.  
  15. <script>
  16.  
  17. jQuery(function($){
  18.  
  19. var post_title = $('.wp-list-table').find('a.row-title');
  20. $.each(post_title,function(index,em){
  21. var text = $(em).html();
  22. // Replace all dashes to *
  23. $(em).html(text.replace(/—/g ,'*'));
  24. });
  25. });
  26.  
  27. </script>
  28. <?php
  29. }
  30. });
  31.  
  32. add_filter( 'manage_pages_columns', 'wpse248405_columns', 25, 1 );
  33. function wpse248405_columns ($cols) {
  34. // remove title column
  35. unset( $cols['title'] );
  36. // add custom column in second place
  37. $cols = array('cb' => $cols['cb']) + array('title' => __( 'Title', 'textdomain' )) + $cols;
  38. // return columns
  39. return $cols;
  40. }
  41.  
  42. add_action( 'manage_pages_custom_column', 'wpse248405_custom_column', 10, 2 );
  43. function wpse248405_custom_column( $col, $post_id ) {
  44. if ($col == 'title') {
  45. $post = get_post( $post_id );
  46. $title = _draft_or_post_title();
  47. $can_edit_post = current_user_can( 'edit_post', $post->ID );
  48. // set up row actions
  49. $actions = array();
  50. if ( $can_edit_post && 'trash' != $post->post_status ) {
  51. $actions['title'] = '<strong><a href="' . get_edit_post_link( $post->ID, true ) . '" aria-label="' . $title . esc_attr( __( 'Edit this item' ) ) . '">' . $title . '</a></strong>';
  52. // invoke row actions
  53. $table = new WP_Posts_List_Table;
  54. echo $table->row_actions( $actions, true );
  55. }
  56. }
  57. }
  58.  
  59. $pad = str_repeat( '&#8212; ', $this->current_level );
  60. echo "<strong>";
  61.  
  62. $format = get_post_format( $post->ID );
  63. if ( $format ) {
  64. $label = get_post_format_string( $format );
  65.  
  66. $format_class = 'post-state-format post-format-icon post-format-' . $format;
  67.  
  68. $format_args = array(
  69. 'post_format' => $format,
  70. 'post_type' => $post->post_type
  71. );
  72.  
  73. echo $this->get_edit_link( $format_args, $label . ':', $format_class );
  74. }
  75.  
  76. $can_edit_post = current_user_can( 'edit_post', $post->ID );
  77. $title = _draft_or_post_title();
  78.  
  79. if ( $can_edit_post && $post->post_status != 'trash' ) {
  80. printf(
  81. '<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
  82. get_edit_post_link( $post->ID ),
  83. /* translators: %s: post title */
  84. esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $title ) ),
  85. $pad,
  86. $title
  87. );
  88. } else {
  89. echo $pad . $title;
  90. }
Add Comment
Please, Sign In to add comment