Ticket #2284: edit page hooks.diff

File edit page hooks.diff, 7.3 kB (added by majelbstoat, 3 years ago)

Patch to add new hooks to the manage pages table.

  • wp-admin/admin-functions.php

    old new  
    607607        } 
    608608} 
    609609 
    610 function page_rows($parent = 0, $level = 0, $pages = 0) { 
    611         global $wpdb, $class, $post; 
    612         if (!$pages) 
    613                 $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order"); 
    614  
    615         if ($pages) { 
    616                 foreach ($pages as $post) { 
    617                         start_wp(); 
    618                         if ($post->post_parent == $parent) { 
    619                                 $post->post_title = wp_specialchars($post->post_title); 
    620                                 $pad = str_repeat('— ', $level); 
    621                                 $id = $post->ID; 
    622                                 $class = ('alternate' == $class) ? '' : 'alternate'; 
     610function page_rows($searching = false, $pages, $pages_columns, $parent = 0, $level = 0) { 
     611        global $class, $post; 
     612        if (!$pages) return false;               
     613        foreach ($pages as $post) { 
     614                start_wp(); 
     615                if (($post->post_parent == $parent) || $searching) { 
     616                        $post->post_title = wp_specialchars($post->post_title); 
     617                        $pad = (!$searching) ? str_repeat('— ', $level) : ""; 
     618                        $id = $post->ID; 
     619                        $class = ('alternate' == $class) ? '' : 'alternate'; 
    623620?> 
    624   <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>  
    625     <th scope="row"><?php echo $post->ID; ?></th>  
    626     <td> 
    627       <?php echo $pad; ?><?php the_title() ?>  
    628     </td>  
    629     <td><?php the_author() ?></td> 
    630     <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>  
    631         <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 
    632     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>  
    633     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>  
    634   </tr>  
    635  
    636 <?php 
    637  
    638                                 page_rows($id, $level +1, $pages); 
     621                <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>  
     622<?  
     623                        foreach($pages_columns as $column_name => $column_display_name) { 
     624                                switch($column_name) { 
     625                                         
     626                                        case 'id': 
     627                                                ?><th scope="row"><?php echo $id ?></th><?php 
     628                                                break; 
     629                                 
     630                                        case 'title': 
     631                                                ?> 
     632                                                <td><?php echo $pad; the_title(); ?></td><?php 
     633                                                break;           
     634                                 
     635                                        case 'owner': 
     636                                                ?><td><?php the_author() ?></td><?php 
     637                                                break; 
     638                                 
     639                                        case 'updated': 
     640                                                ?><td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td><?php 
     641                                                break; 
     642                 
     643                                        case 'control_view': 
     644                                                ?> 
     645                                                <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 
     646                                                <?php 
     647                                                break; 
     648                                 
     649                                        case 'control_edit': 
     650                                                ?> 
     651                                                <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 
     652                                                <?php 
     653                                                break; 
     654                                 
     655                                        case 'control_delete': 
     656                                                ?> 
     657                                                <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td> 
     658                                                <?php 
     659                                                break; 
     660                                 
     661                                        default: 
     662                                                ?><td><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td><?php 
     663                                                break;           
     664                                } 
    639665                        } 
    640                 } 
    641         } else { 
    642                 return false; 
     666                        if (!$searching) page_rows($searching, $pages, $pages_columns, $id, $level +1); 
     667                }  
    643668        } 
    644669} 
    645670 
     671 
    646672function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) { 
    647673        global $wpdb, $bgcolor; 
    648674        if (!$categories) { 
  • wp-admin/edit-pages.php

    old new  
    1212 
    1313<form name="searchform" action="" method="get">  
    1414  <fieldset>  
    15   <legend><?php _e('Search Pages&hellip;') ?></legend> 
     15  <legend><?php _e('Search Pages') ?></legend> 
    1616  <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" />  
    1717  <input type="submit" name="submit" value="<?php _e('Search') ?>"  />  
    1818  </fieldset> 
     
    2020 
    2121<?php 
    2222 
    23 $show_post_type = 'page'; 
    24  
    25 if ( isset($_GET['s']) ) 
    26         wp(); 
     23if (isset($_GET['s']) && ("" != $_GET['s'])) { 
     24        $s = $_GET['s']; 
     25        $searching = true; 
     26        $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' AND (post_title LIKE '%$s%' OR post_content LIKE '%$s%')");         
     27
    2728else 
    28         $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'"); 
     29        $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order"); 
    2930 
    30 if ($posts) { 
     31if ($pages) { 
     32 
     33$pages_columns = array( 
     34  'id' => __('ID'), 
     35  'title' => __('Title'), 
     36  'owner' => __('Owner'), 
     37  'updated' => __('Updated') 
     38); 
     39$pages_columns = apply_filters('manage_pages_columns', $pages_columns); 
     40 
     41// you can not edit these at the moment 
     42$pages_columns['control_view']   = ''; 
     43$pages_columns['control_edit']   = ''; 
     44$pages_columns['control_delete'] = ''; 
     45 
    3146?> 
    3247<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">  
    3348  <tr>  
    34     <th scope="col"><?php _e('ID') ?></th>  
    35     <th scope="col"><?php _e('Title') ?></th>  
    36     <th scope="col"><?php _e('Owner') ?></th> 
    37         <th scope="col"><?php _e('Updated') ?></th> 
    38         <th scope="col"></th>  
    39     <th scope="col"></th>  
    40     <th scope="col"></th>  
     49        <?php foreach($pages_columns as $column_display_name) { ?> 
     50                <th scope="col"><?php echo $column_display_name; ?></th> 
     51        <?php } ?> 
    4152  </tr>  
    4253<?php 
    43 if ( isset($_GET['s']) ) { 
    44 foreach ( $posts as $post ) :  
    45         $class = ('alternate' != $class) ? 'alternate' : ''; ?> 
    46   <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>  
    47     <th scope="row"><?php echo $post->ID; ?></th>  
    48     <td> 
    49       <?php echo $pad; ?><?php the_title() ?>  
    50     </td>  
    51     <td><?php the_author() ?></td> 
    52     <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>  
    53         <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 
    54     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>  
    55     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>  
    56   </tr> 
    57 <?php 
    58 endforeach; 
    59 } else { 
    60         page_rows(); 
    61 
     54page_rows($searching, $pages, $pages_columns); 
    6255?> 
    6356</table>  
    64  
    6557<div id="ajax-response"></div> 
    6658 
    6759<?php 
    6860} else { 
    6961?> 
    70 <p><?php _e('No pages yet.') ?></p> 
     62<p><?php _e('No pages found.') ?></p> 
    7163<?php 
    7264} // end if ($posts) 
    7365?>