Zur Zeit entwickele ich im Rahmen meiner anstehenden Masterarbeit ein eigenständiges Template für Buddypress.
Dies beinhaltet auch eine umgestaltete Adminbar. Bisher habe ich hierzu die admin-bar.css im Ordner bp-core/css/ editiert.
Ich möchte jedoch ein einfaches updaten der Bp-Plugins gewährleisten und ziehe es daher vor nichts an den Bp Dateien zu verändern, sondern alles über Hooks und "custom.php" zu ändern.
Hierfür habe ich ein eigenes plugin geschrieben, welches es mir ermöglicht z.B. das buddypress Adminbar Logo zu ändern, ohne die core Dateien anzufassen:
Hier einmal der Code des Plugins:
<?php
/*
Plugin Name: envicom_adminbar_menu
Plugin URI: -
Description: Creates the Envicom Adminbar without altering the BP admnbar core code.
History: v0.2: 29.03.2008 - Fix for BP RC2 - Introduction of trigger_adminbar_function. adminbar_logo is now in the template image folder.
Author: Jan Wildefeld
Version: 0.2
Author URI: -
*/
add_action('init','i18n_JWAB');
function i18n_JWAB() {
load_muplugin_textdomain('jw_adminbar');
}
// **** Custom BuddyPress admin bar logo with subnav menu ********
function bp_adminbar_custom_logo() {
global $bp;
echo '<li>';
echo '<a href="' . $bp->root_domain . '"><img id="admin-bar-logo" src="' . apply_filters( 'bp_admin_bar_logo_src', BP_PLUGIN_URL . '/bp-core/images/admin_bar_logo.gif' ) . '" alt="' . apply_filters( 'bp_admin_bar_logo_alt_text', __( 'BuddyPress', 'buddypress' ) ) . '" /></a>';
?>
<ul>
<li><a href="<?php echo get_option('home') ?>"><?php _e( 'EnviCom', 'jw_adminbar' ) ?></a></li>
<li class="alt"><a href="#"><?php _e( 'EnviMap', 'jw_adminbar' ) ?></a></li>
<li><a href="#"><?php _e( 'EnviWiki', 'jw_adminbar' ) ?></a></li>
</ul>
</li>
<?php
$doing_admin_bar = false;
}
function bp_adminbar_directories_menu() {
global $bp; ?>
<li class="align-right"><a href="<?php echo get_option('home') ?>"><?php _e( 'Directories ...', 'jw_adminbar' ) ?></a>
<ul>
<li><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li>
<li class="alt"><a href="<?php echo get_option('home') ?>/<?php echo BP_GROUPS_SLUG ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a></li>
<li><a href="<?php echo get_option('home') ?>/<?php echo BP_BLOGS_SLUG ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li>
</ul>
<?php
$doing_admin_bar = false;
}
function trigger_adminbar_hooks(){
remove_action('bp_adminbar_logo', 'bp_adminbar_logo');
add_action('bp_adminbar_menus', 'bp_adminbar_custom_logo', 1 );
add_action('bp_adminbar_menus','bp_adminbar_directories_menu',109);
}
add_action('plugins_loaded','trigger_adminbar_hooks',99);
?>
Alles anzeigen
Meine Frage ist, ob es auch möglich ist die bestehende admin-bar.css Datei per "remove_action" zu entfernen und eine eigene my-admin-bar.css per "add_action", oder ähnlich zu laden?
Die my-admin-bar.css würde ich dann gerne in meinem Theme Ordner speichern.
Meine zweite Frage bezieht sich auf mein admin-bar plugin. Kann ich diesen Code auch in die functions.php auslagern, anstelle es als plugin im mu-plugins zu führen?