Skip to content

Commit

Permalink
Don't inject CSS directly into the head; added CSS file for real this…
Browse files Browse the repository at this point in the history
… time

Before we were injecting CSS directly into the head of *every* admin page. Now, we look to see if it's a document page, and if so
conditionally, inject body tags into the admin body class. Every page will have the .document body class, and if a post is locked, it will have the
.document-locked body class.
  • Loading branch information
benbalter committed Jul 5, 2012
1 parent 35d84ef commit f61385b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
25 changes: 25 additions & 0 deletions css/style.css
@@ -0,0 +1,25 @@
/* Document icon */
.icon32-posts-document{background-position: 0 0 !important;
background-image:url('../img/icon32.png') !important;}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min-moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icon32-posts-document{
background-image:url( '../img/icon64.png' ) !important;
background-size:32px 32px !important;}
}

/* General document edit styling */
#postdiv {display:none;}
#lock-notice {background-color: #D4E8BA; border-color: #92D43B; }
#document-revisions {width: 100%; text-align: left;}
#document-revisions td {padding: 5px 0 0 0;}
#workflow-state select {margin-left: 25px; width: 150px;}
#authordiv select {width: 150px;}
#lock_override {float:right; text-align: right; margin-top: 10px; padding-bottom: 5px; }
#revision-summary {display:none;}
#autosave-alert {display:none;}

/* When documents are locked, hide notices and publish button, etc. */
.document-locked #publish,.document-locked .add_media,.document-locked #lock-notice {display: none;}
32 changes: 18 additions & 14 deletions includes/admin.php
Expand Up @@ -76,7 +76,7 @@ function __construct( &$instance = null) {
add_action( 'admin_init', array( &$this, 'edit_flow_admin_support' ), 20 );

//admin css
add_action( 'admin_head', array( &$this, 'admin_css') );
add_filter( 'admin_body_class', array( &$this, 'admin_body_class_filter' ) );

}

Expand Down Expand Up @@ -295,21 +295,25 @@ function hide_postcustom_metabox( $hidden, $screen ) {

return $hidden;
}



/**
* Inject CSS into admin head
* @since 0.5
* Filter the admin body class to add additional classes which we can use conditionally
* to style the page (e.g., when the document is locked
*/
function admin_css() {
global $post; ?>
<style>
<?php if ( $this->get_document_lock( $post ) ) { ?>
#publish, .add_media, #lock-notice {display: none;}
<?php } ?>
<?php do_action('document_admin_css'); ?>
</style>
<?php }
function admin_body_class_filter( $body_class ) {

global $post;

if ( !$this->verify_post_type() )
return $body_class;

$body_class .= ' document';

if ( $this->get_document_lock( $post ) )
$body_class .= ' document-locked';

return $body_class;
}

/**
* Hide header (gallery, URL, library, etc.) links from media-upload
Expand Down

0 comments on commit f61385b

Please sign in to comment.