• Hi,

    I want to remove the following code from the Admin Panel using Hooks:

    <?php
    $blog_name = get_bloginfo('name', 'display');
    if ( '' == $blog_name ) {
    	$blog_name = '&nbsp;';
    } else {
    	$blog_name_excerpt = wp_html_excerpt($blog_name, 40);
    	if ( $blog_name != $blog_name_excerpt )
    		$blog_name_excerpt = trim($blog_name_excerpt) . '&hellip;';
    	$blog_name = $blog_name_excerpt;
    	unset($blog_name_excerpt);
    }
    $title_class = '';
    if ( function_exists('mb_strlen') ) {
    	if ( mb_strlen($blog_name, 'UTF-8') > 30 )
    		$title_class = 'class="long-title"';
    } else {
    	if ( strlen($blog_name) > 30 )
    		$title_class = 'class="long-title"';
    }
    ?>
    
    <img id="header-logo" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" alt="" width="32" height="32" />
    <h1 id="site-heading" <?php echo $title_class ?>>
    	<a href="<?php echo trailingslashit( get_bloginfo( 'url' ) ); ?>" title="<?php esc_attr_e('Visit Site') ?>">
    		<span id="site-title"><?php echo $blog_name ?></span>
    	</a>
    <?php if ( current_user_can('manage_options') && '1' != get_option('blog_public') ): ?>
    	<a id="privacy-on-link" href="options-privacy.php" title="<?php echo esc_attr( apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') ) ); ?>"><?php echo apply_filters('privacy_on_link_text', __('Search Engines Blocked') ); ?></a>
    <?php endif; ?>
    </h1>

    This is found in the the admin-header.php file in wp-admin. The outputted code is something like this:

    <img height="32" width="32" alt="" src="http://strategycms.com/wp-includes/images/blank.gif" id="header-logo">
    <h1 id="site-heading">
    	<a title="Visit Site" href="http://strategycms.com/">
    		<span id="site-title">Strategy CMS</span>
    	</a>
    </h1>
    
    <div id="wphead-info">
    <div id="user_info">
    <p>Howdy, <a title="Edit your profile" href="profile.php">Moshe</a> | <a title="Log Out" href="http://strategycms.com/wp-login.php?action=logout&_wpnonce=32e0c01265">Log Out</a></p>
    </div>
    
    <div id="favorite-actions"><div id="favorite-first"><a href="post-new.php">New Post</a></div><div id="favorite-toggle"><br></div><div id="favorite-inside" style="width: 126px;"><div class="favorite-action"><a href="edit.php?post_status=draft">Drafts</a></div>
    <div class="favorite-action"><a href="post-new.php?post_type=page">New Page</a></div>
    <div class="favorite-action"><a href="media-new.php">Upload</a></div>
    <div class="favorite-action"><a href="edit-comments.php">Comments</a></div>
    </div></div>
    </div>

    Is this possible? If so, how would I do it?

    Thanks and be well,

    Moshe

Viewing 8 replies - 1 through 8 (of 8 total)
  • Looks like you want to add a custom logo you administration page? If so, please try this code in your theme’s functions.php or a custom plugin:

    //hook the administrative header output
        add_action('admin_head', 'my_custom_logo');
    
        function my_custom_logo() {
        echo '
        <style type="text/css">
        #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }
        </style>
        ';
        }

    If you want to tweak the Favorites menu, code like the following is in order:

    add_filter('favorite_actions', 'custom_favorites');
    function custom_favorites($actions) {
            $actions['options.php'] = array('All Settings', 'unfiltered_html');
            return $actions;
    }

    That custom logo thing is great!

    Very simple solution that I found a few weeks ago. I love it too! Can’t take credit though 🙂

    Thread Starter strategy-web-designs

    (@strategy-web-designs)

    Thanks for your response.

    I actually want to do something else – I want to rearrange the order of the code in the admin section. I want to do that, though, without actually editing the core files. I have managed to add in new code where I want to via hooks, but I can’t see a way to remove the above code via hooks. In essence, I want to be able to relocate and/or delete the code I mentioned above.

    I am somewhat new to using functions and hooks so I don’t know if what I want to do is possible.

    Thanks and be well,

    Moshe

    Perhaps if you could explain your situation in more detail, i might be able to help.

    Thread Starter strategy-web-designs

    (@strategy-web-designs)

    Hello,

    Basically, I just want to know how to remove the above code without touching the core files. Is that possible? If so, how.

    Thanks for your help.

    All the best,

    Moshe

    I don’t really know what to tell you, there are no readily available hooks that I can find. There may be some kind of secret trick that I do not know about. Have you considered using css or javascript to hide the elements?

    Thread Starter strategy-web-designs

    (@strategy-web-designs)

    Hell Michael,

    Thanks for taking the time to help me with this. You have given me the answer that I needed. It seems that this is not possible vis-a-vis hooks – that’s what I wanted to know.

    I have, therefore, hidden the elements via CSS.

    Thanks again,

    Moshe

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to Remove or Replace Code from the Admin Panel’ is closed to new replies.