- Timestamp:
- 06/17/2014 12:00:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/handbook.php
r705 r706 20 20 static function init() { 21 21 22 $post_types = 'handbook'; 23 24 $post_types = apply_filters( 'handbook_post_types', $post_types ); 25 26 if ( ! is_array( $post_types ) ) { 27 $post_types = (array) $post_types; 28 } 22 $post_types = (array) apply_filters( 'handbook_post_types', array( 'handbook' ) ); 29 23 30 24 new WPorg_Handbook_TOC( $post_types ); … … 32 26 foreach ( $post_types as $type ) { 33 27 new WPorg_Handbook( $type ); 34 35 28 } 36 29 } 30 37 31 } 32 38 33 add_action( 'after_setup_theme', array( 'WPorg_Handbook_Init', 'init' ) ); 39 34 … … 61 56 62 57 function __construct( $type ) { 63 if ( 'handbook' != $type ) 58 if ( 'handbook' != $type ) { 64 59 $this->post_type = $type . '-handbook'; 60 } else { 61 $this->post_type = $type; 62 } 65 63 66 64 $this->label = ucwords( str_replace( array( '-', '_' ), ' ', $this->post_type ) ); 67 add_filter( 'user_has_cap', array( $this, 'grant_handbook_caps' ) ); 68 add_filter( 'init', array( $this, 'register_post_type' ) ); 69 add_action( 'admin_page_access_denied', array( $this, 'admin_page_access_denied' ) ); 70 add_filter( 'post_type_link', array( $this, 'post_type_link' ), 10, 2 ); 71 add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); 72 add_action( 'widgets_init', array( $this, 'handbook_sidebar' ), 11 ); // After P2 65 66 add_filter( 'user_has_cap', array( $this, 'grant_handbook_caps' ) ); 67 add_filter( 'init', array( $this, 'register_post_type' ) ); 68 add_action( 'admin_page_access_denied', array( $this, 'admin_page_access_denied' ) ); 69 add_filter( 'post_type_link', array( $this, 'post_type_link' ), 10, 2 ); 70 add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); 71 add_action( 'widgets_init', array( $this, 'handbook_sidebar' ), 11 ); // After P2 73 72 add_action( 'wporg_email_changes_for_post_types', array( $this, 'wporg_email_changes_for_post_types' ) ); 74 73 } 75 74 76 75 function grant_handbook_caps( $caps ) { 77 if ( ! is_user_member_of_blog() ) 76 if ( ! is_user_member_of_blog() ) { 78 77 return $caps; 78 } 79 79 80 foreach ( self::caps() as $cap ) { 80 81 $caps[ $cap ] = true; 81 82 } 83 82 84 if ( ! empty( $caps['edit_pages'] ) ) { 83 85 foreach ( self::editor_caps() as $cap ) { … … 85 87 } 86 88 } 89 87 90 return $caps; 88 91 } … … 94 97 $slug = 'handbook'; 95 98 } 99 96 100 register_post_type( $this->post_type, array( 97 101 'labels' => array( 98 'name' => "{$this->label} Pages",99 'singular_name' => "{$this->label} Page",100 'menu_name' => "{$this->label}",101 'all_items' => "{$this->label} Pages",102 'name' => sprintf( __( '%s Pages', 'wporg' ), $this->label ), 103 'singular_name' => sprintf( __( '%s Page', 'wporg' ), $this->label ), 104 'menu_name' => $this->label, 105 'all_items' => sprintf( __( '%s Pages', 'wporg' ), $this->label ), 102 106 ), 103 'public' => true,104 'show_ui' => true,105 'capability_type' => 'handbook_page',106 'map_meta_cap' => true,107 'has_archive' => true,108 'hierarchical' => true,109 'menu_position' => 11,110 'rewrite' 111 'feeds' => false,112 'slug' => $slug,113 'with_front' => false,107 'public' => true, 108 'show_ui' => true, 109 'capability_type' => 'handbook_page', 110 'map_meta_cap' => true, 111 'has_archive' => true, 112 'hierarchical' => true, 113 'menu_position' => 11, 114 'rewrite' => array( 115 'feeds' => false, 116 'slug' => $slug, 117 'with_front' => false, 114 118 ), 115 'delete_with_user' => false,116 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),119 'delete_with_user' => false, 120 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ), 117 121 ) ); 118 122 } … … 126 130 127 131 function post_type_link( $link, $post ) { 128 if ( $post->post_type === $this->post_type && $post->post_name === $this->post_type ) 132 if ( $post->post_type === $this->post_type && $post->post_name === $this->post_type ) { 129 133 return get_post_type_archive_link( $this->post_type ); 134 } 135 130 136 return $link; 131 137 } … … 138 144 139 145 function handbook_sidebar() { 140 register_sidebar( array( 'id' => $this->post_type, 'name' => $this->label, 'description' => "Used on {$this->label} pages" ) ); 146 register_sidebar( array( 147 'id' => $this->post_type, 148 'name' => $this->label, 149 'description' => sprintf( __( 'Used on %s pages', 'wporg' ), $this->label ), 150 ) ); 141 151 require_once dirname( __FILE__ ) . '/inc/widgets.php'; 142 152 register_widget( 'WPorg_Handbook_Pages_Widget' ); … … 144 154 145 155 function wporg_email_changes_for_post_types( $post_types ) { 146 if ( ! in_array( $this->post_type, $post_types ) ) 156 if ( ! in_array( $this->post_type, $post_types ) ) { 147 157 $post_types[] = $this->post_type; 158 } 159 148 160 return $post_types; 149 161 }
Note: See TracChangeset
for help on using the changeset viewer.