Stigmahost - web hosting company

10 Κώδικες Για Το functions.php Ωστε Να Κάνετε Manage Το WordPress Admin Σας



Εάν είστε προγραμματιστής είναι πρακτικό να καταγράφετε διάφορα κομμάτια κώδικα που μπορείτε να προσθέσετε στο αρχείο functions.php του template σας, ώστε να μπορείτε να τα χρησιμοποιήσετε ξανά. Σε αυτό το post υπάρχει μία σειρά από πράγματα που μπορείτε να χρησιμοποιήσετε για να ελέγξετε την περιοχή του admin.

1. Enable Hidden Admin Feature displaying ALL Site Settings

 

// CUSTOM ADMIN MENU LINK FOR ALL SETTINGS

   function all_settings_link() {
    add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php');
   }
   add_action('admin_menu', 'all_settings_link');

Source

2. Remove Update Notification for all users except Admins.

// REMOVE THE WORDPRESS UPDATE NOTIFICATION FOR ALL USERS EXCEPT SYSADMIN
       global $user_login;
       get_currentuserinfo();
       if (!current_user_can('update_plugins')) { // checks to see if current user can update plugins
        add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
        add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
       }

Source

3. Modify the Login Logo & Image URL Link

// CUSTOM ADMIN LOGIN HEADER LOGO
   function my_custom_login_logo() {
echo '';
   }
   add_action('login_head', 'my_custom_login_logo');
// CUSTOM ADMIN LOGIN HEADER LINK & ALT TEXT
   function change_wp_login_url() {
    echo bloginfo('url');  // OR ECHO YOUR OWN URL
   }
   function change_wp_login_title() {
    echo get_option('blogname'); // OR ECHO YOUR OWN ALT TEXT
   }
   add_filter('login_headerurl', 'change_wp_login_url');
   add_filter('login_headertitle', 'change_wp_login_title');

Source

4. Customize the order of the admin menu

// CUSTOMIZE ADMIN MENU ORDER
   function custom_menu_order($menu_ord) {
       if (!$menu_ord) return true;
       return array(
        'index.php', // this represents the dashboard link
        'edit.php?post_type=events', // this is a custom post type menu
        'edit.php?post_type=news',
        'edit.php?post_type=articles',
        'edit.php?post_type=faqs',
        'edit.php?post_type=mentors',
        'edit.php?post_type=testimonials',
        'edit.php?post_type=services',
        'edit.php?post_type=page', // this is the default page menu
        'edit.php', // this is the default POST admin menu
    );
   }
   add_filter('custom_menu_order', 'custom_menu_order');
   add_filter('menu_order', 'custom_menu_order');

Source

5. Remove unwanted dashboard items

add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
function my_custom_dashboard_widgets() {
global $wp_meta_boxes;
 //Right Now - Comments, Posts, Pages at a glance
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
//Recent Comments
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
//Incoming Links
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
//Plugins - Popular, New and Recently updated WordPress Plugins
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
//Wordpress Development Blog Feed
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
//Other WordPress News Feed
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
//Quick Press Form
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
//Recent Drafts List
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
}

Source

6. WordPress Custom Admin Footer

// customize admin footer text
function custom_admin_footer() {
        echo 'add your custom footer text and html here';
}
add_filter('admin_footer_text', 'custom_admin_footer');

Source

7. Custom Dashboard CSS.

/* Change WordPress dashboard CSS */
function custom_admin_styles() {
    echo '<style type="text/css">#wphead{background:#069}</style>';
}
add_action('admin_head', 'custom_admin_styles');

Source

8. Post Word Count

Προσθέτει μια μέτρηση του συνόλου των λέξεων που δημοσιεύθηκαν στο κάτω μέρος του «Right Now» στον πίνακα ελέγχου διαχειριστή

function post_word_count() {
    $count = 0;
    $posts = get_posts( array(
        'numberposts' => -1,
        'post_type' => array( 'post', 'page' )
    ));
    foreach( $posts as $post ) {
        $count += str_word_count( strip_tags( get_post_field( 'post_content', $post->ID )));
    }
    $num =  number_format_i18n( $count );
    // This block will add your word count to the stats portion of the Right Now box
    $text = _n( 'Word', 'Words', $num );
    echo "<tr><td class='first b'>{$num}</td><td class='t'>{$text}</td></tr>";
    // This line will add your word count to the bottom of the Right Now box.
    echo '<p>This blog contains a total of <strong>' . $num . '</strong> published words!</p>';
}
// add to Content Stats table
add_action( 'right_now_content_table_end', 'post_word_count');
// add to bottom of Activity Box
add_action('activity_box_end', 'post_word_count');

Source

9. Remove WP 3.1 Admin Bar

remove_action('init', 'wp_admin_bar_init');

Source

10. Add custom links to WordPress admin bar

function mytheme_admin_bar_render() {
	global $wp_admin_bar;
	$wp_admin_bar->add_menu( array(
		'parent' => 'new-content', // use 'false' for a root menu, or pass the ID of the parent menu
		'id' => 'new_media', // link ID, defaults to a sanitized title value
		'title' => __('Media'), // link title
		'href' => admin_url( 'media-new.php'), // name of file
		'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
	));
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );

Source


Κατηγορίες Tips & Tricks, Διάφορα | Από τον zeoz

Κανένα σχόλιο

Κανάλι σχολίων

Δεν υπάρχουν σχόλια σε αυτό το άρθρο


Ετικέτες που επιτρέπονται: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

 

^
Top
CSS Design Awards