Changeset 3608
- Timestamp:
- 06/30/2016 09:41:04 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php
r3607 r3608 42 42 add_action( 'edit_form_top', array( $this, 'expl_to_post_controls' ) ); 43 43 add_action( 'admin_bar_menu', array( $this, 'toolbar_edit_link' ), 100 ); 44 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 45 add_action( 'load-post-new.php', array( $this, 'prevent_direct_creation') ); 44 46 45 47 // Permissions. … … 79 81 'hierarchical' => false, 80 82 'show_ui' => true, 81 'show_in_menu' => false, 83 'show_in_menu' => true, 84 'menu_icon' => 'dashicons-info', 85 'show_in_admin_bar' => false, 82 86 'show_in_nav_menus' => false, 83 87 'capability_type' => 'explanation', … … 97 101 foreach ( $this->post_types as $type ) { 98 102 remove_post_type_support( $type, 'editor' ); 103 } 104 } 105 106 /** 107 * Customizes admin menu. 108 * 109 * - Removes "Add new". 110 * - Adds count of pending explanations. 111 * 112 * @access public 113 */ 114 public function admin_menu() { 115 global $menu; 116 117 $menu_slug = 'edit.php?post_type=' . $this->exp_post_type; 118 119 // Remove 'Add New' from submenu. 120 remove_submenu_page( $menu_slug, 'post-new.php?post_type=' . $this->exp_post_type ); 121 122 // Add pending posts count. 123 $counts = wp_count_posts( $this->exp_post_type ); 124 $count = $counts->pending; 125 if ( $count ) { 126 // Find the explanations menu item. 127 foreach ( $menu as $i => $item ) { 128 if ( $menu_slug == $item[2] ) { 129 // Modify it to include the pending count. 130 $menu[ $i ][0] = sprintf( 131 __( 'Explanations %s', 'wporg' ), 132 "<span class='update-plugins count-{$count}'><span class='plugin-count'>" . number_format_i18n( $count ) . "</span></span>" 133 ); 134 break; 135 } 136 } 137 } 138 } 139 140 /** 141 * Prevents direct access to the admin page for creating a new explanation. 142 * 143 * Only prevents admin UI access to directly create a new explanation. It does 144 * not attempt to prevent direct programmatic creation of a new explanation. 145 * 146 * @access public 147 */ 148 public function prevent_direct_creation() { 149 if ( $this->exp_post_type == $_GET['post_type'] ) { 150 wp_safe_redirect( admin_url() ); 151 exit; 99 152 } 100 153 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/admin.scss
r1909 r3608 26 26 /* Explanations */ 27 27 28 .post-type-wporg_explanations . add-new-h2{28 .post-type-wporg_explanations .page-title-action { 29 29 display: none; 30 30 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/admin.css
r1909 r3608 23 23 24 24 /* Explanations */ 25 .post-type-wporg_explanations . add-new-h2{25 .post-type-wporg_explanations .page-title-action { 26 26 display: none; 27 27 }
Note: See TracChangeset
for help on using the changeset viewer.