Use these snippets to modify your WordPress experience. Snippets can be added using a snippet plugin like Code Snippets, WPCode, or WPCodeBox (premium). More will be added over time.

Add Manage Patterns in the Appearance admin menu in classic themes.

No longer needed. Part of WordPress 6.5.
function add_manage_patterns_menu() {
    add_submenu_page(
        'themes.php', // Parent slug for Appearance menu
        'Manage Patterns', // Page title
        'Manage Patterns', // Menu title
        'edit_theme_options', // Capability
        'edit.php?post_type=wp_block' // Menu slug
    );
}

add_action('admin_menu', 'add_manage_patterns_menu');

Add Last Updated column to plugins list, highlight plugins not updated in 6 months

// Add the custom column header
add_filter('manage_plugins_columns', 'add_last_updated_column');
function add_last_updated_column($columns) {
    $new_columns = array();

    foreach ($columns as $key => $label) {
        // Add the 'Last Updated' column after the 'Plugin' column
        $new_columns[$key] = $label;

        if ($key === 'name') { // 'name' is the column ID for 'Plugin'
            $new_columns['last_updated'] = __('Last Updated', 'your-text-domain');
        }
    }

    return $new_columns;
}

// Set width of Last Updated column
add_action('admin_head', 'custom_admin_styles');
function custom_admin_styles() {
    echo '<style>
        .wp-list-table .column-last_updated {
            width: 140px; /* or any other width, to avoid wrapping */
            white-space: nowrap;
        }
    </style>';
}

// Populate the Last Updated column
add_action('manage_plugins_custom_column', 'show_last_updated_column', 10, 3);
function show_last_updated_column($column_name, $plugin_file, $plugin_data) {
    if ($column_name === 'last_updated') {
        // Fetch data from WordPress.org API
        $response = wp_remote_get('https://api.wordpress.org/plugins/info/1.0/' . dirname($plugin_file) . '.json');

        if (is_wp_error($response)) {
            echo __('Unavailable', 'your-text-domain');
        } else {
            $plugin_info = json_decode(wp_remote_retrieve_body($response), true);
            if (!empty($plugin_info) && isset($plugin_info['last_updated'])) {
                $last_updated = strtotime($plugin_info['last_updated']);
                $current_time = current_time('timestamp');
                $six_months_ago = strtotime('-6 months', $current_time);

                if ($last_updated < $six_months_ago) {
                    // More than six months ago, make it bold and red
                    echo '<span style="font-weight: bold; color: red;">' . date('Y-m-d', $last_updated) . '</span>';
                } else {
                    // Less than six months ago, display normally
                    echo date('Y-m-d', $last_updated);
                }
            } else {
                echo __('Not found', 'your-text-domain');
            }
        }
    }
}

Show Alt text and display larger thumbnail in media library list

// Add thumbnail and alt text columns to media library list
function custom_media_columns($columns) {
    $columns['thumb'] = __('Thumbnail', 'text_domain');
    $columns['alt_text'] = __('Alt Text', 'text_domain');
    return $columns;
}
add_filter('manage_media_columns', 'custom_media_columns');

// Display thumbnail and alt text columns in media library list
function custom_media_column_content($column_name, $id) {
    if ($column_name === 'thumb') {
        $image = wp_get_attachment_image_src($id, 'medium');
        $edit_url = get_edit_post_link($id);
        echo '<a href="' . esc_url($edit_url) . '"><img src="' . esc_attr($image[0]) . '" style="max-width: 150px; height: auto;" /></a>';
    }
    elseif ($column_name === 'alt_text') {
        $alt = get_post_meta($id, '_wp_attachment_image_alt', true);
        if (!empty($alt)) {
            echo esc_html($alt);
        } else {
            echo '<em>' . __('No Alt Text', 'text_domain') . '</em>';
        }
    }
}
add_filter('manage_media_custom_column', 'custom_media_column_content', 10, 2);

// Set column width for thumbnail
function custom_media_column_width($defaults) {
    $defaults['thumb'] = 'Thumb 150';
    return $defaults;
}
add_filter('manage_media_columns', 'custom_media_column_width');

add_action('admin_head', 'custom_admin_media_styles');
function custom_admin_media_styles() {
    echo '<style>.media-icon {display: none !important;}</style>';
}