问题:
仪表盘里【设置-常规】,滑倒最下面的“ICP备案号”在5.0.0及以后的wordpress版本里没有显示。
解决方案:
- 文件
wp-content/languages/zh_CN.php
缺失,内容在后面附上。 - 在
wp-config.php
中添加define('WP_ZH_CN_ICP_NUM', true);
- 在自己使用的主题的页脚文件
footer.php
里合适的位置加上
<a href="http://beian.miit.gov.cn" rel="external nofollow noopener noreferrer" target="_blank"><?php echo get_option( 'zh_cn_l10n_icp_num' );?></a>
- 刷新仪表盘,【设置-常规】里出现了ICP备案号,填入刷新网页即可。
附上zh_CN.php:
<?php
/**
* WordPress China Localization Patches Collection
*/
/**
* Legacy database options cleanup
*
* Cleanup of all options that were introduced pre-3.4.
* To save time, this function is only to be called on admin pages.
*
* @since 3.4.0
*/
function zh_cn_l10n_legacy_option_cleanup() {
// 3.3 series
delete_site_option( 'zh_cn_l10n_preference_patches' );
// 3.0.5, 3.1 series, 3.2 series
delete_site_option( 'zh_cn_language_pack_enable_chinese_fake_oembed' );
// 3.0.1, 3.0.2, 3.0.3, 3.0.4
delete_site_option( 'zh_cn_language_pack_options_version' );
delete_site_option( 'zh_cn_language_pack_enable_backend_style_modifications' );
// awkward ones...
delete_site_option( 'zh_cn_language_pack_enable_icpip_num_show' );
delete_site_option( 'zh_cn_language_pack_icpip_num' );
delete_site_option( 'zh_cn_language_pack_is_configured' );
}
add_action( 'admin_init', 'zh_cn_l10n_legacy_option_cleanup' );
/**
* ICP license number
*
* For compliance with the Telecommunications Regulations. Can be turned off
* in wp-config.php.
*
* @since 3.7.0
*/
function zh_cn_l10n_settings_init() {
if ( defined( 'WP_ZH_CN_ICP_NUM' ) && WP_ZH_CN_ICP_NUM ) {
add_settings_field( 'zh_cn_l10n_icp_num',
'ICP备案号',
'zh_cn_l10n_icp_num_callback',
'general' );
register_setting( 'general', 'zh_cn_l10n_icp_num' );
}
}
add_action( 'admin_init', 'zh_cn_l10n_settings_init' );
function zh_cn_l10n_icp_num_callback() {
echo '<input name="zh_cn_l10n_icp_num" type="text" ' .
'id="zh_cn_l10n_icp_num" value="' .
esc_attr( get_option( 'zh_cn_l10n_icp_num' ) ) .
'" class="regluar-text ltr" />' .
'<p class="description">仅对WordPress自带主题有效。</p>';
}
function zh_cn_l10n_icp_num( $content ) {
if ( defined( 'WP_ZH_CN_ICP_NUM' ) && WP_ZH_CN_ICP_NUM &&
get_option( 'zh_cn_l10n_icp_num' ) ) {
echo '<a href="http://beian.miit.gov.cn/" rel="nofollow" ' .
'title="工业和信息化部ICP/IP地址/域名信息备案管理系统">' .
esc_attr( get_option( 'zh_cn_l10n_icp_num' ) ) .
"</a>\n";
}
}
add_action( 'twentyten_credits', 'zh_cn_l10n_icp_num' );
add_action( 'twentyeleven_credits', 'zh_cn_l10n_icp_num' );
add_action( 'twentytwelve_credits', 'zh_cn_l10n_icp_num' );
add_action( 'twentythirteen_credits', 'zh_cn_l10n_icp_num' );
add_action( 'twentyfourteen_credits', 'zh_cn_l10n_icp_num' );
add_action( 'twentyfifteen_credits', 'zh_cn_l10n_icp_num' );
add_action( 'twentysixteen_credits', 'zh_cn_l10n_icp_num' );
add_action( 'twentyseventeen_credits', 'zh_cn_l10n_icp_num' );
?>
Comments | 2 条评论
这样设置会不会对wordpress整体环境造成未知的影响啊?望告知谢谢