[wp-ui] wp-ui Digest, Vol 6, Issue 4
andré renaut
andre.renaut at gmail.com
Wed Jun 2 13:50:14 UTC 2010
another one. blog 1 remain unchanged, every other blog have a specific color
<?php
/*
Plugin Name: Dynamic Site Colors
Plugin URI: http://www.mailpress.org
Description: Dynamic admin header color for multiple sites
Author: André RENAUT
Version: 0-dev
Author URI: http://www.mailpress.org
*/
class Dynamic_Site_Colors
{
function __construct() {
$this->Dynamic_Site_Colors();
}
function Dynamic_Site_Colors() {
add_action('admin_print_styles', array(&$this,
'admin_print_styles'));
}
function admin_print_styles() {
global $current_blog;
if (1 == $current_blog->blog_id) return;
$color = $this->get_color($current_blog->blog_id);
?>
<!-- Dynamic_Site_Colors : <?php echo $site->id; ?> -->
<style type='text/css'>#wphead {background:<?php echo $color; ?>
!important;}</style>
<!-- Dynamic_Site_Colors -->
<?php
}
function get_color($p)
{
$x = pow(3,$p);
$y = intval($p/3) * 10;
$p = (355/113)* pow($p,2);
$c = '';
$c = sprintf("%02X", $this->bc_mod($p, '255')) . sprintf("%02X",
$this->bc_mod($y, '255')) . sprintf("%02X", $this->bc_mod($x, '255'));
return "#$c";
}
function bc_mod( $x, $y )
{
// how many numbers to take at once? carefull not to exceed (int)
$take = 5;
$mod = '';
do
{
$a = (int)$mod.substr( $x, 0, $take );
$x = substr( $x, $take );
$mod = $a % $y;
}
while ( strlen($x) );
return (int)$mod;
}
}
new Dynamic_Site_Colors();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.automattic.com/pipermail/wp-ui/attachments/20100602/f2f1a9d7/attachment.htm>
More information about the wp-ui
mailing list