很抱歉,根据提供的引用内容,没有找到关于WordPress禁止下载的信息。但是,可以根据引用中提到的防盗链设置来限制其他网站对你的WordPress网站上的图片、视频等资源的下载。具体方法如下:
1. 登录你的WordPress管理后台,进入“外观”-“编辑器”。
2. 找到主题目录下的functions.php文件,将以下代码复制粘贴到文件末尾并保存:
```
function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');
function wpbeginner_remove_wp_seo() {
return '';
}
add_filter('wpseo_generator', 'wpbeginner_remove_wp_seo');
function wpbeginner_remove_x_pingback($headers) {
unset($headers['X-Pingback']);
return $headers;
}
add_filter('wp_headers', 'wpbeginner_remove_x_pingback');
function wpbeginner_disable_embeds_code_init() {
remove_action('rest_api_init', 'wp_oembed_register_route');
add_filter('embed_oembed_discover', '__return_false');
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wp_oembed_add_host_js');
add_filter('tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin');
add_filter('rewrite_rules_array', 'disable_embeds_rewrites');
}
add_action('init', 'wpbeginner_disable_embeds_code_init', 9999);
function disable_embeds_tiny_mce_plugin($plugins) {
return array_diff($plugins, array('wpembed'));
}
function disable_embeds_rewrites($rules) {
foreach($rules as $rule => $rewrite) {
if(false !== strpos($rewrite, 'embed=true')) {
unset($rules[$rule]);
}
}
return $rules;
}
function wpbeginner_remove_comments_rss( $for_comments ) {
return;
}
add_filter('post_comments_feed_link', 'wpbeginner_remove_comments_rss');
function wpbeginner_remove_comments_rss_links() {
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'feed_links', 2);
}
add_action('init', 'wpbeginner_remove_comments_rss_links');
function wpbeginner_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style'));
}
add_action('widgets_init', 'wpbeginner_remove_recent_comments_style');
function wpbeginner_remove_gallery_css($css) {
return preg_replace("#<style type='text/css'>(.*?)</style>#s", '', $css);
}
add_filter('gallery_style', 'wpbeginner_remove_gallery_css');
function wpbeginner_remove_post_type_support() {
remove_post_type_support('post', 'trackbacks');
remove_post_type_support('post', 'comments');
}
add_action('init', 'wpbeginner_remove_post_type_support');
function wpbeginner_remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'wpbeginner_remove_dashboard_widgets');
function wpbeginner_remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('about');
$wp_admin_bar->remove_menu('wporg');
$wp_admin_bar->remove_menu('documentation');
$wp_admin_bar->remove_menu('support-forums');
$wp_admin_bar->remove_menu('feedback');
$wp_admin_bar->remove_menu('comments');
$wp_admin_bar->remove_menu('new-content');
$wp_admin_bar->remove_menu('w3tc');
}
add_action('wp_before_admin_bar_render', 'wpbeginner_remove_admin_bar_links');
function wpbeginner_remove_admin_bar_css() {
wp_enqueue_style('admin-bar', false);
}
add_action('wp_enqueue_scripts', 'wpbeginner_remove_admin_bar_css', 999);
function wpbeginner_remove_dashboard_meta() {
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
remove_meta_box('dashboard_plugins', 'dashboard', 'normal');
remove_meta_box('dashboard_primary', 'dashboard', 'side');
remove_meta_box('dashboard_secondary', 'dashboard', 'normal');
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
}
add_action('admin_init', 'wpbeginner_remove_dashboard_meta');
function wpbeginner_remove_footer_admin() {
echo '';
}
add_filter('admin_footer_text', 'wpbeginner_remove_footer_admin');
function wpbeginner_remove_update_nag() {
remove_action('admin_notices', 'update_nag', 3);
}
add_action('admin_menu', 'wpbeginner_remove_update_nag');
function wpbeginner_remove_dashboard_widgets_init() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'wpbeginner_remove_dashboard_widgets_init');
function wpbeginner_remove_dashboard_meta_init() {
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
remove_meta_box('dashboard_plugins', 'dashboard', 'normal');
remove_meta_box('dashboard_primary', 'dashboard', 'side');
remove_meta_box('dashboard_secondary', 'dashboard', 'normal');
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
}
add_action('admin_init', 'wpbeginner_remove_dashboard_meta_init');
function wpbeginner_remove_footer_admin_init() {
echo '';
}
add_filter('admin_footer_text', 'wpbeginner_remove_footer_admin_init');
function wpbeginner_remove_update_nag_init() {
remove_action('admin_notices', 'update_nag', 3);
}
add_action('admin_menu', 'wpbeginner_remove_update_nag_init');
function wpbeginner_remove_admin_bar_links_init() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('about');
$wp_admin_bar->remove_menu('wporg');
$wp_admin_bar->remove_menu('documentation');
$wp_admin_bar->remove_menu('support-forums');
$wp_admin_bar->remove_menu('feedback');
$wp_admin_bar->remove_menu('comments');
$wp_admin_bar->remove_menu('new-content');
$wp_admin_bar->remove_menu('w3tc');
}
add_action('wp_before_admin_bar_render', 'wpbeginner_remove_admin_bar_links_init');
function wpbeginner_remove_admin_bar_css_init() {
wp_enqueue_style('admin-bar', false);
}
add_action('wp_enqueue_scripts', 'wpbeginner_remove_admin_bar_css_init', 999);
function wpbeginner_remove_comments_rss_init( $for_comments ) {
return;
}
add_filter('post_comments_feed_link', 'wpbeginner_remove_comments_rss_init');
function wpbeginner_remove_comments_rss_links_init() {
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'feed_links', 2);
}
add_action('init', 'wpbeginner_remove_comments_rss_links_init');
function wpbeginner_remove_recent_comments_style_init() {
global $wp_widget_factory;
remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style'));
}
add_action('widgets_init', 'wpbeginner_remove_recent_comments_style_init');
function wpbeginner_remove_gallery_css_init($css) {
return preg_replace("#<style type='text/css'>(.*?)</style>#s", '', $css);
}
add_filter('gallery_style', 'wpbeginner_remove_gallery_css_init');
function wpbeginner_remove_post_type_support_init() {
remove_post_type_support('post', 'trackbacks');
remove_post_type_support('post', 'comments');
}
add_action('init', 'wpbeginner_remove_post_type_support_init');
function wpbeginner_remove_dashboard_widgets_init() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'wpbeginner_remove_dashboard_widgets_init');
function wpbeginner_remove_dashboard_meta_init() {
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
remove_meta_box('dashboard_plugins', 'dashboard', 'normal');
remove_meta_box('dashboard_primary', 'dashboard', 'side');
remove_meta_box('dashboard_secondary', 'dashboard', 'normal');
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
}
add_action('admin_init', 'wpbeginner_remove_dashboard_meta_init');
function wpbeginner_remove_footer_admin_init() {
echo '';
}
add_filter('admin_footer_text', 'wpbeginner_remove_footer_admin_init');
function wpbeginner_remove_update_nag_init() {
remove_action('admin_notices', 'update_nag', 3);
}
add_action('admin_menu', 'wpbeginner_remove_update_nag_init');
function wpbeginner_remove_admin_bar_links_init() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('about');
$wp_admin_bar->remove_menu('wporg');
$wp_admin_bar->remove_menu('documentation');
$wp_admin_bar->remove_menu('support-forums');
$wp_admin_bar->remove_menu('feedback');
$wp_admin_bar->remove_menu('comments');
$wp_admin_bar->remove_menu('new-content');
$wp_admin_bar->remove_menu('w3tc');
}
add_action('wp_before_admin_bar_render', 'wpbeginner_remove_admin_bar_links_init');
function wpbeginner_remove_admin_bar_css_init() {
wp_enqueue_style('admin-bar', false);
}
add_action('wp_enqueue_scripts', 'wpbeginner_remove_admin_bar_css_init', 999);
function wpbeginner_remove_comments_rss_init( $for_comments ) {
return;
}
add_filter('post_comments_feed_link', 'wpbeginner_remove_comments_rss_init');
function wpbeginner_remove_comments_rss_links_init() {
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'feed_links', 2);
}
add_action('init', 'wpbeginner_remove_comments_rss_links_init');
function wpbeginner_remove_recent_comments_style_init() {
global $wp_widget_factory;
remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style'));
}
add_action('widgets_init', 'wpbeginner_remove_recent_comments_style_init');
function wpbeginner_remove_gallery_css_init($css) {
return preg_replace("#<style type='text/css'>(.*?)</style>#s", '', $css);
}
add_filter('gallery_style', 'wpbeginner_remove_gallery_css_init');
function wpbeginner_remove_post_type_support_init() {
remove_post_type_support('