Changeset 843479
- Timestamp:
- 01/23/2014 02:01:13 AM (12 years ago)
- Location:
- simple-frontend-template-display/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
simple-frontend-template-display.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-frontend-template-display/trunk/readme.txt
r829641 r843479 5 5 Requires at least: 3.4 6 6 Tested up to: 3.8 7 Stable tag: 0. 2.07 Stable tag: 0.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 == Upgrade Notice == 34 34 35 = 0.3.0 = 36 Adds drop down items to show pages with the same page template (up to 15) and a banner to the landing page 37 35 38 = 0.2.0 = 36 39 Adds a drop down item to show the page template filename & improves several methods … … 40 43 41 44 == Changelog == 45 46 = 0.3.0 = 47 * Added get_similar_pages function to retrieve pages with the same template 42 48 43 49 = 0.2.0 = -
simple-frontend-template-display/trunk/simple-frontend-template-display.php
r829641 r843479 4 4 Plugin Name: Simple Frontend Template Display 5 5 Plugin URI: http://www.mikeselander.com/ 6 Description: Displays the current page template in the admin bar for quick & easy reference7 Version: 0. 26 Description: Displays the current page template in the admin toolbar for quick & easy reference 7 Version: 0.3 8 8 Author: Mike Selander 9 9 Author URI: http://www.mikeselander.com/ … … 20 20 * @author Mike Selander 21 21 * @since 0.0.0 22 * @link http://mikeselander.com22 * @link http://mikeselander.com 23 23 * @copyright 2013 Mike Selander 24 24 */ 25 25 class PageTemplateDisplay{ 26 26 27 const VERSION = '0. 2.0';27 const VERSION = '0.3.0'; 28 28 29 29 /** … … 37 37 38 38 add_action('admin_bar_menu', array( $this, "page_template_display" ), 500 ); 39 add_action('admin_bar_menu', array( $this, "get_similar_pages" ), 501 ); 39 40 40 41 } // end __construct() … … 57 58 // if get_current_template_name returns - set the menu item 58 59 if ( $this->get_current_template_name() ) { 60 59 61 $wp_admin_bar->add_node( 60 62 array( … … 65 67 ) 66 68 ); 69 70 // if get_current_page_slug returns - set the next menu item 67 71 if ( $this->get_current_page_slug() ) { 68 72 $wp_admin_bar->add_node( … … 76 80 } 77 81 78 79 80 82 } // end if template name is returned 81 83 … … 127 129 } // end get_current_page_slug() 128 130 131 /** 132 * Grabs other pages with the same template 133 * 134 * @access public 135 * @since 0.3.0 136 * @return list of pages with 137 */ 138 public function get_similar_pages( $wp_admin_bar ){ 139 global $wp_query; 140 141 if (!is_super_admin() || !is_admin_bar_showing() ) 142 return; 143 144 // if you're not in the admin backend & it's a page 145 if ( ( !is_admin() ) && ( is_page() ) ){ 146 147 // define the variables 148 $template = $this->get_current_page_slug(); 149 $post_id = $wp_query->post->ID; 150 $i = 1; 151 152 // query the pages 153 $args = array( 154 'post_type' => 'page', 155 'meta_key' => '_wp_page_template', 156 'meta_value' => $template, 157 'exclude' => $post_id 158 ); 159 160 $pages = get_pages( $args ); 161 162 // if the query returns results, add a header node 163 if ( !empty( $pages ) ) { 164 165 $wp_admin_bar->add_node( 166 array( 167 'id' => 'similar_pages', 168 'title' => "<strong>".__( 'Similar Pages:', 'page_template' )."</strong>", 169 'parent' => page_template, 170 'href' => false 171 ) 172 ); 173 174 // Loop through the results 175 foreach( $pages as $page ){ 176 177 // Loop until we hit 15 178 if ( $i < 16 ) { 179 180 $wp_admin_bar->add_node( 181 array( 182 'id' => 'similar_page_'.$i, 183 'title' => $page->post_title, 184 'parent' => page_template, 185 'href' => get_permalink($page->ID) 186 ) 187 ); 188 189 } // end if 190 191 $i++; 192 193 } // end foreach 194 195 } // end if have posts 196 197 } // end if !is_admin && is_page() 198 199 } // end get_similar_pages() 200 129 201 } // end PageTemplateDisplay 130 202
Note: See TracChangeset
for help on using the changeset viewer.