Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Removes menus from the admin menu that aren't needed on the documents site
- */
- add_action( 'admin_menu', 'radl_remove_excess_menus', 99, 0 );
- function radl_remove_excess_menus() {
- if( !class_exists( 'RA_Document_Post_Type' ) )
- return;
- $pages_to_remove = array( 'edit.php', 'upload.php', 'link-manager.php', 'edit.php?post_type=page', 'gf_edit_forms' );
- foreach( $pages_to_remove as $p ) {
- remove_menu_page( $p );
- }
- }
- /**
- * Removes editors' abilities to manage taxonomies on the documents site
- * Removes authors' ability to publish posts on the documents site (they can only save as pending/draft)
- */
- add_action( 'init', 'radl_remove_tax_edit_caps', 99, 0 );
- function radl_remove_tax_edit_caps() {
- if( !class_exists( 'RA_Document_Post_Type' ) )
- return;
- foreach( array( 'editor' ) as $r ) {
- $role = get_role( $r );
- $role->remove_cap( 'manage_categories' );
- $role->remove_cap( 'manage_terms' );
- $role->remove_cap( 'edit_terms' );
- $role->remove_cap( 'delete_terms' );
- }
- $role = get_role( 'author' );
- $role->remove_cap( 'publish_posts' );
- }
- /**
- * Removes the Quick Press item from the Document Site dashboard (since we aren't using standard posts in any way)
- */
- add_action( 'wp_dashboard_setup', 'radl_remove_quick_press' );
- function radl_remove_quick_press() {
- if( !class_exists( 'RA_Document_Post_Type' ) )
- return;
- global $wp_meta_boxes;
- $screen_id = is_network_admin() ? 'dashboard-network' : 'dashboard';
- unset( $wp_meta_boxes[$screen_id]['side']['core']['dashboard_quick_press'] );
- return;
- }
- /**
- * Removes the "Insert Gravity Form" button from the document editor
- */
- function remove_gforms_media_button_from_document_editor() {
- /**
- * Check to see if this is the document site
- * If not, we exit the function
- */
- if( !class_exists( 'RA_Document_Post_Type' ) )
- return;
- /**
- * Check to see if we are editing a post or adding a new post
- * If we are doing neither, exit the function
- */
- if( !isset( $_GET['post_type'] ) && ( !isset( $_GET['action'] ) || 'edit' != $_GET['action'] ) )
- return;
- /**
- * Set a variable with the name of the post_type being edited/added
- */
- $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : get_post_type( $_GET['post'] );
- /**
- * If the post_type is not a document, exit the function
- */
- if( 'umw_document' != $post_type )
- return;
- /**
- * Assuming we passed all the criteria above, remove the GForms button
- */
- remove_action( 'media_buttons_context', array('RGForms', 'add_form_button') );
- }
- /**
- * Make sure this action is hooked in after the init action is finished.
- * If we hook into the admin_init action, we avoid having to check to make
- * sure we're in the admin area (since this action only fires in the admin area)
- */
- add_action( 'admin_init', 'remove_gforms_media_button_from_document_editor' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement