WordPress-向后兼容性

因此, 我正在学习WordPress主题开发, 并在WordPress.org上遇到了一些向后兼容的问题。我去研究了创建部分模板的功能, 例如:wp_body_open()。在此页面上, 他们有评论, 涉及向后兼容性。它们具有如下功能:

<?php 
    if ( function_exists( 'wp_body_open' ) ) {
        wp_body_open();
    } else {
        do_action( 'wp_body_open' );
    }
?>

我有点理解它的作用, 但是, 我想知道如何以及为什么将其视为向后兼容?

提前致谢。


#1


WP 5.2.0中引入了功能wp_body_open()。如果尝试运行将在早期WP上调用wp_body_open()的代码, 将导致致命错误。

你首先提到的代码将检查功能的存在。如果存在, 则调用它。如果不存在, 则仅使用钩子。这样, 即使将代码与较旧的WP一起使用, 也不会引起错误。这就是向后兼容的意思。

来源:

https://www.srcmini02.com/64209.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37503.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?