[wp-meta] [Making WordPress.org] #7824: Localized installation packages issues
Making WordPress.org
noreply at wordpress.org
Thu Nov 14 17:15:59 UTC 2024
#7824: Localized installation packages issues
-------------------------------------------+---------------------
Reporter: haozi | Owner: (none)
Type: defect (bug) | Status: new
Priority: high | Milestone:
Component: International Sites (Rosetta) | Resolution:
Keywords: |
-------------------------------------------+---------------------
Comment (by haozi):
According to the manual [https://make.wordpress.org/polyglots/handbook
/for-editors/packaging-localized-wordpress/automated-release-packages
/#minor-custom-changes-for-the-current-stable-version] description, {{{wp-
content/languages/$locale.php}}} file will not be automatically packaged
in.
However, the Chinese team version uses this file to meet government
compliance requirements and provide video embedding for websites in
mainland China that do not support oEmbed.
Can Meta team fix this to allow {{{wp-content/languages/$locale.php}}} to
be packaged into core (like {{{wp-config-simple.php}}} etc)?
The following is the content of the {{{wp-content/languages/zh_CN.php}}}
file created by Chinese team in previous versions:
{{{#!php
<?php
/**
* WordPress 简体中文本地化支持
*
* @since 6.5.0
* @updated 2024-04-13
*/
defined( 'ABSPATH' ) || exit;
/**
* 哔哩哔哩嵌入
*
* @since 6.5.0
*/
function cn_embed_handler_bilibili( $matches, $attr, $url, $rawattr ) {
$width = "100%";
$height = 500;
if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] )
) {
$width = $rawattr['width'];
$height = $rawattr['height'];
}
$av = $matches['id'];
$bv = $matches['id'];
if ( strpos( $matches['id'], 'BV' ) === 0 ) {
$av = "";
} else {
$av = substr( $av, 2 );
$bv = "";
}
$embed = sprintf(
'<iframe
src="//player.bilibili.com/player.html?aid=%1$s&bvid=%2$s&p=1"
width="%3$s" height="%4$s" frameborder="0" allowfullscreen></iframe>',
esc_attr( $av ), esc_attr( $bv ), esc_attr( $width ),
esc_attr( $height ) );
return apply_filters( 'embed_bilibili', $embed, $matches, $attr,
$url, $rawattr );
}
wp_embed_register_handler( 'bilibili',
'#https?://(?:www\.)?bilibili\.com/video/(?<id>[A-Za-z0-9]+)#i',
'cn_embed_handler_bilibili' );
/**
* 优酷视频嵌入
*
* @since 6.5.0
*/
function cn_embed_handler_youku( $matches, $attr, $url, $rawattr ) {
$width = "100%";
$height = 500;
if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] )
) {
$width = $rawattr['width'];
$height = $rawattr['height'];
}
$embed = sprintf(
'<iframe src="//player.youku.com/embed/%1$s" width="%2$s"
height="%3$s" frameborder="0" allowfullscreen></iframe>',
esc_attr( $matches['id'] ), esc_attr( $width ), esc_attr(
$height ) );
return apply_filters( 'embed_youku', $embed, $matches, $attr,
$url, $rawattr );
}
wp_embed_register_handler( 'youku',
'#https?://v\.youku\.com/v_show/id_(?<id>[A-Za-z0-9=]+).html#i',
'cn_embed_handler_youku' );
/**
* 腾讯视频嵌入
*
* @since 6.5.0
*/
function cn_embed_handler_qq( $matches, $attr, $url, $rawattr ) {
$width = "100%";
$height = 500;
if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] )
) {
$width = $rawattr['width'];
$height = $rawattr['height'];
}
$embed = sprintf(
'<iframe src="//v.qq.com/txp/iframe/player.html?vid=%1$s"
width="%2$s" height="%3$s" frameborder="0" allowfullscreen></iframe>',
esc_attr( $matches['id'] ), esc_attr( $width ), esc_attr(
$height ) );
return apply_filters( 'embed_qq', $embed, $matches, $attr, $url,
$rawattr );
}
wp_embed_register_handler( 'qq',
'#https?://v\.qq\.com/x/page/(?<id>[A-Za-z0-9]+)\.html#i',
'cn_embed_handler_qq' );
/**
* ICP 备案号及公安备案号
*
* 为了遵守电信管理条例。可以在 wp-config.php 中关闭。
*
* @since 6.5.0
*/
function cn_settings_init() {
if ( defined( 'CN_ICP' ) && CN_ICP ) {
add_settings_field( 'cn_icp',
'ICP 备案号',
'cn_icp_callback',
'general' );
register_setting( 'general', 'cn_icp' );
}
if ( defined( 'CN_GA' ) && CN_GA ) {
add_settings_field( 'cn_ga',
'公安备案号',
'cn_ga_callback',
'general' );
register_setting( 'general', 'cn_ga' );
}
}
add_action( 'admin_init', 'cn_settings_init' );
function cn_icp_callback() {
echo sprintf(
'<input name="cn_icp" type="text" id="cn_icp" value="%s"
class="regular-text ltr" />' .
'<p class="description">仅对部分支持的主题生效。</p>',
esc_attr( get_option( 'cn_icp' ) )
);
}
function cn_ga_callback() {
echo sprintf(
'<input name="cn_ga" type="text" id="cn_ga" value="%s"
class="regular-text ltr" />' .
'<p class="description">仅对部分支持的主题生效(需自行添加
公安图标)。</p>',
esc_attr( get_option( 'cn_ga' ) )
);
}
// 带链接的 ICP 备案号
function cn_icp(): string {
if ( defined( 'CN_ICP' ) && CN_ICP &&
get_option( 'cn_icp' ) ) {
return sprintf(
'<a target="_blank"
href="https://beian.miit.gov.cn/" rel="nofollow">%s</a>',
esc_attr( get_option( 'cn_icp' ) )
);
}
return '';
}
// 纯文本 ICP 备案号
function cn_icp_text(): string {
if ( defined( 'CN_ICP' ) && CN_ICP &&
get_option( 'cn_icp' ) ) {
return esc_attr( get_option( 'cn_icp' ) );
}
return '';
}
// 带链接的公安备案号
function cn_ga(): string {
if ( defined( 'CN_GA' ) && CN_GA &&
get_option( 'cn_ga' ) ) {
$ga = preg_replace( '/\D/', '', get_option( 'cn_ga' ) );
return sprintf(
'<a target="_blank"
href="https://beian.mps.gov.cn/#/query/webSearch?code=%s"
rel="nofollow">%s</a>',
esc_attr( $ga ),
esc_attr( get_option( 'cn_ga' ) )
);
}
return '';
}
// 纯文本公安备案号
function cn_ga_text(): string {
if ( defined( 'CN_GA' ) && CN_GA &&
get_option( 'cn_ga' ) ) {
return esc_attr( get_option( 'cn_ga' ) );
}
return '';
}
// 注册简码
add_shortcode( 'cn_icp', 'cn_icp' );
add_shortcode( 'cn_icp_text', 'cn_icp_text' );
add_shortcode( 'cn_ga', 'cn_ga' );
add_shortcode( 'cn_ga_text', 'cn_ga_text' );
}}}
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/7824#comment:1>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list