1 | | <?php |
2 | | require_once('admin.php'); |
3 | | $title = __('Pages'); |
4 | | $parent_file = 'edit.php'; |
5 | | wp_enqueue_script( 'listman' ); |
6 | | require_once('admin-header.php'); |
7 | | |
8 | | $post_stati = array( // array( adj, noun ) |
9 | | 'publish' => array(__('Published'), __('Published pages')), |
10 | | 'draft' => array(__('Draft'), __('Draft pages')), |
11 | | 'private' => array(__('Private'), __('Private pages')) |
12 | | ); |
13 | | |
14 | | |
15 | | $post_status_label = __('Pages'); |
16 | | $post_status_q = ''; |
17 | | if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { |
18 | | $post_status_label = $post_stati[$_GET['post_status']][1]; |
19 | | $post_status_q = '&post_status=' . $_GET['post_status']; |
20 | | } |
21 | | |
22 | | ?> |
23 | | |
24 | | <div class="wrap"> |
25 | | |
26 | | <h2><?php |
27 | | // Use $_GET instead of is_ since they can override each other |
28 | | $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : ''; |
29 | | $h2_author = ''; |
30 | | if ( isset($_GET['author']) && $_GET['author'] ) { |
31 | | $author_user = get_userdata( (int) $_GET['author'] ); |
32 | | $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); |
33 | | } |
34 | | printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search ); |
35 | | ?></h2> |
36 | | |
37 | | <p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page »'); ?></a></p> |
38 | | |
39 | | <form name="searchform" id="searchform" action="" method="get"> |
40 | | <fieldset><legend><?php _e('Search Terms…') ?></legend> |
41 | | <input type="text" name="s" id="s" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" size="17" /> |
42 | | </fieldset> |
43 | | |
44 | | |
45 | | <fieldset><legend><?php _e('Page Type…'); ?></legend> |
46 | | <select name='post_status'> |
47 | | <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option> |
48 | | <?php foreach ( $post_stati as $status => $label ) : ?> |
49 | | <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option> |
50 | | <?php endforeach; ?> |
51 | | </select> |
52 | | </fieldset> |
53 | | |
54 | | <?php $editable_ids = get_editable_user_ids( $user_ID ); if ( $editable_ids && count( $editable_ids ) > 1 ) : ?> |
55 | | |
56 | | <fieldset><legend><?php _e('Author…'); ?></legend> |
57 | | <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?> |
58 | | </fieldset> |
59 | | |
60 | | <?php endif; ?> |
61 | | |
62 | | <input type="submit" id="post-query-submit" value="<?php _e('Filter »'); ?>" class="button" /> |
63 | | </form> |
64 | | |
65 | | <br style="clear:both;" /> |
66 | | |
67 | | <?php |
68 | | wp("post_type=page&orderby=menu_order&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc"); |
69 | | |
70 | | $all = !( $h2_search || $post_status_q ); |
71 | | |
72 | | if ($posts) { |
73 | | ?> |
74 | | <table class="widefat"> |
75 | | <thead> |
76 | | <tr> |
77 | | <th scope="col" style="text-align: center"><?php _e('ID') ?></th> |
78 | | <th scope="col"><?php _e('Title') ?></th> |
79 | | <th scope="col"><?php _e('Owner') ?></th> |
80 | | <th scope="col"><?php _e('Updated') ?></th> |
81 | | <th scope="col" colspan="3" style="text-align: center"><?php _e('Action'); ?></th> |
82 | | </tr> |
83 | | </thead> |
84 | | <tbody id="the-list"> |
85 | | <?php page_rows(0, 0, $posts, $all); ?> |
86 | | </tbody> |
87 | | </table> |
88 | | |
89 | | <div id="ajax-response"></div> |
90 | | |
91 | | <?php |
92 | | } else { |
93 | | ?> |
94 | | <p><?php _e('No pages found.') ?></p> |
95 | | <?php |
96 | | } // end if ($posts) |
97 | | ?> |
98 | | |
99 | | <h3><a href="page-new.php"><?php _e('Create New Page »'); ?></a></h3> |
100 | | |
101 | | </div> |
102 | | |
103 | | <?php include('admin-footer.php'); ?> |
| 1 | <?php |
| 2 | require_once('admin.php'); |
| 3 | $title = __('Pages'); |
| 4 | $parent_file = 'edit.php'; |
| 5 | wp_enqueue_script( 'listman' ); |
| 6 | require_once('admin-header.php'); |
| 7 | |
| 8 | $post_stati = array( // array( adj, noun ) |
| 9 | 'publish' => array(__('Published'), __('Published pages')), |
| 10 | 'draft' => array(__('Draft'), __('Draft pages')), |
| 11 | 'private' => array(__('Private'), __('Private pages')) |
| 12 | ); |
| 13 | |
| 14 | |
| 15 | $post_status_label = __('Pages'); |
| 16 | $post_status_q = ''; |
| 17 | if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { |
| 18 | $post_status_label = $post_stati[$_GET['post_status']][1]; |
| 19 | $post_status_q = '&post_status=' . $_GET['post_status']; |
| 20 | } |
| 21 | |
| 22 | ?> |
| 23 | |
| 24 | <div class="wrap"> |
| 25 | |
| 26 | <h2><?php |
| 27 | // Use $_GET instead of is_ since they can override each other |
| 28 | $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : ''; |
| 29 | $h2_author = ''; |
| 30 | if ( isset($_GET['author']) && $_GET['author'] ) { |
| 31 | $author_user = get_userdata( (int) $_GET['author'] ); |
| 32 | $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); |
| 33 | } |
| 34 | printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search ); |
| 35 | ?></h2> |
| 36 | |
| 37 | <p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page »'); ?></a></p> |
| 38 | |
| 39 | <form name="searchform" id="searchform" action="" method="get"> |
| 40 | <fieldset><legend><?php _e('Search Terms…') ?></legend> |
| 41 | <input type="text" name="s" id="s" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" size="17" /> |
| 42 | </fieldset> |
| 43 | |
| 44 | |
| 45 | <fieldset><legend><?php _e('Page Type…'); ?></legend> |
| 46 | <select name='post_status'> |
| 47 | <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option> |
| 48 | <?php foreach ( $post_stati as $status => $label ) : ?> |
| 49 | <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option> |
| 50 | <?php endforeach; ?> |
| 51 | </select> |
| 52 | </fieldset> |
| 53 | |
| 54 | <?php $editable_ids = get_editable_user_ids( $user_ID ); if ( $editable_ids && count( $editable_ids ) > 1 ) : ?> |
| 55 | |
| 56 | <fieldset><legend><?php _e('Author…'); ?></legend> |
| 57 | <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?> |
| 58 | </fieldset> |
| 59 | |
| 60 | <?php endif; ?> |
| 61 | |
| 62 | <input type="submit" id="post-query-submit" value="<?php _e('Filter »'); ?>" class="button" /> |
| 63 | </form> |
| 64 | |
| 65 | <br style="clear:both;" /> |
| 66 | |
| 67 | <?php |
| 68 | wp("post_type=page&orderby=menu_order&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc"); |
| 69 | |
| 70 | $all = !( $h2_search || $post_status_q ); |
| 71 | |
| 72 | if ($posts) { |
| 73 | ?> |
| 74 | <table class="widefat"> |
| 75 | <thead> |
| 76 | <tr> |
| 77 | <th scope="col" style="text-align: center"><?php _e('ID') ?></th> |
| 78 | <th scope="col"><?php _e('Title') ?></th> |
| 79 | <th scope="col"><?php _e('Owner') ?></th> |
| 80 | <th scope="col"><?php _e('Updated') ?></th> |
| 81 | <th scope="col" colspan="3" style="text-align: center"><?php _e('Action'); ?></th> |
| 82 | </tr> |
| 83 | </thead> |
| 84 | <tbody id="the-list"> |
| 85 | <?php |
| 86 | |
| 87 | if ( $all == false ) |
| 88 | { |
| 89 | page_rows(0, 0, $posts, $all); |
| 90 | } |
| 91 | else |
| 92 | { |
| 93 | |
| 94 | $numPagesPerPage = 50; //number of pages to be displayed per page |
| 95 | $pages = $wpdb->get_results("SELECT `post_title`, `ID`, `guid`, `post_author`, `post_modified` FROM `wp_posts` WHERE `post_type` = 'page' ORDER BY `wp_posts`.`ID` DESC", ARRAY_A); |
| 96 | $size = sizeof($pages);//total number of pages in the database |
| 97 | |
| 98 | $numAdminPagesfull =$size/$numPagesPerPage;//get the total number of full admin pages |
| 99 | $numAdminPages = (int)$numAdminPagesfull;//get rid of the fraction if there is one |
| 100 | $fraction = false;//initally set this to false |
| 101 | |
| 102 | //if they are not equal, then the number of pages is not divisble by the $numPagesPerPage |
| 103 | if($numAdminPages != $numAdminPagesfull){ |
| 104 | $numPagesLastPage = ($numAdminPagesfull-$numAdminPages)*$numPagesPerPage;//this gets the number of posts on the last page |
| 105 | $numAdminPages++;//increase it so we know how many pages there are |
| 106 | $fraction = true;//so we know that there arent the full number of pages on the last page |
| 107 | } |
| 108 | |
| 109 | if (isset($_POST['pageNum'])){ |
| 110 | $adminPage = $_POST['pageNum']; |
| 111 | unset($_POST['pageNum']); |
| 112 | if (isset($_POST['back'])){ |
| 113 | unset($_POST['back']); |
| 114 | $adminPage--; |
| 115 | }else if (isset($_POST['next'])){ |
| 116 | unset($_POST['next']); |
| 117 | $adminPage++; |
| 118 | } |
| 119 | }else{ |
| 120 | $adminPage = 1; |
| 121 | } |
| 122 | //if thre is a fraction, and on the last page, then do it differently |
| 123 | if ($fraction && $adminPage == $numAdminPages){ |
| 124 | $lowernum = ($adminPage-1)*$numPagesPerPage; |
| 125 | $uppernum = $lowernum + $numPagesLastPage; |
| 126 | }else{ |
| 127 | //else, get the adminpage and multiply it by the number of pages per page |
| 128 | $lowernum = ($adminPage-1)*$numPagesPerPage; |
| 129 | $uppernum = $adminPage*$numPagesPerPage; |
| 130 | } |
| 131 | |
| 132 | $displayPages ="";//empty this |
| 133 | for ($i = $lowernum; $i < $uppernum; $i++){ |
| 134 | $displayPages[] = $pages[$i];//add the pages to the displayPage |
| 135 | } |
| 136 | //give it to the function to display the pages info on the page |
| 137 | page_rows_modified($displayPages); |
| 138 | } |
| 139 | ?> |
| 140 | </tbody> |
| 141 | </table> |
| 142 | |
| 143 | <div id="ajax-response"></div> |
| 144 | |
| 145 | <?php |
| 146 | } else { |
| 147 | ?> |
| 148 | <p><?php _e('No pages found.') ?></p> |
| 149 | <?php |
| 150 | } // end if ($posts) |
| 151 | if ( $all != false ){ |
| 152 | //if not searched, then display the below |
| 153 | echo '<p>Displaying pages '.$lowernum.' to '.$uppernum.' of total '. $size.' pages.</p>'; |
| 154 | ?> |
| 155 | |
| 156 | <div> |
| 157 | <table> |
| 158 | <tr> |
| 159 | <?php |
| 160 | //the above div may not be styled properly |
| 161 | $z = 0; |
| 162 | //add a button for each page |
| 163 | while ($z < $numAdminPages){ |
| 164 | ?> |
| 165 | |
| 166 | <form action="" method="post"> |
| 167 | <input type="hidden" name="pageNum" id="pageNum" value="<?php echo $z+1; ?>"> |
| 168 | <input type="submit" name="submit" value="<?php echo $z+1; ?>" |
| 169 | <?php if($adminPage != $z+1){ |
| 170 | //if on the page that is being viewed, then style the button |
| 171 | }else {echo 'style="background:#fff;"'; |
| 172 | }?> |
| 173 | /> |
| 174 | </form> |
| 175 | |
| 176 | <?php |
| 177 | $z++; |
| 178 | } |
| 179 | ?> |
| 180 | </tr> |
| 181 | </table> |
| 182 | |
| 183 | </div> |
| 184 | |
| 185 | <div class="navigation"> |
| 186 | <div class="alignleft"><?php |
| 187 | if( $adminPage > 1){ |
| 188 | //if not on the first page, add a button to scroll back a page |
| 189 | ?> |
| 190 | <form action="" method="post"> |
| 191 | <input type="hidden" name="back" id="back" value="true"> |
| 192 | <input type="hidden" name="pageNum" id=pageNum" value="<?php echo $adminPage ?>"> |
| 193 | <p class="submit"> |
| 194 | <input type="submit" name="submit" value="« Previous Page" /> |
| 195 | </p> |
| 196 | </form> |
| 197 | <?php |
| 198 | } |
| 199 | ?> |
| 200 | </div> |
| 201 | |
| 202 | <div class="alignright"><?php |
| 203 | //if not on the last page, add a button to go to the next page |
| 204 | if($adminPage < $numAdminPages){ |
| 205 | ?> |
| 206 | <form action="" method="post"> |
| 207 | <input type="hidden" name="next" id="next" value="true"> |
| 208 | <input type="hidden" name="pageNum" id="pageNum" value="<?php echo $adminPage ?>"> |
| 209 | <p class="submit"> |
| 210 | <input type="submit" name="submit" value="Next Page »" /> |
| 211 | </p> |
| 212 | </form> |
| 213 | <?php |
| 214 | } |
| 215 | ?> |
| 216 | </div> |
| 217 | |
| 218 | </div> |
| 219 | <br><br><br> |
| 220 | <?php |
| 221 | //may need to do some styling, like the above <br> probably shouldnt be used |
| 222 | }?> |
| 223 | |
| 224 | <h3><a href="page-new.php"><?php _e('Create New Page »'); ?></a></h3> |
| 225 | |
| 226 | </div> |
| 227 | |
| 228 | <?php include('admin-footer.php'); ?> |