Skip to content

Instantly share code, notes, and snippets.

@oravecz
Created April 3, 2012 17:45
Show Gist options
  • Select an option

  • Save oravecz/2294055 to your computer and use it in GitHub Desktop.

Select an option

Save oravecz/2294055 to your computer and use it in GitHub Desktop.
1. I've installed stock Wordpress 3.3.1 and uploaded the
WPML 2.4.3. The blog has the "Hello World!" post and
the "Sample Page" page.
2. I activate the WPML plugin and accept the defaults.
3. I activate XML-RPC.
4. Using XML-RPC, I perform a getPost() to obtain the
first post details.
{
"dateCreated": "2012-04-03T19:52:44.000Z",
"userid": "1",
"postid": 1,
"description": "Welcome to WordPress. This is your
first post. Edit or delete it, then start
blogging!",
"title": "Hello world!",
"link": "http://ruwad.info/?p=1",
"permaLink": "http://ruwad.info/?p=1",
"categories": [
"Uncategorized"
],
"mt_excerpt": "",
"mt_text_more": "",
"mt_allow_comments": 1,
"mt_allow_pings": 1,
"mt_keywords": "",
"wp_slug": "hello-world",
"wp_password": "",
"wp_author_id": "1",
"wp_author_display_name": "jcook",
"date_created_gmt": "2012-04-03T19:52:44.000Z",
"post_status": "publish",
"custom_fields": [],
"wp_post_format": "standard",
"sticky": false
}
SQL query: SELECT * FROM `wp_icl_translations` LIMIT 0, 30 ; Rows: 6
translation_id element_type element_id trid language_code source_language_code
1 post_page 2 2 en NULL
2 post_post 1 1 en NULL
3 tax_category 1 4 en NULL
4 tax_link_category 2 7 en NULL
5 comment 1 9 en NULL
6 tax_category 3 4 ar en
Custom fields are empty and this may be as expected.
After all, this is a post that existed prior to using
the WPML plugin.
5. I manually add a new post and its accompanying arabic
translation using wordpress ui. The result of getPost
looks no different than a post without the WPML plugin
installed.
{
"dateCreated": "2012-04-03T19:21:52.000Z",
"userid": "1",
"postid": 5,
"description": "This is a post in English.",
"title": "Example Post 1",
"link": "http://ruwad.info/?p=5",
"permaLink": "http://ruwad.info/?p=5",
"categories": [
"Uncategorized"
],
"mt_excerpt": "",
"mt_text_more": "",
"mt_allow_comments": 1,
"mt_allow_pings": 1,
"mt_keywords": "",
"wp_slug": "",
"wp_password": "",
"wp_author_id": "1",
"wp_author_display_name": "jcook",
"date_created_gmt": "2012-04-03T19:21:52.000Z",
"post_status": "draft",
"custom_fields": [],
"wp_post_format": "standard",
"sticky": false
}
{
"dateCreated": "2012-04-03T19:24:49.000Z",
"userid": "1",
"postid": 7,
"description": "This is a post in Arabic.",
"title": "Example Post 1 (Arabic)",
"link": "http://ruwad.info/?p=7&lang=ar",
"permaLink": "http://ruwad.info/?p=7&lang=ar",
"categories": [
"Uncategorized"
],
"mt_excerpt": "",
"mt_text_more": "",
"mt_allow_comments": 1,
"mt_allow_pings": 1,
"mt_keywords": "",
"wp_slug": "",
"wp_password": "",
"wp_author_id": "1",
"wp_author_display_name": "jcook",
"date_created_gmt": "2012-04-03T19:24:49.000Z",
"post_status": "draft",
"custom_fields": [],
"wp_post_format": "standard",
"sticky": false
}
SQL query: SELECT * FROM `wp_icl_translations` LIMIT 0, 30 ;
Rows: 8
translation_id element_type element_id trid language_code source_language_code
8 post_post 5 10 en NULL
9 post_post 7 10 ar en
So, we can see the database column trid is "tieing"
post 5 and post 7 together as a single entity.
However, there are no custom fields for _wpml_language,
_wpml_trid, or _wpml_translations. Perhaps these
fields are only present when a post is created using
XML-RPC?
6. This time, I insert two new posts into my blog using
the WordPress XML-RPC api. One post is marked using a
custom field as English (Using the _wpml_language =
"en") and the other is Arabic (using _wpml_language =
'ar'). Each post has a custom field with _wpml_trid =
'11'. Here is the request for the Arabic post.
<methodCall>
<methodName>metaWeblog.newPost</methodName>
<params>
<param>
<int>1</int>
<string>admin</string>
<string>Ruw@d13</string>
<struct>
<member>
<name>wp_slug</name>
<value>
<string>title-slug</string>
</value>
</member>
<member>
<name>wp_password</name>
<value><string/></value>
</member>
<member>
<name>wp_page_parent_id</name>
<value><int>0</int></value>
</member>
<member>
<name>wp_page_order</name>
<value><int>0</int></value>
</member>
<member>
<name>wp_author_id</name>
<value><string>1</string></value>
</member>
<member>
<name>title</name>
<value><string>??????</string></value>
</member>
<member>
<name>post_type</name>
<value><string>post</string></value>
</member>
<member>
<name>description</name>
<value>
<string>???? ???</string>
</value>
</member>
<member>
<name>mt_excerpt</name>
<value>
<string>This is an excerpt</string>
</value>
</member>
<member>
<name>mt_text_more</name>
<value><string/></value>
</member>
<member>
<name>mt_allow_comments</name>
<value><int>0</int></value>
</member>
<member>
<name>mt_allow_pings</name>
<value><int>0</int></value>
</member>
<member>
<name>dateCreated</name>
<value>
<dateTime.iso8601>
2009-12-07T18:07:32.000Z
</dateTime.iso8601>
</value>
</member>
<member>
<name>custom_fields</name>
<value><array><data>
<struct>
<member>
<name>key</name>
<value>
<string>key</string>
</value>
</member>
<member>
<name>value</name>
<value>
<string>key-70</string>
</value>
</member>
</struct>
<struct>
<member>
<name>key</name>
<value>
<string>locale</string>
</value>
</member>
<member>
<name>value</name>
<value>
<string>ar</string>
</value>
</member>
</struct>
<struct>
<member>
<name>key</name>
<value>
<string>_wpml_language</string>
</value>
</member>
<member>
<name>value</name>
<value><int>5</int></value>
</member>
</struct>
<struct>
<member>
<name>key</name>
<value>
<string>_wpml_trid</string>
</value>
</member>
<member>
<name>value</name>
<value>
<int>11</int>
</value>
</member>
</struct>
</data></array></value>
</member>
<member>
<name>publish</name>
<value>
<boolean>false</boolean>
</value>
</member>
</struct>
</param>
</params>
</methodCall>
The wp_icl_translations file shows that the use of the
custom fields accomplished nothing. The English post
is #10 and the Arabic post is #12. Neither the
language_code or the trid was affected.
translation_id element_type element_id trid language_code source_language_code
10 post_post 10 11 en NULL
11 post_post 12 12 en NULL
The wp_postmeta table shows that my custom fields were
added to the post, but no _wpml fields appear.
SQL query: SELECT * FROM `wp_postmeta` LIMIT 0, 30 ;
meta_id post_id meta_key meta_value
1 2 _wp_page_template default
5 5 _edit_lock 1333467182:1
4 5 _edit_last 1
6 7 _edit_last 1
7 7 _edit_lock 1333466587:1
8 10 key article-key-70
9 10 locale ar
10 12 key article-key-70
11 12 locale en
@mysticaltech

Copy link
Copy Markdown

Exact same problem today 4 years later !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment