Skip to content

Instantly share code, notes, and snippets.

View Lego2012's full-sized avatar

Leo Merkel Lego2012

View GitHub Profile

Steps to customize the admin columns

Add columns

You can use WordPress hooks such as manage_posts_columns or manage_${post_type}_posts_columns to customize the standard columns. For example, to add a new column for the post type “Books”, the code looks like this:

function my_custom_book_columns($columns) {
    // Neue Spalte hinzufügen
    $columns['book_author'] = __('Autor');
    return $columns;
}
$post_type = 'my_post_type';
// Register the columns.
add_filter( "manage_{$post_type}_posts_columns", function ( $defaults ) {
$defaults['custom-one'] = 'Custom One';
$defaults['custom-two'] = 'Custom Two';
return $defaults;
}
);
function redirect_after_logout(){
wp_redirect( home_url() );
exit();
}
add_action('wp_logout', 'redirect_after_logout');
// Remove WordPress Dashboard Widgets
function bt_remove_dashboard_widgets() {
remove_action( 'welcome_panel', 'wp_welcome_panel' ); // Welcome Panel
remove_meta_box( 'dashboard_site_health', 'dashboard', 'normal' ); // Remove Health
remove_meta_box( 'duplicator_dashboard_widget', 'dashboard', 'normal' ); // Remove Duplicator
remove_meta_box( 'wsf_dashboard_widget', 'dashboard', 'normal' ); // Remove WS Form
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); // Quick Press Widget
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); // Right now
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); // WordPress.com Blog
// Befreit den Header von unnötigen Einträgen
// https://www.drweb.de/wordpress-snippets/
add_action('init', 'evolution_remheadlink');
function evolution_remheadlink()
{
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
// Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
function rd_duplicate_post_as_draft()
{
if (!current_user_can("edit_posts")) {
return;
}
/*
* Nonce verification
add_filter("the_content", "add_image_dimensions");
function add_image_dimensions($content)
{
preg_match_all("/<img[^>]+>/i", $content, $images);
if (count($images) < 1) {
return $content;
}
// Ein neues Logo für den Adminbereich und eine eigene Hintergrundfarbe
// @author Andreas Hecht
// https://www.drweb.de/wordpress-snippets/
function ah_login_logo() {
?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/dein-logo.png);
margin-bottom: 0;
add_theme_support( 'post-thumbnails' );
add_image_size( 'image-480', 480, 9999 );
add_image_size( 'image-640', 640, 9999 );
add_image_size( 'image-720', 720, 9999 );
add_image_size( 'image-960', 960, 9999 );
add_image_size( 'image-1168', 1168, 9999 );
add_image_size( 'image-1440', 1440, 9999 );
add_image_size( 'image-1920', 1920, 9999 );
function my_custom_sizes( $sizes ) {