WordPress全球使用最广泛的知名开源网站博客程序。WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL 数据库的服务器上架设自己的网志。也可以把WordPress 当作一个内容管理系统CMS来使用,WordPress 还是一个免费的开源项目,在GNU通用公共许可证下授权发布。

WordPress v6更新

WordPress 6.0 包括 500 多项增强功能和 400 项错误修复。本页重点介绍了旨在使您的 WordPress 内容创建和网站建设体验功能更加丰富和直观的几个关键改进。您还将为开发人员和任何想要更深入地了解 WordPress 的人找到资源。

增强的写作体验
无论您是在撰写全新的帖子还是在现有页面中添加元素,写作方面的改进比比皆是。探索更多简化内容创建过程的方法,包括:

跨多个块选择文本并一次编辑它。
键入两个左括号[[以快速访问链接菜单。
当您将某些块从一种类型转换为另一种类型时(例如,从段落块转换为代码块),请保留现有样式。
创建自定义按钮,您制作的任何新按钮都将自动保留样式自定义。
通过更新的设置和控件以及标签云的新轮廓样式,使标签云和社交图标更具吸引力。

风格切换
块主题现在包括包含多种样式变体的选项。这进一步扩展了新的样式系统,并启用了在单个主题中切换站点外观和感觉的快捷方式。您可以更改可用设置(如字体粗细)和样式选项(如默认调色板)。只需单击几下即可更改网站的外观。

更多模板选择
WordPress 6.0 包括五个新的模板选项:作者、日期、类别、标签和分类。这些附加模板为内容创建者提供了更大的灵活性。使用您已经知道的工具或此版本中的以下新选项定制每个工具。

特色图像可用于封面块。

新的特色图像大小控件使您更容易获得所需的结果。

在编辑模板时,在根部或块之间,快速插入器会向您显示模式和模板部分,以帮助您更快地工作并发现新的布局选项。

查询块支持对多个作者进行过滤,支持自定义分类法,并支持自定义没有结果时显示的内容。

集成模式
现在,当您在更多地方需要模式时,例如在快速插入器中或创建新的页眉或页脚时,它们会出现。如果您是块主题作者,您甚至可以使用 注册模式目录中的模式theme.json,使您能够优先考虑对您的主题用户最有帮助的特定模式。

更好的列表视图
新的键盘快捷键使您能够从列表视图中选择多个块,批量修改它们,并将它们拖放到列表中。列表视图可以轻松打开和关闭;默认情况下它是折叠的,只要您选择一个块,它就会自动扩展到当前选择。

块锁定控件
现在你可以锁定你的块了。选择禁用移动块、删除块或两者的选项。这简化了项目移交,让您的客户释放他们的创造力,而不必担心在此过程中意外破坏他们的网站。

其他设计工具
设计工具随着每个版本的发布而变得更加强大和直观。
6.0 的一些亮点包括:

新的彩色面板设计节省了空间,但仍然一目了然地显示您的选择。

新的边框控件提供了一种更简单的方法来完全按照您的喜好设置边框。

颜色的透明度级别允许更多创造性的颜色选择。

在组块中一次控制一组块的间隙、边距、排版等。

在堆栈、行和组变体之间切换以定位具有更大布局灵活性的块组。

使用图库块中的间隙支持功能来创建不同的外观 – 从添加所有图像之间的间距,到完全删除间距。

源码下载地址

官方下载:https://wordpress.org/latest.zip

Github:https://github.com/WordPress/WordPress

官方下载:https://cn.wordpress.org/download/

官方下载:https://cn.wordpress.org/wordpress-latest-zh_CN.zip

官方下载:https://cn.wordpress.org/latest-zh_CN.tar.gz

大家更新主题后,如下优化主题,可根据需要把如下代码加到主题目录functions.php文件中:

/*彻底关闭自动更新(核心程序/主题/插件/翻译自动更新*/
add_filter('automatic_updater_disabled', '__return_true');
/*关闭更新检查定时作业*/
remove_action('init', 'wp_schedule_update_checks');
/*移除已有的版本检查定时作业*/
wp_clear_scheduled_hook('wp_version_check');
/*移除已有的插件更新定时作业*/
wp_clear_scheduled_hook('wp_update_plugins');
/*移除已有的主题更新定时作业*/
wp_clear_scheduled_hook('wp_update_themes');
/*移除已有的自动更新定时作业*/
wp_clear_scheduled_hook('wp_maybe_auto_update');
/*移除后台内核更新检查*/
remove_action( 'admin_init', '_maybe_update_core' );
/*移除后台插件更新检查*/
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
/*移除后台主题更新检查*/
remove_action( 'load-themes.php', 'wp_update_themes' );
remove_action( 'load-update.php', 'wp_update_themes' );
remove_action( 'load-update-core.php', 'wp_update_themes' );
remove_action( 'admin_init', '_maybe_update_themes' );
/*关闭程序更新提示*/
add_filter( 'pre_site_transient_update_core', function($a){ return null; });
/*关闭插件更新提示*/
add_filter('pre_site_transient_update_plugins', function($a){return null;});
/*关闭主题更新提示*/
add_filter('pre_site_transient_update_themes', function($a){return null;});
//关闭WordPress的XML-RPC功能
add_filter('xmlrpc_enabled', '__return_false');
/* 关闭XML-RPC的pingback端口 */
add_filter( 'xmlrpc_methods', 'remove_xmlrpc_pingback_ping' );
function remove_xmlrpc_pingback_ping( $methods ) {
unset( $methods['pingback.ping'] );
return $methods;
}
//禁用 pingbacks, enclosures, trackbacks
remove_action( 'do_pings', 'do_all_pings', 10 );
//去掉 _encloseme 和 do_ping 操作
remove_action( 'publish_post','_publish_post_hook',5 );
/* 禁止加载s.w.org获取表情和头像 */
remove_action('wp_head', 'print_emoji_detection_script', 7 );
remove_action('admin_print_scripts','print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
function remove_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}
return $hints;
}
add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
/* 完全禁止REST API、移除wp-json链接 */
function lerm_disable_rest_api( $access ) {
return new WP_Error(
'Stop!',
'Soooooryyyy',
array(
'status' => 403,
)
);
}
add_filter( 'rest_authentication_errors', 'lerm_disable_rest_api' );
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
/* 禁止查询网站静态资源连接版本字符 */
function _remove_script_version ( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
/* 移除前端网页源代码内的头部冗余代码 */
remove_action( 'wp_head', 'feed_links_extra', 3 ); 
remove_action( 'wp_head', 'rsd_link' ); 
remove_action( 'wp_head', 'wlwmanifest_link' ); 
remove_action( 'wp_head', 'index_rel_link' ); 
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); 
remove_action( 'wp_head', 'wp_generator' ); 
/* 禁止新版文章编辑器加载前端样式 */
function wpassist_remove_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
} 
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
add_action( 'wp_enqueue_scripts', 'wpassist_remove_block_library_css' );
/* 禁用5.5版后自带的XML站点地图 */
add_filter( 'wp_sitemaps_enabled', '__return_false' );
/* 移除前后台顶部工具栏指定菜单 */
function admin_bar_item ( WP_Admin_Bar $admin_bar ) {
$admin_bar->remove_menu('wp-logo'); //移动wp的logo
$admin_bar->remove_menu('site-name'); //移动站点名称
$admin_bar->remove_menu('updates'); //移动更新提示
$admin_bar->remove_menu('comments'); //移动评论提示
/*$admin_bar->remove_menu('new-content'); //移除新建按钮 */ 
}
add_action( 'admin_bar_menu', 'admin_bar_item', 500 );
//移除后台仪表盘站点健康状态面板
add_action('wp_dashboard_setup', 'remove_site_health_dashboard_widget');
function remove_site_health_dashboard_widget()
{
remove_meta_box('dashboard_site_health', 'dashboard', 'normal');
}
//移除后台仪表盘菜单:站点健康状态
add_action( 'admin_menu', 'remove_site_health_menu' ); 
function remove_site_health_menu(){
remove_submenu_page( 'tools.php','site-health.php' ); 
}
//移除后台仪表盘菜单:活动、新闻
function bzg_remove_dashboard_widgets() {
global $wp_meta_boxes;
#移除 "活动" 
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
#移除 "WordPress 新闻" 
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
}
add_action('wp_dashboard_setup', 'bzg_remove_dashboard_widgets' );
//移除后台仪表盘菜单:帮助
function bzg_remove_help() {
get_current_screen()->remove_help_tabs();
}
add_action('admin_head', 'bzg_remove_help');

//移除后台页面title标题的wordpress后缀
add_filter('admin_title', 'delAdminTitle', 10, 2);
function delAdminTitle($admin_title, $title){
return $title.' ‹ '.get_bloginfo('name');
}
//移除登陆页面title标题的wordpress后缀
add_filter('login_title', 'remove_login_title', 10, 2);
function remove_login_title($login_title, $title){
return $title.' ‹ '.get_bloginfo('name');
}
/* 禁用4.4+版本之后的响应式图片功能及缩略图裁剪功能*/
// disable generated image sizes 禁止生成图像尺寸
function zm_customize_image_sizes( $sizes ){
unset( $sizes[ 'thumbnail' ]);
unset( $sizes[ 'medium' ]);
unset( $sizes[ 'medium_large' ] );
unset( $sizes[ 'large' ]);
unset( $sizes[ 'full' ] );
unset( $sizes['1536x1536'] );
unset( $sizes['2048x2048'] );
return $sizes;
}

add_filter( 'intermediate_image_sizes_advanced', 'zm_customize_image_sizes' );

// disable scaled image size 禁止缩放图片尺寸
add_filter('big_image_size_threshold', '__return_false');

// disable other image sizes 禁止生成其它图像尺寸
function shapeSpace_disable_other_image_sizes() { 
// disable images added via set_post_thumbnail_size() 禁止通过set_post_thumbnail_size()函数生成的图片尺寸
remove_image_size('post-thumbnail'); 
// disable any other added image sizes 禁止添加其它图像尺寸
remove_image_size('another-size');
}
add_action('init', 'shapeSpace_disable_other_image_sizes');
//切换经典文章编辑器(v5.x开始默认古腾堡编辑器)
add_filter('use_block_editor_for_post', '__return_false');
//替换评论用户头像链接为国内镜像加速访问
add_filter('get_avatar', function ($avatar) {
return str_replace([
'www.gravatar.com/avatar/',
'0.gravatar.com/avatar/',
'1.gravatar.com/avatar/',
'2.gravatar.com/avatar/',
'secure.gravatar.com/avatar/',
'cn.gravatar.com/avatar/'
], 'gravatar.wp-china-yes.net/', $avatar);
});

//取消内容转义
remove_filter('the_content', 'wptexturize');
//取消摘要转义
remove_filter('the_excerpt', 'wptexturize');
//取消评论转义
remove_filter('comment_text', 'wptexturize');
//禁止转义引号字符
remove_filter('the_content', 'wptexturize'); // 禁止英文引号转义为中文引号

//文章插入图片自动移除 img 的 width、height、class 属性;
add_filter( 'post_thumbnail_html', 'fanly_remove_images_attribute', 10 );
add_filter( 'image_send_to_editor', 'fanly_remove_images_attribute', 10 );
function fanly_remove_images_attribute( $html ) {
//$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
$html = preg_replace( '/width="(\d*)"\s+height="(\d*)"\s+class="[^"]*"/', "", $html );
$html = preg_replace( '/ /', "", $html );
return $html;
}

// 自适应图片删除width和height
function ludou_remove_width_height_attribute($content){
preg_match_all('/<[img|IMG].*?src=[\'|"](.*?(?:[\.gif|\.jpg|\.png\.webp]))[\'|"].*?[\/]?>/', $content, $images);
if(!empty($images)) {
foreach($images[0] as $index => $value){
$new_img = preg_replace('/(width|height)="\d*"\s/', "", $images[0][$index]);
$content = str_replace($images[0][$index], $new_img, $content);
}
}
return $content;
}

// 判断是否是移动设备浏览
if(wp_is_mobile()) {
#删除文章内容中img的width和height属性
add_filter('the_content', 'ludou_remove_width_height_attribute', 99);
}

/* 删除文章时删除图片附件 */

发表回复

后才能评论