IT Blog

  • Blog
  • Technology
    • Technology
    • Architecture
    • CMS
    • CRM
    • Web
    • DotNET
    • Python
    • Database
    • BI
    • Program Language
  • Users
    • Login
    • Register
    • Forgot Password?
  • ENEN
    • 中文中文
    • ENEN
Program Language
Program Language

Wordpress + polylang - Globalization

Tables wp_posts: posts wp_terms: post category, menu wp_term_taxonomy: term type (taxonomy), language (description), hierarchy, number of posts associated to it wp_term_relationships: relationship between post-taxonomy,category-taxonomy when polylang activated wp_terms: add language rows: zh - post language, pll_zh-category language wp_term_relationships all posts and categories would add rows to this table in order to identify the relationships. INSERT INTO `wp_terms` (`term_id`, `name`, `slug`, `term_group`) VALUES (3, 'Socials Top Menu', 'socials-top-menu', 0), (33, '报道', 'report', 0), (38, 'English', 'enca', 2), (39, 'English', 'pll_enca', 0), (40, 'pll_5b343bccc90ae', 'pll_5b343bccc90ae', 0), (41, '中文 (中国)', 'zh', 0), --zh post language (42, '中文 (中国)', 'pll_zh', 0), --pll_zh term language (99, 'Report', 'report-calendar-enca', 0); INSERT INTO `wp_term_taxonomy` (`term_taxonomy_id`, `term_id`, `taxonomy`, `description`, `parent`, `count`) VALUES (3, 3, 'nav_menu', '', 0, 7), (33, 33, 'category', '', 13, 56), (38, 38, 'language', 'a:3:{s:6:\"locale\";s:5:\"en_CA\";s:3:\"rtl\";i:0;s:9:\"flag_code\";s:2:\"ca\";}', 0, 2), (39, 39, 'term_language', '', 0, 16), (40, 40, 'term_translations', 'a:2:{s:4:\"enca\";i:99;s:2:\"zh\";i:33;}', 0, 2), (41, 41, 'language', 'a:3:{s:6:\"locale\";s:5:\"zh_CN\";s:3:\"rtl\";i:0;s:9:\"flag_code\";s:2:\"cn\";}', 0, 9), (42, 42, 'term_language', '', 0, 17), (99, 99, 'category', '', 73, 0); INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`, `term_order`) VALUES (33, 3, 0), --nav_menu (33, 40, 0), --term_translations (33, 42, 0), --term_language (43, 33, 0), --category (54, 33, 0), --term_translations a:2:{s:4:"enca";i:53;s:2:"zh";i:20;} (99, 39, 0), --category:Report (379, 41, 0);      --post Add language row for posts after activating polylang INSERT INTO wp_term_relationships (object_id,term_taxonomy_id) SELECT id,41 FROM `wp_posts` --41: zh where id not in (select object_id from wp_term_relationships where term_taxonomy_id=41) and post_type='post'    2,542 total views

2018-06-29 0 Comments 896 Views 0 Like IT Team Read more
PHP

Escape JSON Special Characters using PHP

Escape JSON Special Characters using PHP php > 5.2 $str_valid=json_encode($str); php versions older that 5.2 /**  * @param $value  * @return mixed  */ function escapeJsonString($value) { # list from www.json.org: (\b backspace, \f formfeed)     $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");     $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");     $result = str_replace($escapers, $replacements, $value);     return $result; } result {"message":"\\"}  =>  {\"message\":\"\\\\\"} {\"message\":\"\\\\\"} use the json_encode constant JSON_HEX_APOS as the second parameter which will convert all single quotes ' to \u0027. : var t = <?php echo json_encode($data,JSON_HEX_APOS);?>;  4,590 total views,  10 views today

2018-05-22 0 Comments 1289 Views 0 Like IT Team Read more
Program Language

WP UI Design - Language Selection on Menu Bar

WP UI Design - Language Selection on Menu Bar Recently, I was requested to help for changing the language selection display style on the menu. Currently the website shows English on the menu by default, and the second language, which is Chinese, is hidden on the drop-down menu. Due to the website only support two languages, English and Chinese. Therefore, the owner want to display the second language right on the menu instead of hiding on the drop-down, so that user can switch the language easily. This is reasonable requirement for bilingual website. Website Language Selection UI Design It is common approach to place language selection on the menu bar for those websites support more than one language.     1. Bilingual language support For English as the first language website, we could place the second language button on the menu bar, as shown on Image 1.  When user click on the second language the page will display in the second language, and show first language button on the menu bar. Image 1     2. Multi-language support In the case of supporting multi-lingual, the first approach is not appropriate due to there are more than one language could be selected. In this case, we have to put all other languages on the dropdown list, so that user can pick one of the other languages as preferred, as shown on image 2. Image 2 However, I discovered that the website is using WPGlobus plug-in for WordPress. WPGlobus is a great plug-in for supporting multi-language on WordPress site. By design, the…

2016-11-24 0 Comments 964 Views 0 Like IT Team Read more
12
Chinese (Simplified) Chinese (Simplified) Chinese (Traditional) Chinese (Traditional) English English French French German German Japanese Japanese Korean Korean Russian Russian
Newest Hotspots Random
Newest Hotspots Random
Rich editor not working Making web page scroll down automatically Getting data from Dapper result All Unicode Chars How to keep and display contact form 7 data Common Regular Expressions
Rich editor not working Symbols: Stars Convert UTC time to EST time considering daylight saving time Covid-19 open data Solving SSMS diagram error Restrict WordPress user access some contents
Categories
  • Architecture
  • BI
  • C#
  • CSS
  • Database
  • DotNET
  • Hosting
  • HTML
  • JavaScript
  • PHP
  • Program Language
  • Python
  • Security
  • SEO
  • Technology
  • Web
  • Wordpress

COPYRIGHT © 2021 Hostlike IT Blog. All rights reserved.

This site is supported by Hostlike.com