MuLeI
做创造价值的人
MuLeI的小站

WordPress4.9.4之后版本添加ICP备案号显示

WordPress4.9.4之后版本添加ICP备案号显示
  • 修改wp-config.php文件

站点根目录下找到wp-config.php 文件,在合适的位置添加代码:

define( 'WP_ZH_CN_ICP_NUM', true);
  • 在wp-content/languages/路径下添加zh_CN.php文件

zh_CN.php文件内容:

',
		esc_attr( matches['video_id'] ) );

	return apply_filters( 'embed_tudou',embed, matches,attr, url,rawattr );
}
wp_embed_register_handler( 'tudou',
	'#https?://(?:www\.)?tudou\.com/(?:programs/view|listplay/(?[a-z0-9_=\-]+))/(?[a-z0-9_=\-]+)#i',
	'wp_embed_handler_tudou' );


/**
 * 56.com wp_embed handler
 *
 * Embed code last updated:
 *  Tue, 05 Jun 2012 23:03:29 -0400
 *
 * Feel free to submit or correct URL formats here:
 *  http://cn.wordpress.org/contact/
 *
 * @since 3.4.0
 */
function wp_embed_handler_56com( matches,attr, url,rawattr ) {
	matches['video_id'] =matches['video_id1'] == '' ?
		matches['video_id2'] :matches['video_id1'];

	$embed = sprintf(
		"",
		esc_attr( matches['video_id'] ) );

	return apply_filters( 'embed_56com',embed, matches,attr, url,rawattr );
}
wp_embed_register_handler( '56com',
	'#https?://(?:www\.)?56\.com/[a-z0-9]+/(?:play_album\-aid\-[0-9]+_vid\-(?[a-z0-9_=\-]+)|v_(?[a-z0-9_=\-]+))#i',
	'wp_embed_handler_56com' );


/**
 * Youku wp_embed handler
 *
 * Embed code last updated:
 *  Wed, 06 Jun 2012 00:36:11 -0400
 *
 * Feel free to submit or correct URL formats here:
 *  http://cn.wordpress.org/contact/
 *
 * @since 3.4.0
 */
function wp_embed_handler_youku( matches,attr, url,rawattr ) {
	$embed = sprintf(
		'',
		esc_attr( matches['video_id'] ) );

	return apply_filters( 'embed_youku',embed, matches,attr, url,rawattr );
}
wp_embed_register_handler( 'youku',
	'#https?://v\.youku\.com/v_show/id_(?[a-z0-9_=\-]+)#i',
	'wp_embed_handler_youku' );


/**
 * 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 '' .
		'

仅对WordPress自带主题有效。

'; } 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 '' . esc_attr( get_option( 'zh_cn_l10n_icp_num' ) ) . "\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' ); ?>
  • 在设置->常规中填写备案号,刷新首页即可看到~
本博客所有文章除特别声明外,均采用CC BY-SA 4.0 协议,转载请注明出处!

发表回复

textsms
account_circle
email

MuLeI的小站

WordPress4.9.4之后版本添加ICP备案号显示
WordPress4.9.4之后版本添加ICP备案号显示
扫描二维码继续阅读
2021-03-06