Changeset 816333
- Timestamp:
- 12/07/2013 06:20:34 AM (12 years ago)
- Location:
- page-siblings/trunk
- Files:
-
- 2 edited
-
page-siblings.php (modified) (7 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
page-siblings/trunk/page-siblings.php
r621162 r816333 1 <?php 1 <?php 2 2 /* 3 3 Plugin Name: Page Siblings … … 5 5 Description: Add a metabox with all page edit (and any other hierarchal post types) that display an edit link to its siblings. 6 6 Author: Ionuț Staicu 7 Version: 1.0. 17 Version: 1.0.2 8 8 Author URI: http://iamntz.com 9 9 */ … … 30 30 31 31 add_action('restrict_manage_posts', array( &$this, 'add_column_filters' ) ); 32 add_filter( ' request', array( &$this, 'alter_query' ) );32 add_filter( 'parse_query', array( &$this, 'alter_query' ) ); 33 33 } 34 34 } … … 37 37 38 38 public function add_column_filters(){ 39 $current_setting = (int) $_GET['display_only_parents'];39 $current_setting = isset( $_GET['display_only_parents'] ) ? (int) $_GET['display_only_parents'] : 0; 40 40 ?> 41 41 <select name="display_only_parents"> 42 <option value="0" <?php selected( $current_setting, 0 ); ?>>Display Only Parent Posts</option> 43 <option value="1" <?php selected( $current_setting, 1 ); ?>>No</option> 44 <option value="2" <?php selected( $current_setting, 2 ); ?>>Yes</option> 42 <option value="all" <?php selected( $current_setting, 1 ); ?>>Show Parents And Children</option> 43 <option value="parents_only" <?php selected( $current_setting, 2 ); ?>>Show Only Parents</option> 45 44 </select> 46 <?php 45 <?php 47 46 } // add_column_filters 48 47 49 48 50 public function alter_query( $vars = '' ){ 51 if ( isset( $_GET['display_only_parents'] ) && $_GET['display_only_parents'] == 2 ) { 52 $vars = array_merge( $vars, array( 53 "post_parent" => 0 54 ) ); 49 public function alter_query( $query ){ 50 if ( isset( $_GET['display_only_parents'] ) && $_GET['display_only_parents'] == 'parents_only' ) { 51 $query_vars = &$query->query_vars; 52 $query_vars['post_parent'] = 0; 55 53 } 56 return $vars;57 54 } // alter_query 58 55 … … 68 65 </style> 69 66 <ul> 70 <?php 67 <?php 71 68 72 69 if( $post_data->post_parent > 0 ){ … … 79 76 $parent = get_post( $parent_id ); 80 77 81 if( $parent > 0){78 if( $parent ){ 82 79 $this->print_child( $parent ); 83 80 $this->loop_through_children( $parent_id, $post_type ); 81 }else { 82 echo "<li>This entry doesn't have any siblings</li>"; 84 83 } 85 84 echo "</ul>"; … … 118 117 ( !empty( $prefix ) ? "<span class='pipe'>|</span>{$prefix}" : '' ), 119 118 get_edit_post_link( $child->ID ), 120 ( $child->ID == $_GET['post'] ? 'font-weight:700;' : '' ),119 ( isset( $_GET['post'] ) && $child->ID == $_GET['post'] ? 'font-weight:700;' : '' ), 121 120 esc_attr( $child->post_title ) 122 121 ); -
page-siblings/trunk/readme.txt
r621162 r816333 38 38 = 1.0.1 = 39 39 * added a filtering option to page editing, so you can only display parent pages 40 41 = 1.0.2 = 42 * tweaked code a little & removed PHP notices & warnings
Note: See TracChangeset
for help on using the changeset viewer.