Changeset 2775642
- Timestamp:
- 08/25/2022 04:08:59 PM (4 years ago)
- Location:
- filter-page-by-template/trunk
- Files:
-
- 3 edited
-
filter-page-by-template.php (modified) (7 diffs)
-
includes/five_star_wp_rate_notice.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
filter-page-by-template/trunk/filter-page-by-template.php
r2696282 r2775642 9 9 */ 10 10 11 define ( 'F PBT_EMBEDER_PLUGIN_DIR', dirname(__FILE__) ); // Plugin Directory12 define ( 'F PBT_EMBEDER_PLUGIN_URL', plugin_dir_url(__FILE__) ); // Plugin URL (for http requests)11 define ( 'FILTER_PAGE_BY_TEMPLATE_PLUGIN_DIR', dirname(__FILE__) ); // Plugin Directory 12 define ( 'FILTER_PAGE_BY_TEMPLATE_PLUGIN_URL', plugin_dir_url(__FILE__) ); // Plugin URL (for http requests) 13 13 14 class Filter PagesByTemplate {14 class Filter_Page_By_Template { 15 15 16 public function __construct() 17 { 18 add_action( 'restrict_manage_posts', array( $this, 'filter_dropdown' ) ); 19 add_filter( 'request', array( $this, 'filter_post_list' ) ); 20 21 add_filter('manage_pages_columns', array( $this, 'post_list_columns_head')); 22 add_action('manage_pages_custom_column', array( $this, 'post_list_columns_content' ), 10, 2); 16 public function __construct() { 17 if( $GLOBALS['pagenow'] == 'edit.php' ) { 18 $post_type = $this->current_post_type(); 19 add_action( 'restrict_manage_posts', array( $this, 'filter_dropdown' ) ); 20 add_filter( 'request', array( $this, 'filter_post_list' ) ); 21 add_filter( "manage_{$post_type}_posts_columns", array( $this, 'post_list_columns_head') ); 22 add_action( "manage_{$post_type}_posts_custom_column", array( $this, 'post_list_columns_content' ), 10, 2 ); 23 } 23 24 24 25 add_action( 'init', array( $this , 'load_textdomain' ) ); 25 26 26 } 27 27 28 public function filter_dropdown() 29 { 28 public function current_post_type() { 29 return isset( $_GET['post_type'] ) ? $_GET['post_type'] : 'post'; 30 } 31 32 public function filter_dropdown() { 30 33 if ( $GLOBALS['pagenow'] === 'upload.php' ) { 31 34 return; 32 35 } 33 36 37 $post_type = $this->current_post_type(); 34 38 $template = isset( $_GET['page_template_filter'] ) ? $_GET['page_template_filter'] : "all"; 35 39 $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'meta-box' ); … … 39 43 <option value="all_missing" style="color:red" <?php echo ( $template == 'all_missing' )? ' selected="selected" ' : "";?>><?php _e( 'All Missing Page Templates', 'filter-page-by-template' ) ?></option> 40 44 <option value="default" <?php echo ( $template == 'default' )? ' selected="selected" ' : "";?>><?php echo esc_html( $default_title ); ?></option> 41 <?php page_template_dropdown( $template); ?>45 <?php page_template_dropdown( $template, $post_type ); ?> 42 46 </select> 43 47 <?php 44 48 }//end func 45 49 46 public function filter_post_list( $vars ){ 50 public function filter_post_list( $vars ) { 51 if ( ! isset( $_GET['page_template_filter'] ) ) return $vars; 52 $template = trim( $_GET['page_template_filter'] ); 47 53 48 if ( ! isset( $_GET['page_template_filter'] ) ) return $vars; 49 $template = trim($_GET['page_template_filter']); 50 51 $data = get_option("filter_page_by_template_data", array() ); 54 $data = get_option( "filter_page_by_template_data", array() ); 52 55 $filter_used = isset( $data['filter_used'] ) ? intval( $data['filter_used'] ) : 0; 53 56 $filter_used ++; 54 57 $data['filter_used'] = $filter_used; 55 update_option( "filter_page_by_template_data", $data );58 update_option( "filter_page_by_template_data", $data ); 56 59 57 60 if ( $template == "" || $template == 'all' ) return $vars; 58 61 59 if( $template == 'all_missing') 60 { 62 if( $template == 'all_missing') { 61 63 $templates = wp_get_theme()->get_page_templates( null, 'page' ); 62 $template_files = array_keys( $templates);64 $template_files = array_keys( $templates ); 63 65 $template_files[] = 'default'; 64 66 $vars = array_merge( … … 74 76 ) 75 77 ); 76 } 77 else 78 { 78 } else { 79 79 $vars = array_merge( 80 80 $vars, … … 96 96 97 97 # Add new column to post list 98 public function post_list_columns_head( $columns ) 99 { 98 public function post_list_columns_head( $columns ) { 100 99 $columns['template'] = 'Template'; 101 100 return $columns; … … 103 102 104 103 #post list column content 105 public function post_list_columns_content( $column_name, $post_id ) 106 { 107 $post_type = 'page'; 104 public function post_list_columns_content( $column_name, $post_id ) { 105 $post_type = $this->current_post_type(); 108 106 109 if($column_name == 'template') 110 { 111 $template = get_post_meta($post_id, "_wp_page_template" , true ); 112 if($template) 113 { 114 if($template == 'default') 115 { 107 if( $column_name == 'template' ) { 108 $template = get_post_meta( $post_id, "_wp_page_template" , true ); 109 if( $template ) { 110 if( $template == 'default' ) { 116 111 $template_name = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'meta-box' ); 117 112 echo '<span title="' . esc_attr( __( 'Template file', 'filter-page-by-template' ) ) . ': page.php">'.$template_name.'</span>'; 118 } 119 else 120 { 113 } else { 121 114 $templates = wp_get_theme()->get_page_templates( null, $post_type ); 122 115 123 if( isset( $templates[ $template ] ) ) 124 { 116 if( isset( $templates[ $template ] ) ) { 125 117 echo '<span title="Template file: '.$template.'">'.$templates[ $template ].'</span>'; 126 } 127 else 128 { 118 } else { 129 119 130 120 echo '<span style="color:red" title="' . esc_attr( __( 'This template file does not exist', 'filter-page-by-template' ) ) . '">'.$template.'</span>'; … … 140 130 * @return void 141 131 */ 142 public function load_textdomain() {132 public function load_textdomain() { 143 133 load_plugin_textdomain( 'filter-page-by-template', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 144 134 } … … 147 137 }//end class 148 138 149 if( is_admin() ) 150 { 151 new FilterPagesByTemplate(); 152 include_once(FPBT_EMBEDER_PLUGIN_DIR."/includes/five_star_wp_rate_notice.php"); 139 if( is_admin() ) { 140 new Filter_Page_By_Template(); 141 include_once(FILTER_PAGE_BY_TEMPLATE_PLUGIN_DIR."/includes/five_star_wp_rate_notice.php"); 153 142 } -
filter-page-by-template/trunk/includes/five_star_wp_rate_notice.php
r2696273 r2775642 43 43 function admin_enqueue_scripts() 44 44 { 45 wp_enqueue_script('fpbt_rate_notice', F PBT_EMBEDER_PLUGIN_URL.'js/five_star_wp_rate_notice.js', array('jquery') );45 wp_enqueue_script('fpbt_rate_notice', FILTER_PAGE_BY_TEMPLATE_PLUGIN_URL.'js/five_star_wp_rate_notice.js', array('jquery') ); 46 46 } 47 47 -
filter-page-by-template/trunk/readme.txt
r2696282 r2775642 4 4 Tags: Filter, Page List, Template Filter, Missing templates 5 5 Requires at least: 3.8.0 6 Tested up to: 5.9.27 Stable tag: 2.26 Tested up to: 6.0.1 7 Stable tag: 3.0 8 8 License: GPLv2+ 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 17 17 **Using this plugin you can do :** 18 18 19 * Filter page list according to page template 20 * See which page is using which template 21 * See which page template is being used by which pages 22 * See which pages are using missing templates 23 * Know the PHP file name of templates 19 * Filter page list according to page template. 20 * See which page is using which template. 21 * See which page template is being used by which pages. 22 * See which pages are using missing templates. 23 * Know the PHP file name of templates. 24 * You can do the same things above for posts and any custom post type posts. 24 25 25 26 == Installation == … … 44 45 45 46 == Changelog == 47 = 3.0 (August 25, 2022) = 48 * Show appropriate templates dropdown list for posts and custom post types. 49 * Show template column for posts and custom post types. 50 46 51 = 2.2 (March 19, 2022) = 47 52 * Fix plugin translation. … … 77 82 78 83 == Upgrade Notice == 84 = 3.0 (August 25, 2022) = 85 * Show appropriate templates dropdown list for posts and custom post types. 86 * Show template column for posts and custom post types. 87 79 88 = 2.2 (March 19, 2022) = 80 89 * Fix plugin translation.
Note: See TracChangeset
for help on using the changeset viewer.