[PHP] Code tùy chỉnh thêm cho WordPress – Phần 1

Tắt XML-PRC (Disable XML-RPC)
add_filter( ‘xmlrpc_enabled’, ‘__return_false’ );

Vô hiệu hóa thanh quản trị WP (Disable The WP Admin Bar)
add_filter( ‘show_admin_bar’, ‘__return_false’ );

Tắt số phiên bản của WordPress (WordPress Version Number)
add_filter(‘the_generator’, ‘__return_empty_string’);

Tắt REST API (Disable WordPress REST API)
add_filter(
‘rest_authentication_errors’,
function ( $access ) {
return new WP_Error(
‘rest_disabled’,
__( ‘The WordPress REST API has been disabled.’ ),
array(
‘status’ => rest_authorization_required_code(),
)
);
}
);

Vô hiệu hóa đăng nhập bằng Email (Disable Login by Email)
remove_filter( ‘authenticate’, ‘wp_authenticate_email_password’, 20 );

Tắt tự động cập nhật (Disable Automatic Updates)

// Tắt tự động cập nhật Core (Disable core auto-updates)
add_filter( ‘auto_update_core’, ‘__return_false’ );
// Tắt tự động cập nhật Plugin (Disable auto-updates for plugins).

add_filter( ‘auto_update_plugin’, ‘__return_false’ );
// Tắt tự động cập nhật Theme (Disable auto-updates for themes).

add_filter( ‘auto_update_theme’, ‘__return_false’ );
Thay đổi độ dài trích đoạn của bài viết (Change Excerpt Length)
add_filter(
‘excerpt_length’,
function ( $length ) {
// Number of words to display in the excerpt.
return 40;
},
500
);

Gửi phản hồi