Plugin Directory

Changeset 558000


Ignore:
Timestamp:
06/14/2012 03:11:26 PM (14 years ago)
Author:
BisonTech
Message:
 
Location:
logoreplacer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • logoreplacer/trunk/logoReplacer.php

    r404671 r558000  
    11<?php
     2
    23/*  Copyright 2010 BisonTech. All Rights Reserved.
    34
    4     This program is free software; you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License as published by
    6     the Free Software Foundation; either version 2 of the License, or
    7     (at your option) any later version.
     5  This program is free software; you can redistribute it and/or modify
     6  it under the terms of the GNU General Public License as published by
     7  the Free Software Foundation; either version 2 of the License, or
     8  (at your option) any later version.
    89
    9     This program is distributed in the hope that it will be useful,
    10     but WITHOUT ANY WARRANTY; without even the implied warranty of
    11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12     GNU General Public License for more details:
    13     http://www.gnu.org/licenses/gpl-2.0.html
    14 */
     10  This program is distributed in the hope that it will be useful,
     11  but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  GNU General Public License for more details:
     14  http://www.gnu.org/licenses/gpl-2.0.html
     15 */
    1516
    1617/*
    17 Plugin Name: LogoReplacer
    18 Plugin URI: http://wordpress.org/extend/plugins/logoReplacer/
    19 Description: Replace registration and admin Logo
    20 Author:  http://www.BisonTech.net
    21 Version: 1.2.0
    22 */
     18  Plugin Name: LogoReplacer
     19  Plugin URI: http://wordpress.org/extend/plugins/logoReplacer/
     20  Description: Replace registration and admin Logo
     21  Author:  http://www.BisonTech.net
     22  Version: 2.0.1
     23 */
    2324
    2425
    2526add_action('plugins_loaded', 'lr_init');
    2627
    27 define ('LOGO_DIR',dirname(__FILE__). '/logos/');
     28define('LOGO_DIR', dirname(__FILE__) . '/logos/');
    2829
    2930
    30 function lr_init(){
    31   $version = get_bloginfo('version');
     31class LRLogoImg {
    3232
    33   list($version,$release, $minor) = explode('.',$version);
    34  
    35   //wp 3.1
    36   if (($version >= 3) && ($release >=2) ){
    37        $src_login = LOGO_DIR . 'logo-login.png';
    38   }else{
    39        $src_login = LOGO_DIR . 'logo-login.gif';
    40   }
    41   $src_head = LOGO_DIR . 'wp-logo-vs.png';
    42   if (($version >= 3) && ($release >=2) ){
    43     $dst_login = ABSPATH . '/wp-admin/images/logo-login.png';
    44   }else{
    45     $dst_login = ABSPATH . '/wp-admin/images/logo-login.gif';
    46   }
    47   $dst_head = ABSPATH . '/wp-admin/images/wp-logo-vs.png';
    48   $dst_head2 = ABSPATH . '/wp-admin/images/wp-logo.png';
     33    public $custom_path = NULL;
     34    public $installed_path = NULL;
    4935
    50   $logo_login_md5      = md5_file($src_login);
    51   $logo_head_md5       = md5_file($src_head);
     36    function __construct($sCustomPath, $sInstalledPath) {
    5237
    53   $logo_login_current  = md5_file($dst_login);
    54   $logo_head_current   = md5_file($dst_head);
    55   $logo_head_current2  = md5_file($dst_head2);
     38        $this->installed_path = $sInstalledPath;
     39        $this->custom_path = $sCustomPath;
     40    }
    5641
    57 
    58 
    59   if ($logo_login_current == $logo_login_md5){
    60     //log...
    61   }else{
    62     lr_installLogo($src_login,$dst_login);
    63   }
    64 
    65   if ($logo_head_current == $logo_head_md5){
    66     //log
    67   }else{
    68     lr_installLogo($src_head,$dst_head);
    69   }
    70 
    71   if ($logo_head_current2 == $logo_head_md5){
    72     //log
    73   }else{
    74     lr_installLogo($src_head,$dst_head2);
    75   }
     42    function exec() {
     43        if (md5_file($this->custom_path) != md5_file($this->installed_path)) {
     44            lr_installLogo($this->custom_path, $this->installed_path);
     45        }
     46    }
    7647
    7748}
    7849
    79 function lr_installLogo($src,$dst){
    80     if (is_writable($dst)){
    81         if (file_exists($src)){
    82             if (!copy($src, $dst)) {
    83                 if (DEBUG){
    84                     echo "failed to copy $src...";
    85                 }
    86             }
    87         }else{
    88             if (DEBUG){
    89                 echo 'file not exist';
    90             }
    91         }
    92     }else{
    93         if (DEBUG){
    94             echo 'please make wp-admin directory writable!';
    95         }
    96     }
     50function lr_init() {
     51
     52   
     53    $aImgList = array();
     54    $aImgList[ABSPATH . 'wp-admin/images/logo-login.png'] = LOGO_DIR . 'logo-login.png';
     55    $aImgList[ABSPATH . 'wp-admin/images/logo-login.gif'] = LOGO_DIR . 'logo-login.gif';
     56    $aImgList[ABSPATH . 'wp-admin/images/wp-logo-vs.png'] = LOGO_DIR . 'wp-logo-vs.png';
     57    $aImgList[ABSPATH . 'wp-admin/images/wp-logo.png'] = LOGO_DIR . 'wp-logo.png';
     58    $aImgList[ABSPATH . 'wp-includes/images/admin-bar-sprite.png'] = LOGO_DIR . 'admin-bar-sprite.png';
     59
     60    foreach ($aImgList as $sInstalledPath => $sCustomPath) {       
     61        if (file_exists($sCustomPath)) {
     62            $oLogo = new LRLogoImg($sCustomPath, $sInstalledPath);
     63            $oLogo->exec();
     64        }
     65    }
    9766}
    9867
    99 
     68function lr_installLogo($src, $dst) {
     69    if (is_writable($dst)) {
     70        if (file_exists($src)) {
     71            if (!copy($src, $dst)) {
     72                if (WP_DEBUG) {
     73                    echo "Failed to copy $src...";
     74                }
     75            }
     76        } else {
     77            if (WP_DEBUG) {
     78                echo 'File not exist';
     79            }
     80        }
     81    } else {
     82        if (WP_DEBUG) {
     83            echo 'Please make wp-admin directory writable!';
     84        }
     85    }
     86}
    10087
    10188?>
  • logoreplacer/trunk/readme.txt

    r404671 r558000  
    66Requires at least: 2.0.2
    77Tested up to: 2.1
    8 Stable tag: 1.2
     8Stable tag: 2.0
    99
    1010This plugin replace WP default admin/login/register page.
     
    2020
    21211. Download the .zip file of logoReplacer from the WordPress plugins directory.
    22 1. Unzip it into temp directory, edit logo-login.gif or logo-login.png and wp-logo-vs.png and save with same format.
     221. Unzip it into temp directory, edit all the file in logos directory under plugin directory and save with same format.
    23231. Upload logoReplacer direcotry  into the /wp-content/plugins/
    24241. Activate the plugin through the "Plugins" menu in WordPress.
     
    28281. This is login page with logo modified
    29292. This is the admin page with logo modified
     303. This is the icons and logo of the admin bar modified
    3031
    3132== Changelog ==
     33= 2.0.1 =
     34* Fully rewrited, fix with last wordpress update.
     35* Added admin-bar-sprite.png, now you can change all wp-admin icon bar.
     36
    3237= 1.2.0 =
    3338* Added support for Wordpress 3.2 admin (now login image is a png)
Note: See TracChangeset for help on using the changeset viewer.