// Remove default WordPress jquery
wp_deregister_script( 'jquery' );
//Remove jquery migrate
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );
function remove_jquery_migrate( $scripts ) {
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) {
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
Disable Auto-generated Image Sizes
// Disable Auto Generated Images Sizes
add_action('intermediate_image_sizes_advanced', 'disable_image_sizes');
function disable_image_sizes($sizes) {
//unset($sizes['thumbnail']);
//unset($sizes['medium']);
//unset($sizes['large']);
unset($sizes['medium_large']);
unset($sizes['1536x1536']);
unset($sizes['2048x2048']);
return $sizes;
}
add_action('init', 'disable_other_image_sizes');
function disable_other_image_sizes() {
remove_image_size('post-thumbnail');
remove_image_size('another-size');
}
add_filter('big_image_size_threshold', '__return_false');
Add media file size column
Display the file size in a separate column in the Media screen
add_filter( 'manage_upload_columns', function ( $columns ) {
$columns ['file_size'] = esc_html__( 'File size' );
return $columns;
} );
add_action( 'manage_media_custom_column', function ( $column_name, $media_item ) {
if ( 'file_size' !== $column_name || ! wp_attachment_is_image( $media_item ) ) {
return;
}
$filesize = size_format( filesize( get_attached_file( $media_item ) ), 2 );
echo esc_html( $filesize );
}, 10, 2 );
Decrease Auto-Save interval
if ( ! defined( 'AUTOSAVE_INTERVAL' ) ) {
// Change 5 to the number of minutes you want to use.
define( 'AUTOSAVE_INTERVAL', 5 * MINUTE_IN_SECONDS );
}
Disable update notice for Non-admin users
add_action( 'admin_head', function () {
if ( current_user_can( 'update_core' ) ) {
return;
}
remove_action( 'admin_notices', 'update_nag', 3 );
}, 1 );
Disable WordPress Sitemaps
Disable the auto-generated WordPress Sitemaps added in version 5.5.
add_filter('wp_sitemaps_enabled', '__return_false');
Disable the WordPress Shortlink
remove_action('wp_head', 'wp_shortlink_wp_head' );
Add Featured Image column
add_filter( 'manage_posts_columns', function ( $columns ) {
// You can change this to any other position by changing 'title' to the name of the column you want to put it after.
$move_after = 'title';
$move_after_key = array_search( $move_after, array_keys( $columns ), true );
$first_columns = array_slice( $columns, 0, $move_after_key + 1 );
$last_columns = array_slice( $columns, $move_after_key + 1 );
return array_merge(
$first_columns,
array(
'featured_image' => __( 'Featured Image' ),
),
$last_columns
);
} );
add_action( 'manage_posts_custom_column', function ( $column ) {
if ( 'featured_image' === $column ) {
the_post_thumbnail( array( 300, 80 ) );
}
} );
Set a minimum word count for posts
function snipjar_publish_min_words( $post_id, $post ) {
// Edit the line below to set the desired minimum number of words.
$word_count = 100;
if ( str_word_count( $post->post_content ) < $word_count ) {
wp_die(
sprintf(
// Translators: placeholder adds the minimum number of words.
esc_html__( 'The post content is below the minimum word count. Your post needs to have at least %d words to be published.' ),
absint( $word_count )
)
);
}
}
add_action( 'publish_post', 'snipjar_publish_min_words', 9, 2 );
Disable new user email notifications
function snipjar_new_user_notifications( $user_id, $notify = 'user' ) {
if ( empty( $notify ) || 'admin' === $notify ) {
return;
} elseif ( 'both' === $notify ) {
// Send new users the email but not the admin.
$notify = 'user';
}
wp_send_new_user_notifications( $user_id, $notify );
}
add_action(
'init',
function () {
// Disable default email notifications.
remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications' );
// Replace with custom function that only sends to user.
add_action( 'register_new_user', 'snipjar_new_user_notifications' );
add_action( 'edit_user_created_user', 'snipjar_new_user_notifications', 10, 2 );
}
);
Hide ‘Screen Options’ tab
add_filter('screen_options_show_screen', '__return_false');
Remove Login shake animation
add_action( 'login_footer', function () {
remove_action( 'login_footer', 'wp_shake_js', 12 );
} );