PHP Square Bracket Errors
I built a wordpress plug-in. The plug-in is working fine in a server, but another server returned an error about '[. I compared the two servers. Their php is different. The problematic server got old version of php which is php .5.3. Then I read the php specification. The Square Bracket array declaration which used in C# and Java is only available on Php >=5.4. So I have to change square brackets to array(). Then it works fine.
The Database Object in WordPress
You can access the database via WordPress. You can use any raw SQL too. That is quite easy. You only need to call a global object;
global $wpdb;
For the raw SQL, you can use query method:
$wpdb->query(
"
UPDATE $wpdb->posts
SET post_parent = 10
WHERE ID = 15
"
);
For get the record set,
$drafts = $wpdb->get_results(
"
SELECT *
FROM $wpdb->posts
WHERE post_status = 'draft'
AND post_author =1
"
);
There are insert, update and delete method too.
Please read WordPress development documentation for the further information
WordPress Serialize the JSON object
Although WordPress got its own JSON API, you still have your own JSON API for your own plugin and serialize your own data. That is not a problem. WordPress library got a function to serialize any objects to JSON Format. That is very easy. You can use this function in any parts of your plug-in.
wp_send_json($user);
WordPress Finally got a REST API
I used Wordpress as the development framework for a mobile application project. Wordpress has a set of XMLPRC api for a very long time. Moreover, the mainstream in Mobile development is to use JSON as the communication format, rather than XML. JSON is smaller and easier to deserialize back to an object. Originally, I planned to use a third party plug-in for REST API and with my own code to build my own version REST API for my mobile application. Today, I checked my WordPress; It got an update for WordPress 4.7. After the updates, I found this version finally got an official REST API. That is great. I can build my code on top of that!
You can check this demo from Wordpress
This Special for IT Person
As a person who works in the IT field, what items are on specials this week doesn't sounds very related. But this week, there are a lot of good stuff which our IT people will like. Firstly, Woolworth marked down a $10 Optus pepiad SIM to $2.Wow, 80% off That SIM can have unlimited calls and SMS for 5 days and 500 MB data each day. Moreover, Coles has 20% off on the $30,$50,$100 iTune Gift Card and marked down a $30 Optus Prepaid SIM to $10. That is more than half price. This sim can have a monthly plan with unlimited calls and SMS for 28 days with 3GB data. If you activate it before Feb 2017, Optus will give you 3GB bonus data too.