25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

151 lines
4.8 KiB

  1. <?php
  2. /**
  3. * WordPress China Localization Patches Collection
  4. */
  5. /**
  6. * Legacy database options cleanup
  7. *
  8. * Cleanup of all options that were introduced pre-3.4.
  9. * To save time, this function is only to be called on admin pages.
  10. *
  11. * @since 3.4.0
  12. */
  13. function zh_cn_l10n_legacy_option_cleanup() {
  14. // 3.3 series
  15. delete_site_option( 'zh_cn_l10n_preference_patches' );
  16. // 3.0.5, 3.1 series, 3.2 series
  17. delete_site_option( 'zh_cn_language_pack_enable_chinese_fake_oembed' );
  18. // 3.0.1, 3.0.2, 3.0.3, 3.0.4
  19. delete_site_option( 'zh_cn_language_pack_options_version' );
  20. delete_site_option( 'zh_cn_language_pack_enable_backend_style_modifications' );
  21. // awkward ones...
  22. delete_site_option( 'zh_cn_language_pack_enable_icpip_num_show' );
  23. delete_site_option( 'zh_cn_language_pack_icpip_num' );
  24. delete_site_option( 'zh_cn_language_pack_is_configured' );
  25. }
  26. add_action( 'admin_init', 'zh_cn_l10n_legacy_option_cleanup' );
  27. /**
  28. * Tudou wp_embed handler
  29. *
  30. * Embed code last updated:
  31. * Tue, 05 Jun 2012 22:23:03 -0400
  32. *
  33. * Feel free to submit or correct URL formats here:
  34. * http://cn.wordpress.org/contact/
  35. *
  36. * @since 3.4.0
  37. */
  38. function wp_embed_handler_tudou( $matches, $attr, $url, $rawattr ) {
  39. $embed = sprintf(
  40. '<embed src="http://www.tudou.com/v/%1$s/&resourceId=0_05_05_99&bid=05/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="480" height="400"></embed>',
  41. esc_attr( $matches['video_id'] ) );
  42. return apply_filters( 'embed_tudou', $embed, $matches, $attr, $url, $rawattr );
  43. }
  44. wp_embed_register_handler( 'tudou',
  45. '#https?://(?:www\.)?tudou\.com/(?:programs/view|listplay/(?<list_id>[a-z0-9_=\-]+))/(?<video_id>[a-z0-9_=\-]+)#i',
  46. 'wp_embed_handler_tudou' );
  47. /**
  48. * 56.com wp_embed handler
  49. *
  50. * Embed code last updated:
  51. * Tue, 05 Jun 2012 23:03:29 -0400
  52. *
  53. * Feel free to submit or correct URL formats here:
  54. * http://cn.wordpress.org/contact/
  55. *
  56. * @since 3.4.0
  57. */
  58. function wp_embed_handler_56com( $matches, $attr, $url, $rawattr ) {
  59. $matches['video_id'] = $matches['video_id1'] == '' ?
  60. $matches['video_id2'] : $matches['video_id1'];
  61. $embed = sprintf(
  62. "<embed src='http://player.56.com/v_%1\$s.swf' type='application/x-shockwave-flash' width='480' height='405' allowFullScreen='true' allowNetworking='all' allowScriptAccess='always'></embed>",
  63. esc_attr( $matches['video_id'] ) );
  64. return apply_filters( 'embed_56com', $embed, $matches, $attr, $url, $rawattr );
  65. }
  66. wp_embed_register_handler( '56com',
  67. '#https?://(?:www\.)?56\.com/[a-z0-9]+/(?:play_album\-aid\-[0-9]+_vid\-(?<video_id1>[a-z0-9_=\-]+)|v_(?<video_id2>[a-z0-9_=\-]+))#i',
  68. 'wp_embed_handler_56com' );
  69. /**
  70. * Youku wp_embed handler
  71. *
  72. * Embed code last updated:
  73. * Wed, 06 Jun 2012 00:36:11 -0400
  74. *
  75. * Feel free to submit or correct URL formats here:
  76. * http://cn.wordpress.org/contact/
  77. *
  78. * @since 3.4.0
  79. */
  80. function wp_embed_handler_youku( $matches, $attr, $url, $rawattr ) {
  81. $embed = sprintf(
  82. '<embed src="http://player.youku.com/player.php/sid/%1$s/v.swf" allowFullScreen="true" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>',
  83. esc_attr( $matches['video_id'] ) );
  84. return apply_filters( 'embed_youku', $embed, $matches, $attr, $url, $rawattr );
  85. }
  86. wp_embed_register_handler( 'youku',
  87. '#https?://v\.youku\.com/v_show/id_(?<video_id>[a-z0-9_=\-]+)#i',
  88. 'wp_embed_handler_youku' );
  89. /**
  90. * ICP license number
  91. *
  92. * For compliance with the Telecommunications Regulations. Can be turned off
  93. * in wp-config.php.
  94. *
  95. * @since 3.7.0
  96. */
  97. function zh_cn_l10n_settings_init() {
  98. if ( defined( 'WP_ZH_CN_ICP_NUM' ) && WP_ZH_CN_ICP_NUM ) {
  99. add_settings_field( 'zh_cn_l10n_icp_num',
  100. 'ICP备案号',
  101. 'zh_cn_l10n_icp_num_callback',
  102. 'general' );
  103. register_setting( 'general', 'zh_cn_l10n_icp_num' );
  104. }
  105. }
  106. add_action( 'admin_init', 'zh_cn_l10n_settings_init' );
  107. function zh_cn_l10n_icp_num_callback() {
  108. echo '<input name="zh_cn_l10n_icp_num" type="text" ' .
  109. 'id="zh_cn_l10n_icp_num" value="' .
  110. esc_attr( get_option( 'zh_cn_l10n_icp_num' ) ) .
  111. '" class="regluar-text ltr" />' .
  112. '<p class="description">仅对WordPress自带主题有效。</p>';
  113. }
  114. function zh_cn_l10n_icp_num( $content ) {
  115. if ( defined( 'WP_ZH_CN_ICP_NUM' ) && WP_ZH_CN_ICP_NUM &&
  116. get_option( 'zh_cn_l10n_icp_num' ) ) {
  117. echo '<a href="http://www.miitbeian.gov.cn/" rel="nofollow" ' .
  118. 'title="工业和信息化部ICP/IP地址/域名信息备案管理系统">' .
  119. esc_attr( get_option( 'zh_cn_l10n_icp_num' ) ) .
  120. "</a>\n";
  121. }
  122. }
  123. add_action( 'twentyten_credits', 'zh_cn_l10n_icp_num' );
  124. add_action( 'twentyeleven_credits', 'zh_cn_l10n_icp_num' );
  125. add_action( 'twentytwelve_credits', 'zh_cn_l10n_icp_num' );
  126. add_action( 'twentythirteen_credits', 'zh_cn_l10n_icp_num' );
  127. add_action( 'twentyfourteen_credits', 'zh_cn_l10n_icp_num' );
  128. add_action( 'twentyfifteen_credits', 'zh_cn_l10n_icp_num' );
  129. ?>