public static function register_conversation_on_pageload()
 {
     // if we're not viewing a post, bail
     if (!is_single()) {
         return;
     }
     if (comments_open(get_the_ID()) && !SpotIM_Util::is_conversation_processed(get_the_ID())) {
         // by now this is a post that wasn't processed
         spotim_instance()->api->register_conversation(get_the_ID());
     }
 }
 public static function generate_json()
 {
     $result = array();
     $result = self::start();
     $filename = apply_filters('spotim_json_download_filename', sprintf('spotim-export-%s.json', date_i18n('d-m-Y_h-i', time())));
     // do headers
     SpotIM_Util::send_headers(array('Content-Disposition' => "attachment; filename={$filename}", 'Pragma' => 'no-cache', 'Expires' => '0', 'Content-Type' => 'application/json; charset=' . get_option('blog_charset')));
     require_once 'class-spotim-jsonpretty.php';
     $json_pretty = new SpotIM_JsonPretty();
     echo $json_pretty->prettify(json_encode($result));
     wp_die();
 }
Example #3
0
 public function test_sync_edits()
 {
     $edits_json = $this->_read_json_file('sync-many-edits.json');
     $sync = new SpotIM_Sync($this->_post_id, $edits_json);
     $results = $sync->sync();
     // got edits for r~ and c~?
     $this->assertEquals(1, $results['c~']);
     $this->assertEquals(1, $results['r~']);
     $spotim_comment_id_to_test = 'sp_123_456_c_1';
     // make sure the comments were indeed edited
     $comment = SpotIM_Util::get_comment_by_spotim_id($spotim_comment_id_to_test);
     $this->assertFalse(empty($comment));
     // check if comment's content equals
     $this->assertEquals($comment->comment_content, $edits_json['messages'][$spotim_comment_id_to_test]['content']);
 }