Example #1
0
 public function newPost(SANaverRpcParam $param)
 {
     $message = new xmlrpcmsg("metaWeblog.newPost", array(php_xmlrpc_encode($this->blog_id), php_xmlrpc_encode($this->blog_id), php_xmlrpc_encode($this->api_key), php_xmlrpc_encode($param->getStruct()), php_xmlrpc_encode($param->publish)));
     $response = $this->client->send($message);
     return new SANaverRpcEditPostResult($response);
 }
Example #2
0
 function content_save_pre($content)
 {
     global $post;
     $v = @$_POST['XML_RPC_naver'];
     if ($v == 'no-use' || empty($_POST['content']) || empty($_POST['post_title']) || $_POST['post_type'] == 'page') {
         return $content;
     }
     if (is_object($post)) {
         $status = $post->post_status;
         $p_op_name = 'xml_rpc' . $_POST['post_ID'];
         $p_id = get_option($p_op_name);
         $post_id = $_POST['post_ID'];
         if (!$p_id) {
             add_option($p_op_name, '');
         }
         $param = new SANaverRpcParam();
         $param->setPost_id($p_id);
         $param->setTitle($_POST['post_title']);
         if ($status == 'private') {
             $param->setPublish(false);
         }
         $content = apply_filters('the_content', $_POST['content']);
         $content = str_replace("\\\"", "\"", $content);
         $param->setDescription($content);
         $param->addCategory($v);
         $res = null;
         if ($status == 'future') {
             $future_list = get_option('naver_sync_future_list', array());
             $future_list["future{$post_id}"] = $param->toArray();
             update_option('naver_sync_future_list', $future_list);
             return $content;
         }
         if ('publish' == $status || 'private' == $status) {
             if (empty($p_id)) {
                 $res = $this->rpc->newPost($param);
                 update_option($p_op_name, $res->postid . '');
             } else {
                 $res = $this->rpc->editPost($param);
             }
         } else {
             if ('draft' == $status || 'auto-draft' == $status) {
                 $res = $this->rpc->newPost($param);
                 update_option($p_op_name, $res->postid . '');
             }
         }
     }
     remove_filter('content_save_pre', array($this, 'content_save_pre'));
     return $content;
 }