WordPress v6.0.2 开源强大的博客网站程序

WordPress全球使用最广泛的知名开源网站博客程序。WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL 数据库的服务器上架设自己的网志。也可以把WordPress 当作一个内容管理系统CMS来使用,WordPress 还是一个免费的开源项目,在GNU通用公共许可证下授权发布。5.3扩充并改善了从WordPress 5.0开始带来的区块编辑器,为您带来全新的区块、更直觉的交互和改良的无障碍访问。新功能提升了编辑器的设计自由度,为您带来更多布局选项和样式变化,让设计师能够全面控制网站的外观。这次发布也为您带来了二〇二〇主题,给用户带来更多的设计弹性,并与区块编辑器完美整合。现在要建立美观的网页及高级页面布局,是再也简单不过的事了。

使用区块管理小工具
经过数月的努力,现在,区块的强大扩展已经在区块小工具编辑器和定制器中发挥作用,您可以在整个站点的小工具区添加区块,也可通过定制器进行实时预览。从无代码的迷你布局到庞大的核心和第三方区块库,这些都为创建内容开辟了新的可能性。对于我们的开发者而言,您可以在小工具开发说明中找到更多详细信息。

使用全新的区块和区块样板显示文章
查询循环区块可以根据指定的参数显示文章;就像一个没有代码的 PHP 循环。轻松显示特定分类的文章,以执行如创建作品集或包含您最喜欢的食谱的页面之类的操作。您可以将其是为一个更复杂且强大的最新文章区块!此外,样板建议也使创建具有所需设计的文章列表变得前所未有的简单。

编辑文章周围的模板
可通过熟悉的区块编辑器来编辑包含您创作内容的模板–只需激活区块主题或选择一个支持该功能的主题。从编辑文章切换到编辑页面或反之,您都可以使用熟悉的区块编辑器。在兼容此功能的主题中,有超过20个新区块可用。请阅读相关版本说明以了解此功能极其如何使用的更多信息。

页面结构概览
有时您需要一个简单的着陆页面,或者需要网更复杂的方面进行扩展。随着区块的增加、区块样板的出现以及内容创建的简化,就需要新的解决方案来使复杂的内容变得简单化(使其易于浏览)。列表视图是在内容层和嵌套区块之间跳转的最佳方式。由于列表视图提供了内容中所有区块的概览,您现在可以快速的导航到所需的精确区块。准备好完全专注于您的内容了吗?打开或关闭它以适应您的工作流程。

推荐区块样板
从此版本开始,区块样板转换工具将根据您正在使用的区块向您推荐区块样板。您现在可以通过查询区块和社交图标区块试一试。随着更多区块样板的不断增加,您将能够在不离开编辑器的情况下得到如何设计站点样式的灵感!

图片样式化和上色
使用双色调滤镜为您的图片和封面区块上色。双色调可为您的站点设计增添流行色彩,并使图片(或封面区的视频)与您的主题完美融合。以黑白滤镜为例,双色调效果会将阴影取代为黑色、刀光取代为白色,但您可以自行定义双色调的专属阴影和刀光颜色。有关其如何运作的更多信息,在文档中有详细的介绍。

WordPress优化代码添加到主题目录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 ) r e t u r n n u l l ; ) ; / ∗ 关闭插件更新提示 ∗ / a d d f i l t e r ( ′ p r e s i t e t r a n s i e n t u p d a t e p l u g i n s ′ , f u n c t i o n ( a){ return null; }); /*关闭插件更新提示*/ add_filter('pre_site_transient_update_plugins', function( a)returnnull;);/关闭插件更新提示/addfilter(presitetransientupdateplugins,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’); //移动更新提示 a d m i n b a r − > r e m o v e m e n u ( ′ c o m m e n t s ′ ) ; / / 移动评论提示 / ∗ admin_bar->remove_menu('comments'); //移动评论提示 /* adminbar>removemenu(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 KaTeX parse error: Expected 'EOF', got '#' at position 16: wp_meta_boxes; #̲移除 "活动" unset(wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_activity’]); #移除 “WordPress 新闻” unset(KaTeX parse error: Expected 'EOF', got '}' at position 67: …rd_primary']); }̲ add_action('wp…admin_title, $title){ return KaTeX parse error: Expected 'EOF', got '}' at position 35: …ginfo('name'); }̲ //移除登陆页面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 KaTeX parse error: Expected 'EOF', got '}' at position 8: sizes; }̲ add_filter( 'i…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( KaTeX parse error: Expected '}', got 'EOF' at end of input: 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 KaTeX parse error: Expected 'EOF', got '}' at position 7: html; }̲ // 自适应图片删除widt…content){ preg_match_all(’/<[img|IMG].?src='|"[’|“].?[/]?>/‘, $content, i m a g e s ) ; i f ( ! e m p t y ( images); if(!empty( images);if(!empty(images)) { foreach($images[0] as $index => $value){ $new_img = preg_replace(’/(width|height)="\d”\s/', “”, i m a g e s [ 0 ] [ images[0][ images[0][index]); c o n t e n t = s t r r e p l a c e ( content = str_replace( content=strreplace(images[0][$index], $new_img, $content); } } return KaTeX parse error: Expected 'EOF', got '}' at position 10: content; }̲ // 判断是否是移动设备浏览…post_ID) { global $wpdb; #删除特色图片 $thumbnails = $wpdb->get_results( “SELECT * FROM $wpdb->postmeta WHERE meta_key = ‘_thumbnail_id’ AND post_id = $post_ID” ); foreach ( $thumbnails as $thumbnail ) { wp_delete_attachment( $thumbnail->meta_value, true ); } #删除图片附件 $attachments = $wpdb->get_results( “SELECT * FROM $wpdb->posts WHERE post_parent = $post_ID AND post_type = ‘attachment’” ); foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->ID, true ); } $wpdb->query( “DELETE FROM $wpdb->postmeta WHERE meta_key = ‘_thumbnail_id’ AND post_id = $post_ID” ); } add_action(‘before_delete_post’, ‘delete_post_and_attachments’);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿成学长_Cain

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值