Permalink
Browse files

fix bug for update and tagging version 0.2.5

  • Loading branch information...
chen420 committed Oct 28, 2016
1 parent 1a82f0b commit 8968b3ee655eb42d1022fff22d34cfb452969a13
Showing with 24 additions and 15 deletions.
  1. +1 −1 readme.txt
  2. +2 −2 tinywebdb-api.php
  3. +21 −12 tinywebdb.php
View
@@ -6,7 +6,7 @@ Donate link: http://edu2web.com/tinywebdb-api/donate/
Tags: appinventor, tinywebdb, api
Requires at least: 4.0
Tested up to: 4.6.1
Stable tag: 0.2.4
Stable tag: 0.2.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
View
@@ -8,12 +8,12 @@
Store A Value {ServiceURL}/storeavalue tag,value JSON: ["STORED", "{tag}", {value}]
Author: Hong Chen
Author URI: http://edu2web.com/tinywebdb-api/
Version: 0.2.4
Version: 0.2.5
*/
define("TINYWEBDB", "tools.php?page=tinywebdb-api/tinywebdb-api.php");
define("TINYWEBDB_VER", "0.2.4");
define("TINYWEBDB_VER", "0.2.5");
//***** Hooks *****
register_activation_hook(__FILE__,'wp_tinywebdb_api_install'); //Install
View
@@ -64,6 +64,8 @@ public static function get_action() {
function wp_tinywebdb_api_get_postid($tagName){
$postid = NULL;
$tagName = wp_strip_all_tags($tagName);
$tagtype = get_option("wp_tinywebdb_api_tag_type");
if ($tagtype=='') {
$tagtype = 'id';
@@ -123,19 +125,26 @@ public static function getvalue($tagName) {
public static function storeavalue($tagName, $tagValue) {
// Create post object
$args = array(
'post_title' => wp_strip_all_tags( $tagName ),
'post_content' => $tagValue,
'post_status' => 'publish',
);
// Insert the post into the database
$postid = wp_insert_post( $args );
if ($postid == 0) {
$postid = TinyWebDB::wp_tinywebdb_api_get_postid($tagName);
$postid = TinyWebDB::wp_tinywebdb_api_get_postid($tagName);
$tagValue = stripslashes($tagValue);
$tagValue = trim($tagValue, '"');
$post = get_post( $postid );
if (empty($post)) {
// Create post object
$args = array(
'post_title' => wp_strip_all_tags( $tagName ),
'post_name' => wp_strip_all_tags( $tagName ),
'post_content' => $tagValue,
'post_status' => 'publish',
);
// Insert the post into the database
$postid = wp_insert_post( $args );
} else {
$args = array(
'ID' => wp_strip_all_tags( $postid ),
'ID' => $postid,
'post_content' => $tagValue,
);
$postid = wp_update_post( $args );

0 comments on commit 8968b3e

Please sign in to comment.